26#ifndef LLVM_TRANSFORMS_VECTORIZE_LOOPVECTORIZATIONLEGALITY_H
27#define LLVM_TRANSFORMS_VECTORIZE_LOOPVECTORIZATIONLEGALITY_H
38class BlockFrequencyInfo;
45class OptimizationRemarkEmitter;
46class PredicatedScalarEvolution;
47class ProfileSummaryInfo;
48class TargetLibraryInfo;
49class TargetTransformInfo;
77 Hint(
const char *Name,
unsigned Value, HintKind Kind)
80 bool validate(
unsigned Val);
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)
249 : TheLoop(L), LI(LI), PSE(PSE),
TTI(
TTI), TLI(TLI), DT(DT), LAIs(LAIs),
250 ORE(ORE), Requirements(R), Hints(
H), DB(DB), AC(AC), BFI(BFI),
379 return MaskedOp.contains(
I);
388 return ConditionalAssumes;
399 bool canVectorizeLoopNestCFG(
Loop *Lp,
bool UseVPlanNativePath);
404 bool setupOuterLoopInductions();
412 bool canVectorizeLoopCFG(
Loop *Lp,
bool UseVPlanNativePath);
417 bool canVectorizeInstrs();
423 bool canVectorizeMemory();
427 bool canVectorizeWithIfConvert();
431 bool canVectorizeOuterLoop();
441 bool blockCanBePredicated(
473 PredicatedScalarEvolution &PSE;
476 TargetTransformInfo *TTI;
479 TargetLibraryInfo *TLI;
485 LoopAccessInfoManager &LAIs;
487 const LoopAccessInfo *LAI =
nullptr;
490 OptimizationRemarkEmitter *ORE;
496 PHINode *PrimaryInduction =
nullptr;
510 SmallPtrSet<Instruction *, 4> InductionCastsToIgnore;
517 MapVector<Instruction *, Instruction *> SinkAfter;
520 Type *WidestIndTy =
nullptr;
524 SmallPtrSet<Value *, 4> AllowedExit;
527 LoopVectorizationRequirements *Requirements;
530 LoopVectorizeHints *Hints;
542 SmallPtrSet<const Instruction *, 8> MaskedOp;
546 SmallPtrSet<Instruction *, 8> ConditionalAssumes;
549 BlockFrequencyInfo *BFI;
550 ProfileSummaryInfo *PSI;
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
This file implements a map that provides insertion order iteration.
A cache of @llvm.assume calls within a function.
LLVM Basic Block Representation.
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
static constexpr ElementCount get(ScalarTy MinVal, bool Scalable)
A struct for saving information about induction variables.
Drive the analysis of memory accesses in the loop.
const MemoryDepChecker & getDepChecker() const
the Memory Dependence Checker which can determine the loop-independent and loop-carried dependences b...
const RuntimePointerChecking * getRuntimePointerChecking() const
unsigned getNumLoads() const
bool hasStride(Value *V) const
Pointer has a symbolic stride.
uint64_t getMaxSafeDepDistBytes() const
unsigned getNumStores() const
const ValueToValueMap & getSymbolicStrides() const
If an access has a symbolic strides, this maps the pointer value to the stride symbol.
LoopVectorizationLegality checks if it is legal to vectorize a loop, and to what vectorization factor...
MapVector< PHINode *, InductionDescriptor > InductionList
InductionList saves induction variables and maps them to the induction descriptor.
unsigned getNumStores() const
bool isInvariantStoreOfReduction(StoreInst *SI)
Returns True if given store is a final invariant store of one of the reductions found in the loop.
uint64_t getMaxSafeVectorWidthInBits() const
RecurrenceSet & getFixedOrderRecurrences()
Return the fixed-order recurrences found in the loop.
bool isInvariantAddressOfReduction(Value *V)
Returns True if given address is invariant and is used to store recurrent expression.
unsigned getMaxSafeDepDistBytes()
bool blockNeedsPredication(BasicBlock *BB) const
Return true if the block BB needs to be predicated in order for the loop to be vectorized.
const SmallPtrSetImpl< Instruction * > & getConditionalAssumes() const
Returns all assume calls in predicated blocks.
bool canVectorize(bool UseVPlanNativePath)
Returns true if it is legal to vectorize this loop.
int isConsecutivePtr(Type *AccessTy, Value *Ptr) const
Check if this pointer is consecutive when vectorizing.
SmallPtrSet< const PHINode *, 8 > RecurrenceSet
RecurrenceSet contains the phi nodes that are recurrences other than inductions and reductions.
bool canVectorizeFPMath(bool EnableStrictReductions)
Returns true if it is legal to vectorize the FP math operations in this loop.
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, BlockFrequencyInfo *BFI, ProfileSummaryInfo *PSI)
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.
const InductionDescriptor * getPointerInductionDescriptor(PHINode *Phi) const
Returns a pointer to the induction descriptor, if Phi is pointer induction.
const InductionDescriptor * getIntOrFpInductionDescriptor(PHINode *Phi) const
Returns a pointer to the induction descriptor, if Phi is an integer or floating point induction.
bool isInductionPhi(const Value *V) const
Returns True if V is a Phi node of an induction variable in this loop.
PHINode * getPrimaryInduction()
Returns the primary induction variable.
bool isUniform(Value *V) const
Returns true if the value V is uniform within the loop.
const InductionList & getInductionVars() const
Returns the induction variables found in the loop.
const ReductionList & getReductionVars() const
Returns the reduction variables found in the loop.
bool isSafeForAnyVectorWidth() const
unsigned getNumLoads() const
Type * getWidestInductionType()
Returns the widest induction type.
const LoopAccessInfo * getLAI() const
bool prepareToFoldTailByMasking()
Return true if we can vectorize this loop while folding its tail by masking, and mark all respective ...
MapVector< PHINode *, RecurrenceDescriptor > ReductionList
ReductionList contains the reduction descriptors for all of the reductions that were found in the loo...
bool isMaskRequired(const Instruction *I) const
Returns true if vector representation of the instruction I requires mask.
const RuntimePointerChecking * getRuntimePointerChecking() const
Returns the information that we collected about runtime memory check.
bool isUniformMemOp(Instruction &I) const
A uniform memory op is a load or store which accesses the same memory location on all lanes.
bool isInductionVariable(const Value *V) const
Returns True if V can be considered as an induction variable in this loop.
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...
This holds vectorization requirements that must be verified late in the process.
Instruction * getExactFPInst()
void addExactFPMathInst(Instruction *I)
Track the 1st floating-point instruction that can not be reassociated.
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...
@ SK_Unspecified
Not selected.
@ SK_FixedWidthOnly
Disables vectorization with scalable vectors.
bool isScalableVectorizationDisabled() const
enum ForceKind getForce() const
bool allowVectorization(Function *F, Loop *L, bool VectorizeOnlyWhenForced) const
bool allowReordering() const
When enabling loop hints are provided we allow the vectorizer to change the order of operations that ...
void emitRemarkWithHints() const
Dumps all the hint information.
bool isPotentiallyUnsafe() const
ElementCount getWidth() const
@ FK_Enabled
Forcing enabled.
@ FK_Undefined
Not selected.
@ FK_Disabled
Forcing disabled.
unsigned getPredicate() const
void setAlreadyVectorized()
Mark the loop L as already vectorized by setting the width to 1.
const char * vectorizeAnalysisPassName() const
If hints are provided that force vectorization, use the AlwaysPrint pass name to force the frontend t...
unsigned getInterleave() const
unsigned getIsVectorized() const
void setPotentiallyUnsafe()
Represents a single loop in the control flow graph.
size_type count(const KeyT &Key) const
bool isSafeForAnyVectorWidth() const
Return true if the number of elements that are safe to operate on simultaneously is not bounded.
uint64_t getMaxSafeVectorWidthInBits() const
Return the number of elements that are safe to operate on simultaneously, multiplied by the size of t...
An interface layer with SCEV used to manage how we see SCEV expressions for values in the context of ...
Analysis providing profile information.
Holds information about the memory runtime legality checks to verify that a group of pointers do not ...
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
An instruction for storing to memory.
StringRef - Represent a constant reference to a string, i.e.
Provides information about what library functions are available for the current target.
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
@ BasicBlock
Various leaf nodes.
This is an optimization pass for GlobalISel generic memory operations.
bool hasDisableAllTransformsHint(const Loop *L)
Look for the loop attribute that disables all transformation heuristic.
TransformationMode hasUnrollTransformation(const Loop *L)
@ TM_Disable
The transformation should not be applied.