class LoopAccessInfo
Declaration
class LoopAccessInfo { /* full declaration omitted */ };
Description
Drive the analysis of memory accesses in the loop This class is responsible for analyzing the memory accesses of a loop. It collects the accesses and then its main helper the AccessAnalysis class finds and categorizes the dependences in buildDependenceSets. For memory dependences that can be analyzed at compile time, it determines whether the dependence is part of cycle inhibiting vectorization. This work is delegated to the MemoryDepChecker class. For memory dependences that cannot be determined at compile time, it generates run-time checks to prove independence. This is done by AccessAnalysis::canCheckPtrAtRT and the checks are maintained by the RuntimePointerCheck class. If pointers can wrap or can't be expressed as affine AddRec expressions by ScalarEvolution, we will generate run-time checks by emitting a SCEVUnionPredicate. Checks for both memory dependences and the SCEV predicates contained in the PSE must be emitted in order for the results of this analysis to be valid.
Declared at: llvm/include/llvm/Analysis/LoopAccessAnalysis.h:561
Member Variables
- private std::unique_ptr<PredicatedScalarEvolution> PSE
- private std::unique_ptr<RuntimePointerChecking> PtrRtChecking
- We need to check that all of the pointers in this list are disjoint at runtime. Using std::unique_ptr to make using move ctor simpler.
- private std::unique_ptr<MemoryDepChecker> DepChecker
- the Memory Dependence Checker which can determine the loop-independent and loop-carried dependences between memory accesses.
- private llvm::Loop* TheLoop
- private unsigned int NumLoads = 0
- private unsigned int NumStores = 0
- private uint64_t MaxSafeDepDistBytes = -1
- private bool CanVecMem = false
- Cache the result of analyzeLoop.
- private bool HasConvergentOp = false
- private bool HasDependenceInvolvingLoopInvariantAddress = false
- Indicator that there are non vectorizable stores to a uniform address.
- private SmallVector<llvm::StoreInst*> StoresToInvariantAddresses
- List of stores to invariant addresses.
- private std::unique_ptr<OptimizationRemarkAnalysis> Report
- The diagnostics report generated for the analysis. E.g. why we couldn't analyze the loop.
- private llvm::ValueToValueMap SymbolicStrides
- If an access has a symbolic strides, this maps the pointer value to the stride symbol.
- private SmallPtrSet<llvm::Value*, 8> StrideSet
- Set of symbolic strides values.
Method Overview
- public LoopAccessInfo(llvm::Loop * L, llvm::ScalarEvolution * SE, const llvm::TargetLibraryInfo * TLI, llvm::AAResults * AA, llvm::DominatorTree * DT, llvm::LoopInfo * LI)
- private void analyzeLoop(llvm::AAResults * AA, llvm::LoopInfo * LI, const llvm::TargetLibraryInfo * TLI, llvm::DominatorTree * DT)
- public static bool blockNeedsPredication(llvm::BasicBlock * BB, llvm::Loop * TheLoop, llvm::DominatorTree * DT)
- private bool canAnalyzeLoop()
- public bool canVectorizeMemory() const
- private void collectStridedAccess(llvm::Value * LoadOrStoreInst)
- private void emitUnsafeDependenceRemark()
- public const llvm::MemoryDepChecker & getDepChecker() const
- public SmallVector<llvm::Instruction *, 4> getInstructionsForAccess(llvm::Value * Ptr, bool isWrite) const
- public uint64_t getMaxSafeDepDistBytes() const
- public unsigned int getNumLoads() const
- public unsigned int getNumRuntimePointerChecks() const
- public unsigned int getNumStores() const
- public const llvm::PredicatedScalarEvolution & getPSE() const
- public const llvm::OptimizationRemarkAnalysis * getReport() const
- public const llvm::RuntimePointerChecking * getRuntimePointerChecking() const
- public const ArrayRef<llvm::StoreInst *> getStoresToInvariantAddresses() const
- public const llvm::ValueToValueMap & getSymbolicStrides() const
- public bool hasConvergentOp() const
- public bool hasDependenceInvolvingLoopInvariantAddress() const
- public bool hasStride(llvm::Value * V) const
- public bool isUniform(llvm::Value * V) const
- public void print(llvm::raw_ostream & OS, unsigned int Depth = 0) const
- private llvm::OptimizationRemarkAnalysis & recordAnalysis(llvm::StringRef RemarkName, llvm::Instruction * Instr = nullptr)
Methods
¶LoopAccessInfo(llvm::Loop* L,
llvm::ScalarEvolution* SE,
const llvm::TargetLibraryInfo* TLI,
llvm::AAResults* AA,
llvm::DominatorTree* DT,
llvm::LoopInfo* LI)
LoopAccessInfo(llvm::Loop* L,
llvm::ScalarEvolution* SE,
const llvm::TargetLibraryInfo* TLI,
llvm::AAResults* AA,
llvm::DominatorTree* DT,
llvm::LoopInfo* LI)
Declared at: llvm/include/llvm/Analysis/LoopAccessAnalysis.h:563
Parameters
- llvm::Loop* L
- llvm::ScalarEvolution* SE
- const llvm::TargetLibraryInfo* TLI
- llvm::AAResults* AA
- llvm::DominatorTree* DT
- llvm::LoopInfo* LI
¶void analyzeLoop(
llvm::AAResults* AA,
llvm::LoopInfo* LI,
const llvm::TargetLibraryInfo* TLI,
llvm::DominatorTree* DT)
void analyzeLoop(
llvm::AAResults* AA,
llvm::LoopInfo* LI,
const llvm::TargetLibraryInfo* TLI,
llvm::DominatorTree* DT)
Description
Analyze the loop.
Declared at: llvm/include/llvm/Analysis/LoopAccessAnalysis.h:642
Parameters
- llvm::AAResults* AA
- llvm::LoopInfo* LI
- const llvm::TargetLibraryInfo* TLI
- llvm::DominatorTree* DT
¶static bool blockNeedsPredication(
llvm::BasicBlock* BB,
llvm::Loop* TheLoop,
llvm::DominatorTree* DT)
static bool blockNeedsPredication(
llvm::BasicBlock* BB,
llvm::Loop* TheLoop,
llvm::DominatorTree* DT)
Description
Return true if the block BB needs to be predicated in order for the loop to be vectorized.
Declared at: llvm/include/llvm/Analysis/LoopAccessAnalysis.h:587
Parameters
- llvm::BasicBlock* BB
- llvm::Loop* TheLoop
- llvm::DominatorTree* DT
¶bool canAnalyzeLoop()
bool canAnalyzeLoop()
Description
Check if the structure of the loop allows it to be analyzed by this pass.
Declared at: llvm/include/llvm/Analysis/LoopAccessAnalysis.h:647
¶bool canVectorizeMemory() const
bool canVectorizeMemory() const
Description
Return true we can analyze the memory accesses in the loop and there are no memory dependence cycles.
Declared at: llvm/include/llvm/Analysis/LoopAccessAnalysis.h:568
¶void collectStridedAccess(
llvm::Value* LoadOrStoreInst)
void collectStridedAccess(
llvm::Value* LoadOrStoreInst)
Description
Collect memory access with loop invariant strides. Looks for accesses like "a[i * StrideA]" where "StrideA" is loop invariant.
Declared at: llvm/include/llvm/Analysis/LoopAccessAnalysis.h:661
Parameters
- llvm::Value* LoadOrStoreInst
¶void emitUnsafeDependenceRemark()
void emitUnsafeDependenceRemark()
Declared at: llvm/include/llvm/Analysis/LoopAccessAnalysis.h:666
¶const llvm::MemoryDepChecker& getDepChecker()
const
const llvm::MemoryDepChecker& getDepChecker()
const
Description
the Memory Dependence Checker which can determine the loop-independent and loop-carried dependences between memory accesses.
Declared at: llvm/include/llvm/Analysis/LoopAccessAnalysis.h:603
¶SmallVector<llvm::Instruction*, 4>
getInstructionsForAccess(llvm::Value* Ptr,
bool isWrite) const
SmallVector<llvm::Instruction*, 4>
getInstructionsForAccess(llvm::Value* Ptr,
bool isWrite) const
Description
Return the list of instructions that use \p Ptr to read or write memory.
Declared at: llvm/include/llvm/Analysis/LoopAccessAnalysis.h:607
Parameters
- llvm::Value* Ptr
- bool isWrite
¶uint64_t getMaxSafeDepDistBytes() const
uint64_t getMaxSafeDepDistBytes() const
Declared at: llvm/include/llvm/Analysis/LoopAccessAnalysis.h:593
¶unsigned int getNumLoads() const
unsigned int getNumLoads() const
Declared at: llvm/include/llvm/Analysis/LoopAccessAnalysis.h:595
¶unsigned int getNumRuntimePointerChecks() const
unsigned int getNumRuntimePointerChecks() const
Description
Number of memchecks required to prove independence of otherwise may-alias pointers.
Declared at: llvm/include/llvm/Analysis/LoopAccessAnalysis.h:581
¶unsigned int getNumStores() const
unsigned int getNumStores() const
Declared at: llvm/include/llvm/Analysis/LoopAccessAnalysis.h:594
¶const llvm::PredicatedScalarEvolution& getPSE()
const
const llvm::PredicatedScalarEvolution& getPSE()
const
Description
Used to add runtime SCEV checks. Simplifies SCEV expressions and converts them to a more usable form. All SCEV expressions during the analysis should be re-written (and therefore simplified) according to PSE. A user of LoopAccessAnalysis will need to emit the runtime checks associated with this predicate.
Declared at: llvm/include/llvm/Analysis/LoopAccessAnalysis.h:638
¶const llvm::OptimizationRemarkAnalysis*
getReport() const
const llvm::OptimizationRemarkAnalysis*
getReport() const
Description
The diagnostics report generated for the analysis. E.g. why we couldn't analyze the loop.
Declared at: llvm/include/llvm/Analysis/LoopAccessAnalysis.h:599
¶const llvm::RuntimePointerChecking*
getRuntimePointerChecking() const
const llvm::RuntimePointerChecking*
getRuntimePointerChecking() const
Declared at: llvm/include/llvm/Analysis/LoopAccessAnalysis.h:575
¶const ArrayRef<llvm::StoreInst*>
getStoresToInvariantAddresses() const
const ArrayRef<llvm::StoreInst*>
getStoresToInvariantAddresses() const
Description
Return the list of stores to invariant addresses.
Declared at: llvm/include/llvm/Analysis/LoopAccessAnalysis.h:629
¶const llvm::ValueToValueMap& getSymbolicStrides()
const
const llvm::ValueToValueMap& getSymbolicStrides()
const
Description
If an access has a symbolic strides, this maps the pointer value to the stride symbol.
Declared at: llvm/include/llvm/Analysis/LoopAccessAnalysis.h:614
¶bool hasConvergentOp() const
bool hasConvergentOp() const
Description
Return true if there is a convergent operation in the loop. There may still be reported runtime pointer checks that would be required, but it is not legal to insert them.
Declared at: llvm/include/llvm/Analysis/LoopAccessAnalysis.h:573
¶bool hasDependenceInvolvingLoopInvariantAddress()
const
bool hasDependenceInvolvingLoopInvariantAddress()
const
Description
If the loop has memory dependence involving an invariant address, i.e. two stores or a store and a load, then return true, else return false.
Declared at: llvm/include/llvm/Analysis/LoopAccessAnalysis.h:624
¶bool hasStride(llvm::Value* V) const
bool hasStride(llvm::Value* V) const
Description
Pointer has a symbolic stride.
Declared at: llvm/include/llvm/Analysis/LoopAccessAnalysis.h:617
Parameters
- llvm::Value* V
¶bool isUniform(llvm::Value* V) const
bool isUniform(llvm::Value* V) const
Description
Returns true if the value V is uniform within the loop.
Declared at: llvm/include/llvm/Analysis/LoopAccessAnalysis.h:591
Parameters
- llvm::Value* V
¶void print(llvm::raw_ostream& OS,
unsigned int Depth = 0) const
void print(llvm::raw_ostream& OS,
unsigned int Depth = 0) const
Description
Print the information about the memory accesses in the loop.
Declared at: llvm/include/llvm/Analysis/LoopAccessAnalysis.h:620
Parameters
- llvm::raw_ostream& OS
- unsigned int Depth = 0
¶llvm::OptimizationRemarkAnalysis& recordAnalysis(
llvm::StringRef RemarkName,
llvm::Instruction* Instr = nullptr)
llvm::OptimizationRemarkAnalysis& recordAnalysis(
llvm::StringRef RemarkName,
llvm::Instruction* Instr = nullptr)
Description
Save the analysis remark. LAA does not directly emits the remarks. Instead it stores it which the client can retrieve and presents as its own analysis (e.g. -Rpass-analysis=loop-vectorize).
Declared at: llvm/include/llvm/Analysis/LoopAccessAnalysis.h:654
Parameters
- llvm::StringRef RemarkName
- llvm::Instruction* Instr = nullptr