llvm::promoteLoopAccessesToScalars

Promote must-alias loop memory accesses to scalars via load/store motion.

Synopsis

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);

Description

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.

Return Value

True if any accesses were promoted.

Parameters

NameDescription
PointerMustAliasesMust-alias pointer set considered for promotion.
ExitBlocksLoop exit blocks used for sunk stores.
InsertPtsInsertion points in the corresponding exit blocks.
MSSAInsertPtsMemorySSA insertion points for promoted accesses.
PICPredecessor-iterator cache for the transform.
LILoop info for the function.
DTDominator tree for the function.
ACAssumption cache for the function.
TLITarget library info.
TTITarget transform info.
CurLoopLoop whose accesses may be promoted.
MSSAUMemorySSA updater for the transform.
SafetyInfoLoop safety information for faulting ops.
OREOptional remark emitter for diagnostics.
AllowSpeculationWhether to hoist values that may not always execute.
HasReadsOutsideSetWhether the alias set has reads outside the set.