LLVM: llvm::LoopVectorizationLegality Class Reference (original ) (raw )LoopVectorizationLegality checks if it is legal to vectorize a loop, and to what vectorization factor. More...
#include "[llvm/Transforms/Vectorize/LoopVectorizationLegality.h](LoopVectorizationLegality%5F8h%5Fsource.html)"
Public Member Functions
LoopVectorizationLegality (Loop *L, PredicatedScalarEvolution &PSE, DominatorTree *DT, TargetTransformInfo *TTI , TargetLibraryInfo *TLI, Function *F , LoopAccessInfoManager &LAIs, LoopInfo *LI, OptimizationRemarkEmitter *ORE, LoopVectorizationRequirements *R, LoopVectorizeHints *H , DemandedBits *DB, AssumptionCache *AC, bool AllowRuntimeSCEVChecks, AAResults *AA)
bool
canVectorize (bool UseVPlanNativePath)
Returns true if it is legal to vectorize this loop.
bool
canVectorizeFPMath (bool EnableStrictReductions)
Returns true if it is legal to vectorize the FP math operations in this loop.
bool
canFoldTailByMasking () const
Return true if we can vectorize this loop while folding its tail by masking.
void
prepareToFoldTailByMasking ()
Mark all respective loads/stores for masking.
PHINode *
getPrimaryInduction ()
Returns the primary induction variable.
const ReductionList &
getReductionVars () const
Returns the reduction variables found in the loop.
const RecurrenceDescriptor &
getRecurrenceDescriptor (PHINode *PN) const
Returns the recurrence descriptor associated with a given phi node PN, expecting one to exist.
const InductionList &
getInductionVars () const
Returns the induction variables found in the loop.
RecurrenceSet &
getFixedOrderRecurrences ()
Return the fixed-order recurrences found in the loop.
IntegerType *
getWidestInductionType ()
Returns the widest induction type.
bool
isInvariantStoreOfReduction (StoreInst *SI)
Returns True if given store is a final invariant store of one of the reductions found in the loop.
bool
isInvariantAddressOfReduction (Value *V)
Returns True if given address is invariant and is used to store recurrent expression.
bool
isInductionPhi (const Value *V) const
Returns True if V is a Phi node of an induction variable in this loop.
const InductionDescriptor *
getIntOrFpInductionDescriptor (PHINode *Phi) const
Returns a pointer to the induction descriptor, if Phi is an integer or floating point induction.
const InductionDescriptor *
getPointerInductionDescriptor (PHINode *Phi) const
Returns a pointer to the induction descriptor, if Phi is pointer induction.
bool
isCastedInductionVariable (const Value *V) const
Returns True if V is a cast that is part of an induction def-use chain, and had been proven to be redundant under a runtime guard (in other words, the cast has the same SCEV expression as the induction phi).
bool
isInductionVariable (const Value *V) const
Returns True if V can be considered as an induction variable in this loop.
bool
isReductionVariable (PHINode *PN) const
Returns True if PN is a reduction variable in this loop.
bool
isFixedOrderRecurrence (const PHINode *Phi) const
Returns True if Phi is a fixed-order recurrence in this loop.
bool
blockNeedsPredication (const BasicBlock *BB) const
Return true if the block BB needs to be predicated in order for the loop to be vectorized.
int
isConsecutivePtr (Type *AccessTy, Value *Ptr) const
Check if this pointer is consecutive when vectorizing.
bool
isInvariant (Value *V) const
Returns true if V is invariant across all loop iterations according to SCEV .
bool
isUniform (Value *V, ElementCount VF) const
Returns true if value V is uniform across VF lanes, when VF is provided, and otherwise if V is invariant across all loop iterations.
bool
isUniformMemOp (Instruction &I , ElementCount VF) const
A uniform memory op is a load or store which accesses the same memory location on all VF lanes, if VF is provided and otherwise if the memory location is invariant.
const RuntimePointerChecking *
getRuntimePointerChecking () const
Returns the information that we collected about runtime memory check.
const LoopAccessInfo *
getLAI () const
bool
isSafeForAnyVectorWidth () const
uint64_t
getMaxSafeVectorWidthInBits () const
bool
hasUncountableEarlyExit () const
Returns true if the loop has exactly one uncountable early exit, i.e.
BasicBlock *
getUncountableEarlyExitingBlock () const
Returns the uncountable early exiting block, if there is exactly one.
bool
hasUncountableExitWithSideEffects () const
Returns true if this is an early exit loop with state-changing or potentially-faulting operations and the condition for the uncountable exit must be determined before any of the state changes or potentially faulting operations take place.
bool
isSafeForAnyStoreLoadForwardDistances () const
Return true if there is store-load forwarding dependencies.
uint64_t
getMaxStoreLoadForwardSafeDistanceInBits () const
Return safe power-of-2 number of elements, which do not prevent store-load forwarding and safe to operate simultaneously.
bool
isMaskRequired (const Instruction *I ) const
Returns true if vector representation of the instruction I requires mask.
bool
hasVectorCallVariants () const
Returns true if there is at least one function call in the loop which has a vectorized variant available.
unsigned
getNumStores () const
unsigned
getNumLoads () const
std::optional< const HistogramInfo * >
getHistogramInfo (Instruction *I ) const
Returns a HistogramInfo* for the given instruction if it was determined to be part of a load -> update -> store sequence where multiple lanes may be working on the same memory address.
bool
hasHistograms () const
Returns a list of all known histogram operations in the loop.
const SmallPtrSetImpl < const Instruction * > &
getPotentiallyFaultingLoads () const
Returns potentially faulting loads.
PredicatedScalarEvolution *
getPredicatedScalarEvolution () const
Loop *
getLoop () const
LoopInfo *
getLoopInfo () const
AssumptionCache *
getAssumptionCache () const
ScalarEvolution *
getScalarEvolution () const
DominatorTree *
getDominatorTree () const
const SmallVector < BasicBlock *, 4 > &
getCountableExitingBlocks () const
Returns all exiting blocks with a countable exit, i.e.
LoopVectorizationLegality checks if it is legal to vectorize a loop, and to what vectorization factor.
This class does not look at the profitability of vectorization, only the legality. This class has two main kinds of checks:
Memory checks - The code in canVectorizeMemory checks if vectorization will change the order of memory accesses in a way that will change the correctness of the program.
Scalars checks - The code in canVectorizeInstrs and canVectorizeMemory checks for a number of different conditions, such as the availability of a single induction variable, that all types are supported and vectorize-able, etc. This code reflects the capabilities of InnerLoopVectorizer . This class is also used by InnerLoopVectorizer for identifying induction variable and the different reduction variables.
Definition at line 261 of file LoopVectorizationLegality.h .
◆ InductionList◆ RecurrenceSet◆ ReductionList
llvm::LoopVectorizationLegality::LoopVectorizationLegality ( Loop * L , PredicatedScalarEvolution & PSE , DominatorTree * DT , TargetTransformInfo * TTI , TargetLibraryInfo * TLI , Function * F , LoopAccessInfoManager & LAIs , LoopInfo * LI , OptimizationRemarkEmitter * ORE , LoopVectorizationRequirements * R , LoopVectorizeHints * H , DemandedBits * DB , AssumptionCache * AC , bool AllowRuntimeSCEVChecks , AAResults * AA )
inline
◆ blockNeedsPredication()◆ canFoldTailByMasking()
bool llvm::LoopVectorizationLegality::canFoldTailByMasking
(
)
const
◆ canVectorize()
bool llvm::LoopVectorizationLegality::canVectorize
(
bool
UseVPlanNativePath
)
Returns true if it is legal to vectorize this loop.
This does not mean that it is profitable to vectorize this loop, only that it is legal to do so. Temporarily taking UseVPlanNativePath parameter. If true, take the new code path being implemented for outer loop vectorization (should be functional for inner loop vectorization) based on VPlan . If false, good old LV code.
Definition at line 1977 of file LoopVectorizationLegality.cpp .
References assert() , llvm::dbgs() , DEBUG_TYPE , llvm::LoopVectorizeHints::FK_Enabled , hasUncountableEarlyExit() , hasUncountableExitWithSideEffects() , llvm::isa() , LLVM_DEBUG , PragmaVectorizeSCEVCheckThreshold , llvm::reportVectorizationFailure() , and VectorizeSCEVCheckThreshold .
Referenced by llvm::LoopVectorizePass::processLoop() .
◆ canVectorizeFPMath()
bool llvm::LoopVectorizationLegality::canVectorizeFPMath
(
bool
EnableStrictReductions
)
◆ getAssumptionCache()
AssumptionCache * llvm::LoopVectorizationLegality::getAssumptionCache ( ) const
inline
◆ getCountableExitingBlocks()◆ getDominatorTree()
DominatorTree * llvm::LoopVectorizationLegality::getDominatorTree ( ) const
inline
◆ getFixedOrderRecurrences()
RecurrenceSet & llvm::LoopVectorizationLegality::getFixedOrderRecurrences ( )
inline
◆ getHistogramInfo()Returns a HistogramInfo* for the given instruction if it was determined to be part of a load -> update -> store sequence where multiple lanes may be working on the same memory address.
Definition at line 454 of file LoopVectorizationLegality.h .
References I .
◆ getInductionVars()
◆ getIntOrFpInductionDescriptor()◆ getLAI()◆ getLoop()
Loop * llvm::LoopVectorizationLegality::getLoop ( ) const
inline
◆ getLoopInfo()
LoopInfo * llvm::LoopVectorizationLegality::getLoopInfo ( ) const
inline
◆ getMaxSafeVectorWidthInBits()
uint64_t llvm::LoopVectorizationLegality::getMaxSafeVectorWidthInBits ( ) const
inline
◆ getMaxStoreLoadForwardSafeDistanceInBits()
uint64_t llvm::LoopVectorizationLegality::getMaxStoreLoadForwardSafeDistanceInBits ( ) const
inline
Return safe power-of-2 number of elements, which do not prevent store-load forwarding and safe to operate simultaneously.
Definition at line 434 of file LoopVectorizationLegality.h .
◆ getNumLoads()
unsigned llvm::LoopVectorizationLegality::getNumLoads ( ) const
inline
◆ getNumStores()
unsigned llvm::LoopVectorizationLegality::getNumStores ( ) const
inline
◆ getPointerInductionDescriptor()◆ getPotentiallyFaultingLoads()◆ getPredicatedScalarEvolution()◆ getPrimaryInduction()
PHINode * llvm::LoopVectorizationLegality::getPrimaryInduction ( )
inline
◆ getRecurrenceDescriptor()◆ getReductionVars()
◆ getRuntimePointerChecking()◆ getScalarEvolution()
ScalarEvolution * llvm::LoopVectorizationLegality::getScalarEvolution ( ) const
inline
◆ getUncountableEarlyExitingBlock()
BasicBlock * llvm::LoopVectorizationLegality::getUncountableEarlyExitingBlock ( ) const
inline
◆ getWidestInductionType()
IntegerType * llvm::LoopVectorizationLegality::getWidestInductionType ( )
inline
◆ hasHistograms()
bool llvm::LoopVectorizationLegality::hasHistograms ( ) const
inline
◆ hasUncountableEarlyExit()
bool llvm::LoopVectorizationLegality::hasUncountableEarlyExit ( ) const
inline
◆ hasUncountableExitWithSideEffects()
bool llvm::LoopVectorizationLegality::hasUncountableExitWithSideEffects ( ) const
inline
Returns true if this is an early exit loop with state-changing or potentially-faulting operations and the condition for the uncountable exit must be determined before any of the state changes or potentially faulting operations take place.
Definition at line 423 of file LoopVectorizationLegality.h .
Referenced by canVectorize() .
◆ hasVectorCallVariants()
bool llvm::LoopVectorizationLegality::hasVectorCallVariants ( ) const
inline
Returns true if there is at least one function call in the loop which has a vectorized variant available.
Definition at line 446 of file LoopVectorizationLegality.h .
◆ isCastedInductionVariable()
bool llvm::LoopVectorizationLegality::isCastedInductionVariable
(
const Value *
V
)
const
◆ isConsecutivePtr()
int llvm::LoopVectorizationLegality::isConsecutivePtr
(
Type *
AccessTy ,
Value *
Ptr ) const
Check if this pointer is consecutive when vectorizing.
This happens when the last index of the GEP is the induction variable, or that the pointer itself is an induction variable. This check allows us to vectorize A[idx] into a wide load/store. Returns: 0 - Stride is unknown or non-consecutive. 1 - Address is consecutive. -1 - Address is consecutive, and decreasing. NOTE: This method must only be used before modifying the original scalar loop. Do not use after invoking 'createVectorizedLoopSkeleton' (PR34965).
Definition at line 474 of file LoopVectorizationLegality.cpp .
References llvm::getPtrStride() .
◆ isFixedOrderRecurrence()
bool llvm::LoopVectorizationLegality::isFixedOrderRecurrence
(
const PHINode *
Phi
)
const
◆ isInductionPhi()
bool llvm::LoopVectorizationLegality::isInductionPhi
(
const Value *
V
)
const
◆ isInductionVariable()
bool llvm::LoopVectorizationLegality::isInductionVariable
(
const Value *
V
)
const
◆ isInvariant()
bool llvm::LoopVectorizationLegality::isInvariant
(
Value *
V
)
const
◆ isInvariantAddressOfReduction()
bool llvm::LoopVectorizationLegality::isInvariantAddressOfReduction
(
Value *
V
)
◆ isInvariantStoreOfReduction()
bool llvm::LoopVectorizationLegality::isInvariantStoreOfReduction
(
StoreInst *
SI
)
◆ isMaskRequired()◆ isReductionVariable()
bool llvm::LoopVectorizationLegality::isReductionVariable ( PHINode * PN ) const
inline
◆ isSafeForAnyStoreLoadForwardDistances()
bool llvm::LoopVectorizationLegality::isSafeForAnyStoreLoadForwardDistances ( ) const
inline
◆ isSafeForAnyVectorWidth()
bool llvm::LoopVectorizationLegality::isSafeForAnyVectorWidth ( ) const
inline
Returns true if value V is uniform across VF lanes, when VF is provided, and otherwise if V is invariant across all loop iterations.
Definition at line 586 of file LoopVectorizationLegality.cpp .
References llvm::all_of() , llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::getKnownMinValue() , llvm::ScalarEvolution::getSCEV() , I , llvm::isa() , isInvariant() , llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::isScalable() , llvm::ElementCount::isScalar() , llvm::ScalarEvolution::isSCEVable() , llvm::reverse() , and llvm::seq() .
Referenced by isUniformMemOp() .
◆ prepareToFoldTailByMasking()
void llvm::LoopVectorizationLegality::prepareToFoldTailByMasking
(
)
The documentation for this class was generated from the following files: