Go to the documentation of this file.
26 #ifndef LLVM_TRANSFORMS_VECTORIZE_LOOPVECTORIZATIONLEGALITY_H
27 #define LLVM_TRANSFORMS_VECTORIZE_LOOPVECTORIZATIONLEGALITY_H
36 class AssumptionCache;
38 class BlockFrequencyInfo;
45 class OptimizationRemarkEmitter;
46 class PredicatedScalarEvolution;
47 class ProfileSummaryInfo;
48 class TargetLibraryInfo;
49 class TargetTransformInfo;
102 static StringRef Prefix() {
return "llvm.loop."; }
105 bool PotentiallyUnsafe =
false;
133 bool VectorizeOnlyWhenForced)
const;
144 if (Interleave.Value)
145 return Interleave.Value;
190 void getHintsFromMetadata();
218 if (
I && !ExactFPMathInst)
227 return NumRuntimePointerChecks;
231 unsigned NumRuntimePointerChecks = 0;
257 : TheLoop(L), LI(LI), PSE(PSE),
TTI(
TTI), TLI(TLI), DT(DT),
258 GetLAA(GetLAA), ORE(ORE), Requirements(R), Hints(
H), DB(DB), AC(AC),
259 BFI(BFI), PSI(PSI) {}
399 return MaskedOp.contains(
I);
408 return ConditionalAssumes;
419 bool canVectorizeLoopNestCFG(
Loop *Lp,
bool UseVPlanNativePath);
424 bool setupOuterLoopInductions();
432 bool canVectorizeLoopCFG(
Loop *Lp,
bool UseVPlanNativePath);
437 bool canVectorizeInstrs();
443 bool canVectorizeMemory();
447 bool canVectorizeWithIfConvert();
451 bool canVectorizeOuterLoop();
461 bool blockCanBePredicated(
493 PredicatedScalarEvolution &PSE;
496 TargetTransformInfo *TTI;
499 TargetLibraryInfo *TLI;
509 const LoopAccessInfo *LAI =
nullptr;
512 OptimizationRemarkEmitter *ORE;
518 PHINode *PrimaryInduction =
nullptr;
532 SmallPtrSet<Instruction *, 4> InductionCastsToIgnore;
539 MapVector<Instruction *, Instruction *> SinkAfter;
542 Type *WidestIndTy =
nullptr;
546 SmallPtrSet<Value *, 4> AllowedExit;
549 LoopVectorizationRequirements *Requirements;
552 LoopVectorizeHints *Hints;
564 SmallPtrSet<const Instruction *, 8> MaskedOp;
568 SmallPtrSet<Instruction *, 8> ConditionalAssumes;
571 BlockFrequencyInfo *BFI;
572 ProfileSummaryInfo *PSI;
577 #endif // LLVM_TRANSFORMS_VECTORIZE_LOOPVECTORIZATIONLEGALITY_H
SmallPtrSet< const PHINode *, 8 > RecurrenceSet
RecurrenceSet contains the phi nodes that are recurrences other than inductions and reductions.
TransformationMode hasUnrollTransformation(const Loop *L)
void setPotentiallyUnsafe()
const ReductionList & getReductionVars() const
Returns the reduction variables found in the loop.
This is an optimization pass for GlobalISel generic memory operations.
MapVector< Instruction *, Instruction * > & getSinkAfter()
Return the set of instructions to sink to handle first-order recurrences.
unsigned getNumLoads() const
bool hasDisableAllTransformsHint(const Loop *L)
Look for the loop attribute that disables all transformation heuristic.
Represents a single loop in the control flow graph.
const LoopAccessInfo * getLAI() const
unsigned getPredicate() const
An interface layer with SCEV used to manage how we see SCEV expressions for values in the context of ...
void addRuntimePointerChecks(unsigned Num)
@ SK_Unspecified
Not selected.
LoopVectorizationLegality checks if it is legal to vectorize a loop, and to what vectorization factor...
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
uint64_t getMaxSafeVectorWidthInBits() const
Return the number of elements that are safe to operate on simultaneously, multiplied by the size of t...
@ SK_FixedWidthOnly
Disables vectorization with scalable vectors.
The instances of the Type class are immutable: once they are created, they are never changed.
ElementCount getWidth() const
bool canVectorizeFPMath(bool EnableStrictReductions)
Returns true if it is legal to vectorize the FP math operations in this loop.
unsigned getIsVectorized() const
LoopVectorizeHints(const Loop *L, bool InterleaveOnlyWhenForced, OptimizationRemarkEmitter &ORE, const TargetTransformInfo *TTI=nullptr)
void validate(const Triple &TT, const FeatureBitset &FeatureBits)
bool prepareToFoldTailByMasking()
Return true if we can vectorize this loop while folding its tail by masking, and mark all respective ...
unsigned getNumRuntimePointerChecks() const
LLVM Basic Block Representation.
This holds vectorization requirements that must be verified late in the process.
@ FK_Undefined
Not selected.
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
A struct for saving information about induction variables.
static ElementCount get(ScalarTy MinVal, bool Scalable)
MapVector< PHINode *, RecurrenceDescriptor > ReductionList
ReductionList contains the reduction descriptors for all of the reductions that were found in the loo...
bool isInvariantStoreOfReduction(StoreInst *SI)
Returns True if given store is a final invariant store of one of the reductions found in the loop.
unsigned getNumLoads() const
const char * vectorizeAnalysisPassName() const
If hints are provided that force vectorization, use the AlwaysPrint pass name to force the frontend t...
void addExactFPMathInst(Instruction *I)
Track the 1st floating-point instruction that can not be reassociated.
bool blockNeedsPredication(BasicBlock *BB) const
Return true if the block BB needs to be predicated in order for the loop to be vectorized.
const InductionDescriptor * getPointerInductionDescriptor(PHINode *Phi) const
Returns a pointer to the induction descriptor, if Phi is pointer induction.
enum ForceKind getForce() const
bool hasStride(Value *V) const
Pointer has a symbolic stride.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Analysis providing profile information.
const SmallPtrSetImpl< Instruction * > & getConditionalAssumes() const
Returns all assume calls in predicated blocks.
An instruction for storing to memory.
const ValueToValueMap & getSymbolicStrides() const
If an access has a symbolic strides, this maps the pointer value to the stride symbol.
Utility class for getting and setting loop vectorizer hints in the form of loop metadata.
@ SK_PreferScalable
Vectorize loops using scalable vectors or fixed-width vectors, but favor scalable vectors when the co...
Holds information about the memory runtime legality checks to verify that a group of pointers do not ...
bool isMaskRequired(const Instruction *I) const
Returns true if vector representation of the instruction I requires mask.
@ FK_Enabled
Forcing enabled.
unsigned getInterleave() const
bool allowVectorization(Function *F, Loop *L, bool VectorizeOnlyWhenForced) const
const RuntimePointerChecking * getRuntimePointerChecking() const
RecurrenceSet & getFirstOrderRecurrences()
Return the first-order recurrences found in the loop.
Drive the analysis of memory accesses in the loop.
bool isInvariantAddressOfReduction(Value *V)
Returns True if given address is invariant and is used to store recurrent expression.
LoopVectorizationLegality(Loop *L, PredicatedScalarEvolution &PSE, DominatorTree *DT, TargetTransformInfo *TTI, TargetLibraryInfo *TLI, AAResults *AA, Function *F, std::function< const LoopAccessInfo &(Loop &)> *GetLAA, LoopInfo *LI, OptimizationRemarkEmitter *ORE, LoopVectorizationRequirements *R, LoopVectorizeHints *H, DemandedBits *DB, AssumptionCache *AC, BlockFrequencyInfo *BFI, ProfileSummaryInfo *PSI)
@ TM_Disable
The transformation should not be applied.
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 red...
unsigned getNumStores() const
bool isInductionVariable(const Value *V) const
Returns True if V can be considered as an induction variable in this loop.
StandardInstrumentations SI(Debug, VerifyEach)
@ BasicBlock
Various leaf nodes.
print Print MemDeps of function
Instruction * getExactFPInst()
bool isUniform(Value *V)
Returns true if the value V is uniform within the loop.
const MemoryDepChecker & getDepChecker() const
the Memory Dependence Checker which can determine the loop-independent and loop-carried dependences b...
int isConsecutivePtr(Type *AccessTy, Value *Ptr) const
Check if this pointer is consecutive when vectorizing.
StringRef - Represent a constant reference to a string, i.e.
A cache of @llvm.assume calls within a function.
void emitRemarkWithHints() const
Dumps all the hint information.
const RuntimePointerChecking * getRuntimePointerChecking() const
Returns the information that we collected about runtime memory check.
const InductionDescriptor * getIntOrFpInductionDescriptor(PHINode *Phi) const
Returns a pointer to the induction descriptor, if Phi is an integer or floating point induction.
uint64_t getMaxSafeDepDistBytes() const
bool isReductionVariable(PHINode *PN) const
Returns True if PN is a reduction variable in this loop.
bool isUniformMemOp(Instruction &I)
A uniform memory op is a load or store which accesses the same memory location on all lanes.
unsigned getNumStores() const
size_type count(const KeyT &Key) const
bool isFirstOrderRecurrence(const PHINode *Phi) const
Returns True if Phi is a first-order recurrence in this loop.
bool isSafeForAnyVectorWidth() const
Return true if the number of elements that are safe to operate on simultaneously is not bounded.
uint64_t getMaxSafeVectorWidthInBits() const
Provides information about what library functions are available for the current target.
bool isInductionPhi(const Value *V) const
Returns True if V is a Phi node of an induction variable in this loop.
void setAlreadyVectorized()
Mark the loop L as already vectorized by setting the width to 1.
bool isScalableVectorizationDisabled() const
bool isSafeForAnyVectorWidth() const
bool allowReordering() const
When enabling loop hints are provided we allow the vectorizer to change the order of operations that ...
const Value * getLoadStorePointerOperand(const Value *V)
A helper function that returns the pointer operand of a load or store instruction.
const InductionList & getInductionVars() const
Returns the induction variables found in the loop.
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
PHINode * getPrimaryInduction()
Returns the primary induction variable.
unsigned getMaxSafeDepDistBytes()
@ FK_Disabled
Forcing disabled.
bool canVectorize(bool UseVPlanNativePath)
Returns true if it is legal to vectorize this loop.
LLVM Value Representation.
Type * getWidestInductionType()
Returns the widest induction type.
bool isPotentiallyUnsafe() const
MapVector< PHINode *, InductionDescriptor > InductionList
InductionList saves induction variables and maps them to the induction descriptor.