LLVM
15.0.0git
|
Drive the analysis of memory accesses in the loop. More...
#include "llvm/Analysis/LoopAccessAnalysis.h"
Public Member Functions | |
LoopAccessInfo (Loop *L, ScalarEvolution *SE, const TargetLibraryInfo *TLI, AAResults *AA, DominatorTree *DT, LoopInfo *LI) | |
bool | canVectorizeMemory () const |
Return true we can analyze the memory accesses in the loop and there are no memory dependence cycles. More... | |
bool | hasConvergentOp () const |
Return true if there is a convergent operation in the loop. More... | |
const RuntimePointerChecking * | getRuntimePointerChecking () const |
unsigned | getNumRuntimePointerChecks () const |
Number of memchecks required to prove independence of otherwise may-alias pointers. More... | |
bool | isUniform (Value *V) const |
Returns true if the value V is uniform within the loop. More... | |
uint64_t | getMaxSafeDepDistBytes () const |
unsigned | getNumStores () const |
unsigned | getNumLoads () const |
const OptimizationRemarkAnalysis * | getReport () const |
The diagnostics report generated for the analysis. More... | |
const MemoryDepChecker & | getDepChecker () const |
the Memory Dependence Checker which can determine the loop-independent and loop-carried dependences between memory accesses. More... | |
SmallVector< Instruction *, 4 > | getInstructionsForAccess (Value *Ptr, bool isWrite) const |
Return the list of instructions that use Ptr to read or write memory. More... | |
const ValueToValueMap & | getSymbolicStrides () const |
If an access has a symbolic strides, this maps the pointer value to the stride symbol. More... | |
bool | hasStride (Value *V) const |
Pointer has a symbolic stride. More... | |
void | print (raw_ostream &OS, unsigned Depth=0) const |
Print the information about the memory accesses in the loop. More... | |
bool | hasDependenceInvolvingLoopInvariantAddress () const |
If the loop has memory dependence involving an invariant address, i.e. More... | |
const ArrayRef< StoreInst * > | getStoresToInvariantAddresses () const |
Return the list of stores to invariant addresses. More... | |
const PredicatedScalarEvolution & | getPSE () const |
Used to add runtime SCEV checks. More... | |
Static Public Member Functions | |
static bool | blockNeedsPredication (BasicBlock *BB, Loop *TheLoop, DominatorTree *DT) |
Return true if the block BB needs to be predicated in order for the loop to be vectorized. More... | |
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.
Definition at line 511 of file LoopAccessAnalysis.h.
LoopAccessInfo::LoopAccessInfo | ( | Loop * | L, |
ScalarEvolution * | SE, | ||
const TargetLibraryInfo * | TLI, | ||
AAResults * | AA, | ||
DominatorTree * | DT, | ||
LoopInfo * | LI | ||
) |
Definition at line 2330 of file LoopAccessAnalysis.cpp.
|
static |
Return true if the block BB needs to be predicated in order for the loop to be vectorized.
Definition at line 2231 of file LoopAccessAnalysis.cpp.
References assert(), BB, llvm::LoopBase< BlockT, LoopT >::contains(), llvm::DominatorTree::dominates(), and llvm::LoopBase< BlockT, LoopT >::getLoopLatch().
Referenced by llvm::LoopVectorizationLegality::blockNeedsPredication().
|
inline |
Return true we can analyze the memory accesses in the loop and there are no memory dependence cycles.
Definition at line 518 of file LoopAccessAnalysis.h.
|
inline |
the Memory Dependence Checker which can determine the loop-independent and loop-carried dependences between memory accesses.
Definition at line 553 of file LoopAccessAnalysis.h.
Referenced by llvm::LoopVersioning::annotateLoopWithNoAlias(), llvm::MemoryDepChecker::Dependence::getDestination(), llvm::LoopVectorizationLegality::getMaxSafeVectorWidthInBits(), llvm::MemoryDepChecker::Dependence::getSource(), and llvm::LoopVectorizationLegality::isSafeForAnyVectorWidth().
|
inline |
Return the list of instructions that use Ptr
to read or write memory.
Definition at line 557 of file LoopAccessAnalysis.h.
|
inline |
Definition at line 543 of file LoopAccessAnalysis.h.
Referenced by llvm::LoopVectorizationLegality::getMaxSafeDepDistBytes().
|
inline |
Definition at line 545 of file LoopAccessAnalysis.h.
Referenced by llvm::LoopVectorizationLegality::getNumLoads().
|
inline |
Number of memchecks required to prove independence of otherwise may-alias pointers.
Definition at line 531 of file LoopAccessAnalysis.h.
|
inline |
Definition at line 544 of file LoopAccessAnalysis.h.
Referenced by llvm::LoopVectorizationLegality::getNumStores().
|
inline |
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.
Definition at line 588 of file LoopAccessAnalysis.h.
Referenced by canTailPredicateLoop().
|
inline |
The diagnostics report generated for the analysis.
E.g. why we couldn't analyze the loop.
Definition at line 549 of file LoopAccessAnalysis.h.
|
inline |
Definition at line 525 of file LoopAccessAnalysis.h.
Referenced by llvm::LoopVectorizationLegality::canVectorize(), GeneratedRTChecks::Create(), llvm::InnerLoopVectorizer::emitMemRuntimeChecks(), llvm::LoopVectorizationLegality::getRuntimePointerChecking(), llvm::LoopVersioning::prepareNoAliasMetadata(), and llvm::LoopVersioning::versionLoop().
Return the list of stores to invariant addresses.
Definition at line 579 of file LoopAccessAnalysis.h.
|
inline |
If an access has a symbolic strides, this maps the pointer value to the stride symbol.
Definition at line 564 of file LoopAccessAnalysis.h.
Referenced by llvm::LoopVectorizationCostModel::runtimeChecksRequired().
|
inline |
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.
Definition at line 523 of file LoopAccessAnalysis.h.
|
inline |
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.
Definition at line 574 of file LoopAccessAnalysis.h.
|
inline |
Pointer has a symbolic stride.
Definition at line 567 of file LoopAccessAnalysis.h.
Referenced by llvm::LoopVectorizationLegality::hasStride().
bool LoopAccessInfo::isUniform | ( | Value * | V | ) | const |
Returns true if the value V is uniform within the loop.
Definition at line 2260 of file LoopAccessAnalysis.cpp.
References llvm::ScalarEvolution::getSCEV(), llvm::PredicatedScalarEvolution::getSE(), llvm::Value::getType(), llvm::ScalarEvolution::isLoopInvariant(), and llvm::ScalarEvolution::isSCEVable().
Referenced by llvm::LoopVectorizationLegality::isUniform().
void LoopAccessInfo::print | ( | raw_ostream & | OS, |
unsigned | Depth = 0 |
||
) | const |
Print the information about the memory accesses in the loop.
Definition at line 2340 of file LoopAccessAnalysis.cpp.
References llvm::Depth, llvm::raw_ostream::indent(), and llvm::MemoryDepChecker::Dependence::print().
Referenced by llvm::LoopAccessLegacyAnalysis::print().