LLVM  5.0.0
Public Member Functions | Static Public Member Functions | List of all members
llvm::LoopAccessInfo Class Reference

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, 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...
 

Detailed 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.

Definition at line 483 of file LoopAccessAnalysis.h.

Constructor & Destructor Documentation

LoopAccessInfo::LoopAccessInfo ( Loop *  L,
ScalarEvolution *  SE,
const TargetLibraryInfo *  TLI,
AliasAnalysis *  AA,
DominatorTree *  DT,
LoopInfo *  LI 
)

Definition at line 2075 of file LoopAccessAnalysis.cpp.

Member Function Documentation

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 2049 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 1978 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().

bool LoopAccessInfo::blockNeedsPredication ( BasicBlock *  BB,
Loop *  TheLoop,
DominatorTree *  DT 
)
static

Return true if the block BB needs to be predicated in order for the loop to be vectorized.

Definition at line 1854 of file LoopAccessAnalysis.cpp.

References assert(), llvm::LoopBase< N, M >::contains(), llvm::DominatorTree::dominates(), and llvm::LoopBase< N, M >::getLoopLatch().

bool llvm::LoopAccessInfo::canVectorizeMemory ( ) const
inline

Return true we can analyze the memory accesses in the loop and there are no memory dependence cycles.

Definition at line 490 of file LoopAccessAnalysis.h.

const MemoryDepChecker& llvm::LoopAccessInfo::getDepChecker ( ) const
inline

the Memory Dependence Checker which can determine the loop-independent and loop-carried dependences between memory accesses.

Definition at line 538 of file LoopAccessAnalysis.h.

Referenced by llvm::LoopVersioning::annotateLoopWithNoAlias(), llvm::MemoryDepChecker::Dependence::getDestination(), and llvm::MemoryDepChecker::Dependence::getSource().

SmallVector<Instruction *, 4> llvm::LoopAccessInfo::getInstructionsForAccess ( Value *  Ptr,
bool  isWrite 
) const
inline

Return the list of instructions that use Ptr to read or write memory.

Definition at line 542 of file LoopAccessAnalysis.h.

uint64_t llvm::LoopAccessInfo::getMaxSafeDepDistBytes ( ) const
inline

Definition at line 510 of file LoopAccessAnalysis.h.

unsigned llvm::LoopAccessInfo::getNumLoads ( ) const
inline

Definition at line 512 of file LoopAccessAnalysis.h.

unsigned llvm::LoopAccessInfo::getNumRuntimePointerChecks ( ) const
inline

Number of memchecks required to prove independence of otherwise may-alias pointers.

Definition at line 498 of file LoopAccessAnalysis.h.

unsigned llvm::LoopAccessInfo::getNumStores ( ) const
inline

Definition at line 511 of file LoopAccessAnalysis.h.

const PredicatedScalarEvolution& llvm::LoopAccessInfo::getPSE ( ) const
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 569 of file LoopAccessAnalysis.h.

Referenced by llvm::LoopVersioning::LoopVersioning(), and llvm::LoopVersioning::versionLoop().

const OptimizationRemarkAnalysis* llvm::LoopAccessInfo::getReport ( ) const
inline

The diagnostics report generated for the analysis.

E.g. why we couldn't analyze the loop.

Definition at line 534 of file LoopAccessAnalysis.h.

const RuntimePointerChecking* llvm::LoopAccessInfo::getRuntimePointerChecking ( ) const
inline
const ValueToValueMap& llvm::LoopAccessInfo::getSymbolicStrides ( ) const
inline

If an access has a symbolic strides, this maps the pointer value to the stride symbol.

Definition at line 549 of file LoopAccessAnalysis.h.

bool llvm::LoopAccessInfo::hasStoreToLoopInvariantAddress ( ) const
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 560 of file LoopAccessAnalysis.h.

bool llvm::LoopAccessInfo::hasStride ( Value *  V) const
inline

Pointer has a symbolic stride.

Definition at line 552 of file LoopAccessAnalysis.h.

bool LoopAccessInfo::isUniform ( Value *  V) const

Returns true if the value V is uniform within the loop.

Definition at line 1883 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 2087 of file LoopAccessAnalysis.cpp.

References llvm::raw_ostream::indent().

Referenced by llvm::LoopAccessLegacyAnalysis::print().


The documentation for this class was generated from the following files: