23 #define LV_NAME "loop-vectorize" 24 #define DEBUG_TYPE LV_NAME 28 cl::desc(
"Enable if-conversion during vectorization."));
32 cl::desc(
"The maximum allowed number of runtime memory checks with a " 33 "vectorize(enable) pragma."));
37 cl::desc(
"The maximum number of SCEV checks allowed."));
41 cl::desc(
"The maximum number of SCEV checks allowed with a " 42 "vectorize(enable) pragma"));
65 R <<
"loop not vectorized: ";
69 bool LoopVectorizeHints::Hint::validate(
unsigned Val) {
78 return (Val == 0 || Val == 1);
84 bool InterleaveOnlyWhenForced,
87 Interleave(
"interleave.count", InterleaveOnlyWhenForced, HK_UNROLL),
88 Force(
"vectorize.enable", FK_Undefined, HK_FORCE),
89 IsVectorized(
"isvectorized", 0, HK_ISVECTORIZED), TheLoop(L), ORE(ORE) {
91 getHintsFromMetadata();
97 if (IsVectorized.Value != 1)
101 IsVectorized.Value = Width.Value == 1 && Interleave.Value == 1;
102 LLVM_DEBUG(
if (InterleaveOnlyWhenForced && Interleave.Value == 1)
dbgs()
103 <<
"LV: Interleaving disabled by the pass manager\n");
109 LLVM_DEBUG(
dbgs() <<
"LV: Not vectorizing: #pragma vectorize disable.\n");
115 LLVM_DEBUG(
dbgs() <<
"LV: Not vectorizing: No #pragma vectorize enable.\n");
121 LLVM_DEBUG(
dbgs() <<
"LV: Not vectorizing: Disabled/already vectorized.\n");
129 <<
"loop not vectorized: vectorization and interleaving are " 130 "explicitly disabled, or the loop has already been " 145 TheLoop->getStartLoc(),
146 TheLoop->getHeader())
147 <<
"loop not vectorized: vectorization is explicitly disabled";
150 TheLoop->getStartLoc(), TheLoop->getHeader());
151 R <<
"loop not vectorized";
153 R <<
" (Force=" <<
NV(
"Force",
true);
154 if (Width.Value != 0)
155 R <<
", Vector Width=" <<
NV(
"VectorWidth", Width.Value);
156 if (Interleave.Value != 0)
157 R <<
", Interleave Count=" <<
NV(
"InterleaveCount", Interleave.Value);
175 void LoopVectorizeHints::getHintsFromMetadata() {
176 MDNode *LoopID = TheLoop->getLoopID();
184 for (
unsigned i = 1, ie = LoopID->
getNumOperands(); i < ie; ++i) {
191 if (!MD || MD->getNumOperands() == 0)
194 for (
unsigned i = 1, ie = MD->getNumOperands(); i < ie; ++i)
198 assert(Args.
size() == 0 &&
"too many arguments for MDString");
206 if (Args.
size() == 1)
207 setHint(Name, Args[0]);
221 Hint *Hints[] = {&Width, &Interleave, &Force, &IsVectorized};
222 for (
auto H : Hints) {
223 if (Name ==
H->Name) {
224 if (
H->validate(Val))
227 LLVM_DEBUG(
dbgs() <<
"LV: ignoring invalid hint '" << Name <<
"'\n");
242 bool LoopVectorizeHints::matchesHintMetadataName(
MDNode *Node,
248 for (
auto H : HintTypes)
254 void LoopVectorizeHints::writeHintsToMetadata(
ArrayRef<Hint> HintTypes) {
255 if (HintTypes.
empty())
261 MDNode *LoopID = TheLoop->getLoopID();
263 for (
unsigned i = 1, ie = LoopID->
getNumOperands(); i < ie; ++i) {
266 if (!matchesHintMetadataName(Node, HintTypes))
272 for (
auto H : HintTypes)
281 TheLoop->setLoopID(NewLoopID);
291 PassName,
"CantReorderFPOps", UnsafeAlgebraInst->getDebugLoc(),
292 UnsafeAlgebraInst->getParent())
293 <<
"loop not vectorized: cannot prove it is safe to reorder " 294 "floating-point operations";
300 bool PragmaThresholdReached =
302 bool ThresholdReached =
305 PragmaThresholdReached) {
310 <<
"loop not vectorized: cannot prove it is safe to reorder " 361 if (!LatchBr || LatchBr->isUnconditional()) {
370 dbgs() <<
"LV: Loop latch condition is not a compare instruction.\n");
374 Value *CondOp0 = LatchCmp->getOperand(0);
375 Value *CondOp1 = LatchCmp->getOperand(1);
376 Value *IVUpdate = IV->getIncomingValueForBlock(Latch);
379 LLVM_DEBUG(
dbgs() <<
"LV: Loop latch condition is not uniform.\n");
393 for (
Loop *SubLp : *Lp)
406 for (
Value *V : Phi.incoming_values())
407 if (
auto *
C = dyn_cast<Constant>(V))
440 if (!AllowedExit.
count(Inst))
446 LLVM_DEBUG(
dbgs() <<
"LV: Found an outside user for : " << *UI <<
'\n');
457 int Stride =
getPtrStride(PSE, Ptr, TheLoop, Strides,
true,
false);
458 if (Stride == 1 || Stride == -1)
464 return LAI->isUniform(V);
467 bool LoopVectorizationLegality::canVectorizeOuterLoop() {
468 assert(!TheLoop->empty() &&
"We are not vectorizing an outer loop.");
472 bool DoExtraAnalysis = ORE->allowExtraAnalysis(
DEBUG_TYPE);
479 LLVM_DEBUG(
dbgs() <<
"LV: Unsupported basic block terminator.\n");
480 ORE->emit(createMissedAnalysis(
"CFGNotUnderstood")
481 <<
"loop control flow is not understood by vectorizer");
491 if (Br && Br->isConditional() &&
492 !TheLoop->isLoopInvariant(Br->getCondition()) &&
493 !LI->isLoopHeader(Br->getSuccessor(0)) &&
494 !LI->isLoopHeader(Br->getSuccessor(1))) {
496 ORE->emit(createMissedAnalysis(
"CFGNotUnderstood")
497 <<
"loop control flow is not understood by vectorizer");
511 <<
"LV: Not vectorizing: Outer loop contains divergent loops.\n");
512 ORE->emit(createMissedAnalysis(
"CFGNotUnderstood")
513 <<
"loop control flow is not understood by vectorizer");
521 if (!setupOuterLoopInductions()) {
523 dbgs() <<
"LV: Not vectorizing: Unsupported outer loop Phi(s).\n");
524 ORE->emit(createMissedAnalysis(
"UnsupportedPhi")
525 <<
"Unsupported outer loop Phi(s)");
535 void LoopVectorizationLegality::addInductionPhi(
538 Inductions[Phi] =
ID;
546 InductionCastsToIgnore.insert(*Casts.
begin());
569 if (!PrimaryInduction || PhiTy == WidestIndTy)
570 PrimaryInduction = Phi;
579 if (PSE.getUnionPredicate().isAlwaysTrue()) {
587 bool LoopVectorizationLegality::setupOuterLoopInductions() {
591 auto isSupportedPhi = [&](
PHINode &Phi) ->
bool {
595 addInductionPhi(&Phi, ID, AllowedExit);
602 <<
"LV: Found unsupported PHI for outer loop vectorization.\n");
613 bool LoopVectorizationLegality::canVectorizeInstrs() {
625 if (
auto *Phi = dyn_cast<PHINode>(&
I)) {
630 ORE->emit(createMissedAnalysis(
"CFGNotUnderstood", Phi)
631 <<
"loop control flow is not understood by vectorizer");
650 ORE->emit(createMissedAnalysis(
"CFGNotUnderstood", Phi)
651 <<
"control flow not understood by vectorizer");
662 Reductions[Phi] = RedDes;
682 addInductionPhi(Phi, ID, AllowedExit);
690 FirstOrderRecurrences.insert(Phi);
697 addInductionPhi(Phi, ID, AllowedExit);
701 ORE->emit(createMissedAnalysis(
"NonReductionValueUsedOutsideLoop", Phi)
702 <<
"value that could not be identified as " 703 "reduction is used outside the loop");
704 LLVM_DEBUG(
dbgs() <<
"LV: Found an unidentified PHI." << *Phi <<
"\n");
714 !isa<DbgInfoIntrinsic>(CI) &&
715 !(CI->getCalledFunction() && TLI &&
716 TLI->isFunctionVectorizable(CI->getCalledFunction()->getName()))) {
721 TLI && CI->getCalledFunction() &&
722 CI->getType()->isFloatingPointTy() &&
723 TLI->getLibFunc(CI->getCalledFunction()->getName(), Func) &&
724 TLI->hasOptimizedCodeGen(Func);
731 ORE->emit(createMissedAnalysis(
"CantVectorizeLibcall", CI)
732 <<
"library call cannot be vectorized. " 733 "Try compiling with -fno-math-errno, -ffast-math, " 736 ORE->emit(createMissedAnalysis(
"CantVectorizeCall", CI)
737 <<
"call instruction cannot be vectorized");
740 dbgs() <<
"LV: Found a non-intrinsic callsite.\n");
748 auto *SE = PSE.getSE();
749 if (!SE->isLoopInvariant(PSE.getSCEV(CI->getOperand(1)), TheLoop)) {
750 ORE->emit(createMissedAnalysis(
"CantVectorizeIntrinsic", CI)
751 <<
"intrinsic instruction cannot be vectorized");
753 <<
"LV: Found unvectorizable intrinsic " << *CI <<
"\n");
761 !
I.getType()->isVoidTy()) ||
762 isa<ExtractElementInst>(
I)) {
763 ORE->emit(createMissedAnalysis(
"CantVectorizeInstructionReturnType", &
I)
764 <<
"instruction return type cannot be vectorized");
770 if (
auto *
ST = dyn_cast<StoreInst>(&
I)) {
771 Type *
T =
ST->getValueOperand()->getType();
773 ORE->emit(createMissedAnalysis(
"CantVectorizeStore",
ST)
774 <<
"store instruction cannot be vectorized");
783 }
else if (
I.getType()->isFloatingPointTy() && (CI ||
I.isBinaryOp()) &&
786 Hints->setPotentiallyUnsafe();
796 if (PSE.getUnionPredicate().isAlwaysTrue()) {
800 ORE->emit(createMissedAnalysis(
"ValueUsedOutsideLoop", &
I)
801 <<
"value cannot be used outside the loop");
807 if (!PrimaryInduction) {
808 LLVM_DEBUG(
dbgs() <<
"LV: Did not find one integer induction var.\n");
809 if (Inductions.empty()) {
810 ORE->emit(createMissedAnalysis(
"NoInductionVariable")
811 <<
"loop induction variable could not be identified");
813 }
else if (!WidestIndTy) {
814 ORE->emit(createMissedAnalysis(
"NoIntegerInductionVariable")
815 <<
"integer loop induction variable could not be identified");
823 if (PrimaryInduction && WidestIndTy != PrimaryInduction->getType())
824 PrimaryInduction =
nullptr;
829 bool LoopVectorizationLegality::canVectorizeMemory() {
830 LAI = &(*GetLAA)(*TheLoop);
835 "loop not vectorized: ", *LAR);
838 if (!LAI->canVectorizeMemory())
841 if (LAI->hasDependenceInvolvingLoopInvariantAddress()) {
842 ORE->emit(createMissedAnalysis(
"CantVectorizeStoreToLoopInvariantAddress")
843 <<
"write to a loop invariant address could not " 846 dbgs() <<
"LV: Non vectorizable stores to a uniform address\n");
849 Requirements->addRuntimePointerChecks(LAI->getNumRuntimePointerChecks());
850 PSE.addPredicate(LAI->getPSE().getUnionPredicate());
857 PHINode *PN = dyn_cast_or_null<PHINode>(In0);
861 return Inductions.count(PN);
866 return (Inst && InductionCastsToIgnore.count(Inst));
870 return isInductionPhi(V) || isCastedInductionVariable(V);
874 return FirstOrderRecurrences.count(Phi);
881 bool LoopVectorizationLegality::blockCanBePredicated(
883 const bool IsAnnotatedParallel = TheLoop->isAnnotatedParallel();
887 for (
Value *Operand :
I.operands()) {
888 if (
auto *
C = dyn_cast<Constant>(Operand))
893 if (
I.mayReadFromMemory()) {
897 if (!SafePtrs.
count(LI->getPointerOperand())) {
901 if (!IsAnnotatedParallel)
907 if (
I.mayWriteToMemory()) {
926 bool LoopVectorizationLegality::canVectorizeWithIfConvert() {
928 ORE->emit(createMissedAnalysis(
"IfConversionDisabled")
929 <<
"if-conversion is disabled");
933 assert(TheLoop->getNumBlocks() > 1 &&
"Single block loops are vectorizable");
940 if (blockNeedsPredication(BB))
953 ORE->emit(createMissedAnalysis(
"LoopContainsSwitch", BB->
getTerminator())
954 <<
"loop contains a switch statement");
959 if (blockNeedsPredication(BB)) {
960 if (!blockCanBePredicated(BB, SafePointes)) {
961 ORE->emit(createMissedAnalysis(
"NoCFGForSelect", BB->
getTerminator())
962 <<
"control flow cannot be substituted for a select");
966 ORE->emit(createMissedAnalysis(
"NoCFGForSelect", BB->
getTerminator())
967 <<
"control flow cannot be substituted for a select");
977 bool LoopVectorizationLegality::canVectorizeLoopCFG(
Loop *Lp,
978 bool UseVPlanNativePath) {
980 "VPlan-native path is not enabled.");
990 bool DoExtraAnalysis = ORE->allowExtraAnalysis(
DEBUG_TYPE);
995 LLVM_DEBUG(
dbgs() <<
"LV: Loop doesn't have a legal pre-header.\n");
996 ORE->emit(createMissedAnalysis(
"CFGNotUnderstood")
997 <<
"loop control flow is not understood by vectorizer");
1006 ORE->emit(createMissedAnalysis(
"CFGNotUnderstood")
1007 <<
"loop control flow is not understood by vectorizer");
1008 if (DoExtraAnalysis)
1016 ORE->emit(createMissedAnalysis(
"CFGNotUnderstood")
1017 <<
"loop control flow is not understood by vectorizer");
1018 if (DoExtraAnalysis)
1028 ORE->emit(createMissedAnalysis(
"CFGNotUnderstood")
1029 <<
"loop control flow is not understood by vectorizer");
1030 if (DoExtraAnalysis)
1039 bool LoopVectorizationLegality::canVectorizeLoopNestCFG(
1040 Loop *Lp,
bool UseVPlanNativePath) {
1044 bool DoExtraAnalysis = ORE->allowExtraAnalysis(
DEBUG_TYPE);
1045 if (!canVectorizeLoopCFG(Lp, UseVPlanNativePath)) {
1046 if (DoExtraAnalysis)
1054 for (
Loop *SubLp : *Lp)
1055 if (!canVectorizeLoopNestCFG(SubLp, UseVPlanNativePath)) {
1056 if (DoExtraAnalysis)
1070 bool DoExtraAnalysis = ORE->allowExtraAnalysis(
DEBUG_TYPE);
1073 if (!canVectorizeLoopNestCFG(TheLoop, UseVPlanNativePath)) {
1074 if (DoExtraAnalysis)
1081 LLVM_DEBUG(
dbgs() <<
"LV: Found a loop: " << TheLoop->getHeader()->getName()
1086 if (!TheLoop->empty()) {
1087 assert(UseVPlanNativePath &&
"VPlan-native path is not enabled.");
1089 if (!canVectorizeOuterLoop()) {
1090 LLVM_DEBUG(
dbgs() <<
"LV: Not vectorizing: Unsupported outer loop.\n");
1100 assert(TheLoop->empty() &&
"Inner loop expected.");
1102 unsigned NumBlocks = TheLoop->getNumBlocks();
1103 if (NumBlocks != 1 && !canVectorizeWithIfConvert()) {
1105 if (DoExtraAnalysis)
1112 if (!canVectorizeInstrs()) {
1113 LLVM_DEBUG(
dbgs() <<
"LV: Can't vectorize the instructions or CFG\n");
1114 if (DoExtraAnalysis)
1121 if (!canVectorizeMemory()) {
1122 LLVM_DEBUG(
dbgs() <<
"LV: Can't vectorize due to memory conflicts\n");
1123 if (DoExtraAnalysis)
1130 << (LAI->getRuntimePointerChecking()->Need
1131 ?
" (with a runtime bound check)" 1139 if (PSE.getUnionPredicate().getComplexity() > SCEVThreshold) {
1140 ORE->emit(createMissedAnalysis(
"TooManySCEVRunTimeChecks")
1141 <<
"Too many SCEV assumptions need to be made and checked " 1144 if (DoExtraAnalysis)
1159 LLVM_DEBUG(
dbgs() <<
"LV: checking if tail can be folded by masking.\n");
1161 if (!PrimaryInduction) {
1162 ORE->emit(createMissedAnalysis(
"NoPrimaryInduction")
1163 <<
"Missing a primary induction variable in the loop, which is " 1164 <<
"needed in order to fold tail by masking as required.");
1165 LLVM_DEBUG(
dbgs() <<
"LV: No primary induction, cannot fold tail by " 1171 if (!Reductions.empty()) {
1172 ORE->emit(createMissedAnalysis(
"ReductionFoldingTailByMasking")
1173 <<
"Cannot fold tail by masking in the presence of reductions.");
1174 LLVM_DEBUG(
dbgs() <<
"LV: Loop has reductions, cannot fold tail by " 1180 for (
auto *AE : AllowedExit) {
1184 if (TheLoop->contains(UI))
1186 ORE->emit(createMissedAnalysis(
"LiveOutFoldingTailByMasking")
1187 <<
"Cannot fold tail by masking in the presence of live outs.");
1188 LLVM_DEBUG(
dbgs() <<
"LV: Cannot fold tail by masking, loop has an " 1189 <<
"outside user for : " << *UI <<
'\n');
1200 if (!blockCanBePredicated(BB, SafePointers)) {
1201 ORE->emit(createMissedAnalysis(
"NoCFGForSelect", BB->
getTerminator())
1202 <<
"control flow cannot be substituted for a select");
1203 LLVM_DEBUG(
dbgs() <<
"LV: Cannot fold tail by masking as required.\n");
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.
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.
void replaceOperandWith(unsigned I, Metadata *New)
Replace a specific operand.
static MDString * get(LLVMContext &Context, StringRef Str)
ConstantInt * getConstIntStepValue() const
void push_back(const T &Elt)
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 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...
Value * getStartValue() const
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.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool endswith(StringRef Suffix) const
Check if this string ends with the given Suffix.
bool hasUnsafeAlgebra()
Returns true if the recurrence has unsafe algebra which requires a relaxed floating-point model...
amdgpu Simplify well known AMD library false Value Value const Twine & Name
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.
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.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool startswith(StringRef Prefix) const
Check if this string starts with the given Prefix.
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.
static bool isValidElementType(Type *ElemTy)
Return true if the specified type is valid as a element type.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Value * getLoadStorePointerOperand(Value *V)
A helper function that returns the pointer operand of a load or store instruction.
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."))
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE StringRef substr(size_t Start, size_t N=npos) const
Return a reference to the substring from [Start, Start + N).
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.
LLVM_ATTRIBUTE_ALWAYS_INLINE iterator begin()
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.
OptimizationRemarkAnalysis createLVMissedAnalysis(const char *PassName, StringRef RemarkName, Loop *TheLoop, Instruction *I=nullptr)
Create an analysis remark that explains why vectorization failed.
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.
bool canFoldTailByMasking()
Return true if we can vectorize this loop while folding its tail by masking.
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...
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 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.
iterator_range< user_iterator > users()
bool hasUnsafeAlgebra()
Returns true if the induction type is FP and the binary operator does not have the "fast-math" proper...
amdgpu Simplify well known AMD library false Value Value * Arg
const SmallVectorImpl< Instruction * > & getCastInsts() const
Returns a reference to the type cast instructions in the induction update chain, that are redundant w...
LoopVectorizeHints(const Loop *L, bool InterleaveOnlyWhenForced, OptimizationRemarkEmitter &ORE)
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
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.
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.
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.
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.
bool empty() const
empty - Check if the array is empty.
const BasicBlock * getParent() const