Promote must-alias loop memory accesses to scalars via load/store motion.
Declared in <llvm/Transforms/Utils/LoopUtils.h>
bool
promoteLoopAccessesToScalars(
SmallSetVector<Value*, 8> const& PointerMustAliases,
SmallVectorImpl<BasicBlock*>& ExitBlocks,
SmallVectorImpl<BasicBlock::iterator>& InsertPts,
SmallVectorImpl<MemoryAccess*>& MSSAInsertPts,
PredIteratorCache& PIC,
LoopInfo* LI,
DominatorTree* DT,
AssumptionCache* AC,
TargetLibraryInfo const* TLI,
TargetTransformInfo* TTI,
Loop* CurLoop,
MemorySSAUpdater& MSSAU,
ICFLoopSafetyInfo* SafetyInfo,
OptimizationRemarkEmitter* ORE,
bool AllowSpeculation,
bool HasReadsOutsideSet);
Try to promote memory values to scalars by sinking stores out of the loop and moving loads to before the loop. We do this by looping over the stores in the loop, looking for stores to Must pointers which are loop invariant. It takes a set of must-alias values, Loop exit blocks vector, loop exit blocks insertion point vector, PredIteratorCache, LoopInfo, DominatorTree, Loop, AliasSet information for all instructions of the loop and loop safety information as arguments. Diagnostics is emitted via ORE. It returns changed status. AllowSpeculation is whether values should be hoisted even if they are not guaranteed to execute in the loop, but are safe to speculatively execute.
True if any accesses were promoted.
| Name | Description |
|---|---|
| PointerMustAliases | Must-alias pointer set considered for promotion. |
| ExitBlocks | Loop exit blocks used for sunk stores. |
| InsertPts | Insertion points in the corresponding exit blocks. |
| MSSAInsertPts | MemorySSA insertion points for promoted accesses. |
| PIC | Predecessor-iterator cache for the transform. |
| LI | Loop info for the function. |
| DT | Dominator tree for the function. |
| AC | Assumption cache for the function. |
| TLI | Target library info. |
| TTI | Target transform info. |
| CurLoop | Loop whose accesses may be promoted. |
| MSSAU | MemorySSA updater for the transform. |
| SafetyInfo | Loop safety information for faulting ops. |
| ORE | Optional remark emitter for diagnostics. |
| AllowSpeculation | Whether to hoist values that may not always execute. |
| HasReadsOutsideSet | Whether the alias set has reads outside the set. |