30#define DEBUG_TYPE "loop-vectorize"
36 cl::desc(
"Maximize bandwidth when selecting vectorization factor which "
37 "will be determined by the smallest type in loop."));
40 "vectorizer-maximize-bandwidth-for-vector-calls",
cl::init(
true),
42 cl::desc(
"Try wider VFs if they enable the use of vector variants"));
46 cl::desc(
"Discard VFs if their register pressure is too high."));
51 "Pretend that scalable vectors are supported, even if the target does "
52 "not support them. This flag should only be used for testing."));
56 cl::desc(
"Prefer in-loop vector reductions, "
57 "overriding the targets preference."));
63 cl::desc(
"Assume the target supports masked memory operations (used for "
68 cl::desc(
"Assume the target supports gather/scatter operations (used for "
73 cl::desc(
"Scale the cost of scalable epilogue VFs by this factor."));
81 dbgs() <<
"LV: " << Prefix << DebugMsg;
102 if (
I &&
I->getDebugLoc())
103 DL =
I->getDebugLoc();
115 <<
"loop not vectorized: " << OREMsg);
130 "Vectorizing: ", TheLoop->
isInnermost() ?
"innermost loop" :
"outer loop",
136 <<
"vectorized " << LoopType <<
"loop (vectorization width: "
137 <<
ore::NV(
"VectorizationFactor", VFWidth)
138 <<
", interleaved count: " <<
ore::NV(
"InterleaveCount", IC) <<
")";
146 (IsLoad ? TTI.isLegalMaskedLoad(ScalarTy, Alignment,
AddressSpace)
147 : TTI.isLegalMaskedStore(ScalarTy, Alignment,
AddressSpace));
161 (LI && TTI.isLegalMaskedGather(Ty,
Align)) ||
162 (
SI && TTI.isLegalMaskedScatter(Ty,
Align));
170bool VFSelectionContext::useMaxBandwidth(
bool IsScalable)
const {
175 (
TTI.shouldMaximizeVectorBandwidth(RegKind) ||
186 if (TTI.shouldConsiderVectorizationRegPressure())
193 VF, VF.
isScalable() ? MaxPermissibleVFWithoutMaxBW.ScalableVF
194 : MaxPermissibleVFWithoutMaxBW.FixedVF);
198 ElementCount VF,
unsigned MaxTripCount,
unsigned UserIC,
199 bool FoldTailByMasking,
bool RequiresScalarEpilogue)
const {
201 if (VF.
isScalable() &&
F.hasFnAttribute(Attribute::VScaleRange)) {
202 auto Attr =
F.getFnAttribute(Attribute::VScaleRange);
203 auto Min = Attr.getVScaleRangeMin();
210 if (MaxTripCount > 0 && RequiresScalarEpilogue)
215 unsigned IC = UserIC > 0 ? UserIC : 1;
216 unsigned EstimatedVFTimesIC = EstimatedVF * IC;
218 if (MaxTripCount && MaxTripCount <= EstimatedVFTimesIC &&
226 if (ClampedUpperTripCount == 0)
227 ClampedUpperTripCount = 1;
228 LLVM_DEBUG(
dbgs() <<
"LV: Clamping the MaxVF to maximum power of two not "
229 "exceeding the constant trip count"
230 << (UserIC > 0 ?
" divided by UserIC" :
"") <<
": "
231 << ClampedUpperTripCount <<
"\n");
238ElementCount VFSelectionContext::getMaximizedVFForTarget(
239 unsigned MaxTripCount,
unsigned SmallestType,
unsigned WidestType,
240 ElementCount MaxSafeVF,
unsigned UserIC,
bool FoldTailByMasking,
241 bool RequiresScalarEpilogue) {
242 bool ComputeScalableMaxVF = MaxSafeVF.
isScalable();
243 const TypeSize WidestRegister = TTI.getRegisterBitWidth(
248 auto MinVF = [](
const ElementCount &
LHS,
const ElementCount &
RHS) {
250 "Scalable flags must match");
258 ComputeScalableMaxVF);
259 MaxVectorElementCount = MinVF(MaxVectorElementCount, MaxSafeVF);
261 << (MaxVectorElementCount * WidestType) <<
" bits.\n");
263 if (!MaxVectorElementCount) {
265 << (ComputeScalableMaxVF ?
"scalable" :
"fixed")
266 <<
" vector registers.\n");
271 clampVFByMaxTripCount(MaxVectorElementCount, MaxTripCount, UserIC,
272 FoldTailByMasking, RequiresScalarEpilogue);
275 if (MaxVF != MaxVectorElementCount)
279 MaxPermissibleVFWithoutMaxBW.ScalableVF = MaxVF;
281 MaxPermissibleVFWithoutMaxBW.FixedVF = MaxVF;
283 if (useMaxBandwidth(ComputeScalableMaxVF)) {
286 ComputeScalableMaxVF);
287 MaxVF = MinVF(MaxVectorElementCountMaxBW, MaxSafeVF);
289 if (ElementCount MinVF =
290 TTI.getMinimumVF(SmallestType, ComputeScalableMaxVF)) {
293 <<
") with target's minimum: " << MinVF <<
'\n');
298 MaxVF = clampVFByMaxTripCount(MaxVF, MaxTripCount, UserIC,
299 FoldTailByMasking, RequiresScalarEpilogue);
305 if (
F.hasFnAttribute(Attribute::VScaleRange))
306 return F.getFnAttribute(Attribute::VScaleRange).getVScaleRangeMax();
311std::optional<uint64_t>
314 return EC.getFixedValue();
317 return uint64_t(EC.getKnownMinValue()) * *MaxVScale;
322bool VFSelectionContext::isScalableVectorizationAllowed() {
323 if (IsScalableVectorizationAllowed)
324 return *IsScalableVectorizationAllowed;
326 IsScalableVectorizationAllowed =
false;
332 "ScalableVectorizationDisabled", ORE, TheLoop);
336 LLVM_DEBUG(
dbgs() <<
"LV: Scalable vectorization is available\n");
339 std::numeric_limits<ElementCount::ScalarTy>::max());
348 if (!
all_of(Legal->getReductionVars(), [&](
const auto &
Reduction) ->
bool {
349 return TTI.isLegalToVectorizeReduction(Reduction.second, MaxScalableVF);
352 "Scalable vectorization not supported for the reduction "
353 "operations found in this loop.",
354 "ScalableVFUnfeasible", ORE, TheLoop);
360 if (
any_of(ElementTypesInLoop, [&](
Type *Ty) {
361 return !Ty->
isVoidTy() && !TTI.isElementTypeLegalForScalableVector(Ty);
364 "for all element types found in this loop.",
365 "ScalableVFUnfeasible", ORE, TheLoop);
369 if (!Legal->isSafeForAnyVectorWidth() && !
getMaxVScale(F)) {
371 "for safe distance analysis.",
372 "ScalableVFUnfeasible", ORE, TheLoop);
376 IsScalableVectorizationAllowed =
true;
381VFSelectionContext::getMaxLegalScalableVF(
unsigned MaxSafeElements) {
382 if (!isScalableVectorizationAllowed())
386 std::numeric_limits<ElementCount::ScalarTy>::max());
387 if (Legal->isSafeForAnyVectorWidth())
388 return MaxScalableVF;
396 "Max legal vector width too small, scalable vectorization "
398 "ScalableVFUnfeasible", ORE, TheLoop);
400 return MaxScalableVF;
404 unsigned MaxTripCount,
ElementCount UserVF,
unsigned UserIC,
405 bool FoldTailByMasking,
bool RequiresScalarEpilogue) {
412 unsigned MaxSafeElementsPowerOf2 =
414 if (!Legal->isSafeForAnyStoreLoadForwardDistances()) {
415 unsigned SLDist = Legal->getMaxStoreLoadForwardSafeDistanceInBits();
416 MaxSafeElementsPowerOf2 =
417 std::min(MaxSafeElementsPowerOf2, SLDist / WidestType);
421 auto MaxSafeScalableVF = getMaxLegalScalableVF(MaxSafeElementsPowerOf2);
423 if (!Legal->isSafeForAnyVectorWidth())
424 MaxSafeElements = MaxSafeElementsPowerOf2;
426 LLVM_DEBUG(
dbgs() <<
"LV: The max safe fixed VF is: " << MaxSafeFixedVF
428 LLVM_DEBUG(
dbgs() <<
"LV: The max safe scalable VF is: " << MaxSafeScalableVF
434 UserVF.
isScalable() ? MaxSafeScalableVF : MaxSafeFixedVF;
451 <<
" is unsafe, clamping to max safe VF="
452 << MaxSafeFixedVF <<
".\n");
455 TheLoop->getStartLoc(),
456 TheLoop->getHeader())
457 <<
"User-specified vectorization factor "
458 <<
ore::NV(
"UserVectorizationFactor", UserVF)
459 <<
" is unsafe, clamping to maximum safe vectorization factor "
460 <<
ore::NV(
"VectorizationFactor", MaxSafeFixedVF);
462 return MaxSafeFixedVF;
467 <<
" is ignored because scalable vectors are not "
471 TheLoop->getStartLoc(),
472 TheLoop->getHeader())
473 <<
"User-specified vectorization factor "
474 <<
ore::NV(
"UserVectorizationFactor", UserVF)
475 <<
" is ignored because the target does not support scalable "
476 "vectors. The compiler will pick a more suitable value.";
480 <<
" is unsafe. Ignoring scalable UserVF.\n");
483 TheLoop->getStartLoc(),
484 TheLoop->getHeader())
485 <<
"User-specified vectorization factor "
486 <<
ore::NV(
"UserVectorizationFactor", UserVF)
487 <<
" is unsafe. Ignoring the hint to let the compiler pick a "
488 "more suitable value.";
493 LLVM_DEBUG(
dbgs() <<
"LV: The Smallest and Widest types: " << SmallestType
494 <<
" / " << WidestType <<
" bits.\n");
498 if (
auto MaxVF = getMaximizedVFForTarget(
499 MaxTripCount, SmallestType, WidestType, MaxSafeFixedVF, UserIC,
500 FoldTailByMasking, RequiresScalarEpilogue))
501 Result.FixedVF = MaxVF;
503 if (
auto MaxVF = getMaximizedVFForTarget(
504 MaxTripCount, SmallestType, WidestType, MaxSafeScalableVF, UserIC,
505 FoldTailByMasking, RequiresScalarEpilogue))
507 Result.ScalableVF = MaxVF;
515std::pair<unsigned, unsigned>
517 unsigned MinWidth = -1U;
518 unsigned MaxWidth = 8;
523 if (ElementTypesInLoop.empty() && !Legal->getReductionVars().empty()) {
524 for (
const auto &[
_, RdxDesc] : Legal->getReductionVars()) {
529 std::min(RdxDesc.getMinWidthCastToRecurrenceTypeInBits(),
530 RdxDesc.getRecurrenceType()->getScalarSizeInBits()));
531 MaxWidth = std::max(MaxWidth,
532 RdxDesc.getRecurrenceType()->getScalarSizeInBits());
535 for (
Type *
T : ElementTypesInLoop) {
536 MinWidth = std::min<unsigned>(
537 MinWidth,
DL.getTypeSizeInBits(
T->getScalarType()).getFixedValue());
538 MaxWidth = std::max<unsigned>(
539 MaxWidth,
DL.getTypeSizeInBits(
T->getScalarType()).getFixedValue());
551 return {MinWidth, MaxWidth};
556 ElementTypesInLoop.clear();
564 if (ValuesToIgnore && ValuesToIgnore->
contains(&
I))
574 if (!Legal->isReductionVariable(PN))
577 Legal->getRecurrenceDescriptor(PN);
587 T = ST->getValueOperand()->getType();
590 "Expected the load/store/recurrence type to be sized");
592 ElementTypesInLoop.insert(
T);
597void VFSelectionContext::initializeVScaleForTuning() {
601 if (
F.hasFnAttribute(Attribute::VScaleRange)) {
602 auto Attr =
F.getFnAttribute(Attribute::VScaleRange);
603 auto Min = Attr.getVScaleRangeMin();
604 auto Max = Attr.getVScaleRangeMax();
605 if (Max && Min == Max) {
606 VScaleForTuning = Max;
611 VScaleForTuning = TTI.getVScaleForTuning();
616 return !Hints->allowReordering() && RdxDesc.
isOrdered();
622 Loop *L =
const_cast<Loop *
>(TheLoop);
623 if (Legal->getRuntimePointerChecking()->Need) {
625 "Runtime ptr check is required with -Os/-Oz",
626 "runtime pointer checks needed. Enable vectorization of this "
627 "loop with '#pragma clang loop vectorize(enable)' when "
628 "compiling with -Os/-Oz",
629 "CantVersionLoopWithOptForSize", ORE, L);
633 if (!PSE.getPredicate().isAlwaysTrue()) {
635 "Runtime SCEV check is required with -Os/-Oz",
636 "runtime SCEV checks needed. Enable vectorization of this "
637 "loop with '#pragma clang loop vectorize(enable)' when "
638 "compiling with -Os/-Oz",
639 "CantVersionLoopWithOptForSize", ORE, L);
644 if (!Legal->getLAI()->getSymbolicStrides().empty()) {
646 "Runtime stride check for small trip count",
647 "runtime stride == 1 checks needed. Enable vectorization of "
648 "this loop without such check by compiling with -Os/-Oz",
649 "CantVersionLoopWithOptForSize", ORE, L);
662 if (!InLoopReductions.empty())
665 for (
const auto &Reduction : Legal->getReductionVars()) {
666 PHINode *Phi = Reduction.first;
688 !TTI.preferInLoopReduction(Kind, Phi->getType()))
696 bool InLoop = !ReductionOperations.
empty();
699 InLoopReductions.insert(Phi);
702 for (
auto *
I : ReductionOperations) {
703 InLoopReductionImmediateChains[
I] = LastChain;
707 LLVM_DEBUG(
dbgs() <<
"LV: Using " << (InLoop ?
"inloop" :
"out of loop")
708 <<
" reduction for phi: " << *Phi <<
"\n");
714 const unsigned MaxTripCount,
716 bool IsEpilogue)
const {
722 if (
A.Width.isScalable() && CostA.
isValid() && !
B.Width.isScalable() &&
731 if (IsEpilogue &&
A.Width.isScalable() !=
B.Width.isScalable() &&
732 A.Cost.isValid() &&
B.Cost.isValid()) {
733 auto [FixedCost, ScalableCost] = std::make_pair(CostA, CostB);
734 if (
B.Width.isFixed())
739 if (FixedCost <= ScalableCost)
740 return A.Width.isFixed();
744 unsigned EstimatedWidthA =
A.Width.getKnownMinValue();
745 unsigned EstimatedWidthB =
B.Width.getKnownMinValue();
747 if (
A.Width.isScalable())
748 EstimatedWidthA *= *VScale;
749 if (
B.Width.isScalable())
750 EstimatedWidthB *= *VScale;
757 return CostA < CostB ||
758 (CostA == CostB && EstimatedWidthA > EstimatedWidthB);
763 bool PreferScalable = !TTI.preferFixedOverScalableIfEqualCost() &&
764 A.Width.isScalable() && !
B.Width.isScalable();
774 bool LowerCostWithoutTC =
775 CmpFn(CostA * EstimatedWidthB, CostB * EstimatedWidthA);
777 return LowerCostWithoutTC;
779 auto GetCostForTC = [MaxTripCount, HasTail](
unsigned VF,
791 return VectorCost * (MaxTripCount / VF) +
792 ScalarCost * (MaxTripCount % VF);
793 return VectorCost *
divideCeil(MaxTripCount, VF);
796 auto RTCostA = GetCostForTC(EstimatedWidthA, CostA,
A.ScalarCost);
797 auto RTCostB = GetCostForTC(EstimatedWidthB, CostB,
B.ScalarCost);
798 bool LowerCostWithTC = CmpFn(RTCostA, RTCostB);
799 LLVM_DEBUG(
if (LowerCostWithTC != LowerCostWithoutTC) {
800 dbgs() <<
"LV: VF " << (LowerCostWithTC ?
A.Width :
B.Width)
801 <<
" has lower cost than VF "
802 << (LowerCostWithTC ?
B.Width :
A.Width)
803 <<
" when taking the cost of the remaining scalar loop iterations "
804 "into consideration for a maximum trip count of "
805 << MaxTripCount <<
".\n";
807 return LowerCostWithTC;
813 bool IsEpilogue)
const {
814 const unsigned MaxTripCount = PSE.getSmallConstantMaxTripCount();
815 return LoopVectorizationPlanner::isMoreProfitable(
A,
B, MaxTripCount, HasTail,
828 "Scalable vectorization requested but not supported by the target",
829 "the scalable user-specified vectorization width for outer-loop "
830 "vectorization cannot be used because the target does not support "
832 "ScalableVFUnfeasible", ORE, TheLoop);
840 auto RegKind = TTI.enableScalableVectorization()
847 unsigned N = std::max<uint64_t>(
855 <<
"overriding computed VF.\n");
860 "VF needs to be a power of two");
864 <<
"VF " << VF <<
" to build VPlans.\n");
874 switch (R.getVPRecipeID()) {
875 case VPRecipeBase::VPFirstOrderRecurrencePHISC:
878 case VPRecipeBase::VPWidenIntOrFpInductionSC:
879 return !cast<VPWidenIntOrFpInductionRecipe>(&R)->getPHINode();
880 case VPRecipeBase::VPReductionPHISC: {
881 auto *RedPhi = cast<VPReductionPHIRecipe>(&R);
884 RecurKind Kind = RedPhi->getRecurrenceKind();
885 if (RecurrenceDescriptor::isFPMinMaxNumRecurrenceKind(Kind) ||
886 RecurrenceDescriptor::isFindLastRecurrenceKind(Kind) ||
887 !RedPhi->getUnderlyingValue())
894 if (RecurrenceDescriptor::isFindIVRecurrenceKind(Kind)) {
895 auto *RdxResult = vputils::findComputeReductionResult(RedPhi);
897 "FindIV reduction must have ComputeReductionResult");
898 return any_of(RdxResult->users(),
899 std::not_fn(IsaPred<VPInstruction>));
909bool LoopVectorizationPlanner::isCandidateForEpilogueVectorization(
910 VPlan &MainPlan)
const {
920 if (OrigLoop->getExitingBlock() != OrigLoop->getLoopLatch())
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
loop Loop Strength Reduction
This file defines the LoopVectorizationLegality class.
static cl::opt< float > ScalableEpilogueVFCostScaleFactor("scalable-epilogue-vf-cost-scale-factor", cl::init(2.0), cl::Hidden, cl::desc("Scale the cost of scalable epilogue VFs by this factor."))
static bool hasUnsupportedHeaderPhiRecipe(VPlan &Plan)
static void debugVectorizationMessage(const StringRef Prefix, const StringRef DebugMsg, Instruction *I)
Write a DebugMsg about vectorization to the debug output stream.
static cl::opt< bool > ForceTargetSupportsGatherScatterOps("force-target-supports-gather-scatter-ops", cl::init(false), cl::Hidden, cl::desc("Assume the target supports gather/scatter operations (used for " "testing)."))
cl::opt< bool > VPlanBuildOuterloopStressTest
static cl::opt< bool > ForceTargetSupportsScalableVectors("force-target-supports-scalable-vectors", cl::init(false), cl::Hidden, cl::desc("Pretend that scalable vectors are supported, even if the target does " "not support them. This flag should only be used for testing."))
static cl::opt< bool > ConsiderRegPressure("vectorizer-consider-reg-pressure", cl::init(false), cl::Hidden, cl::desc("Discard VFs if their register pressure is too high."))
static cl::opt< bool > UseWiderVFIfCallVariantsPresent("vectorizer-maximize-bandwidth-for-vector-calls", cl::init(true), cl::Hidden, cl::desc("Try wider VFs if they enable the use of vector variants"))
static OptimizationRemarkAnalysis createLVAnalysis(StringRef RemarkName, const Loop *TheLoop, Instruction *I, DebugLoc DL={})
Create an analysis remark that explains why vectorization failed RemarkName is the identifier for the...
static cl::opt< bool > ForceTargetSupportsMaskedMemoryOps("force-target-supports-masked-memory-ops", cl::init(false), cl::Hidden, cl::desc("Assume the target supports masked memory operations (used for " "testing)."))
Note: This currently only applies to llvm.masked.load and llvm.masked.store.
static cl::opt< bool > MaximizeBandwidth("vectorizer-maximize-bandwidth", cl::init(false), cl::Hidden, cl::desc("Maximize bandwidth when selecting vectorization factor which " "will be determined by the smallest type in loop."))
This file provides a LoopVectorizationPlanner class.
LLVM Basic Block Representation.
A parsed version of the target data layout string in and methods for querying it.
constexpr bool isVector() const
One or more elements.
static constexpr ElementCount getScalable(ScalarTy MinVal)
static constexpr ElementCount getFixed(ScalarTy MinVal)
static constexpr ElementCount get(ScalarTy MinVal, bool Scalable)
constexpr bool isScalar() const
Exactly one element.
bool isInnermost() const
Return true if the loop does not contain any (natural) loops.
BlockT * getHeader() const
bool hasVectorCallVariants() const
Returns true if there is at least one function call in the loop which has a vectorized variant availa...
bool isScalableVectorizationDisabled() const
bool isScalableVectorizationAlwaysPreferred() const
Represents a single loop in the control flow graph.
DebugLoc getStartLoc() const
Return the debug location of the start of this loop.
The RecurrenceDescriptor is used to identify recurrences variables in a loop.
Type * getRecurrenceType() const
Returns the type of the recurrence.
bool hasUsesOutsideReductionChain() const
Returns true if the reduction PHI has any uses outside the reduction chain.
static bool isFindLastRecurrenceKind(RecurKind Kind)
Returns true if the recurrence kind is of the form select(cmp(),x,y) where one of (x,...
LLVM_ABI SmallVector< Instruction *, 4 > getReductionOpChain(PHINode *Phi, Loop *L) const
Attempts to find a chain of operations from Phi to LoopExitInst that can be treated as a set of reduc...
static bool isAnyOfRecurrenceKind(RecurKind Kind)
Returns true if the recurrence kind is of the form select(cmp(),x,y) where one of (x,...
RecurKind getRecurrenceKind() const
bool isOrdered() const
Expose an ordered FP reduction to the instance users.
static bool isFindIVRecurrenceKind(RecurKind Kind)
Returns true if the recurrence kind is of the form select(cmp(),x,y) where one of (x,...
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
bool contains(ConstPtrType Ptr) const
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Represent a constant reference to a string, i.e.
The instances of the Type class are immutable: once they are created, they are never changed.
bool isVoidTy() const
Return true if this is 'void'.
FixedScalableVFPair computeVPlanOuterloopVF(ElementCount UserVF)
Returns a scalable VF to use for outer-loop vectorization if the target supports it and a fixed VF ot...
std::pair< unsigned, unsigned > getSmallestAndWidestTypes() const
bool supportsScalableVectors() const
bool runtimeChecksRequired()
Check whether vectorization would require runtime checks.
bool isLegalGatherOrScatter(Value *V, ElementCount VF) const
Returns true if the target machine can represent V as a masked gather or scatter operation.
bool isLegalMaskedLoadOrStore(bool IsLoad, Type *ScalarTy, Align Alignment, unsigned AddressSpace) const
Returns true if the target machine supports a masked load (if IsLoad) or masked store of scalar type ...
void collectInLoopReductions()
Split reductions into those that happen in the loop, and those that happen outside.
FixedScalableVFPair computeFeasibleMaxVF(unsigned MaxTripCount, ElementCount UserVF, unsigned UserIC, bool FoldTailByMasking, bool RequiresScalarEpilogue)
const LoopVectorizeHints & getHints() const
bool useOrderedReductions(const RecurrenceDescriptor &RdxDesc) const
Returns true if we should use strict in-order reductions for the given RdxDesc.
bool shouldConsiderRegPressureForVF(ElementCount VF) const
void collectElementTypesForWidening(const SmallPtrSetImpl< const Value * > *ValuesToIgnore=nullptr)
Collect element types in the loop that need widening.
std::optional< unsigned > getVScaleForTuning() const
void computeMinimalBitwidths()
Compute smallest bitwidth each instruction can be represented with.
iterator_range< iterator > phis()
Returns an iterator range over the PHI-like recipes in the block.
const VPBasicBlock * getEntryBasicBlock() const
VPRecipeBase is a base class modeling a sequence of one or more output IR instructions.
VPlan models a candidate for vectorization, encoding various decisions take to produce efficient outp...
LLVM_ABI_FOR_TEST VPRegionBlock * getVectorLoopRegion()
Returns the VPRegionBlock of the vector loop.
LLVM Value Representation.
static LLVM_ABI VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
static constexpr bool isKnownLE(const FixedOrScalableQuantity &LHS, const FixedOrScalableQuantity &RHS)
static constexpr bool isKnownLT(const FixedOrScalableQuantity &LHS, const FixedOrScalableQuantity &RHS)
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
constexpr bool isZero() const
static constexpr bool isKnownGT(const FixedOrScalableQuantity &LHS, const FixedOrScalableQuantity &RHS)
void reportVectorizationFailure(const StringRef DebugMsg, const StringRef OREMsg, const StringRef ORETag, OptimizationRemarkEmitter *ORE, const Loop *TheLoop, Instruction *I=nullptr)
Reports a vectorization failure: print DebugMsg for debugging purposes along with the corresponding o...
void reportVectorizationInfo(const StringRef Msg, const StringRef ORETag, OptimizationRemarkEmitter *ORE, const Loop *TheLoop, Instruction *I=nullptr, DebugLoc DL={})
Reports an informative message: print Msg for debugging purposes as well as an optimization remark.
void reportVectorization(OptimizationRemarkEmitter *ORE, Loop *TheLoop, ElementCount VFWidth, unsigned IC)
Report successful vectorization of the loop.
initializer< Ty > init(const Ty &Val)
DiagnosticInfoOptimizationBase::Argument NV
This is an optimization pass for GlobalISel generic memory operations.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Align getLoadStoreAlignment(const Value *I)
A helper function that returns the alignment of load or store instruction.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
std::optional< uint64_t > getMaxRuntimeElementCount(ElementCount EC, const Function &F)
constexpr bool isPowerOf2_32(uint32_t Value)
Return true if the argument is a power of two > 0.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
constexpr T divideCeil(U Numerator, V Denominator)
Returns the integer ceil(Numerator / Denominator).
RecurKind
These are the kinds of recurrences that we support.
std::optional< unsigned > getMaxVScale(const Function &F)
Type * getLoadStoreType(const Value *I)
A helper function that returns the type of a load or store instruction.
T bit_floor(T Value)
Returns the largest integral power of two no greater than Value if Value is nonzero.
LLVM_ABI MapVector< Instruction *, uint64_t > computeMinimumValueSizes(ArrayRef< BasicBlock * > Blocks, DemandedBits &DB, const TargetTransformInfo *TTI=nullptr)
Compute a map of integer instructions to their minimum legal type size.
cl::opt< bool > PreferInLoopReductions
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
This struct is a compact representation of a valid (non-zero power of two) alignment.
A class that represents two vectorization factors (initialized with 0 by default).
static FixedScalableVFPair getNone()
TODO: The following VectorizationFactor was pulled out of LoopVectorizationCostModel class.
static LLVM_ABI ElementCount VectorizationFactor
VF as overridden by the user.