24#ifndef LLVM_TRANSFORMS_VECTORIZE_VPLAN_H
25#define LLVM_TRANSFORMS_VECTORIZE_VPLAN_H
51class InnerLoopVectorizer;
53struct VPTransformState;
55class RecurrenceDescriptor;
63class VPReplicateRecipe;
66class LoopVectorizationCostModel;
81 const unsigned char SubclassID;
98 VPlan *Plan =
nullptr;
108 assert(Predecessor &&
"Cannot add nullptr predecessor!");
113 void removePredecessor(VPBlockBase *Predecessor) {
114 auto Pos =
find(Predecessors, Predecessor);
115 assert(Pos &&
"Predecessor does not exist");
116 Predecessors.
erase(Pos);
120 void removeSuccessor(VPBlockBase *
Successor) {
122 assert(Pos &&
"Successor does not exist");
123 Successors.
erase(Pos);
128 void replacePredecessor(VPBlockBase *Old, VPBlockBase *New) {
129 auto I =
find(Predecessors, Old);
131 assert(Old->getParent() ==
New->getParent() &&
132 "replaced predecessor must have the same parent");
138 void replaceSuccessor(VPBlockBase *Old, VPBlockBase *New) {
139 auto I =
find(Successors, Old);
141 assert(Old->getParent() ==
New->getParent() &&
142 "replaced successor must have the same parent");
148 : SubclassID(SC),
Name(
N) {}
155 using VPBlockTy =
enum { VPRegionBlockSC, VPBasicBlockSC, VPIRBasicBlockSC };
207 return (Successors.
size() == 1 ? *Successors.
begin() :
nullptr);
213 return (Predecessors.
size() == 1 ? *Predecessors.
begin() :
nullptr);
266 assert(Successors.
empty() &&
"Setting one successor when others exist.");
268 "connected blocks must have the same parent");
277 assert(Successors.
empty() &&
"Setting two successors when others exist.");
278 appendSuccessor(IfTrue);
279 appendSuccessor(IfFalse);
286 assert(Predecessors.
empty() &&
"Block predecessors already set.");
287 for (
auto *Pred : NewPreds)
288 appendPredecessor(Pred);
295 assert(Successors.
empty() &&
"Block successors already set.");
296 for (
auto *Succ : NewSuccs)
297 appendSuccessor(Succ);
310 assert(Successors.
size() == 2 &&
"must have 2 successors to swap");
328#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
381 template <
typename IterT>
471#define VP_CLASSOF_IMPL(VPDefID) \
472 static inline bool classof(const VPDef *D) { \
473 return D->getVPDefID() == VPDefID; \
475 static inline bool classof(const VPValue *V) { \
476 auto *R = V->getDefiningRecipe(); \
477 return R && R->getVPDefID() == VPDefID; \
479 static inline bool classof(const VPUser *U) { \
480 auto *R = dyn_cast<VPRecipeBase>(U); \
481 return R && R->getVPDefID() == VPDefID; \
483 static inline bool classof(const VPRecipeBase *R) { \
484 return R->getVPDefID() == VPDefID; \
486 static inline bool classof(const VPSingleDefRecipe *R) { \
487 return R->getVPDefID() == VPDefID; \
495 template <
typename IterT>
503 template <
typename IterT>
509 switch (R->getVPDefID()) {
510 case VPRecipeBase::VPDerivedIVSC:
511 case VPRecipeBase::VPEVLBasedIVPHISC:
512 case VPRecipeBase::VPExpandSCEVSC:
513 case VPRecipeBase::VPInstructionSC:
514 case VPRecipeBase::VPReductionEVLSC:
515 case VPRecipeBase::VPReductionSC:
516 case VPRecipeBase::VPReplicateSC:
517 case VPRecipeBase::VPScalarIVStepsSC:
518 case VPRecipeBase::VPVectorPointerSC:
519 case VPRecipeBase::VPReverseVectorPointerSC:
520 case VPRecipeBase::VPWidenCallSC:
521 case VPRecipeBase::VPWidenCanonicalIVSC:
522 case VPRecipeBase::VPWidenCastSC:
523 case VPRecipeBase::VPWidenGEPSC:
524 case VPRecipeBase::VPWidenIntrinsicSC:
525 case VPRecipeBase::VPWidenSC:
526 case VPRecipeBase::VPWidenEVLSC:
527 case VPRecipeBase::VPWidenSelectSC:
528 case VPRecipeBase::VPBlendSC:
529 case VPRecipeBase::VPPredInstPHISC:
530 case VPRecipeBase::VPCanonicalIVPHISC:
531 case VPRecipeBase::VPActiveLaneMaskPHISC:
532 case VPRecipeBase::VPFirstOrderRecurrencePHISC:
533 case VPRecipeBase::VPWidenPHISC:
534 case VPRecipeBase::VPWidenIntOrFpInductionSC:
535 case VPRecipeBase::VPWidenPointerInductionSC:
536 case VPRecipeBase::VPReductionPHISC:
537 case VPRecipeBase::VPScalarCastSC:
538 case VPRecipeBase::VPPartialReductionSC:
540 case VPRecipeBase::VPBranchOnMaskSC:
541 case VPRecipeBase::VPInterleaveSC:
542 case VPRecipeBase::VPIRInstructionSC:
543 case VPRecipeBase::VPWidenLoadEVLSC:
544 case VPRecipeBase::VPWidenLoadSC:
545 case VPRecipeBase::VPWidenStoreEVLSC:
546 case VPRecipeBase::VPWidenStoreSC:
547 case VPRecipeBase::VPHistogramSC:
556 auto *R = dyn_cast<VPRecipeBase>(U);
570#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
578 enum class OperationType :
unsigned char {
603 struct ExactFlagsTy {
606 struct NonNegFlagsTy {
609 struct FastMathFlagsTy {
618 FastMathFlagsTy(
const FastMathFlags &FMF);
621 OperationType OpType;
636 OpType =
Other.OpType;
641 template <
typename IterT>
644 OpType = OperationType::Other;
648 template <
typename IterT>
651 if (
auto *
Op = dyn_cast<CmpInst>(&
I)) {
652 OpType = OperationType::Cmp;
654 }
else if (
auto *
Op = dyn_cast<PossiblyDisjointInst>(&
I)) {
655 OpType = OperationType::DisjointOp;
657 }
else if (
auto *
Op = dyn_cast<OverflowingBinaryOperator>(&
I)) {
658 OpType = OperationType::OverflowingBinOp;
659 WrapFlags = {
Op->hasNoUnsignedWrap(),
Op->hasNoSignedWrap()};
660 }
else if (
auto *
Op = dyn_cast<PossiblyExactOperator>(&
I)) {
661 OpType = OperationType::PossiblyExactOp;
663 }
else if (
auto *
GEP = dyn_cast<GetElementPtrInst>(&
I)) {
664 OpType = OperationType::GEPOp;
666 }
else if (
auto *PNNI = dyn_cast<PossiblyNonNegInst>(&
I)) {
667 OpType = OperationType::NonNegOp;
669 }
else if (
auto *
Op = dyn_cast<FPMathOperator>(&
I)) {
670 OpType = OperationType::FPMathOp;
671 FMFs =
Op->getFastMathFlags();
673 OpType = OperationType::Other;
678 template <
typename IterT>
684 template <
typename IterT>
690 template <
typename IterT>
696 template <
typename IterT>
703 template <
typename IterT>
711 return R->getVPDefID() == VPRecipeBase::VPInstructionSC ||
712 R->getVPDefID() == VPRecipeBase::VPWidenSC ||
713 R->getVPDefID() == VPRecipeBase::VPWidenEVLSC ||
714 R->getVPDefID() == VPRecipeBase::VPWidenGEPSC ||
715 R->getVPDefID() == VPRecipeBase::VPWidenCastSC ||
716 R->getVPDefID() == VPRecipeBase::VPWidenIntrinsicSC ||
717 R->getVPDefID() == VPRecipeBase::VPReplicateSC ||
718 R->getVPDefID() == VPRecipeBase::VPReverseVectorPointerSC ||
719 R->getVPDefID() == VPRecipeBase::VPVectorPointerSC;
723 auto *R = dyn_cast<VPRecipeBase>(U);
732 case OperationType::OverflowingBinOp:
736 case OperationType::DisjointOp:
739 case OperationType::PossiblyExactOp:
742 case OperationType::GEPOp:
745 case OperationType::FPMathOp:
749 case OperationType::NonNegOp:
752 case OperationType::Cmp:
753 case OperationType::Other:
761 case OperationType::OverflowingBinOp:
765 case OperationType::DisjointOp:
768 case OperationType::PossiblyExactOp:
771 case OperationType::GEPOp:
772 cast<GetElementPtrInst>(
I)->setNoWrapFlags(
GEPFlags);
774 case OperationType::FPMathOp:
775 I->setHasAllowReassoc(
FMFs.AllowReassoc);
776 I->setHasNoNaNs(
FMFs.NoNaNs);
777 I->setHasNoInfs(
FMFs.NoInfs);
778 I->setHasNoSignedZeros(
FMFs.NoSignedZeros);
779 I->setHasAllowReciprocal(
FMFs.AllowReciprocal);
780 I->setHasAllowContract(
FMFs.AllowContract);
781 I->setHasApproxFunc(
FMFs.ApproxFunc);
783 case OperationType::NonNegOp:
786 case OperationType::Cmp:
787 case OperationType::Other:
793 assert(OpType == OperationType::Cmp &&
794 "recipe doesn't have a compare predicate");
806 assert(OpType == OperationType::OverflowingBinOp &&
807 "recipe doesn't have a NUW flag");
812 assert(OpType == OperationType::OverflowingBinOp &&
813 "recipe doesn't have a NSW flag");
818 assert(OpType == OperationType::DisjointOp &&
819 "recipe cannot have a disjoing flag");
823#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
852 Instruction::OtherOpsEnd + 1,
888 typedef unsigned char OpcodeTy;
892 const std::string
Name;
900 bool doesGeneratePerAllLanes()
const;
904 bool canGenerateScalarForFirstLane()
const;
919 bool isFPMathOp()
const;
933 VPValue *
B, DebugLoc
DL = {},
const Twine &
Name =
"");
945 assert(Opcode == Instruction::Or &&
"only OR opcodes can be disjoint");
955 FastMathFlags
FMFs, DebugLoc
DL = {},
const Twine &
Name =
"");
962 New->transferFlags(*
this);
980#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
993 case Instruction::Ret:
994 case Instruction::Br:
995 case Instruction::Store:
996 case Instruction::Switch:
997 case Instruction::IndirectBr:
998 case Instruction::Resume:
999 case Instruction::CatchRet:
1000 case Instruction::Unreachable:
1001 case Instruction::Fence:
1002 case Instruction::AtomicRMW:
1062#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1070 "Op must be an operand of the recipe");
1076 "Op must be an operand of the recipe");
1082 "Op must be an operand of the recipe");
1100 template <
typename IterT>
1106 template <
typename IterT>
1114 R->transferFlags(*
this);
1119 return R->getVPDefID() == VPRecipeBase::VPWidenSC ||
1120 R->getVPDefID() == VPRecipeBase::VPWidenEVLSC;
1124 auto *R = dyn_cast<VPRecipeBase>(U);
1138#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1151 template <
typename IterT>
1180 "Op must be an operand of the recipe");
1186#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1205 ResultTy(ResultTy) {
1207 "opcode of underlying cast doesn't match");
1212 ResultTy(ResultTy) {}
1219 *cast<CastInst>(UV));
1233#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1257 ResultTy(ResultTy) {}
1277#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1288 "Op must be an operand of the recipe");
1302 bool MayReadFromMemory;
1305 bool MayWriteToMemory;
1308 bool MayHaveSideEffects;
1315 VectorIntrinsicID(VectorIntrinsicID), ResultTy(Ty),
1324 VectorIntrinsicID(VectorIntrinsicID), ResultTy(Ty) {
1330 MayHaveSideEffects = MayWriteToMemory ||
1331 !Attrs.hasFnAttr(Attribute::NoUnwind) ||
1332 !Attrs.hasFnAttr(Attribute::WillReturn);
1336 std::initializer_list<VPValue *> CallArguments,
1376#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1396 *cast<Instruction>(UV)),
1400 "last operand must be the called function");
1430#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1447 template <
typename IterT>
1450 :
VPRecipeBase(VPDef::VPHistogramSC, Operands, DL), Opcode(Opcode) {}
1475#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1484 template <
typename IterT>
1504#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1521 bool isPointerLoopInvariant()
const {
1525 bool isIndexLoopInvariant(
unsigned I)
const {
1529 bool areAllOperandsInvariant()
const {
1531 return Op->isDefinedOutsideLoopRegions();
1536 template <
typename IterT>
1559#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1577 IndexedTy(IndexedTy) {}
1588 "Op must be an operand of the recipe");
1602 "Op must be an operand of the recipe");
1613#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1630 IndexedTy(IndexedTy) {}
1638 "Op must be an operand of the recipe");
1645 "Op must be an operand of the recipe");
1662#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1706 return B->getVPDefID() >= VPDef::VPFirstHeaderPHISC &&
1707 B->getVPDefID() <= VPDef::VPLastHeaderPHISC;
1710 auto *
B = V->getDefiningRecipe();
1711 return B &&
B->getVPDefID() >= VPRecipeBase::VPFirstHeaderPHISC &&
1712 B->getVPDefID() <= VPRecipeBase::VPLastHeaderPHISC;
1722#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1766 return R->getVPDefID() == VPDef::VPWidenIntOrFpInductionSC ||
1767 R->getVPDefID() == VPDef::VPWidenPointerInductionSC;
1771 auto *R = V->getDefiningRecipe();
1794 "VPWidenIntOrFpInductionRecipe generates its own backedge value");
1801 "VPWidenIntOrFpInductionRecipe generates its own backedge value");
1843#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1883 bool IsScalarAfterVectorization;
1890 bool IsScalarAfterVectorization,
DebugLoc DL)
1893 IsScalarAfterVectorization(IsScalarAfterVectorization) {}
1918#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1953 "Op must be an operand of the recipe");
1957#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1991#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
2000 IncomingBlocks.
push_back(IncomingBlock);
2020 return R->getVPDefID() == VPDef::VPFirstOrderRecurrencePHISC;
2034#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
2057 unsigned VFScaleFactor = 1;
2063 VPValue &Start,
bool IsInLoop =
false,
2064 bool IsOrdered =
false,
unsigned VFScaleFactor = 1)
2066 RdxDesc(RdxDesc), IsInLoop(IsInLoop), IsOrdered(IsOrdered),
2067 VFScaleFactor(VFScaleFactor) {
2068 assert((!IsOrdered || IsInLoop) &&
"IsOrdered requires IsInLoop");
2076 IsOrdered, VFScaleFactor);
2084 return R->getVPDefID() == VPDef::VPReductionPHISC;
2090#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
2124 [[maybe_unused]]
auto *AccumulatorRecipe =
2126 assert((isa<VPReductionPHIRecipe>(AccumulatorRecipe) ||
2127 isa<VPPartialReductionRecipe>(AccumulatorRecipe)) &&
2128 "Unexpected operand order for partial reduction recipe");
2149#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
2204#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
2213 "Op must be an operand of the recipe");
2217 [
this](
VPUser *U) {
return U->onlyFirstLaneUsed(
this); });
2230 bool HasMask =
false;
2234 bool NeedsMaskForGaps =
false;
2239 bool NeedsMaskForGaps)
2241 NeedsMaskForGaps(NeedsMaskForGaps) {
2242 for (
unsigned i = 0; i < IG->
getFactor(); ++i)
2244 if (
I->getType()->isVoidTy())
2249 for (
auto *SV : StoredValues)
2293#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
2310 "Op must be an operand of the recipe");
2325 bool IsConditional =
false;
2332 IsOrdered(IsOrdered) {
2334 IsConditional =
true;
2356 return R->getVPDefID() == VPRecipeBase::VPReductionSC ||
2357 R->getVPDefID() == VPRecipeBase::VPReductionEVLSC;
2361 auto *R = dyn_cast<VPRecipeBase>(U);
2372#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
2407 R.isOrdered(), R.getDebugLoc()) {}
2420#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
2432 "Op must be an operand of the recipe");
2449 template <
typename IterT>
2451 bool IsUniform,
VPValue *Mask =
nullptr)
2453 IsUniform(IsUniform), IsPredicated(Mask) {
2464 Copy->transferFlags(*
this);
2479#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
2492 "Op must be an operand of the recipe");
2499 "Op must be an operand of the recipe");
2540#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
2544 O << Indent <<
"BRANCH-ON-MASK ";
2563 "Op must be an operand of the recipe");
2598#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
2607 "Op must be an operand of the recipe");
2636 std::initializer_list<VPValue *> Operands,
2649 return R->getVPDefID() == VPRecipeBase::VPWidenLoadSC ||
2650 R->getVPDefID() == VPRecipeBase::VPWidenStoreSC ||
2651 R->getVPDefID() == VPRecipeBase::VPWidenLoadEVLSC ||
2652 R->getVPDefID() == VPRecipeBase::VPWidenStoreEVLSC;
2656 auto *R = dyn_cast<VPRecipeBase>(U);
2714#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
2723 "Op must be an operand of the recipe");
2736 {L.getAddr(), &EVL}, L.isConsecutive(),
2737 L.isReverse(), L.getDebugLoc()),
2754#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
2763 "Op must be an operand of the recipe");
2794#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
2803 "Op must be an operand of the recipe");
2817 S.isConsecutive(), S.isReverse(), S.getDebugLoc()) {
2836#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
2845 "Op must be an operand of the recipe");
2884#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
2913 return D->getVPDefID() == VPDef::VPCanonicalIVPHISC;
2918 "cannot execute this recipe, should be replaced by VPScalarPHIRecipe");
2921#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
2935 "Op must be an operand of the recipe");
2942 "Op must be an operand of the recipe");
2976 return D->getVPDefID() == VPDef::VPActiveLaneMaskPHISC;
2982#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
3007 return D->getVPDefID() == VPDef::VPEVLBasedIVPHISC;
3012 "cannot execute this recipe, should be replaced by VPScalarPHIRecipe");
3025 "Op must be an operand of the recipe");
3029#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
3047 cast<VPCanonicalIVPHIRecipe>(
getOperand(0)));
3064#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
3087 const Twine &Name =
"")
3091 Start, CanonicalIV, Step, Name) {}
3097 FPBinOp(FPBinOp), Name(Name.str()) {}
3119#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
3135 "Op must be an operand of the recipe");
3151 InductionOpcode(Opcode) {}
3156 IV, Step, IndDesc.getInductionOpcode(),
3181#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
3192 "Op must be an operand of the recipe");
3262 return V->getVPBlockID() == VPBlockBase::VPBasicBlockSC ||
3263 V->getVPBlockID() == VPBlockBase::VPIRBasicBlockSC;
3267 assert(Recipe &&
"No recipe to append.");
3268 assert(!Recipe->Parent &&
"Recipe already in VPlan");
3269 Recipe->Parent =
this;
3300#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
3357 return V->getVPBlockID() == VPBlockBase::VPIRBasicBlockSC;
3393 const std::string &
Name =
"",
bool IsReplicator =
false)
3395 IsReplicator(IsReplicator) {
3396 assert(Entry->getPredecessors().empty() &&
"Entry block has predecessors.");
3398 Entry->setParent(
this);
3402 :
VPBlockBase(VPRegionBlockSC,
Name), Entry(nullptr), Exiting(nullptr),
3403 IsReplicator(IsReplicator) {}
3410 return V->getVPBlockID() == VPBlockBase::VPRegionBlockSC;
3420 "Entry block cannot have predecessors.");
3432 "Exit block cannot have successors.");
3433 Exiting = ExitingBlock;
3454#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
3506 VPValue *BackedgeTakenCount =
nullptr;
3537 : Entry(Entry), ScalarHeader(ScalarHeader) {
3538 Entry->setPlan(
this);
3540 "scalar header must be a leaf node");
3576 bool RequiresScalarEpilogueCheck,
3577 bool TailFolded,
Loop *TheLoop);
3634 assert(TripCount &&
"trip count needs to be set before accessing it");
3642 "TripCount always must be set");
3643 TripCount = NewTripCount;
3648 if (!BackedgeTakenCount)
3649 BackedgeTakenCount =
new VPValue();
3650 return BackedgeTakenCount;
3665 assert(
hasVF(VF) &&
"Cannot set VF not already in plan");
3686 assert(UFs.
size() == 1 &&
"Expected a single UF");
3691 assert(
hasUF(UF) &&
"Cannot set the UF not already in plan");
3704 assert(V &&
"Trying to get or add the VPValue of a null Value");
3705 if (!Value2VPValue.
count(V)) {
3709 assert(!Value2VPValue.
count(V) &&
"Value already exists in VPlan");
3710 Value2VPValue[V] = VPV;
3713 assert(Value2VPValue.
count(V) &&
"Value does not exist in VPlan");
3714 assert(Value2VPValue[V]->isLiveIn() &&
3715 "Only live-ins should be in mapping");
3716 return Value2VPValue[V];
3722#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
3739 if (EntryVPBB->
empty()) {
3743 return cast<VPCanonicalIVPHIRecipe>(&*EntryVPBB->
begin());
3747 return SCEVToExpansion.
lookup(S);
3752 SCEVToExpansion[S] = V;
3773 const std::string &
Name =
"",
3774 bool IsReplicator =
false) {
3785 bool IsReplicator =
false) {
3803#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
static MCDisassembler::DecodeStatus addOperand(MCInst &Inst, const MCOperand &Opnd)
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
This file defines the DenseMap class.
std::optional< std::vector< StOtherPiece > > Other
This file defines an InstructionCost class that is used when calculating the cost of an instruction,...
mir Rename Register Operands
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file implements the SmallBitVector class.
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
This file contains the declarations of the entities induced by Vectorization Plans,...
#define VP_CLASSOF_IMPL(VPDefID)
static const uint32_t IV[8]
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
ArrayRef< T > slice(size_t N, size_t M) const
slice(n, m) - Chop off the first N elements of the array, and keep M elements in the array.
LLVM Basic Block Representation.
This class represents a function call, abstracting a target machine's calling convention.
This is the base class for all instructions that perform data casts.
Instruction::CastOps getOpcode() const
Return the opcode of this CastInst.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
An abstraction over a floating-point predicate, and a pack of an integer predicate with samesign info...
This class represents an Operation in the Expression.
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
bool contains(const_arg_type_t< KeyT > Val) const
Return true if the specified key is in the map, false otherwise.
Utility class for floating point operations which can have information about relaxed accuracy require...
Convenience struct for specifying and reasoning about fast-math flags.
Represents flags for the getelementptr instruction/expression.
static GEPNoWrapFlags none()
an instruction for type-safe pointer arithmetic to access elements of arrays and structs
A struct for saving information about induction variables.
InductionKind
This enum represents the kinds of inductions that we support.
bool mayWriteToMemory() const LLVM_READONLY
Return true if this instruction may modify memory.
bool mayHaveSideEffects() const LLVM_READONLY
Return true if the instruction may have side effects.
bool mayReadFromMemory() const LLVM_READONLY
Return true if this instruction may read memory.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
The group of interleaved loads/stores sharing the same stride and close to each other.
uint32_t getFactor() const
InstTy * getMember(uint32_t Index) const
Get the member with the given index Index.
InstTy * getInsertPos() const
This is an important class for using LLVM in a threaded context.
An instruction for reading from memory.
Represents a single loop in the control flow graph.
bool onlyWritesMemory() const
Whether this function only (at most) writes memory.
bool onlyReadsMemory() const
Whether this function only (at most) reads memory.
An interface layer with SCEV used to manage how we see SCEV expressions for values in the context of ...
The RecurrenceDescriptor is used to identify recurrences variables in a loop.
This class represents an analyzed expression in the program.
The main scalar evolution driver.
This class represents the LLVM 'select' instruction.
size_type size() const
Determine the number of elements in the SetVector.
iterator end()
Get an iterator to the end of the SetVector.
void clear()
Completely clear the SetVector.
size_type count(const key_type &key) const
Count the number of elements of a given key in the SetVector.
bool empty() const
Determine if the SetVector is empty or not.
iterator begin()
Get an iterator to the beginning of the SetVector.
bool insert(const value_type &X)
Insert a new element into the SetVector.
bool contains(const key_type &key) const
Check if the SetVector contains the given key.
This class provides computation of slot numbers for LLVM Assembly writing.
A SetVector that performs no allocations if smaller than a certain size.
iterator erase(const_iterator CI)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An instruction for storing to memory.
StringRef - Represent a constant reference to a string, i.e.
This class represents a truncation of integer types.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
std::string str() const
Return the twine contents as a std::string.
The instances of the Type class are immutable: once they are created, they are never changed.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
A recipe for generating the active lane mask for the vector loop that is used to predicate the vector...
void execute(VPTransformState &State) override
Generate the active lane mask phi of the vector loop.
VPActiveLaneMaskPHIRecipe * clone() override
Clone the current recipe.
static bool classof(const VPHeaderPHIRecipe *D)
VPActiveLaneMaskPHIRecipe(VPValue *StartMask, DebugLoc DL)
~VPActiveLaneMaskPHIRecipe() override=default
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
VPBasicBlock serves as the leaf of the Hierarchical Control-Flow Graph.
RecipeListTy::const_iterator const_iterator
void appendRecipe(VPRecipeBase *Recipe)
Augment the existing recipes of a VPBasicBlock with an additional Recipe as the last recipe.
RecipeListTy::const_reverse_iterator const_reverse_iterator
RecipeListTy::iterator iterator
Instruction iterators...
void execute(VPTransformState *State) override
The method which generates the output IR instructions that correspond to this VPBasicBlock,...
RecipeListTy & getRecipeList()
Returns a reference to the list of recipes.
VPBasicBlock(const unsigned char BlockSC, const Twine &Name="")
iterator begin()
Recipe iterator methods.
RecipeListTy::reverse_iterator reverse_iterator
VPBasicBlock * clone() override
Clone the current block and it's recipes, without updating the operands of the cloned recipes.
iterator_range< iterator > phis()
Returns an iterator range over the PHI-like recipes in the block.
InstructionCost cost(ElementCount VF, VPCostContext &Ctx) override
Return the cost of this VPBasicBlock.
iterator getFirstNonPhi()
Return the position of the first non-phi node recipe in the block.
void connectToPredecessors(VPTransformState &State)
Connect the VPBBs predecessors' in the VPlan CFG to the IR basic block generated for this VPBB.
VPRegionBlock * getEnclosingLoopRegion()
const_reverse_iterator rbegin() const
VPBasicBlock * splitAt(iterator SplitAt)
Split current block at SplitAt by inserting a new block between the current block and its successors ...
RecipeListTy Recipes
The VPRecipes held in the order of output instructions to generate.
void executeRecipes(VPTransformState *State, BasicBlock *BB)
Execute the recipes in the IR basic block BB.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print this VPBsicBlock to O, prefixing all lines with Indent.
const VPRecipeBase & front() const
const_iterator begin() const
bool isExiting() const
Returns true if the block is exiting it's parent region.
VPRecipeBase * getTerminator()
If the block has multiple successors, return the branch recipe terminating the block.
const VPRecipeBase & back() const
void insert(VPRecipeBase *Recipe, iterator InsertPt)
const_iterator end() const
static bool classof(const VPBlockBase *V)
Method to support type inquiry through isa, cast, and dyn_cast.
static RecipeListTy VPBasicBlock::* getSublistAccess(VPRecipeBase *)
Returns a pointer to a member of the recipe list.
reverse_iterator rbegin()
const_reverse_iterator rend() const
A recipe for vectorizing a phi-node as a sequence of mask-based select instructions.
VPBlendRecipe(PHINode *Phi, ArrayRef< VPValue * > Operands)
The blend operation is a User of the incoming values and of their respective masks,...
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
InstructionCost computeCost(ElementCount VF, VPCostContext &Ctx) const override
Return the cost of this VPWidenMemoryRecipe.
bool onlyFirstLaneUsed(const VPValue *Op) const override
Returns true if the recipe only uses the first lane of operand Op.
VPValue * getIncomingValue(unsigned Idx) const
Return incoming value number Idx.
VPValue * getMask(unsigned Idx) const
Return mask number Idx.
unsigned getNumIncomingValues() const
Return the number of incoming values, taking into account when normalized the first incoming value wi...
VPBlendRecipe * clone() override
Clone the current recipe.
void execute(VPTransformState &State) override
Generate the phi/select nodes.
bool isNormalized() const
A normalized blend is one that has an odd number of operands, whereby the first operand does not have...
VPBlockBase is the building block of the Hierarchical Control-Flow Graph.
void setSuccessors(ArrayRef< VPBlockBase * > NewSuccs)
Set each VPBasicBlock in NewSuccss as successor of this VPBlockBase.
VPRegionBlock * getParent()
VPBlocksTy & getPredecessors()
iterator_range< VPBlockBase ** > predecessors()
const VPBasicBlock * getExitingBasicBlock() const
LLVM_DUMP_METHOD void dump() const
Dump this VPBlockBase to dbgs().
void setName(const Twine &newName)
size_t getNumSuccessors() const
iterator_range< VPBlockBase ** > successors()
virtual void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const =0
Print plain-text dump of this VPBlockBase to O, prefixing all lines with Indent.
void swapSuccessors()
Swap successors of the block. The block must have exactly 2 successors.
void printSuccessors(raw_ostream &O, const Twine &Indent) const
Print the successors of this block to O, prefixing all lines with Indent.
bool isLegalToHoistInto()
Return true if it is legal to hoist instructions into this block.
virtual ~VPBlockBase()=default
const VPBlocksTy & getHierarchicalPredecessors()
size_t getNumPredecessors() const
void setPredecessors(ArrayRef< VPBlockBase * > NewPreds)
Set each VPBasicBlock in NewPreds as predecessor of this VPBlockBase.
VPBlockBase * getEnclosingBlockWithPredecessors()
const VPBlocksTy & getPredecessors() const
virtual VPBlockBase * clone()=0
Clone the current block and it's recipes without updating the operands of the cloned recipes,...
enum { VPRegionBlockSC, VPBasicBlockSC, VPIRBasicBlockSC } VPBlockTy
An enumeration for keeping track of the concrete subclass of VPBlockBase that are actually instantiat...
virtual InstructionCost cost(ElementCount VF, VPCostContext &Ctx)=0
Return the cost of the block.
void setPlan(VPlan *ParentPlan)
Sets the pointer of the plan containing the block.
const VPRegionBlock * getParent() const
const std::string & getName() const
void clearSuccessors()
Remove all the successors of this block.
VPBlockBase * getSingleHierarchicalSuccessor()
void setTwoSuccessors(VPBlockBase *IfTrue, VPBlockBase *IfFalse)
Set two given VPBlockBases IfTrue and IfFalse to be the two successors of this VPBlockBase.
VPBlockBase * getSinglePredecessor() const
virtual void execute(VPTransformState *State)=0
The method which generates the output IR that correspond to this VPBlockBase, thereby "executing" the...
const VPBlocksTy & getHierarchicalSuccessors()
void clearPredecessors()
Remove all the predecessor of this block.
unsigned getVPBlockID() const
void printAsOperand(raw_ostream &OS, bool PrintType=false) const
VPBlockBase(const unsigned char SC, const std::string &N)
VPBlocksTy & getSuccessors()
VPBlockBase * getEnclosingBlockWithSuccessors()
An Enclosing Block of a block B is any block containing B, including B itself.
const VPBasicBlock * getEntryBasicBlock() const
void setOneSuccessor(VPBlockBase *Successor)
Set a given VPBlockBase Successor as the single successor of this VPBlockBase.
void setParent(VPRegionBlock *P)
VPBlockBase * getSingleHierarchicalPredecessor()
VPBlockBase * getSingleSuccessor() const
const VPBlocksTy & getSuccessors() const
Class that provides utilities for VPBlockBases in VPlan.
A recipe for generating conditional branches on the bits of a mask.
VPValue * getMask() const
Return the mask used by this recipe.
InstructionCost computeCost(ElementCount VF, VPCostContext &Ctx) const override
Return the cost of this VPBranchOnMaskRecipe.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
VPBranchOnMaskRecipe(VPValue *BlockInMask)
VPBranchOnMaskRecipe * clone() override
Clone the current recipe.
bool usesScalars(const VPValue *Op) const override
Returns true if the recipe uses scalars of operand Op.
void execute(VPTransformState &State) override
Generate the extraction of the appropriate bit from the block mask and the conditional branch.
VPlan-based builder utility analogous to IRBuilder.
Canonical scalar induction phi of the vector loop.
bool onlyFirstPartUsed(const VPValue *Op) const override
Returns true if the recipe only uses the first part of operand Op.
~VPCanonicalIVPHIRecipe() override=default
static bool classof(const VPHeaderPHIRecipe *D)
VPCanonicalIVPHIRecipe * clone() override
Clone the current recipe.
VPCanonicalIVPHIRecipe(VPValue *StartV, DebugLoc DL)
bool onlyFirstLaneUsed(const VPValue *Op) const override
Returns true if the recipe only uses the first lane of operand Op.
Type * getScalarType() const
Returns the scalar type of the induction.
void execute(VPTransformState &State) override
Generate the phi nodes.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
InstructionCost computeCost(ElementCount VF, VPCostContext &Ctx) const override
Return the cost of this VPCanonicalIVPHIRecipe.
This class augments a recipe with a set of VPValues defined by the recipe.
unsigned getVPDefID() const
A recipe for converting the input value IV value to the corresponding value of an IV with different s...
void execute(VPTransformState &State) override
Generate the transformed value of the induction at offset StartValue (1.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
InstructionCost computeCost(ElementCount VF, VPCostContext &Ctx) const override
Return the cost of this VPDerivedIVRecipe.
VPValue * getStepValue() const
Type * getScalarType() const
VPDerivedIVRecipe * clone() override
Clone the current recipe.
VPDerivedIVRecipe(InductionDescriptor::InductionKind Kind, const FPMathOperator *FPBinOp, VPValue *Start, VPValue *IV, VPValue *Step, const Twine &Name="")
~VPDerivedIVRecipe() override=default
bool onlyFirstLaneUsed(const VPValue *Op) const override
Returns true if the recipe only uses the first lane of operand Op.
VPValue * getStartValue() const
VPDerivedIVRecipe(const InductionDescriptor &IndDesc, VPValue *Start, VPCanonicalIVPHIRecipe *CanonicalIV, VPValue *Step, const Twine &Name="")
A recipe for generating the phi node for the current index of elements, adjusted in accordance with E...
static bool classof(const VPHeaderPHIRecipe *D)
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
VPEVLBasedIVPHIRecipe * clone() override
Clone the current recipe.
~VPEVLBasedIVPHIRecipe() override=default
void execute(VPTransformState &State) override
Generate the phi nodes.
InstructionCost computeCost(ElementCount VF, VPCostContext &Ctx) const override
Return the cost of this VPEVLBasedIVPHIRecipe.
VPEVLBasedIVPHIRecipe(VPValue *StartIV, DebugLoc DL)
bool onlyFirstLaneUsed(const VPValue *Op) const override
Returns true if the recipe only uses the first lane of operand Op.
Recipe to expand a SCEV expression.
VPExpandSCEVRecipe(const SCEV *Expr, ScalarEvolution &SE)
InstructionCost computeCost(ElementCount VF, VPCostContext &Ctx) const override
Return the cost of this VPExpandSCEVRecipe.
const SCEV * getSCEV() const
void execute(VPTransformState &State) override
Generate a canonical vector induction variable of the vector loop, with.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
VPExpandSCEVRecipe * clone() override
Clone the current recipe.
~VPExpandSCEVRecipe() override=default
A recipe representing a sequence of load -> update -> store as part of a histogram operation.
void execute(VPTransformState &State) override
Produce a vectorized histogram operation.
VP_CLASSOF_IMPL(VPDef::VPHistogramSC)
VPHistogramRecipe * clone() override
Clone the current recipe.
InstructionCost computeCost(ElementCount VF, VPCostContext &Ctx) const override
Return the cost of this VPHistogramRecipe.
VPHistogramRecipe(unsigned Opcode, iterator_range< IterT > Operands, DebugLoc DL={})
VPValue * getMask() const
Return the mask operand if one was provided, or a null pointer if all lanes should be executed uncond...
unsigned getOpcode() const
~VPHistogramRecipe() override=default
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
A special type of VPBasicBlock that wraps an existing IR basic block.
void execute(VPTransformState *State) override
The method which generates the output IR instructions that correspond to this VPBasicBlock,...
BasicBlock * getIRBasicBlock() const
~VPIRBasicBlock() override
static bool classof(const VPBlockBase *V)
VPIRBasicBlock * clone() override
Clone the current block and it's recipes, without updating the operands of the cloned recipes.
A recipe to wrap on original IR instruction not to be modified during execution, execept for PHIs.
Instruction & getInstruction() const
bool onlyFirstPartUsed(const VPValue *Op) const override
Returns true if the VPUser only uses the first part of operand Op.
~VPIRInstruction() override=default
void execute(VPTransformState &State) override
The method which generates the output IR instructions that correspond to this VPRecipe,...
bool onlyFirstLaneUsed(const VPValue *Op) const override
Returns true if the VPUser only uses the first lane of operand Op.
VPIRInstruction * clone() override
Clone the current recipe.
InstructionCost computeCost(ElementCount VF, VPCostContext &Ctx) const override
Return the cost of this VPIRInstruction.
void extractLastLaneOfOperand(VPBuilder &Builder)
Update the recipes single operand to the last lane of the operand using Builder.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
bool usesScalars(const VPValue *Op) const override
Returns true if the VPUser uses scalars of operand Op.
VPIRInstruction(Instruction &I)
This is a concrete Recipe that models a single VPlan-level instruction.
VPInstruction(VPValue *Ptr, VPValue *Offset, GEPNoWrapFlags Flags, DebugLoc DL={}, const Twine &Name="")
VPInstruction(unsigned Opcode, ArrayRef< VPValue * > Operands, DebugLoc DL, const Twine &Name="")
VPInstruction * clone() override
Clone the current recipe.
@ ResumePhi
Creates a scalar phi in a leaf VPBB with a single predecessor in VPlan.
@ FirstOrderRecurrenceSplice
@ CanonicalIVIncrementForPart
@ CalculateTripCountMinusVF
bool opcodeMayReadOrWriteFromMemory() const
Returns true if the underlying opcode may read from or write to memory.
LLVM_DUMP_METHOD void dump() const
Print the VPInstruction to dbgs() (for debugging).
StringRef getName() const
Returns the symbolic name assigned to the VPInstruction.
InstructionCost computeCost(ElementCount VF, VPCostContext &Ctx) const override
Return the cost of this VPInstruction.
unsigned getOpcode() const
VPInstruction(unsigned Opcode, std::initializer_list< VPValue * > Operands, WrapFlagsTy WrapFlags, DebugLoc DL={}, const Twine &Name="")
bool onlyFirstPartUsed(const VPValue *Op) const override
Returns true if the recipe only uses the first part of operand Op.
VPInstruction(unsigned Opcode, std::initializer_list< VPValue * > Operands, DebugLoc DL={}, const Twine &Name="")
VPInstruction(unsigned Opcode, std::initializer_list< VPValue * > Operands, DisjointFlagsTy DisjointFlag, DebugLoc DL={}, const Twine &Name="")
bool isVectorToScalar() const
Returns true if this VPInstruction produces a scalar value from a vector, e.g.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the VPInstruction to O.
bool onlyFirstLaneUsed(const VPValue *Op) const override
Returns true if the recipe only uses the first lane of operand Op.
bool isSingleScalar() const
Returns true if this VPInstruction's operands are single scalars and the result is also a single scal...
void execute(VPTransformState &State) override
Generate the instruction.
VPInterleaveRecipe is a recipe for transforming an interleave group of load or stores into one wide l...
bool onlyFirstLaneUsed(const VPValue *Op) const override
The recipe only uses the first lane of the address.
~VPInterleaveRecipe() override=default
VPValue * getAddr() const
Return the address accessed by this recipe.
VPInterleaveRecipe(const InterleaveGroup< Instruction > *IG, VPValue *Addr, ArrayRef< VPValue * > StoredValues, VPValue *Mask, bool NeedsMaskForGaps)
VPValue * getMask() const
Return the mask used by this recipe.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
VPInterleaveRecipe * clone() override
Clone the current recipe.
void execute(VPTransformState &State) override
Generate the wide load or store, and shuffles.
ArrayRef< VPValue * > getStoredValues() const
Return the VPValues stored by this interleave group.
Instruction * getInsertPos() const
const InterleaveGroup< Instruction > * getInterleaveGroup()
InstructionCost computeCost(ElementCount VF, VPCostContext &Ctx) const override
Return the cost of this VPInterleaveRecipe.
unsigned getNumStoreOperands() const
Returns the number of stored operands of this interleave group.
In what follows, the term "input IR" refers to code that is fed into the vectorizer whereas the term ...
A recipe for forming partial reductions.
~VPPartialReductionRecipe() override=default
void execute(VPTransformState &State) override
Generate the reduction in the loop.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
InstructionCost computeCost(ElementCount VF, VPCostContext &Ctx) const override
Return the cost of this VPPartialReductionRecipe.
unsigned getOpcode() const
Get the binary op's opcode.
VPPartialReductionRecipe(unsigned Opcode, VPValue *Op0, VPValue *Op1, Instruction *ReductionInst=nullptr)
VPPartialReductionRecipe(Instruction *ReductionInst, VPValue *Op0, VPValue *Op1)
VPPartialReductionRecipe * clone() override
Clone the current recipe.
VPPredInstPHIRecipe is a recipe for generating the phi nodes needed when control converges back from ...
~VPPredInstPHIRecipe() override=default
bool usesScalars(const VPValue *Op) const override
Returns true if the recipe uses scalars of operand Op.
void execute(VPTransformState &State) override
Generates phi nodes for live-outs (from a replicate region) as needed to retain SSA form.
VPPredInstPHIRecipe * clone() override
Clone the current recipe.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
InstructionCost computeCost(ElementCount VF, VPCostContext &Ctx) const override
Return the cost of this VPPredInstPHIRecipe.
VPPredInstPHIRecipe(VPValue *PredV, DebugLoc DL)
Construct a VPPredInstPHIRecipe given PredInst whose value needs a phi nodes after merging back from ...
VPRecipeBase is a base class modeling a sequence of one or more output IR instructions.
bool mayReadFromMemory() const
Returns true if the recipe may read from memory.
bool mayReadOrWriteMemory() const
Returns true if the recipe may read from or write to memory.
bool mayHaveSideEffects() const
Returns true if the recipe may have side-effects.
bool mayWriteToMemory() const
Returns true if the recipe may write to memory.
virtual InstructionCost computeCost(ElementCount VF, VPCostContext &Ctx) const
Compute the cost of this recipe either using a recipe's specialized implementation or using the legac...
virtual ~VPRecipeBase()=default
VPBasicBlock * getParent()
DebugLoc getDebugLoc() const
Returns the debug location of the recipe.
virtual void execute(VPTransformState &State)=0
The method which generates the output IR instructions that correspond to this VPRecipe,...
void moveBefore(VPBasicBlock &BB, iplist< VPRecipeBase >::iterator I)
Unlink this recipe and insert into BB before I.
void insertBefore(VPRecipeBase *InsertPos)
Insert an unlinked recipe into a basic block immediately before the specified recipe.
void insertAfter(VPRecipeBase *InsertPos)
Insert an unlinked Recipe into a basic block immediately after the specified Recipe.
static bool classof(const VPDef *D)
Method to support type inquiry through isa, cast, and dyn_cast.
iplist< VPRecipeBase >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
VPRecipeBase(const unsigned char SC, ArrayRef< VPValue * > Operands, DebugLoc DL={})
virtual VPRecipeBase * clone()=0
Clone the current recipe.
const VPBasicBlock * getParent() const
InstructionCost cost(ElementCount VF, VPCostContext &Ctx)
Return the cost of this recipe, taking into account if the cost computation should be skipped and the...
static bool classof(const VPUser *U)
VPRecipeBase(const unsigned char SC, iterator_range< IterT > Operands, DebugLoc DL={})
void removeFromParent()
This method unlinks 'this' from the containing basic block, but does not delete it.
bool isPhi() const
Returns true for PHI-like recipes.
void moveAfter(VPRecipeBase *MovePos)
Unlink this recipe from its current VPBasicBlock and insert it into the VPBasicBlock that MovePos liv...
Class to record LLVM IR flag for a recipe along with it.
NonNegFlagsTy NonNegFlags
CmpInst::Predicate CmpPredicate
GEPNoWrapFlags getGEPNoWrapFlags() const
VPRecipeWithIRFlags(const unsigned char SC, IterT Operands, CmpInst::Predicate Pred, DebugLoc DL={})
void setFlags(Instruction *I) const
Set the IR flags for I.
VPRecipeWithIRFlags(const unsigned char SC, IterT Operands, GEPNoWrapFlags GEPFlags, DebugLoc DL={})
static bool classof(const VPRecipeBase *R)
VPRecipeWithIRFlags(const unsigned char SC, IterT Operands, FastMathFlags FMFs, DebugLoc DL={})
void dropPoisonGeneratingFlags()
Drop all poison-generating flags.
bool hasFastMathFlags() const
Returns true if the recipe has fast-math flags.
VPRecipeWithIRFlags(const unsigned char SC, IterT Operands, Instruction &I)
DisjointFlagsTy DisjointFlags
VPRecipeWithIRFlags(const unsigned char SC, IterT Operands, WrapFlagsTy WrapFlags, DebugLoc DL={})
VPRecipeWithIRFlags(const unsigned char SC, IterT Operands, DisjointFlagsTy DisjointFlags, DebugLoc DL={})
void transferFlags(VPRecipeWithIRFlags &Other)
bool hasNoUnsignedWrap() const
void printFlags(raw_ostream &O) const
CmpInst::Predicate getPredicate() const
bool hasNoSignedWrap() const
static bool classof(const VPUser *U)
FastMathFlags getFastMathFlags() const
VPRecipeWithIRFlags(const unsigned char SC, IterT Operands, DebugLoc DL={})
A recipe to represent inloop reduction operations with vector-predication intrinsics,...
void execute(VPTransformState &State) override
Generate the reduction in the loop.
bool onlyFirstLaneUsed(const VPValue *Op) const override
Returns true if the recipe only uses the first lane of operand Op.
VPValue * getEVL() const
The VPValue of the explicit vector length.
VPReductionEVLRecipe(VPReductionRecipe &R, VPValue &EVL, VPValue *CondOp)
VPReductionEVLRecipe * clone() override
Clone the current recipe.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
~VPReductionEVLRecipe() override=default
A recipe for handling reduction phis.
bool isOrdered() const
Returns true, if the phi is part of an ordered reduction.
VPReductionPHIRecipe * clone() override
Clone the current recipe.
~VPReductionPHIRecipe() override=default
VPReductionPHIRecipe(PHINode *Phi, const RecurrenceDescriptor &RdxDesc, VPValue &Start, bool IsInLoop=false, bool IsOrdered=false, unsigned VFScaleFactor=1)
Create a new VPReductionPHIRecipe for the reduction Phi described by RdxDesc.
bool isInLoop() const
Returns true, if the phi is part of an in-loop reduction.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
void execute(VPTransformState &State) override
Generate the phi/select nodes.
static bool classof(const VPHeaderPHIRecipe *R)
const RecurrenceDescriptor & getRecurrenceDescriptor() const
A recipe to represent inloop reduction operations, performing a reduction on a vector operand into a ...
bool isConditional() const
Return true if the in-loop reduction is conditional.
static bool classof(const VPRecipeBase *R)
VPReductionRecipe(const RecurrenceDescriptor &R, Instruction *I, VPValue *ChainOp, VPValue *VecOp, VPValue *CondOp, bool IsOrdered, DebugLoc DL={})
VPReductionRecipe(const unsigned char SC, const RecurrenceDescriptor &R, Instruction *I, ArrayRef< VPValue * > Operands, VPValue *CondOp, bool IsOrdered, DebugLoc DL)
InstructionCost computeCost(ElementCount VF, VPCostContext &Ctx) const override
Return the cost of VPReductionRecipe.
VPValue * getVecOp() const
The VPValue of the vector value to be reduced.
const RecurrenceDescriptor & getRecurrenceDescriptor() const
Return the recurrence decriptor for the in-loop reduction.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
VPValue * getCondOp() const
The VPValue of the condition for the block.
bool isOrdered() const
Return true if the in-loop reduction is ordered.
~VPReductionRecipe() override=default
VPValue * getChainOp() const
The VPValue of the scalar Chain being accumulated.
VPReductionRecipe * clone() override
Clone the current recipe.
void execute(VPTransformState &State) override
Generate the reduction in the loop.
static bool classof(const VPUser *U)
VPRegionBlock represents a collection of VPBasicBlocks and VPRegionBlocks which form a Single-Entry-S...
VPRegionBlock * clone() override
Clone all blocks in the single-entry single-exit region of the block and their recipes without updati...
const VPBlockBase * getEntry() const
bool isReplicator() const
An indicator whether this region is to generate multiple replicated instances of output IR correspond...
void setExiting(VPBlockBase *ExitingBlock)
Set ExitingBlock as the exiting VPBlockBase of this VPRegionBlock.
VPBlockBase * getExiting()
void setEntry(VPBlockBase *EntryBlock)
Set EntryBlock as the entry VPBlockBase of this VPRegionBlock.
InstructionCost cost(ElementCount VF, VPCostContext &Ctx) override
Return the cost of the block.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print this VPRegionBlock to O (recursively), prefixing all lines with Indent.
void execute(VPTransformState *State) override
The method which generates the output IR instructions that correspond to this VPRegionBlock,...
const VPBlockBase * getExiting() const
VPBasicBlock * getPreheaderVPBB()
Returns the pre-header VPBasicBlock of the loop region.
~VPRegionBlock() override
static bool classof(const VPBlockBase *V)
Method to support type inquiry through isa, cast, and dyn_cast.
VPReplicateRecipe replicates a given instruction producing multiple scalar copies of the original sca...
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
void execute(VPTransformState &State) override
Generate replicas of the desired Ingredient.
~VPReplicateRecipe() override=default
InstructionCost computeCost(ElementCount VF, VPCostContext &Ctx) const override
Return the cost of this VPReplicateRecipe.
bool onlyFirstLaneUsed(const VPValue *Op) const override
Returns true if the recipe only uses the first lane of operand Op.
bool usesScalars(const VPValue *Op) const override
Returns true if the recipe uses scalars of operand Op.
bool isPredicated() const
VPReplicateRecipe * clone() override
Clone the current recipe.
VPReplicateRecipe(Instruction *I, iterator_range< IterT > Operands, bool IsUniform, VPValue *Mask=nullptr)
unsigned getOpcode() const
VPValue * getMask()
Return the mask of a predicated VPReplicateRecipe.
bool shouldPack() const
Returns true if the recipe is used by a widened recipe via an intervening VPPredInstPHIRecipe.
A recipe to compute the pointers for widened memory accesses of IndexTy in reverse order.
InstructionCost computeCost(ElementCount VF, VPCostContext &Ctx) const override
Return the cost of this VPVectorPointerRecipe.
VPReverseVectorPointerRecipe * clone() override
Clone the current recipe.
bool onlyFirstPartUsed(const VPValue *Op) const override
Returns true if the recipe only uses the first part of operand Op.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
void execute(VPTransformState &State) override
The method which generates the output IR instructions that correspond to this VPRecipe,...
bool onlyFirstLaneUsed(const VPValue *Op) const override
Returns true if the VPUser only uses the first lane of operand Op.
VPReverseVectorPointerRecipe(VPValue *Ptr, VPValue *VF, Type *IndexedTy, GEPNoWrapFlags GEPFlags, DebugLoc DL)
const VPValue * getVFValue() const
VPScalarCastRecipe is a recipe to create scalar cast instructions.
InstructionCost computeCost(ElementCount VF, VPCostContext &Ctx) const override
Return the cost of this VPScalarCastRecipe.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Each concrete VPDef prints itself.
~VPScalarCastRecipe() override=default
VPScalarCastRecipe * clone() override
Clone the current recipe.
bool onlyFirstLaneUsed(const VPValue *Op) const override
Returns true if the VPUser only uses the first lane of operand Op.
VPScalarCastRecipe(Instruction::CastOps Opcode, VPValue *Op, Type *ResultTy, DebugLoc DL)
void execute(VPTransformState &State) override
The method which generates the output IR instructions that correspond to this VPRecipe,...
Type * getResultType() const
Returns the result type of the cast.
A recipe for handling phi nodes of integer and floating-point inductions, producing their scalar valu...
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
bool onlyFirstLaneUsed(const VPValue *Op) const override
Returns true if the recipe only uses the first lane of operand Op.
VPValue * getStepValue() const
InstructionCost computeCost(ElementCount VF, VPCostContext &Ctx) const override
Return the cost of this VPScalarIVStepsRecipe.
VPScalarIVStepsRecipe(const InductionDescriptor &IndDesc, VPValue *IV, VPValue *Step)
VPScalarIVStepsRecipe * clone() override
Clone the current recipe.
VPScalarIVStepsRecipe(VPValue *IV, VPValue *Step, Instruction::BinaryOps Opcode, FastMathFlags FMFs)
~VPScalarIVStepsRecipe() override=default
void execute(VPTransformState &State) override
Generate the scalarized versions of the phi node as needed by their users.
Recipe to generate a scalar PHI.
VPScalarPHIRecipe(VPValue *Start, VPValue *BackedgeValue, DebugLoc DL, StringRef Name)
bool onlyFirstLaneUsed(const VPValue *Op) const override
Returns true if the recipe only uses the first lane of operand Op.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
~VPScalarPHIRecipe() override=default
void execute(VPTransformState &State) override
Generate the phi/select nodes.
VPScalarPHIRecipe * clone() override
Clone the current recipe.
VPSingleDef is a base class for recipes for modeling a sequence of one or more output IR that define ...
VPSingleDefRecipe(const unsigned char SC, ArrayRef< VPValue * > Operands, DebugLoc DL={})
Instruction * getUnderlyingInstr()
Returns the underlying instruction.
static bool classof(const VPRecipeBase *R)
const Instruction * getUnderlyingInstr() const
VPSingleDefRecipe(const unsigned char SC, IterT Operands, DebugLoc DL={})
static bool classof(const VPUser *U)
LLVM_DUMP_METHOD void dump() const
Print this VPSingleDefRecipe to dbgs() (for debugging).
VPSingleDefRecipe(const unsigned char SC, IterT Operands, Value *UV, DebugLoc DL={})
virtual VPSingleDefRecipe * clone() override=0
Clone the current recipe.
This class can be used to assign names to VPValues.
Helper to access the operand that contains the unroll part for this recipe after unrolling.
VPValue * getUnrollPartOperand(VPUser &U) const
Return the VPValue operand containing the unroll part or null if there is no such operand.
unsigned getUnrollPart(VPUser &U) const
Return the unroll part.
This class augments VPValue with operands which provide the inverse def-use edges from VPValue's user...
void setOperand(unsigned I, VPValue *New)
unsigned getNumOperands() const
operand_iterator op_end()
operand_iterator op_begin()
VPValue * getOperand(unsigned N) const
void addOperand(VPValue *Operand)
bool isDefinedOutsideLoopRegions() const
Returns true if the VPValue is defined outside any loop region.
VPRecipeBase * getDefiningRecipe()
Returns the recipe defining this VPValue or nullptr if it is not defined by a recipe,...
Value * getUnderlyingValue() const
Return the underlying Value attached to this VPValue.
unsigned getNumUsers() const
Value * getLiveInIRValue()
Returns the underlying IR value, if this VPValue is defined outside the scope of VPlan.
bool isLiveIn() const
Returns true if this VPValue is a live-in, i.e. defined outside the VPlan.
friend class VPRecipeBase
A recipe to compute the pointers for widened memory accesses of IndexTy.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
VPVectorPointerRecipe(VPValue *Ptr, Type *IndexedTy, GEPNoWrapFlags GEPFlags, DebugLoc DL)
void execute(VPTransformState &State) override
The method which generates the output IR instructions that correspond to this VPRecipe,...
bool onlyFirstPartUsed(const VPValue *Op) const override
Returns true if the recipe only uses the first part of operand Op.
bool onlyFirstLaneUsed(const VPValue *Op) const override
Returns true if the VPUser only uses the first lane of operand Op.
InstructionCost computeCost(ElementCount VF, VPCostContext &Ctx) const override
Return the cost of this VPHeaderPHIRecipe.
VPVectorPointerRecipe * clone() override
Clone the current recipe.
A recipe for widening Call instructions using library calls.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
const_operand_range arg_operands() const
VPWidenCallRecipe * clone() override
Clone the current recipe.
Function * getCalledScalarFunction() const
InstructionCost computeCost(ElementCount VF, VPCostContext &Ctx) const override
Return the cost of this VPWidenCallRecipe.
void execute(VPTransformState &State) override
Produce a widened version of the call instruction.
operand_range arg_operands()
~VPWidenCallRecipe() override=default
VPWidenCallRecipe(Value *UV, Function *Variant, ArrayRef< VPValue * > CallArguments, DebugLoc DL={})
A Recipe for widening the canonical induction variable of the vector loop.
void execute(VPTransformState &State) override
Generate a canonical vector induction variable of the vector loop, with start = {<Part*VF,...
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
~VPWidenCanonicalIVRecipe() override=default
InstructionCost computeCost(ElementCount VF, VPCostContext &Ctx) const override
Return the cost of this VPWidenCanonicalIVPHIRecipe.
VPWidenCanonicalIVRecipe * clone() override
Clone the current recipe.
VPWidenCanonicalIVRecipe(VPCanonicalIVPHIRecipe *CanonicalIV)
VPWidenCastRecipe is a recipe to create vector cast instructions.
VPWidenCastRecipe(Instruction::CastOps Opcode, VPValue *Op, Type *ResultTy, CastInst &UI)
Instruction::CastOps getOpcode() const
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
Type * getResultType() const
Returns the result type of the cast.
VPWidenCastRecipe(Instruction::CastOps Opcode, VPValue *Op, Type *ResultTy)
void execute(VPTransformState &State) override
Produce widened copies of the cast.
~VPWidenCastRecipe() override=default
InstructionCost computeCost(ElementCount VF, VPCostContext &Ctx) const override
Return the cost of this VPWidenCastRecipe.
VPWidenCastRecipe * clone() override
Clone the current recipe.
A recipe for widening operations with vector-predication intrinsics with explicit vector length (EVL)...
const VPValue * getEVL() const
~VPWidenEVLRecipe() override=default
VPWidenEVLRecipe(Instruction &I, iterator_range< IterT > Operands, VPValue &EVL)
VPWidenRecipe * clone() override final
Clone the current recipe.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override final
Print the recipe.
VP_CLASSOF_IMPL(VPDef::VPWidenEVLSC)
VPWidenEVLRecipe(VPWidenRecipe &W, VPValue &EVL)
void execute(VPTransformState &State) override final
Produce a vp-intrinsic using the opcode and operands of the recipe, processing EVL elements.
bool onlyFirstLaneUsed(const VPValue *Op) const override
Returns true if the recipe only uses the first lane of operand Op.
A recipe for handling GEP instructions.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
void execute(VPTransformState &State) override
Generate the gep nodes.
InstructionCost computeCost(ElementCount VF, VPCostContext &Ctx) const override
Return the cost of this VPWidenGEPRecipe.
VPWidenGEPRecipe * clone() override
Clone the current recipe.
~VPWidenGEPRecipe() override=default
VPWidenGEPRecipe(GetElementPtrInst *GEP, iterator_range< IterT > Operands)
Base class for widened induction (VPWidenIntOrFpInductionRecipe and VPWidenPointerInductionRecipe),...
static bool classof(const VPValue *V)
VPValue * getBackedgeValue() override
Returns the incoming value from the loop backedge.
PHINode * getPHINode() const
VPWidenInductionRecipe(unsigned char Kind, PHINode *IV, VPValue *Start, VPValue *Step, const InductionDescriptor &IndDesc, DebugLoc DL)
VPValue * getStepValue()
Returns the step value of the induction.
const InductionDescriptor & getInductionDescriptor() const
Returns the induction descriptor for the recipe.
VPRecipeBase & getBackedgeRecipe() override
Returns the backedge value as a recipe.
static bool classof(const VPRecipeBase *R)
static bool classof(const VPHeaderPHIRecipe *R)
const VPValue * getStepValue() const
virtual void execute(VPTransformState &State) override=0
Generate the phi nodes.
A recipe for handling phi nodes of integer and floating-point inductions, producing their vector valu...
const TruncInst * getTruncInst() const
const VPValue * getVFValue() const
~VPWidenIntOrFpInductionRecipe() override=default
VPWidenIntOrFpInductionRecipe(PHINode *IV, VPValue *Start, VPValue *Step, VPValue *VF, const InductionDescriptor &IndDesc, TruncInst *Trunc, DebugLoc DL)
VPWidenIntOrFpInductionRecipe * clone() override
Clone the current recipe.
TruncInst * getTruncInst()
Returns the first defined value as TruncInst, if it is one or nullptr otherwise.
void execute(VPTransformState &State) override
Generate the vectorized and scalarized versions of the phi node as needed by their users.
VPWidenIntOrFpInductionRecipe(PHINode *IV, VPValue *Start, VPValue *Step, VPValue *VF, const InductionDescriptor &IndDesc, DebugLoc DL)
VPValue * getLastUnrolledPartOperand()
Returns the VPValue representing the value of this induction at the last unrolled part,...
Type * getScalarType() const
Returns the scalar type of the induction.
bool isCanonical() const
Returns true if the induction is canonical, i.e.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
VPValue * getSplatVFValue()
A recipe for widening vector intrinsics.
bool onlyFirstLaneUsed(const VPValue *Op) const override
Returns true if the VPUser only uses the first lane of operand Op.
VPWidenIntrinsicRecipe(Intrinsic::ID VectorIntrinsicID, std::initializer_list< VPValue * > CallArguments, Type *Ty, DebugLoc DL={})
Intrinsic::ID getVectorIntrinsicID() const
Return the ID of the intrinsic.
bool mayReadFromMemory() const
Returns true if the intrinsic may read from memory.
StringRef getIntrinsicName() const
Return to name of the intrinsic as string.
VPWidenIntrinsicRecipe(Intrinsic::ID VectorIntrinsicID, ArrayRef< VPValue * > CallArguments, Type *Ty, DebugLoc DL={})
bool mayHaveSideEffects() const
Returns true if the intrinsic may have side-effects.
VPWidenIntrinsicRecipe * clone() override
Clone the current recipe.
bool mayWriteToMemory() const
Returns true if the intrinsic may write to memory.
~VPWidenIntrinsicRecipe() override=default
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
Type * getResultType() const
Return the scalar return type of the intrinsic.
void execute(VPTransformState &State) override
Produce a widened version of the vector intrinsic.
InstructionCost computeCost(ElementCount VF, VPCostContext &Ctx) const override
Return the cost of this vector intrinsic.
VPWidenIntrinsicRecipe(CallInst &CI, Intrinsic::ID VectorIntrinsicID, ArrayRef< VPValue * > CallArguments, Type *Ty, DebugLoc DL={})
A common base class for widening memory operations.
bool IsMasked
Whether the memory access is masked.
bool Reverse
Whether the consecutive accessed addresses are in reverse order.
bool isConsecutive() const
Return whether the loaded-from / stored-to addresses are consecutive.
static bool classof(const VPUser *U)
void execute(VPTransformState &State) override
Generate the wide load/store.
VPWidenMemoryRecipe * clone() override
Clone the current recipe.
InstructionCost computeCost(ElementCount VF, VPCostContext &Ctx) const override
Return the cost of this VPWidenMemoryRecipe.
Instruction & getIngredient() const
bool Consecutive
Whether the accessed addresses are consecutive.
static bool classof(const VPRecipeBase *R)
VPWidenMemoryRecipe(const char unsigned SC, Instruction &I, std::initializer_list< VPValue * > Operands, bool Consecutive, bool Reverse, DebugLoc DL)
VPValue * getMask() const
Return the mask used by this recipe.
bool isMasked() const
Returns true if the recipe is masked.
void setMask(VPValue *Mask)
VPValue * getAddr() const
Return the address accessed by this recipe.
bool isReverse() const
Return whether the consecutive loaded/stored addresses are in reverse order.
A recipe for handling phis that are widened in the vector loop.
void addIncoming(VPValue *IncomingV, VPBasicBlock *IncomingBlock)
Adds a pair (IncomingV, IncomingBlock) to the phi.
VPWidenPHIRecipe(PHINode *Phi, VPValue *Start=nullptr, DebugLoc DL={})
Create a new VPWidenPHIRecipe for Phi with start value Start and debug location DL.
VPValue * getIncomingValue(unsigned I)
Returns the I th incoming VPValue.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
VPWidenPHIRecipe * clone() override
Clone the current recipe.
~VPWidenPHIRecipe() override=default
VPBasicBlock * getIncomingBlock(unsigned I)
Returns the I th incoming VPBasicBlock.
void execute(VPTransformState &State) override
Generate the phi/select nodes.
VPWidenPointerInductionRecipe * clone() override
Clone the current recipe.
~VPWidenPointerInductionRecipe() override=default
VPWidenPointerInductionRecipe(PHINode *Phi, VPValue *Start, VPValue *Step, const InductionDescriptor &IndDesc, bool IsScalarAfterVectorization, DebugLoc DL)
Create a new VPWidenPointerInductionRecipe for Phi with start value Start.
bool onlyScalarsGenerated(bool IsScalable)
Returns true if only scalar values will be generated.
VPValue * getFirstUnrolledPartOperand()
Returns the VPValue representing the value of this induction at the first unrolled part,...
void execute(VPTransformState &State) override
Generate vector values for the pointer induction.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
VPWidenRecipe is a recipe for producing a widened instruction using the opcode and operands of the re...
InstructionCost computeCost(ElementCount VF, VPCostContext &Ctx) const override
Return the cost of this VPWidenRecipe.
void execute(VPTransformState &State) override
Produce a widened instruction using the opcode and operands of the recipe, processing State....
VPWidenRecipe * clone() override
Clone the current recipe.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
~VPWidenRecipe() override=default
VPWidenRecipe(Instruction &I, iterator_range< IterT > Operands)
unsigned getOpcode() const
VPWidenRecipe(unsigned VPDefOpcode, Instruction &I, iterator_range< IterT > Operands)
static bool classof(const VPRecipeBase *R)
static bool classof(const VPUser *U)
VPlanPrinter prints a given VPlan to a given output stream.
Class that maps (parts of) an existing VPlan to trees of combined VPInstructions.
VPlan models a candidate for vectorization, encoding various decisions take to produce efficient outp...
void printDOT(raw_ostream &O) const
Print this VPlan in DOT format to O.
std::string getName() const
Return a string with the name of the plan and the applicable VFs and UFs.
void prepareToExecute(Value *TripCount, Value *VectorTripCount, VPTransformState &State)
Prepare the plan for execution, setting up the required live-in values.
VPBasicBlock * getEntry()
VPRegionBlock * createVPRegionBlock(VPBlockBase *Entry, VPBlockBase *Exiting, const std::string &Name="", bool IsReplicator=false)
Create a new VPRegionBlock with Entry, Exiting and Name.
VPValue & getVectorTripCount()
The vector trip count.
void setName(const Twine &newName)
VPValue & getVFxUF()
Returns VF * UF of the vector loop region.
VPValue & getVF()
Returns the VF of the vector loop region.
VPValue * getTripCount() const
The trip count of the original loop.
VPValue * getOrCreateBackedgeTakenCount()
The backedge taken count of the original loop.
iterator_range< SmallSetVector< ElementCount, 2 >::iterator > vectorFactors() const
Returns an iterator range over all VFs of the plan.
VPlan(BasicBlock *ScalarHeaderBB, VPValue *TC)
Construct a VPlan with a new VPBasicBlock as entry, a VPIRBasicBlock wrapping ScalarHeaderBB and a tr...
bool isExitBlock(VPBlockBase *VPBB)
Returns true if VPBB is an exit block.
const VPBasicBlock * getEntry() const
static VPlanPtr createInitialVPlan(Type *InductionTy, PredicatedScalarEvolution &PSE, bool RequiresScalarEpilogueCheck, bool TailFolded, Loop *TheLoop)
Create initial VPlan, having an "entry" VPBasicBlock (wrapping original scalar pre-header) which cont...
VPIRBasicBlock * createEmptyVPIRBasicBlock(BasicBlock *IRBB)
Create a VPIRBasicBlock wrapping IRBB, but do not create VPIRInstructions wrapping the instructions i...
bool hasVF(ElementCount VF)
void addSCEVExpansion(const SCEV *S, VPValue *V)
bool hasUF(unsigned UF) const
void setVF(ElementCount VF)
VPRegionBlock * createVPRegionBlock(const std::string &Name="", bool IsReplicator=false)
Create a new VPRegionBlock with Name and entry and exiting blocks set to nullptr.
auto getExitBlocks()
Return an iterator range over the VPIRBasicBlock wrapping the exit blocks of the VPlan,...
VPRegionBlock * getVectorLoopRegion()
Returns the VPRegionBlock of the vector loop.
InstructionCost cost(ElementCount VF, VPCostContext &Ctx)
Return the cost of this plan.
const VPBasicBlock * getMiddleBlock() const
Returns the 'middle' block of the plan, that is the block that selects whether to execute the scalar ...
void resetTripCount(VPValue *NewTripCount)
Resets the trip count for the VPlan.
VPBasicBlock * getMiddleBlock()
void setEntry(VPBasicBlock *VPBB)
VPBasicBlock * createVPBasicBlock(const Twine &Name, VPRecipeBase *Recipe=nullptr)
Create a new VPBasicBlock with Name and containing Recipe if present.
VPIRBasicBlock * createVPIRBasicBlock(BasicBlock *IRBB)
Create a VPIRBasicBlock from IRBB containing VPIRInstructions for all instructions in IRBB,...
VPValue * getOrAddLiveIn(Value *V)
Gets the live-in VPValue for V or adds a new live-in (if none exists yet) for V.
LLVM_DUMP_METHOD void dump() const
Dump the plan to stderr (for debugging).
bool hasScalarVFOnly() const
VPBasicBlock * getScalarPreheader() const
Return the VPBasicBlock for the preheader of the scalar loop.
void execute(VPTransformState *State)
Generate the IR code for this VPlan.
VPCanonicalIVPHIRecipe * getCanonicalIV()
Returns the canonical induction recipe of the vector loop.
void print(raw_ostream &O) const
Print this VPlan to O.
void addVF(ElementCount VF)
VPIRBasicBlock * getScalarHeader() const
Return the VPIRBasicBlock wrapping the header of the scalar loop.
VPValue * getLiveIn(Value *V) const
Return the live-in VPValue for V, if there is one or nullptr otherwise.
VPValue * getSCEVExpansion(const SCEV *S) const
void printLiveIns(raw_ostream &O) const
Print the live-ins of this VPlan to O.
VPBasicBlock * getVectorPreheader()
Returns the preheader of the vector loop region, if one exists, or null otherwise.
VPlan * duplicate()
Clone the current VPlan, update all VPValues of the new VPlan and cloned recipes to refer to the clon...
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
An ilist node that can access its parent list.
base_list_type::const_reverse_iterator const_reverse_iterator
base_list_type::reverse_iterator reverse_iterator
base_list_type::const_iterator const_iterator
base_list_type::iterator iterator
iterator insert(iterator where, pointer New)
A range adaptor for a pair of iterators.
This class implements an extremely fast bulk output stream that can only output to a stream.
This file defines classes to implement an intrusive doubly linked list class (i.e.
This file defines the ilist_node class template, which is a convenient base class for creating classe...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ BasicBlock
Various leaf nodes.
AttributeList getAttributes(LLVMContext &C, ID id)
Return the attributes for an intrinsic.
This is an optimization pass for GlobalISel generic memory operations.
auto find(R &&Range, const T &Val)
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
auto cast_or_null(const Y &Val)
auto dyn_cast_or_null(const Y &Val)
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::unique_ptr< VPlan > VPlanPtr
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
DWARFExpression::Operation Op
raw_ostream & operator<<(raw_ostream &OS, const APFixedPoint &FX)
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Struct to hold various analysis needed for cost computations.
A recipe for handling first-order recurrence phis.
void execute(VPTransformState &State) override
Generate the phi nodes.
VPFirstOrderRecurrencePHIRecipe * clone() override
Clone the current recipe.
VPFirstOrderRecurrencePHIRecipe(PHINode *Phi, VPValue &Start)
InstructionCost computeCost(ElementCount VF, VPCostContext &Ctx) const override
Return the cost of this first-order recurrence phi recipe.
static bool classof(const VPHeaderPHIRecipe *R)
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
DisjointFlagsTy(bool IsDisjoint)
WrapFlagsTy(bool HasNUW, bool HasNSW)
A recipe for widening load operations with vector-predication intrinsics, using the address to load f...
void execute(VPTransformState &State) override
Generate the wide load or gather.
InstructionCost computeCost(ElementCount VF, VPCostContext &Ctx) const override
Return the cost of this VPWidenLoadEVLRecipe.
VPValue * getEVL() const
Return the EVL operand.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
bool onlyFirstLaneUsed(const VPValue *Op) const override
Returns true if the recipe only uses the first lane of operand Op.
VPWidenLoadEVLRecipe(VPWidenLoadRecipe &L, VPValue &EVL, VPValue *Mask)
A recipe for widening load operations, using the address to load from and an optional mask.
VP_CLASSOF_IMPL(VPDef::VPWidenLoadSC)
VPWidenLoadRecipe(LoadInst &Load, VPValue *Addr, VPValue *Mask, bool Consecutive, bool Reverse, DebugLoc DL)
bool onlyFirstLaneUsed(const VPValue *Op) const override
Returns true if the recipe only uses the first lane of operand Op.
void execute(VPTransformState &State) override
Generate a wide load or gather.
VPWidenLoadRecipe * clone() override
Clone the current recipe.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
A recipe for widening select instructions.
bool isInvariantCond() const
VPWidenSelectRecipe * clone() override
Clone the current recipe.
VPWidenSelectRecipe(SelectInst &I, iterator_range< IterT > Operands)
VPValue * getCond() const
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
InstructionCost computeCost(ElementCount VF, VPCostContext &Ctx) const override
Return the cost of this VPWidenSelectRecipe.
void execute(VPTransformState &State) override
Produce a widened version of the select instruction.
~VPWidenSelectRecipe() override=default
A recipe for widening store operations with vector-predication intrinsics, using the value to store,...
VPValue * getStoredValue() const
Return the address accessed by this recipe.
void execute(VPTransformState &State) override
Generate the wide store or scatter.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
bool onlyFirstLaneUsed(const VPValue *Op) const override
Returns true if the recipe only uses the first lane of operand Op.
VPWidenStoreEVLRecipe(VPWidenStoreRecipe &S, VPValue &EVL, VPValue *Mask)
InstructionCost computeCost(ElementCount VF, VPCostContext &Ctx) const override
Return the cost of this VPWidenStoreEVLRecipe.
VPValue * getEVL() const
Return the EVL operand.
A recipe for widening store operations, using the stored value, the address to store to and an option...
void execute(VPTransformState &State) override
Generate a wide store or scatter.
bool onlyFirstLaneUsed(const VPValue *Op) const override
Returns true if the recipe only uses the first lane of operand Op.
VPWidenStoreRecipe(StoreInst &Store, VPValue *Addr, VPValue *StoredVal, VPValue *Mask, bool Consecutive, bool Reverse, DebugLoc DL)
VP_CLASSOF_IMPL(VPDef::VPWidenStoreSC)
VPValue * getStoredValue() const
Return the value stored by this recipe.
VPWidenStoreRecipe * clone() override
Clone the current recipe.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
VPlanIngredient(const Value *V)
void print(raw_ostream &O) const