|
LLVM
4.0.0
|
Drive the analysis of memory accesses in the loop. More...
#include <LoopAccessAnalysis.h>
Public Member Functions | |
| LoopAccessInfo (Loop *L, ScalarEvolution *SE, const TargetLibraryInfo *TLI, AliasAnalysis *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... | |
| 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 |
| std::pair< Instruction *, Instruction * > | addRuntimeChecks (Instruction *Loc) const |
| Add code that checks at runtime if the accessed arrays overlap. More... | |
| std::pair< Instruction *, Instruction * > | addRuntimeChecks (Instruction *Loc, const SmallVectorImpl< RuntimePointerChecking::PointerCheck > &PointerChecks) const |
Generete the instructions for the checks in PointerChecks. More... | |
| 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 | hasStoreToLoopInvariantAddress () const |
| Checks existence of store to invariant address inside loop. 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 516 of file LoopAccessAnalysis.h.
| LoopAccessInfo::LoopAccessInfo | ( | Loop * | L, |
| ScalarEvolution * | SE, | ||
| const TargetLibraryInfo * | TLI, | ||
| AliasAnalysis * | AA, | ||
| DominatorTree * | DT, | ||
| LoopInfo * | LI | ||
| ) |
Definition at line 2018 of file LoopAccessAnalysis.cpp.
| std::pair< Instruction *, Instruction * > LoopAccessInfo::addRuntimeChecks | ( | Instruction * | Loc | ) | const |
Add code that checks at runtime if the accessed arrays overlap.
Returns a pair of instructions where the first element is the first instruction generated in possibly a sequence of instructions and the second value is the final comparator value or NULL if no check is needed.
Definition at line 1992 of file LoopAccessAnalysis.cpp.
Referenced by llvm::LoopVersioning::versionLoop().
| std::pair< Instruction *, Instruction * > LoopAccessInfo::addRuntimeChecks | ( | Instruction * | Loc, |
| const SmallVectorImpl< RuntimePointerChecking::PointerCheck > & | PointerChecks | ||
| ) | const |
Generete the instructions for the checks in PointerChecks.
Returns a pair of instructions where the first element is the first instruction generated in possibly a sequence of instructions and the second value is the final comparator value or NULL if no check is needed.
Definition at line 1921 of file LoopAccessAnalysis.cpp.
References assert(), Check(), llvm::IRBuilder< T, Inserter >::CreateAnd(), llvm::IRBuilder< T, Inserter >::CreateBitCast(), llvm::IRBuilder< T, Inserter >::CreateICmpULT(), llvm::IRBuilder< T, Inserter >::CreateOr(), expandBounds(), llvm::Value::getContext(), getFirstInst(), llvm::LoopBase< N, M >::getHeader(), llvm::Type::getInt8PtrTy(), llvm::ConstantInt::getTrue(), and llvm::IRBuilder< T, Inserter >::Insert().
|
static |
Return true if the block BB needs to be predicated in order for the loop to be vectorized.
Definition at line 1800 of file LoopAccessAnalysis.cpp.
References assert(), llvm::LoopBase< N, M >::contains(), llvm::DominatorTree::dominates(), and llvm::LoopBase< N, M >::getLoopLatch().
|
inline |
Return true we can analyze the memory accesses in the loop and there are no memory dependence cycles.
Definition at line 523 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 571 of file LoopAccessAnalysis.h.
Referenced by llvm::LoopVersioning::annotateLoopWithNoAlias(), llvm::MemoryDepChecker::Dependence::getDestination(), and llvm::MemoryDepChecker::Dependence::getSource().
|
inline |
Return the list of instructions that use Ptr to read or write memory.
Definition at line 575 of file LoopAccessAnalysis.h.
|
inline |
Definition at line 543 of file LoopAccessAnalysis.h.
|
inline |
Definition at line 545 of file LoopAccessAnalysis.h.
|
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.
|
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 602 of file LoopAccessAnalysis.h.
Referenced by llvm::LoopVersioning::LoopVersioning(), and llvm::LoopVersioning::versionLoop().
|
inline |
The diagnostics report generated for the analysis.
E.g. why we couldn't analyze the loop.
Definition at line 567 of file LoopAccessAnalysis.h.
|
inline |
Definition at line 525 of file LoopAccessAnalysis.h.
Referenced by llvm::LoopVersioning::LoopVersioning(), and llvm::LoopVersioning::prepareNoAliasMetadata().
|
inline |
If an access has a symbolic strides, this maps the pointer value to the stride symbol.
Definition at line 582 of file LoopAccessAnalysis.h.
|
inline |
Checks existence of store to invariant address inside loop.
If the loop has any store to invariant address, then it returns true, else returns false.
Definition at line 593 of file LoopAccessAnalysis.h.
Pointer has a symbolic stride.
Definition at line 585 of file LoopAccessAnalysis.h.
References llvm::SmallPtrSetImpl< PtrType >::count().
Returns true if the value V is uniform within the loop.
Definition at line 1829 of file LoopAccessAnalysis.cpp.
References llvm::ScalarEvolution::getSCEV(), llvm::Value::getType(), llvm::ScalarEvolution::isLoopInvariant(), and llvm::ScalarEvolution::isSCEVable().
| void LoopAccessInfo::print | ( | raw_ostream & | OS, |
| unsigned | Depth = 0 |
||
| ) | const |
Print the information about the memory accesses in the loop.
Definition at line 2030 of file LoopAccessAnalysis.cpp.
References llvm::raw_ostream::indent().
Referenced by llvm::LoopAccessLegacyAnalysis::print().
1.8.6