25 #define LV_NAME "loop-vectorize" 26 #define DEBUG_TYPE LV_NAME 32 cl::desc(
"Enable if-conversion during vectorization."));
36 cl::desc(
"The maximum allowed number of runtime memory checks with a " 37 "vectorize(enable) pragma."));
41 cl::desc(
"The maximum number of SCEV checks allowed."));
45 cl::desc(
"The maximum number of SCEV checks allowed with a " 46 "vectorize(enable) pragma"));
63 return (Val == 0 || Val == 1);
69 bool InterleaveOnlyWhenForced,
72 Interleave(
"interleave.count", InterleaveOnlyWhenForced, HK_UNROLL),
73 Force(
"vectorize.enable", FK_Undefined, HK_FORCE),
74 IsVectorized(
"isvectorized", 0, HK_ISVECTORIZED),
75 Predicate(
"vectorize.predicate.enable", FK_Undefined, HK_PREDICATE), TheLoop(L),
78 getHintsFromMetadata();
84 if (IsVectorized.Value != 1)
88 IsVectorized.Value = Width.Value == 1 && Interleave.Value == 1;
89 LLVM_DEBUG(
if (InterleaveOnlyWhenForced && Interleave.Value == 1)
dbgs()
90 <<
"LV: Interleaving disabled by the pass manager\n");
103 {
Twine(Prefix(),
"vectorize.").
str(),
104 Twine(Prefix(),
"interleave.").
str()},
109 IsVectorized.Value = 1;
115 LLVM_DEBUG(
dbgs() <<
"LV: Not vectorizing: #pragma vectorize disable.\n");
121 LLVM_DEBUG(
dbgs() <<
"LV: Not vectorizing: No #pragma vectorize enable.\n");
127 LLVM_DEBUG(
dbgs() <<
"LV: Not vectorizing: Disabled/already vectorized.\n");
135 <<
"loop not vectorized: vectorization and interleaving are " 136 "explicitly disabled, or the loop has already been " 151 TheLoop->getStartLoc(),
152 TheLoop->getHeader())
153 <<
"loop not vectorized: vectorization is explicitly disabled";
156 TheLoop->getStartLoc(), TheLoop->getHeader());
157 R <<
"loop not vectorized";
159 R <<
" (Force=" <<
NV(
"Force",
true);
160 if (Width.Value != 0)
161 R <<
", Vector Width=" <<
NV(
"VectorWidth", Width.Value);
162 if (Interleave.Value != 0)
163 R <<
", Interleave Count=" <<
NV(
"InterleaveCount", Interleave.Value);
181 void LoopVectorizeHints::getHintsFromMetadata() {
182 MDNode *LoopID = TheLoop->getLoopID();
190 for (
unsigned i = 1, ie = LoopID->
getNumOperands(); i < ie; ++i) {
197 if (!MD || MD->getNumOperands() == 0)
200 for (
unsigned i = 1, ie = MD->getNumOperands(); i < ie; ++i)
204 assert(Args.
size() == 0 &&
"too many arguments for MDString");
212 if (Args.
size() == 1)
213 setHint(Name, Args[0]);
227 Hint *Hints[] = {&Width, &Interleave, &Force, &IsVectorized, &
Predicate};
228 for (
auto H : Hints) {
229 if (Name ==
H->Name) {
230 if (
H->validate(Val))
233 LLVM_DEBUG(
dbgs() <<
"LV: ignoring invalid hint '" << Name <<
"'\n");
246 PassName,
"CantReorderFPOps", UnsafeAlgebraInst->getDebugLoc(),
247 UnsafeAlgebraInst->getParent())
248 <<
"loop not vectorized: cannot prove it is safe to reorder " 249 "floating-point operations";
255 bool PragmaThresholdReached =
257 bool ThresholdReached =
260 PragmaThresholdReached) {
265 <<
"loop not vectorized: cannot prove it is safe to reorder " 316 if (!LatchBr || LatchBr->isUnconditional()) {
325 dbgs() <<
"LV: Loop latch condition is not a compare instruction.\n");
329 Value *CondOp0 = LatchCmp->getOperand(0);
330 Value *CondOp1 = LatchCmp->getOperand(1);
331 Value *IVUpdate = IV->getIncomingValueForBlock(Latch);
334 LLVM_DEBUG(
dbgs() <<
"LV: Loop latch condition is not uniform.\n");
348 for (
Loop *SubLp : *Lp)
361 for (
Value *V : Phi.incoming_values())
362 if (
auto *
C = dyn_cast<Constant>(V))
395 if (!AllowedExit.
count(Inst))
401 LLVM_DEBUG(
dbgs() <<
"LV: Found an outside user for : " << *UI <<
'\n');
412 bool CanAddPredicate = !TheLoop->getHeader()->getParent()->hasOptSize();
413 int Stride =
getPtrStride(PSE, Ptr, TheLoop, Strides, CanAddPredicate,
false);
414 if (Stride == 1 || Stride == -1)
420 return LAI->isUniform(V);
423 bool LoopVectorizationLegality::canVectorizeOuterLoop() {
424 assert(!TheLoop->empty() &&
"We are not vectorizing an outer loop.");
428 bool DoExtraAnalysis = ORE->allowExtraAnalysis(
DEBUG_TYPE);
436 "loop control flow is not understood by vectorizer",
437 "CFGNotUnderstood", ORE, TheLoop);
450 if (!EnableVPlanPredication && Br && Br->isConditional() &&
451 !TheLoop->isLoopInvariant(Br->getCondition()) &&
452 !LI->isLoopHeader(Br->getSuccessor(0)) &&
453 !LI->isLoopHeader(Br->getSuccessor(1))) {
455 "loop control flow is not understood by vectorizer",
456 "CFGNotUnderstood", ORE, TheLoop);
469 "loop control flow is not understood by vectorizer",
470 "CFGNotUnderstood", ORE, TheLoop);
478 if (!setupOuterLoopInductions()) {
480 "Unsupported outer loop Phi(s)",
481 "UnsupportedPhi", ORE, TheLoop);
491 void LoopVectorizationLegality::addInductionPhi(
494 Inductions[Phi] =
ID;
502 InductionCastsToIgnore.insert(*Casts.
begin());
525 if (!PrimaryInduction || PhiTy == WidestIndTy)
526 PrimaryInduction = Phi;
535 if (PSE.getUnionPredicate().isAlwaysTrue()) {
543 bool LoopVectorizationLegality::setupOuterLoopInductions() {
547 auto isSupportedPhi = [&](
PHINode &Phi) ->
bool {
551 addInductionPhi(&Phi, ID, AllowedExit);
558 <<
"LV: Found unsupported PHI for outer loop vectorization.\n");
569 bool LoopVectorizationLegality::canVectorizeInstrs() {
581 if (
auto *Phi = dyn_cast<PHINode>(&
I)) {
587 "loop control flow is not understood by vectorizer",
588 "CFGNotUnderstood", ORE, TheLoop);
608 "loop control flow is not understood by vectorizer",
609 "CFGNotUnderstood", ORE, TheLoop, Phi);
619 Reductions[Phi] = RedDes;
639 addInductionPhi(Phi, ID, AllowedExit);
647 FirstOrderRecurrences.insert(Phi);
654 addInductionPhi(Phi, ID, AllowedExit);
659 "value that could not be identified as " 660 "reduction is used outside the loop",
661 "NonReductionValueUsedOutsideLoop", ORE, TheLoop, Phi);
671 !isa<DbgInfoIntrinsic>(CI) &&
672 !(CI->getCalledFunction() && TLI &&
673 TLI->isFunctionVectorizable(CI->getCalledFunction()->getName()))) {
678 TLI && CI->getCalledFunction() &&
679 CI->getType()->isFloatingPointTy() &&
680 TLI->getLibFunc(CI->getCalledFunction()->getName(), Func) &&
681 TLI->hasOptimizedCodeGen(Func);
689 "library call cannot be vectorized. " 690 "Try compiling with -fno-math-errno, -ffast-math, " 692 "CantVectorizeLibcall", ORE, TheLoop, CI);
695 "call instruction cannot be vectorized",
696 "CantVectorizeLibcall", ORE, TheLoop, CI);
704 auto *SE = PSE.getSE();
706 for (
unsigned i = 0,
e = CI->getNumArgOperands(); i !=
e; ++i)
708 if (!SE->isLoopInvariant(PSE.getSCEV(CI->getOperand(i)), TheLoop)) {
710 "intrinsic instruction cannot be vectorized",
711 "CantVectorizeIntrinsic", ORE, TheLoop, CI);
720 !
I.getType()->isVoidTy()) ||
721 isa<ExtractElementInst>(
I)) {
723 "instruction return type cannot be vectorized",
724 "CantVectorizeInstructionReturnType", ORE, TheLoop, &
I);
729 if (
auto *
ST = dyn_cast<StoreInst>(&
I)) {
730 Type *
T =
ST->getValueOperand()->getType();
733 "store instruction cannot be vectorized",
734 "CantVectorizeStore", ORE, TheLoop,
ST);
740 if (
ST->getMetadata(LLVMContext::MD_nontemporal)) {
743 assert(VecTy &&
"did not find vectorized version of stored type");
745 assert(Alignment &&
"Alignment should be set");
746 if (!TTI->isLegalNTStore(VecTy, *Alignment)) {
748 "nontemporal store instruction cannot be vectorized",
749 "nontemporal store instruction cannot be vectorized",
750 "CantVectorizeNontemporalStore", ORE, TheLoop,
ST);
755 }
else if (
auto *
LD = dyn_cast<LoadInst>(&
I)) {
756 if (
LD->getMetadata(LLVMContext::MD_nontemporal)) {
760 assert(VecTy &&
"did not find vectorized version of load type");
762 assert(Alignment &&
"Alignment should be set");
763 if (!TTI->isLegalNTLoad(VecTy, *Alignment)) {
765 "nontemporal load instruction cannot be vectorized",
766 "nontemporal load instruction cannot be vectorized",
767 "CantVectorizeNontemporalLoad", ORE, TheLoop,
LD);
777 }
else if (
I.getType()->isFloatingPointTy() && (CI ||
I.isBinaryOp()) &&
780 Hints->setPotentiallyUnsafe();
790 if (PSE.getUnionPredicate().isAlwaysTrue()) {
795 "value cannot be used outside the loop",
796 "ValueUsedOutsideLoop", ORE, TheLoop, &
I);
802 if (!PrimaryInduction) {
803 if (Inductions.empty()) {
805 "loop induction variable could not be identified",
806 "NoInductionVariable", ORE, TheLoop);
808 }
else if (!WidestIndTy) {
810 "integer loop induction variable could not be identified",
811 "NoIntegerInductionVariable", ORE, TheLoop);
814 LLVM_DEBUG(
dbgs() <<
"LV: Did not find one integer induction var.\n");
822 BasicBlock *LoopLatch = TheLoop->getLoopLatch();
823 if (
any_of(FirstOrderRecurrences, [LoopLatch,
this](
const PHINode *Phi) {
826 return SinkAfter.find(V) != SinkAfter.end();
833 if (PrimaryInduction && WidestIndTy != PrimaryInduction->getType())
834 PrimaryInduction =
nullptr;
839 bool LoopVectorizationLegality::canVectorizeMemory() {
840 LAI = &(*GetLAA)(*TheLoop);
845 "loop not vectorized: ", *LAR);
848 if (!LAI->canVectorizeMemory())
851 if (LAI->hasDependenceInvolvingLoopInvariantAddress()) {
853 "write to a loop invariant address could not be vectorized",
854 "CantVectorizeStoreToLoopInvariantAddress", ORE, TheLoop);
857 Requirements->addRuntimePointerChecks(LAI->getNumRuntimePointerChecks());
858 PSE.addPredicate(LAI->getPSE().getUnionPredicate());
865 PHINode *PN = dyn_cast_or_null<PHINode>(In0);
869 return Inductions.count(PN);
874 return (Inst && InductionCastsToIgnore.count(Inst));
878 return isInductionPhi(V) || isCastedInductionVariable(V);
882 return FirstOrderRecurrences.count(Phi);
889 bool LoopVectorizationLegality::blockCanBePredicated(
891 const bool IsAnnotatedParallel = TheLoop->isAnnotatedParallel();
895 for (
Value *Operand :
I.operands()) {
896 if (
auto *
C = dyn_cast<Constant>(Operand))
901 if (
I.mayReadFromMemory()) {
905 if (!SafePtrs.
count(LI->getPointerOperand())) {
909 if (!IsAnnotatedParallel || PreserveGuards)
915 if (
I.mayWriteToMemory()) {
934 bool LoopVectorizationLegality::canVectorizeWithIfConvert() {
937 "if-conversion is disabled",
938 "IfConversionDisabled",
943 assert(TheLoop->getNumBlocks() > 1 &&
"Single block loops are vectorizable");
954 if (!blockNeedsPredication(BB)) {
981 "loop contains a switch statement",
982 "LoopContainsSwitch", ORE, TheLoop,
988 if (blockNeedsPredication(BB)) {
989 if (!blockCanBePredicated(BB, SafePointes)) {
991 "Control flow cannot be substituted for a select",
992 "control flow cannot be substituted for a select",
993 "NoCFGForSelect", ORE, TheLoop,
999 "Control flow cannot be substituted for a select",
1000 "control flow cannot be substituted for a select",
1001 "NoCFGForSelect", ORE, TheLoop,
1012 bool LoopVectorizationLegality::canVectorizeLoopCFG(
Loop *Lp,
1013 bool UseVPlanNativePath) {
1015 "VPlan-native path is not enabled.");
1025 bool DoExtraAnalysis = ORE->allowExtraAnalysis(
DEBUG_TYPE);
1031 "loop control flow is not understood by vectorizer",
1032 "CFGNotUnderstood", ORE, TheLoop);
1033 if (DoExtraAnalysis)
1042 "loop control flow is not understood by vectorizer",
1043 "CFGNotUnderstood", ORE, TheLoop);
1044 if (DoExtraAnalysis)
1053 "loop control flow is not understood by vectorizer",
1054 "CFGNotUnderstood", ORE, TheLoop);
1055 if (DoExtraAnalysis)
1066 "loop control flow is not understood by vectorizer",
1067 "CFGNotUnderstood", ORE, TheLoop);
1068 if (DoExtraAnalysis)
1077 bool LoopVectorizationLegality::canVectorizeLoopNestCFG(
1078 Loop *Lp,
bool UseVPlanNativePath) {
1082 bool DoExtraAnalysis = ORE->allowExtraAnalysis(
DEBUG_TYPE);
1083 if (!canVectorizeLoopCFG(Lp, UseVPlanNativePath)) {
1084 if (DoExtraAnalysis)
1092 for (
Loop *SubLp : *Lp)
1093 if (!canVectorizeLoopNestCFG(SubLp, UseVPlanNativePath)) {
1094 if (DoExtraAnalysis)
1108 bool DoExtraAnalysis = ORE->allowExtraAnalysis(
DEBUG_TYPE);
1111 if (!canVectorizeLoopNestCFG(TheLoop, UseVPlanNativePath)) {
1112 if (DoExtraAnalysis)
1119 LLVM_DEBUG(
dbgs() <<
"LV: Found a loop: " << TheLoop->getHeader()->getName()
1124 if (!TheLoop->empty()) {
1125 assert(UseVPlanNativePath &&
"VPlan-native path is not enabled.");
1127 if (!canVectorizeOuterLoop()) {
1129 "unsupported outer loop",
1130 "UnsupportedOuterLoop",
1141 assert(TheLoop->empty() &&
"Inner loop expected.");
1143 unsigned NumBlocks = TheLoop->getNumBlocks();
1144 if (NumBlocks != 1 && !canVectorizeWithIfConvert()) {
1146 if (DoExtraAnalysis)
1153 if (!canVectorizeInstrs()) {
1154 LLVM_DEBUG(
dbgs() <<
"LV: Can't vectorize the instructions or CFG\n");
1155 if (DoExtraAnalysis)
1162 if (!canVectorizeMemory()) {
1163 LLVM_DEBUG(
dbgs() <<
"LV: Can't vectorize due to memory conflicts\n");
1164 if (DoExtraAnalysis)
1171 << (LAI->getRuntimePointerChecking()->Need
1172 ?
" (with a runtime bound check)" 1180 if (PSE.getUnionPredicate().getComplexity() > SCEVThreshold) {
1182 "Too many SCEV assumptions need to be made and checked at runtime",
1183 "TooManySCEVRunTimeChecks", ORE, TheLoop);
1184 if (DoExtraAnalysis)
1199 LLVM_DEBUG(
dbgs() <<
"LV: checking if tail can be folded by masking.\n");
1201 if (!PrimaryInduction) {
1203 "No primary induction, cannot fold tail by masking",
1204 "Missing a primary induction variable in the loop, which is " 1205 "needed in order to fold tail by masking as required.",
1206 "NoPrimaryInduction", ORE, TheLoop);
1212 for (
auto &
Reduction : *getReductionVars())
1216 for (
auto *AE : AllowedExit) {
1219 if (ReductionLiveOuts.
count(AE))
1223 if (TheLoop->contains(UI))
1226 "Cannot fold tail by masking, loop has an outside user for",
1227 "Cannot fold tail by masking in the presence of live outs.",
1228 "LiveOutFoldingTailByMasking", ORE, TheLoop, UI);
1239 if (!blockCanBePredicated(BB, SafePointers,
true)) {
1241 "Cannot fold tail by masking as required",
1242 "control flow cannot be substituted for a select",
1243 "NoCFGForSelect", ORE, TheLoop,
static bool isUniformLoop(Loop *Lp, Loop *OuterLp)
static unsigned RuntimeMemoryCheckThreshold
performing memory disambiguation checks at runtime do not make more than this number of comparisons...
A parsed version of the target data layout string in and methods for querying it. ...
This class is the base class for the comparison instructions.
unsigned getWidth() const
bool allowReordering() const
BlockT * getLoopLatch() const
If there is a single latch block for this loop, return it.
static Type * getWiderType(const DataLayout &DL, Type *Ty0, Type *Ty1)
DiagnosticInfoOptimizationBase::Argument NV
This class represents lattice values for constants.
void reportVectorizationFailure(const StringRef DebugMsg, const StringRef OREMsg, const StringRef ORETag, OptimizationRemarkEmitter *ORE, Loop *TheLoop, Instruction *I=nullptr)
Reports a vectorization failure: print DebugMsg for debugging purposes along with the corresponding o...
Instruction * getUnsafeAlgebraInst()
Returns first unsafe algebra instruction in the PHI node's use-chain.
bool isCastedInductionVariable(const Value *V)
Returns True if V is a cast that is part of an induction def-use chain, and had been proven to be red...
static bool isInductionPHI(PHINode *Phi, const Loop *L, ScalarEvolution *SE, InductionDescriptor &D, const SCEV *Expr=nullptr, SmallVectorImpl< Instruction *> *CastsToIgnore=nullptr)
Returns true if Phi is an induction in the loop L.
amdgpu Simplify well known AMD library false FunctionCallee Value const Twine & Name
static MDString * get(LLVMContext &Context, StringRef Str)
ConstantInt * getConstIntStepValue() const
LLVM_NODISCARD bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
void push_back(const T &Elt)
llvm::MDNode * makePostTransformationMetadata(llvm::LLVMContext &Context, MDNode *OrigLoopID, llvm::ArrayRef< llvm::StringRef > RemovePrefixes, llvm::ArrayRef< llvm::MDNode *> AddAttrs)
Create a new LoopID after the loop has been transformed.
The main scalar evolution driver.
bool isUniform(Value *V)
Returns true if the value V is uniform within the loop.
TODO: The following VectorizationFactor was pulled out of LoopVectorizationCostModel class...
This class represents a function call, abstracting a target machine's calling convention.
int64_t getPtrStride(PredicatedScalarEvolution &PSE, Value *Ptr, const Loop *Lp, const ValueToValueMap &StridesMap=ValueToValueMap(), bool Assume=false, bool ShouldCheckWrap=true)
If the pointer has a constant stride return it in units of its element size.
BlockT * getLoopPreheader() const
If there is a preheader for this loop, return it.
bool mustSuppressSpeculation(const LoadInst &LI)
Return true if speculation of the given load must be suppressed to avoid ordering or interfering with...
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly...
InductionKind getKind() const
const MDOperand & getOperand(unsigned I) const
An instruction for reading from memory.
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
cl::opt< bool > EnableVPlanPredication
Value * getStartValue() const
LLVMContext & getContext() const
Get the context in which this basic block lives.
const char * vectorizeAnalysisPassName() const
If hints are provided that force vectorization, use the AlwaysPrint pass name to force the frontend t...
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
Intrinsic::ID getVectorIntrinsicIDForCall(const CallInst *CI, const TargetLibraryInfo *TLI)
Returns intrinsic ID for call.
const Value * getLoadStorePointerOperand(const Value *V)
A helper function that returns the pointer operand of a load or store instruction.
bool hasUnsafeAlgebra()
Returns true if the recurrence has unsafe algebra which requires a relaxed floating-point model...
unsigned getNumBackEdges() const
Calculate the number of back edges to the loop header.
This file defines the LoopVectorizationLegality class.
const DataLayout & getDataLayout() const
Get the data layout for the module's target platform.
static const unsigned MaxVectorWidth
Maximum SIMD width.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
bool isFloatingPointTy() const
Return true if this is one of the six floating-point types.
static cl::opt< bool > EnableIfConversion("enable-if-conversion", cl::init(true), cl::Hidden, cl::desc("Enable if-conversion during vectorization."))
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
bool isIntegerTy() const
True if this is an instance of IntegerType.
LLVM_NODISCARD StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
BlockT * getHeader() const
int isConsecutivePtr(Value *Ptr)
Check if this pointer is consecutive when vectorizing.
bool isOne() const
This is just a convenience method to make client code smaller for a common case.
Type * getType() const
All values are typed, get the type of this value.
bool isInductionVariable(const Value *V)
Returns True if V can be considered as an induction variable in this loop.
void setLoopID(MDNode *LoopID) const
Set the llvm.loop loop id metadata for this loop.
static bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
An instruction for storing to memory.
static cl::opt< unsigned > PragmaVectorizeMemoryCheckThreshold("pragma-vectorize-memory-check-threshold", cl::init(128), cl::Hidden, cl::desc("The maximum allowed number of runtime memory checks with a " "vectorize(enable) pragma."))
bool blockNeedsPredication(BasicBlock *BB)
Return true if the block BB needs to be predicated in order for the loop to be vectorized.
StringRef getString() const
IntegerType * getIntPtrType(LLVMContext &C, unsigned AddressSpace=0) const
Returns an integer type with size at least as big as that of a pointer in the given address space...
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata *> MDs)
enum ForceKind getForce() const
initializer< Ty > init(const Ty &Val)
Integer induction variable. Step = C.
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
static bool hasOutsideLoopUser(const Loop *TheLoop, Instruction *Inst, SmallPtrSetImpl< Value *> &AllowedExit)
Check that the instruction has outside loop users and is not an identified reduction variable...
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
LLVM Basic Block Representation.
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important class for using LLVM in a threaded context.
Conditional or Unconditional Branch instruction.
bool prepareToFoldTailByMasking()
Return true if we can vectorize this loop while folding its tail by masking, and mark all respective ...
Instruction * getUnsafeAlgebraInst()
Returns induction operator that does not have "fast-math" property and requires FP unsafe mode...
Value * getIncomingValueForBlock(const BasicBlock *BB) const
bool allowVectorization(Function *F, Loop *L, bool VectorizeOnlyWhenForced) const
bool isPointerTy() const
True if this is an instance of PointerType.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly...
amdgpu Simplify well known AMD library false FunctionCallee Value * Arg
Value * getPointerOperand()
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
static bool isReductionPHI(PHINode *Phi, Loop *TheLoop, RecurrenceDescriptor &RedDes, DemandedBits *DB=nullptr, AssumptionCache *AC=nullptr, DominatorTree *DT=nullptr)
Returns true if Phi is a reduction in TheLoop.
static bool isUniformLoopNest(Loop *Lp, Loop *OuterLp)
bool doesNotMeet(Function *F, Loop *L, const LoopVectorizeHints &Hints)
DebugLoc getStartLoc() const
Return the debug location of the start of this loop.
static bool isFirstOrderRecurrence(PHINode *Phi, Loop *TheLoop, DenseMap< Instruction *, Instruction *> &SinkAfter, DominatorTree *DT)
Returns true if Phi is a first-order recurrence.
bool isLoopInvariant(const Value *V) const
Return true if the specified value is loop invariant.
unsigned getIsVectorized() const
The RecurrenceDescriptor is used to identify recurrences variables in a loop.
bool contains(const LoopT *L) const
Return true if the specified loop is contained within in this loop.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements...
This is the shared class of boolean and integer constants.
auto size(R &&Range, typename std::enable_if< std::is_same< typename std::iterator_traits< decltype(Range.begin())>::iterator_category, std::random_access_iterator_tag >::value, void >::type *=nullptr) -> decltype(std::distance(Range.begin(), Range.end()))
Get the size of a range.
A struct for saving information about induction variables.
testing::Matcher< const detail::ErrorHolder & > Failed()
unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type...
This struct is a compact representation of a valid (power of two) or undefined (0) alignment...
DenseMap< const Value *, Value * > ValueToValueMap
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
bool isFirstOrderRecurrence(const PHINode *Phi)
Returns True if Phi is a first-order recurrence in this loop.
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
static const unsigned MaxInterleaveFactor
Maximum vectorization interleave count.
bool hasVectorInstrinsicScalarOpd(Intrinsic::ID ID, unsigned ScalarOpdIdx)
Identifies if the vector form of the intrinsic has a scalar operand.
unsigned getNumIncomingValues() const
Return the number of incoming edges.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
PHINode * getCanonicalInductionVariable() const
Check to see if the loop has a canonical induction variable: an integer recurrence that starts at 0 a...
static bool canIfConvertPHINodes(BasicBlock *BB)
Check whether it is safe to if-convert this phi node.
const Module * getModule() const
Return the module owning the function this instruction belongs to or nullptr it the function does not...
bool isInductionPhi(const Value *V)
Returns True if V is a Phi node of an induction variable in this loop.
Class for arbitrary precision integers.
iterator_range< user_iterator > users()
loop Loop Strength Reduction
bool hasUnsafeAlgebra()
Returns true if the induction type is FP and the binary operator does not have the "fast-math" proper...
const SmallVectorImpl< Instruction * > & getCastInsts() const
Returns a reference to the type cast instructions in the induction update chain, that are redundant w...
bool isDereferenceableAndAlignedInLoop(LoadInst *LI, Loop *L, ScalarEvolution &SE, DominatorTree &DT)
Return true if we can prove that the given load (which is assumed to be within the specified loop) wo...
LoopVectorizeHints(const Loop *L, bool InterleaveOnlyWhenForced, OptimizationRemarkEmitter &ORE)
MDNode * getLoopID() const
Return the llvm.loop loop id metadata node for this loop if it is present.
static IntegerType * getInt32Ty(LLVMContext &C)
LLVM_NODISCARD bool empty() const
Instruction * getLoopExitInstr()
StringRef getValueAsString() const
Return the attribute's value as a string.
Represents a single loop in the control flow graph.
static VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
const Function * getParent() const
Return the enclosing method, or null if none.
LLVM_NODISCARD std::enable_if<!is_simple_type< Y >::value, typename cast_retty< X, const Y >::ret_type >::type dyn_cast(const Y &Val)
iterator_range< const_phi_iterator > phis() const
Returns a range that iterates over the phis in the basic block.
Collection of parameters shared beetween the Loop Vectorizer and the Loop Access Analysis.
bool canVectorize(bool UseVPlanNativePath)
Returns true if it is legal to vectorize this loop.
std::string str() const
Return the twine contents as a std::string.
void setAlreadyVectorized()
Mark the loop L as already vectorized by setting the width to 1.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
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.
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
static unsigned VectorizationInterleave
Interleave factor as overridden by the user.
static Type * convertPointerToIntegerType(const DataLayout &DL, Type *Ty)
StringRef - Represent a constant reference to a string, i.e.
static cl::opt< unsigned > VectorizeSCEVCheckThreshold("vectorize-scev-check-threshold", cl::init(16), cl::Hidden, cl::desc("The maximum number of SCEV checks allowed."))
static cl::opt< unsigned > PragmaVectorizeSCEVCheckThreshold("pragma-vectorize-scev-check-threshold", cl::init(128), cl::Hidden, cl::desc("The maximum number of SCEV checks allowed with a " "vectorize(enable) pragma"))
Utility class for getting and setting loop vectorizer hints in the form of loop metadata.
static bool isInterleaveForced()
True if force-vector-interleave was specified by the user.
unsigned getNumOperands() const
Return number of MDNode operands.
MaybeAlign getLoadStoreAlignment(Value *I)
A helper function that returns the alignment of load or store instruction.
BlockT * getExitingBlock() const
If getExitingBlocks would return exactly one block, return that block.
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
void emitRemarkWithHints() const
Dumps all the hint information.
void validate(const Triple &TT, const FeatureBitset &FeatureBits)