46#define LV_NAME "loop-vectorize"
47#define DEBUG_TYPE LV_NAME
52 return cast<VPExpressionRecipe>(
this)->mayReadOrWriteMemory();
54 return cast<VPInstruction>(
this)->opcodeMayReadOrWriteFromMemory();
55 case VPInterleaveEVLSC:
57 return cast<VPInterleaveBase>(
this)->getNumStoreOperands() > 0;
58 case VPWidenStoreEVLSC:
65 return !cast<VPWidenCallRecipe>(
this)
66 ->getCalledScalarFunction()
68 case VPWidenIntrinsicSC:
69 return cast<VPWidenIntrinsicRecipe>(
this)->mayWriteToMemory();
70 case VPCanonicalIVPHISC:
71 case VPBranchOnMaskSC:
72 case VPFirstOrderRecurrencePHISC:
73 case VPReductionPHISC:
74 case VPScalarIVStepsSC:
78 case VPReductionEVLSC:
80 case VPVectorPointerSC:
81 case VPWidenCanonicalIVSC:
84 case VPWidenIntOrFpInductionSC:
85 case VPWidenLoadEVLSC:
89 case VPWidenSelectSC: {
93 assert((!
I || !
I->mayWriteToMemory()) &&
94 "underlying instruction may write to memory");
105 return cast<VPExpressionRecipe>(
this)->mayReadOrWriteMemory();
106 case VPInstructionSC:
107 return cast<VPInstruction>(
this)->opcodeMayReadOrWriteFromMemory();
108 case VPWidenLoadEVLSC:
113 ->mayReadFromMemory();
115 return !cast<VPWidenCallRecipe>(
this)
116 ->getCalledScalarFunction()
117 ->onlyWritesMemory();
118 case VPWidenIntrinsicSC:
119 return cast<VPWidenIntrinsicRecipe>(
this)->mayReadFromMemory();
120 case VPBranchOnMaskSC:
121 case VPFirstOrderRecurrencePHISC:
122 case VPPredInstPHISC:
123 case VPScalarIVStepsSC:
124 case VPWidenStoreEVLSC:
128 case VPReductionEVLSC:
130 case VPVectorPointerSC:
131 case VPWidenCanonicalIVSC:
134 case VPWidenIntOrFpInductionSC:
137 case VPWidenSelectSC: {
141 assert((!
I || !
I->mayReadFromMemory()) &&
142 "underlying instruction may read from memory");
154 return cast<VPExpressionRecipe>(
this)->mayHaveSideEffects();
156 case VPFirstOrderRecurrencePHISC:
157 case VPPredInstPHISC:
158 case VPVectorEndPointerSC:
160 case VPInstructionSC:
162 case VPWidenCallSC: {
163 Function *Fn = cast<VPWidenCallRecipe>(
this)->getCalledScalarFunction();
166 case VPWidenIntrinsicSC:
167 return cast<VPWidenIntrinsicRecipe>(
this)->mayHaveSideEffects();
169 case VPReductionEVLSC:
171 case VPScalarIVStepsSC:
172 case VPVectorPointerSC:
173 case VPWidenCanonicalIVSC:
176 case VPWidenIntOrFpInductionSC:
178 case VPWidenPointerInductionSC:
180 case VPWidenSelectSC: {
184 assert((!
I || !
I->mayHaveSideEffects()) &&
185 "underlying instruction has side-effects");
188 case VPInterleaveEVLSC:
191 case VPWidenLoadEVLSC:
193 case VPWidenStoreEVLSC:
198 "mayHaveSideffects result for ingredient differs from this "
201 case VPReplicateSC: {
202 auto *R = cast<VPReplicateRecipe>(
this);
203 return R->getUnderlyingInstr()->mayHaveSideEffects();
211 assert(!Parent &&
"Recipe already in some VPBasicBlock");
213 "Insertion position not in any VPBasicBlock");
219 assert(!Parent &&
"Recipe already in some VPBasicBlock");
225 assert(!Parent &&
"Recipe already in some VPBasicBlock");
227 "Insertion position not in any VPBasicBlock");
259 if (
auto *S = dyn_cast<VPSingleDefRecipe>(
this))
260 UI = dyn_cast_or_null<Instruction>(S->getUnderlyingValue());
261 else if (
auto *IG = dyn_cast<VPInterleaveBase>(
this))
262 UI = IG->getInsertPos();
263 else if (
auto *WidenMem = dyn_cast<VPWidenMemoryRecipe>(
this))
264 UI = &WidenMem->getIngredient();
277 dbgs() <<
"Cost of " << RecipeCost <<
" for VF " << VF <<
": ";
290 isa<VPPhi, VPIRPhi>(
this);
294 auto *VPI = dyn_cast<VPInstruction>(
this);
301 std::optional<unsigned> Opcode;
308 OpR =
Op->getDefiningRecipe();
311 Type *InputTypeA =
nullptr, *InputTypeB =
nullptr;
318 auto *WidenCastR = dyn_cast<VPWidenCastRecipe>(R);
321 if (WidenCastR->getOpcode() == Instruction::CastOps::ZExt)
323 if (WidenCastR->getOpcode() == Instruction::CastOps::SExt)
332 Widen = dyn_cast<VPWidenRecipe>(
Op->getDefiningRecipe());
341 ExtAType = GetExtendKind(ExtAR);
342 ExtBType = GetExtendKind(ExtBR);
345 if (isa<VPWidenCastRecipe>(OpR)) {
347 ExtAType = GetExtendKind(OpR);
348 }
else if (isa<VPReductionPHIRecipe>(OpR)) {
350 if (isa<VPWidenCastRecipe>(RedPhiOp1R)) {
352 ExtAType = GetExtendKind(RedPhiOp1R);
353 }
else if (
auto Widen = dyn_cast<VPWidenRecipe>(RedPhiOp1R))
355 }
else if (
auto Widen = dyn_cast<VPWidenRecipe>(OpR)) {
357 }
else if (
auto Reduction = dyn_cast<VPPartialReductionRecipe>(OpR)) {
362 PhiType, VF, ExtAType, ExtBType,
370 "Unhandled partial reduction opcode");
374 assert(PhiVal && BinOpVal &&
"Phi and Mul must be set");
378 CallInst *V = Builder.CreateIntrinsic(
379 RetTy, Intrinsic::experimental_vector_partial_reduce_add,
380 {PhiVal, BinOpVal},
nullptr,
"partial.reduce");
385#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
388 O << Indent <<
"PARTIAL-REDUCE ";
396 assert(OpType == OperationType::FPMathOp &&
397 "recipe doesn't have fast math flags");
409#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
413template <
unsigned PartOpIdx>
416 if (U.getNumOperands() == PartOpIdx + 1)
417 return U.getOperand(PartOpIdx);
421template <
unsigned PartOpIdx>
423 if (
auto *UnrollPartOp = getUnrollPartOperand(U))
424 return cast<ConstantInt>(UnrollPartOp->getLiveInIRValue())->getZExtValue();
440 "Set flags not supported for the provided opcode");
441 assert((getNumOperandsForOpcode(Opcode) == -1u ||
443 "number of operands does not match opcode");
447unsigned VPInstruction::getNumOperandsForOpcode(
unsigned Opcode) {
458 case Instruction::Alloca:
459 case Instruction::ExtractValue:
460 case Instruction::Freeze:
461 case Instruction::Load:
474 case Instruction::ICmp:
475 case Instruction::FCmp:
476 case Instruction::Store:
485 case Instruction::Select:
492 case Instruction::Call:
493 case Instruction::GetElementPtr:
494 case Instruction::PHI:
495 case Instruction::Switch:
503bool VPInstruction::doesGeneratePerAllLanes()
const {
507bool VPInstruction::canGenerateScalarForFirstLane()
const {
513 case Instruction::Freeze:
514 case Instruction::ICmp:
515 case Instruction::PHI:
516 case Instruction::Select:
536 "only PtrAdd opcodes are supported for now");
570 if (
auto *
I = dyn_cast<Instruction>(Res))
581 case Instruction::ExtractElement: {
584 unsigned IdxToExtract =
592 case Instruction::Freeze: {
596 case Instruction::FCmp:
597 case Instruction::ICmp: {
603 case Instruction::PHI: {
606 case Instruction::Select: {
631 {VIVElem0, ScalarTC},
nullptr, Name);
647 if (!V1->getType()->isVectorTy())
667 "Requested vector length should be an integer.");
674 {AVL, VFArg, State.Builder.getTrue()});
680 assert(Part != 0 &&
"Must have a positive part");
711 for (
unsigned FieldIndex = 0; FieldIndex != StructTy->getNumElements();
749 auto *PhiR = cast<VPReductionPHIRecipe>(
getOperand(0));
750 auto *OrigPhi = cast<PHINode>(PhiR->getUnderlyingValue());
763 auto *PhiR = cast<VPReductionPHIRecipe>(
getOperand(0));
765 RecurKind RK = PhiR->getRecurrenceKind();
767 "Unexpected reduction kind");
768 assert(!PhiR->isInLoop() &&
769 "In-loop FindLastIV reduction is not supported yet");
781 for (
unsigned Part = 1; Part <
UF; ++Part)
782 ReducedPartRdx =
createMinMaxOp(Builder, MinMaxKind, ReducedPartRdx,
793 auto *PhiR = cast<VPReductionPHIRecipe>(
getOperand(0));
796 RecurKind RK = PhiR->getRecurrenceKind();
798 "should be handled by ComputeFindIVResult");
804 for (
unsigned Part = 0; Part <
UF; ++Part)
805 RdxParts[Part] = State.
get(
getOperand(1 + Part), PhiR->isInLoop());
812 Value *ReducedPartRdx = RdxParts[0];
813 if (PhiR->isOrdered()) {
814 ReducedPartRdx = RdxParts[
UF - 1];
817 for (
unsigned Part = 1; Part <
UF; ++Part) {
818 Value *RdxPart = RdxParts[Part];
820 ReducedPartRdx =
createMinMaxOp(Builder, RK, ReducedPartRdx, RdxPart);
826 Opcode = Instruction::Add;
831 Builder.
CreateBinOp(Opcode, RdxPart, ReducedPartRdx,
"bin.rdx");
838 if (State.
VF.
isVector() && !PhiR->isInLoop()) {
845 return ReducedPartRdx;
853 "invalid offset to extract from");
857 assert(
Offset <= 1 &&
"invalid offset to extract from");
860 if (isa<ExtractElementInst>(Res))
871 "can only generate first lane for PtrAdd");
891 Value *Res =
nullptr;
896 Builder.
CreateMul(RuntimeVF, ConstantInt::get(IdxTy,
Idx - 1));
899 : Builder.
CreateSub(LaneToExtract, VectorStart);
925 Value *Res =
nullptr;
926 for (
int Idx = LastOpIdx;
Idx >= 0; --
Idx) {
960 case Instruction::FNeg:
962 case Instruction::UDiv:
963 case Instruction::SDiv:
964 case Instruction::SRem:
965 case Instruction::URem:
966 case Instruction::Add:
967 case Instruction::FAdd:
968 case Instruction::Sub:
969 case Instruction::FSub:
970 case Instruction::Mul:
971 case Instruction::FMul:
972 case Instruction::FDiv:
973 case Instruction::FRem:
974 case Instruction::Shl:
975 case Instruction::LShr:
976 case Instruction::AShr:
977 case Instruction::And:
978 case Instruction::Or:
979 case Instruction::Xor: {
1000 {TargetTransformInfo::OK_AnyValue, TargetTransformInfo::OP_None},
1003 case Instruction::Freeze:
1007 case Instruction::ExtractValue:
1010 case Instruction::ICmp:
1011 case Instruction::FCmp: {
1017 Ctx.
CostKind, {TTI::OK_AnyValue, TTI::OP_None},
1018 {TTI::OK_AnyValue, TTI::OP_None}, CtxI);
1021 return std::nullopt;
1033 assert(!doesGeneratePerAllLanes() &&
1034 "Should only generate a vector value or single scalar, not scalars "
1042 case Instruction::Select: {
1055 case Instruction::ExtractElement:
1071 Instruction::Or, cast<VectorType>(VecTy), std::nullopt, Ctx.
CostKind);
1083 {PredTy, Type::getInt1Ty(Ctx.LLVMCtx)});
1093 cast<VectorType>(VectorTy),
1094 cast<VectorType>(VectorTy), Mask,
1099 unsigned Multiplier =
1111 I32Ty, {Arg0Ty, I32Ty, I1Ty});
1128 "unexpected VPInstruction witht underlying value");
1136 getOpcode() == Instruction::ExtractElement ||
1147 case Instruction::PHI:
1158 assert(!State.
Lane &&
"VPInstruction executing an Lane");
1161 "Set flags not supported for the provided opcode");
1164 bool GeneratesPerFirstLaneOnly = canGenerateScalarForFirstLane() &&
1167 bool GeneratesPerAllLanes = doesGeneratePerAllLanes();
1168 if (GeneratesPerAllLanes) {
1170 Lane != NumLanes; ++Lane) {
1171 Value *GeneratedValue = generatePerLane(State,
VPLane(Lane));
1172 assert(GeneratedValue &&
"generatePerLane must produce a value");
1173 State.
set(
this, GeneratedValue,
VPLane(Lane));
1178 Value *GeneratedValue = generate(State);
1181 assert(GeneratedValue &&
"generate must produce a value");
1184 !GeneratesPerFirstLaneOnly) ||
1186 "scalar value but not only first lane defined");
1187 State.
set(
this, GeneratedValue,
1188 GeneratesPerFirstLaneOnly);
1195 case Instruction::ExtractElement:
1196 case Instruction::Freeze:
1197 case Instruction::FCmp:
1198 case Instruction::ICmp:
1199 case Instruction::Select:
1200 case Instruction::PHI:
1233 case Instruction::ExtractElement:
1235 case Instruction::PHI:
1237 case Instruction::FCmp:
1238 case Instruction::ICmp:
1239 case Instruction::Select:
1240 case Instruction::Or:
1241 case Instruction::Freeze:
1275 case Instruction::FCmp:
1276 case Instruction::ICmp:
1277 case Instruction::Select:
1287#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1295 O << Indent <<
"EMIT" << (
isSingleScalar() ?
"-SCALAR" :
"") <<
" ";
1307 O <<
"combined load";
1310 O <<
"combined store";
1313 O <<
"active lane mask";
1316 O <<
"EXPLICIT-VECTOR-LENGTH";
1319 O <<
"first-order splice";
1322 O <<
"branch-on-cond";
1325 O <<
"TC > VF ? TC - VF : 0";
1331 O <<
"branch-on-count";
1337 O <<
"buildstructvector";
1343 O <<
"extract-lane";
1346 O <<
"extract-last-element";
1349 O <<
"extract-penultimate-element";
1352 O <<
"compute-anyof-result";
1355 O <<
"compute-find-iv-result";
1358 O <<
"compute-reduction-result";
1373 O <<
"first-active-lane";
1376 O <<
"reduction-start-vector";
1379 O <<
"resume-for-epilogue";
1422#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1425 O << Indent <<
"EMIT" << (
isSingleScalar() ?
"-SCALAR" :
"") <<
" ";
1431 O <<
"wide-iv-step ";
1435 O <<
"step-vector " << *ResultTy;
1438 O <<
"vscale " << *ResultTy;
1444 O <<
" to " << *ResultTy;
1459 for (
unsigned Idx = 0;
Idx != NumIncoming; ++
Idx) {
1467#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1470 O << Indent <<
"EMIT" << (
isSingleScalar() ?
"-SCALAR" :
"") <<
" ";
1478 if (
auto *Phi = dyn_cast<PHINode>(&
I))
1485 "PHINodes must be handled by VPIRPhi");
1500 "can only update exiting operands to phi nodes");
1510#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1513 O << Indent <<
"IR " << I;
1533 if (Phi->getBasicBlockIndex(PredBB) == -1)
1534 Phi->addIncoming(V, PredBB);
1536 Phi->setIncomingValueForBlock(PredBB, V);
1546 assert(R->getNumOperands() == R->getParent()->getNumPredecessors() &&
1547 "Number of phi operands must match number of predecessors");
1548 unsigned Position = R->getParent()->getIndexForPredecessor(IncomingBlock);
1549 R->removeOperand(Position);
1552#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1566#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1572 O <<
" (extra operand" << (
getNumOperands() > 1 ?
"s" :
"") <<
": ";
1577 std::get<1>(
Op)->printAsOperand(O);
1586 if (!LVer || !isa<LoadInst, StoreInst>(&
I))
1590 Metadata.emplace_back(LLVMContext::MD_alias_scope, AliasScopeMD);
1592 Metadata.emplace_back(LLVMContext::MD_noalias, NoAliasMD);
1596 for (
const auto &[Kind, Node] :
Metadata)
1597 I.setMetadata(Kind, Node);
1602 for (
const auto &[KindA, MDA] :
Metadata) {
1603 for (
const auto &[KindB, MDB] :
Other.Metadata) {
1604 if (KindA == KindB && MDA == MDB) {
1610 Metadata = std::move(MetadataIntersection);
1615 assert(Variant !=
nullptr &&
"Can't create vector function.");
1629 Args.push_back(Arg);
1635 CI->getOperandBundlesAsDefs(OpBundles);
1642 if (!V->getType()->isVoidTy())
1653#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1656 O << Indent <<
"WIDEN-CALL ";
1668 O <<
" @" << CalledFn->
getName() <<
"(";
1674 O <<
" (using library function";
1676 O <<
": " << Variant->
getName();
1701 Args.push_back(Arg);
1709 "Can't retrieve vector intrinsic or vector-predication intrinsics.");
1714 CI->getOperandBundlesAsDefs(OpBundles);
1721 if (!V->getType()->isVoidTy())
1738 auto *V =
Op->getUnderlyingValue();
1740 if (
auto *UI = dyn_cast_or_null<CallBase>(R.getUnderlyingValue())) {
1761 R.hasFastMathFlags() ? R.getFastMathFlags() :
FastMathFlags();
1764 dyn_cast_or_null<IntrinsicInst>(R.getUnderlyingValue()),
1788#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1791 O << Indent <<
"WIDEN-INTRINSIC ";
1820 Value *Mask =
nullptr;
1822 Mask = State.
get(VPMask);
1829 if (Opcode == Instruction::Sub)
1832 assert(Opcode == Instruction::Add &&
"only add or sub supported for now");
1868 {PtrTy, IncTy, MaskTy});
1875#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
1878 O << Indent <<
"WIDEN-HISTOGRAM buckets: ";
1881 if (Opcode == Instruction::Sub)
1884 assert(Opcode == Instruction::Add);
1897 O << Indent <<
"WIDEN-SELECT ";
1922 State.
set(
this, Sel);
1923 if (
auto *
I = dyn_cast<Instruction>(Sel)) {
1924 if (isa<FPMathOperator>(
I))
1949 [](
VPValue *
Op) {
return Op->getUnderlyingValue(); }))
1950 Operands.append(SI->op_begin(), SI->op_end());
1951 bool IsLogicalOr =
match(
this,
m_LogicalOr(m_VPValue(Op0), m_VPValue(Op1)));
1953 IsLogicalOr ? Instruction::Or : Instruction::And, VectorTy,
1962 if (
auto *Cmp = dyn_cast<CmpInst>(SI->getCondition()))
1963 Pred = Cmp->getPredicate();
1965 Instruction::Select, VectorTy, CondTy, Pred, Ctx.
CostKind,
1966 {TTI::OK_AnyValue, TTI::OP_None}, {TTI::OK_AnyValue, TTI::OP_None}, SI);
1969VPIRFlags::FastMathFlagsTy::FastMathFlagsTy(
const FastMathFlags &FMF) {
1982 case OperationType::OverflowingBinOp:
1983 return Opcode == Instruction::Add || Opcode == Instruction::Sub ||
1984 Opcode == Instruction::Mul ||
1985 Opcode == VPInstruction::VPInstruction::CanonicalIVIncrementForPart;
1986 case OperationType::Trunc:
1987 return Opcode == Instruction::Trunc;
1988 case OperationType::DisjointOp:
1989 return Opcode == Instruction::Or;
1990 case OperationType::PossiblyExactOp:
1991 return Opcode == Instruction::AShr;
1992 case OperationType::GEPOp:
1993 return Opcode == Instruction::GetElementPtr ||
1996 case OperationType::FPMathOp:
1997 return Opcode == Instruction::FAdd || Opcode == Instruction::FMul ||
1998 Opcode == Instruction::FSub || Opcode == Instruction::FNeg ||
1999 Opcode == Instruction::FDiv || Opcode == Instruction::FRem ||
2000 Opcode == Instruction::FCmp || Opcode == Instruction::Select ||
2004 case OperationType::NonNegOp:
2005 return Opcode == Instruction::ZExt;
2007 case OperationType::Cmp:
2008 return Opcode == Instruction::FCmp || Opcode == Instruction::ICmp;
2009 case OperationType::Other:
2016#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
2019 case OperationType::Cmp:
2022 case OperationType::DisjointOp:
2026 case OperationType::PossiblyExactOp:
2030 case OperationType::OverflowingBinOp:
2036 case OperationType::Trunc:
2042 case OperationType::FPMathOp:
2045 case OperationType::GEPOp:
2053 case OperationType::NonNegOp:
2057 case OperationType::Other:
2065 auto &Builder = State.
Builder;
2067 case Instruction::Call:
2068 case Instruction::Br:
2069 case Instruction::PHI:
2070 case Instruction::GetElementPtr:
2071 case Instruction::Select:
2073 case Instruction::UDiv:
2074 case Instruction::SDiv:
2075 case Instruction::SRem:
2076 case Instruction::URem:
2077 case Instruction::Add:
2078 case Instruction::FAdd:
2079 case Instruction::Sub:
2080 case Instruction::FSub:
2081 case Instruction::FNeg:
2082 case Instruction::Mul:
2083 case Instruction::FMul:
2084 case Instruction::FDiv:
2085 case Instruction::FRem:
2086 case Instruction::Shl:
2087 case Instruction::LShr:
2088 case Instruction::AShr:
2089 case Instruction::And:
2090 case Instruction::Or:
2091 case Instruction::Xor: {
2099 if (
auto *VecOp = dyn_cast<Instruction>(V)) {
2108 case Instruction::ExtractValue: {
2113 State.
set(
this, Extract);
2116 case Instruction::Freeze: {
2119 State.
set(
this, Freeze);
2122 case Instruction::ICmp:
2123 case Instruction::FCmp: {
2125 bool FCmp = Opcode == Instruction::FCmp;
2137 if (
auto *
I = dyn_cast<Instruction>(
C))
2154 "inferred type and type from generated instructions do not match");
2161 case Instruction::UDiv:
2162 case Instruction::SDiv:
2163 case Instruction::SRem:
2164 case Instruction::URem:
2169 case Instruction::FNeg:
2170 case Instruction::Add:
2171 case Instruction::FAdd:
2172 case Instruction::Sub:
2173 case Instruction::FSub:
2174 case Instruction::Mul:
2175 case Instruction::FMul:
2176 case Instruction::FDiv:
2177 case Instruction::FRem:
2178 case Instruction::Shl:
2179 case Instruction::LShr:
2180 case Instruction::AShr:
2181 case Instruction::And:
2182 case Instruction::Or:
2183 case Instruction::Xor:
2184 case Instruction::Freeze:
2185 case Instruction::ExtractValue:
2186 case Instruction::ICmp:
2187 case Instruction::FCmp:
2194#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
2197 O << Indent <<
"WIDEN ";
2206 auto &Builder = State.
Builder;
2213 State.
set(
this, Cast);
2214 if (
auto *CastOp = dyn_cast<Instruction>(Cast)) {
2231 if (isa<VPInterleaveBase>(R))
2233 if (
const auto *ReplicateRecipe = dyn_cast<VPReplicateRecipe>(R))
2236 const auto *WidenMemoryRecipe = dyn_cast<VPWidenMemoryRecipe>(R);
2237 if (WidenMemoryRecipe ==
nullptr)
2239 if (!WidenMemoryRecipe->isConsecutive())
2241 if (WidenMemoryRecipe->isReverse())
2243 if (WidenMemoryRecipe->isMasked())
2251 if ((Opcode == Instruction::Trunc || Opcode == Instruction::FPTrunc) &&
2253 if (
auto *StoreRecipe = dyn_cast<VPRecipeBase>(*
user_begin()))
2254 CCH = ComputeCCH(StoreRecipe);
2257 else if (Opcode == Instruction::ZExt || Opcode == Instruction::SExt ||
2258 Opcode == Instruction::FPExt) {
2270 Opcode, DestTy, SrcTy, CCH, Ctx.
CostKind,
2274#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
2277 O << Indent <<
"WIDEN-CAST ";
2295 : ConstantFP::get(Ty,
C);
2298#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
2303 O <<
" = WIDEN-INDUCTION ";
2307 O <<
" (truncated to " << *TI->getType() <<
")";
2319 auto *CanIV = cast<VPCanonicalIVPHIRecipe>(&*
getParent()->begin());
2320 return StartC && StartC->isZero() && StepC && StepC->isOne() &&
2324#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
2329 O <<
" = DERIVED-IV ";
2353 assert(BaseIVTy == Step->
getType() &&
"Types of BaseIV and Step must match!");
2360 AddOp = Instruction::Add;
2361 MulOp = Instruction::Mul;
2363 AddOp = InductionOpcode;
2364 MulOp = Instruction::FMul;
2373 Type *VecIVTy =
nullptr;
2374 Value *UnitStepVec =
nullptr, *SplatStep =
nullptr, *SplatIV =
nullptr;
2383 unsigned StartLane = 0;
2386 StartLane = State.
Lane->getKnownLane();
2387 EndLane = StartLane + 1;
2391 StartIdx0 = ConstantInt::get(IntStepTy, 0);
2404 auto *InitVec = Builder.
CreateAdd(SplatStartIdx, UnitStepVec);
2418 for (
unsigned Lane = StartLane; Lane < EndLane; ++Lane) {
2424 "Expected StartIdx to be folded to a constant when VF is not "
2432#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
2437 O <<
" = SCALAR-STEPS ";
2451 if (areAllOperandsInvariant()) {
2486 if (isIndexLoopInvariant(
I - 1))
2497 "NewGEP is not a pointer vector");
2498 State.
set(
this, NewGEP);
2502#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
2505 O << Indent <<
"WIDEN-GEP ";
2506 O << (isPointerLoopInvariant() ?
"Inv" :
"Var");
2508 O <<
"[" << (isIndexLoopInvariant(
I) ?
"Inv" :
"Var") <<
"]";
2512 O <<
" = getelementptr";
2523 return !IsUnitStride || (IsScalable && (IsReverse || CurrentPart > 0))
2529 auto &Builder = State.
Builder;
2531 bool IsUnitStride = Stride == 1 || Stride == -1;
2533 IsUnitStride, CurrentPart, Builder);
2537 if (IndexTy != RunTimeVF->
getType())
2541 ConstantInt::get(IndexTy, Stride * (int64_t)CurrentPart), RunTimeVF);
2543 Value *LastLane = Builder.
CreateSub(RunTimeVF, ConstantInt::get(IndexTy, 1));
2545 LastLane = Builder.
CreateMul(ConstantInt::get(IndexTy, Stride), LastLane);
2549 ResultPtr = Builder.
CreateGEP(IndexedTy, ResultPtr, LastLane,
"",
2552 State.
set(
this, ResultPtr,
true);
2555#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
2560 O <<
" = vector-end-pointer";
2567 auto &Builder = State.
Builder;
2570 true, CurrentPart, Builder);
2577 State.
set(
this, ResultPtr,
true);
2580#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
2585 O <<
" = vector-pointer ";
2605#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
2608 O << Indent <<
"BLEND ";
2630 assert(!State.
Lane &&
"Reduction being replicated.");
2634 "In-loop AnyOf reductions aren't currently supported");
2660 PrevInChain, NewVecOp);
2661 PrevInChain = NewRed;
2662 NextInChain = NewRed;
2671 PrevInChain, NewRed);
2673 State.
set(
this, NextInChain,
true);
2677 assert(!State.
Lane &&
"Reduction being replicated.");
2679 auto &Builder = State.
Builder;
2691 Mask = State.
get(CondOp);
2707 State.
set(
this, NewRed,
true);
2714 auto *VectorTy = cast<VectorType>(
toVectorTy(ElementTy, VF));
2717 std::optional<FastMathFlags> OptionalFMF =
2724 "Any-of reduction not implemented in VPlan-based cost model currently.");
2740 ExpressionTypes ExpressionType,
2744 ExpressionRecipes.begin(), ExpressionRecipes.end())
2747 assert(!ExpressionRecipes.empty() &&
"Nothing to combine?");
2751 "expression cannot contain recipes with side-effects");
2755 for (
auto *R : ExpressionRecipes)
2756 ExpressionRecipesAsSetOfUsers.
insert(R);
2762 if (R != ExpressionRecipes.back() &&
2763 any_of(
R->users(), [&ExpressionRecipesAsSetOfUsers](
VPUser *U) {
2764 return !ExpressionRecipesAsSetOfUsers.contains(U);
2769 R->replaceUsesWithIf(CopyForExtUsers, [&ExpressionRecipesAsSetOfUsers](
2771 return !ExpressionRecipesAsSetOfUsers.
contains(&U);
2776 R->removeFromParent();
2783 for (
auto *R : ExpressionRecipes) {
2785 auto *
Def =
Op->getDefiningRecipe();
2789 LiveInPlaceholders.push_back(
new VPValue());
2790 R->setOperand(
Idx, LiveInPlaceholders.back());
2796 for (
auto *R : ExpressionRecipes)
2797 R->insertBefore(
this);
2800 LiveInPlaceholders[
Idx]->replaceAllUsesWith(
Op);
2803 ExpressionRecipes.clear();
2809 auto *SrcVecTy = cast<VectorType>(
2812 "VPExpressionRecipe only supports integer types currently.");
2814 cast<VPReductionRecipe>(ExpressionRecipes.back())->getRecurrenceKind());
2815 switch (ExpressionType) {
2816 case ExpressionTypes::ExtendedReduction: {
2819 cast<VPWidenCastRecipe>(ExpressionRecipes.front())->getOpcode() ==
2821 RedTy, SrcVecTy, std::nullopt, Ctx.
CostKind);
2823 case ExpressionTypes::MulAccReduction:
2827 case ExpressionTypes::ExtMulAccReduction:
2829 cast<VPWidenCastRecipe>(ExpressionRecipes.front())->getOpcode() ==
2831 Opcode, RedTy, SrcVecTy, Ctx.
CostKind);
2838 return R->mayReadFromMemory() || R->mayWriteToMemory();
2846 "expression cannot contain recipes with side-effects");
2850#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
2854 O << Indent <<
"EXPRESSION ";
2857 auto *Red = cast<VPReductionRecipe>(ExpressionRecipes.back());
2860 switch (ExpressionType) {
2861 case ExpressionTypes::ExtendedReduction: {
2868 auto *Ext0 = cast<VPWidenCastRecipe>(ExpressionRecipes[0]);
2870 << *Ext0->getResultType();
2871 if (Red->isConditional()) {
2878 case ExpressionTypes::MulAccReduction:
2879 case ExpressionTypes::ExtMulAccReduction: {
2887 bool IsExtended = ExpressionType == ExpressionTypes::ExtMulAccReduction;
2888 auto *
Mul = cast<VPWidenRecipe>(IsExtended ? ExpressionRecipes[2]
2889 : ExpressionRecipes[0]);
2895 auto *Ext0 = cast<VPWidenCastRecipe>(ExpressionRecipes[0]);
2897 << *Ext0->getResultType() <<
"), (";
2903 auto *Ext1 = cast<VPWidenCastRecipe>(ExpressionRecipes[1]);
2905 << *Ext1->getResultType() <<
")";
2907 if (Red->isConditional()) {
2919 O << Indent <<
"REDUCE ";
2939 O << Indent <<
"REDUCE ";
2967 assert((!Instr->getType()->isAggregateType() ||
2969 "Expected vectorizable or non-aggregate type.");
2972 bool IsVoidRetTy = Instr->getType()->isVoidTy();
2976 Cloned->
setName(Instr->getName() +
".cloned");
2981 if (ResultTy != Cloned->
getType())
2989 cast<CmpInst>(Cloned)->setPredicate(RepRecipe->
getPredicate());
2997 auto InputLane = Lane;
3007 State.
set(RepRecipe, Cloned, Lane);
3010 if (
auto *
II = dyn_cast<AssumeInst>(Cloned))
3017 [](
VPValue *
Op) { return Op->isDefinedOutsideLoopRegions(); })) &&
3018 "Expected a recipe is either within a region or all of its operands "
3019 "are defined outside the vectorized region.");
3026 assert(IsSingleScalar &&
"VPReplicateRecipes outside replicate regions "
3027 "must have already been unrolled");
3033 "uniform recipe shouldn't be predicated");
3039 State.
Lane->isFirstLane()
3051 if (
auto *PredR = dyn_cast<VPPredInstPHIRecipe>(U))
3065 case Instruction::GetElementPtr:
3071 case Instruction::Call: {
3077 for (
const VPValue *ArgOp : ArgOps)
3080 if (CalledFn->isIntrinsic())
3083 switch (CalledFn->getIntrinsicID()) {
3084 case Intrinsic::assume:
3085 case Intrinsic::lifetime_end:
3086 case Intrinsic::lifetime_start:
3087 case Intrinsic::sideeffect:
3088 case Intrinsic::pseudoprobe:
3089 case Intrinsic::experimental_noalias_scope_decl: {
3092 "scalarizing intrinsic should be free");
3103 if (CalledFn->isIntrinsic())
3104 ScalarCallCost = std::min(
3108 return ScalarCallCost;
3118 for (
Type *VectorTy :
3130 for (
auto *
Op : ArgOps) {
3131 if (
Op->isLiveIn() || isa<VPReplicateRecipe, VPPredInstPHIRecipe>(
Op) ||
3136 ScalarizationCost +=
3140 return ScalarCallCost * VF.
getFixedValue() + ScalarizationCost;
3142 case Instruction::Add:
3143 case Instruction::Sub:
3144 case Instruction::FAdd:
3145 case Instruction::FSub:
3146 case Instruction::Mul:
3147 case Instruction::FMul:
3148 case Instruction::FDiv:
3149 case Instruction::FRem:
3150 case Instruction::Shl:
3151 case Instruction::LShr:
3152 case Instruction::AShr:
3153 case Instruction::And:
3154 case Instruction::Or:
3155 case Instruction::Xor:
3156 case Instruction::ICmp:
3157 case Instruction::FCmp:
3166#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
3169 O << Indent << (IsSingleScalar ?
"CLONE " :
"REPLICATE ");
3178 O <<
"@" << CB->getCalledFunction()->getName() <<
"(";
3196 assert(State.
Lane &&
"Branch on Mask works only on single instance.");
3199 Value *ConditionBit = State.
get(BlockInMask, *State.
Lane);
3204 assert(isa<UnreachableInst>(CurrentTerminator) &&
3205 "Expected to replace unreachable terminator with conditional branch.");
3209 CurrentTerminator->eraseFromParent();
3221 assert(State.
Lane &&
"Predicated instruction PHI works per instance.");
3226 assert(PredicatingBB &&
"Predicated block has no single predecessor.");
3228 "operand must be VPReplicateRecipe");
3243 State.
reset(
this, VPhi);
3245 State.
set(
this, VPhi);
3257 Phi->addIncoming(ScalarPredInst, PredicatedBB);
3261 State.
set(
this, Phi, *State.
Lane);
3268#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
3271 O << Indent <<
"PHI-PREDICATED-INSTRUCTION ";
3283 ->getAddressSpace();
3284 unsigned Opcode = isa<VPWidenLoadRecipe, VPWidenLoadEVLRecipe>(
this)
3286 : Instruction::Store;
3293 "Inconsecutive memory access should not have the order.");
3315 isa<VPWidenLoadRecipe, VPWidenLoadEVLRecipe>(
this) ?
getOperand(0)
3325 cast<VectorType>(Ty), {}, Ctx.
CostKind, 0);
3334 auto &Builder = State.
Builder;
3335 Value *Mask =
nullptr;
3336 if (
auto *VPMask =
getMask()) {
3339 Mask = State.
get(VPMask);
3348 "wide.masked.gather");
3359 State.
set(
this, NewLI);
3362#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
3365 O << Indent <<
"WIDEN ";
3377 Value *AllTrueMask =
3379 return Builder.
CreateIntrinsic(ValTy, Intrinsic::experimental_vp_reverse,
3380 {Operand, AllTrueMask, EVL},
nullptr,
Name);
3389 auto &Builder = State.
Builder;
3393 Value *Mask =
nullptr;
3395 Mask = State.
get(VPMask);
3405 nullptr,
"wide.masked.gather");
3408 {
Addr, Mask, EVL},
nullptr,
"vp.op.load");
3416 State.
set(
this, Res);
3433 Instruction::Load, Ty, Alignment, AS, Ctx.
CostKind);
3439 cast<VectorType>(Ty), {}, Ctx.
CostKind, 0);
3442#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
3445 O << Indent <<
"WIDEN ";
3457 auto &Builder = State.
Builder;
3459 Value *Mask =
nullptr;
3460 if (
auto *VPMask =
getMask()) {
3463 Mask = State.
get(VPMask);
3468 Value *StoredVal = State.
get(StoredVPValue);
3487#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
3490 O << Indent <<
"WIDEN store ";
3500 auto &Builder = State.
Builder;
3503 Value *StoredVal = State.
get(StoredValue);
3507 Value *Mask =
nullptr;
3509 Mask = State.
get(VPMask);
3516 if (CreateScatter) {
3518 Intrinsic::vp_scatter,
3519 {StoredVal, Addr, Mask, EVL});
3522 Intrinsic::vp_store,
3523 {StoredVal, Addr, Mask, EVL});
3544 Instruction::Store, Ty, Alignment, AS, Ctx.
CostKind);
3550 cast<VectorType>(Ty), {}, Ctx.
CostKind, 0);
3553#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
3556 O << Indent <<
"WIDEN vp.store ";
3564 auto VF = DstVTy->getElementCount();
3565 auto *SrcVecTy = cast<VectorType>(V->getType());
3566 assert(VF == SrcVecTy->getElementCount() &&
"Vector dimensions do not match");
3567 Type *SrcElemTy = SrcVecTy->getElementType();
3568 Type *DstElemTy = DstVTy->getElementType();
3569 assert((
DL.getTypeSizeInBits(SrcElemTy) ==
DL.getTypeSizeInBits(DstElemTy)) &&
3570 "Vector elements must have same size");
3581 "Only one type should be a pointer type");
3583 "Only one type should be a floating point type");
3595 unsigned Factor = Vals.
size();
3596 assert(Factor > 1 &&
"Tried to interleave invalid number of vectors");
3600 for (
Value *Val : Vals)
3601 assert(Val->getType() == VecTy &&
"Tried to interleave mismatched types");
3606 if (VecTy->isScalableTy()) {
3607 assert(Factor <= 8 &&
"Unsupported interleave factor for scalable vectors");
3615 const unsigned NumElts = VecTy->getElementCount().getFixedValue();
3649 assert(!State.
Lane &&
"Interleave group being replicated.");
3651 "Masking gaps for scalable vectors is not yet supported.");
3657 unsigned InterleaveFactor = Group->
getFactor();
3664 auto CreateGroupMask = [&BlockInMask, &State,
3665 &InterleaveFactor](
Value *MaskForGaps) ->
Value * {
3667 assert(!MaskForGaps &&
"Interleaved groups with gaps are not supported.");
3668 assert(InterleaveFactor <= 8 &&
3669 "Unsupported deinterleave factor for scalable vectors");
3670 auto *ResBlockInMask = State.
get(BlockInMask);
3678 Value *ResBlockInMask = State.
get(BlockInMask);
3682 "interleaved.mask");
3684 ShuffledMask, MaskForGaps)
3690 if (isa<LoadInst>(Instr)) {
3691 Value *MaskForGaps =
nullptr;
3695 assert(MaskForGaps &&
"Mask for Gaps is required but it is null");
3699 if (BlockInMask || MaskForGaps) {
3700 Value *GroupMask = CreateGroupMask(MaskForGaps);
3704 PoisonVec,
"wide.masked.vec");
3713 if (VecTy->isScalableTy()) {
3716 assert(InterleaveFactor <= 8 &&
3717 "Unsupported deinterleave factor for scalable vectors");
3721 nullptr,
"strided.vec");
3724 auto CreateStridedVector = [&InterleaveFactor, &State,
3725 &NewLoad](
unsigned Index) ->
Value * {
3726 assert(Index < InterleaveFactor &&
"Illegal group index");
3727 if (State.VF.isScalable())
3728 return State.Builder.CreateExtractValue(NewLoad, Index);
3734 return State.Builder.CreateShuffleVector(NewLoad, StrideMask,
3738 for (
unsigned I = 0, J = 0;
I < InterleaveFactor; ++
I) {
3745 Value *StridedVec = CreateStridedVector(
I);
3748 if (Member->getType() != ScalarTy) {
3755 StridedVec = State.Builder.CreateVectorReverse(StridedVec,
"reverse");
3757 State.set(VPDefs[J], StridedVec);
3767 Value *MaskForGaps =
3770 "Mismatch between NeedsMaskForGaps and MaskForGaps");
3774 unsigned StoredIdx = 0;
3775 for (
unsigned i = 0; i < InterleaveFactor; i++) {
3777 "Fail to get a member from an interleaved store group");
3787 Value *StoredVec = State.
get(StoredValues[StoredIdx]);
3795 if (StoredVec->
getType() != SubVT)
3804 if (BlockInMask || MaskForGaps) {
3805 Value *GroupMask = CreateGroupMask(MaskForGaps);
3807 IVec, ResAddr, Group->
getAlign(), GroupMask);
3817#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
3821 O << Indent <<
"INTERLEAVE-GROUP with factor " << IG->
getFactor() <<
" at ";
3832 for (
unsigned i = 0; i < IG->
getFactor(); ++i) {
3836 O <<
"\n" << Indent <<
" store ";
3838 O <<
" to index " << i;
3840 O <<
"\n" << Indent <<
" ";
3842 O <<
" = load from index " << i;
3850 assert(!State.
Lane &&
"Interleave group being replicated.");
3852 "Only support scalable VF for EVL tail-folding.");
3854 "Masking gaps for scalable vectors is not yet supported.");
3860 unsigned InterleaveFactor = Group->
getFactor();
3861 assert(InterleaveFactor <= 8 &&
3862 "Unsupported deinterleave/interleave factor for scalable vectors");
3870 EVL, ConstantInt::get(EVL->
getType(), InterleaveFactor),
"interleave.evl",
3874 Value *GroupMask =
nullptr;
3884 if (isa<LoadInst>(Instr)) {
3886 VecTy, Intrinsic::vp_load, {ResAddr, GroupMask, InterleaveEVL},
nullptr,
3900 nullptr,
"strided.vec");
3903 for (
unsigned I = 0, J = 0;
I < InterleaveFactor; ++
I) {
3911 if (Member->getType() != ScalarTy) {
3930 for (
unsigned I = 0, StoredIdx = 0;
I < InterleaveFactor;
I++) {
3938 Value *StoredVec = State.
get(StoredValues[StoredIdx]);
3940 if (StoredVec->
getType() != SubVT)
3951 {IVec, ResAddr, GroupMask, InterleaveEVL});
3960#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
3964 O << Indent <<
"INTERLEAVE-GROUP with factor " << IG->
getFactor() <<
" at ";
3976 for (
unsigned i = 0; i < IG->
getFactor(); ++i) {
3980 O <<
"\n" << Indent <<
" vp.store ";
3982 O <<
" to index " << i;
3984 O <<
"\n" << Indent <<
" ";
3986 O <<
" = vp.load from index " << i;
3997 unsigned InsertPosIdx = 0;
3998 for (
unsigned Idx = 0; IG->getFactor(); ++
Idx)
3999 if (
auto *Member = IG->getMember(
Idx)) {
4000 if (Member == InsertPos)
4007 auto *VectorTy = cast<VectorType>(
toVectorTy(ValTy, VF));
4010 unsigned InterleaveFactor = IG->getFactor();
4015 for (
unsigned IF = 0; IF < InterleaveFactor; IF++)
4016 if (IG->getMember(IF))
4021 InsertPos->
getOpcode(), WideVecTy, IG->getFactor(), Indices,
4024 if (!IG->isReverse())
4027 return Cost + IG->getNumMembers() *
4029 VectorTy, VectorTy, {}, Ctx.
CostKind,
4033#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
4036 O << Indent <<
"EMIT ";
4038 O <<
" = CANONICAL-INDUCTION ";
4044 return IsScalarAfterVectorization &&
4048#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
4052 "unexpected number of operands");
4053 O << Indent <<
"EMIT ";
4055 O <<
" = WIDEN-POINTER-INDUCTION ";
4071 O << Indent <<
"EMIT ";
4073 O <<
" = EXPAND SCEV " << *Expr;
4091 Value *CanonicalVectorIV = Builder.
CreateAdd(VStart, VStep,
"vec.iv");
4092 State.
set(
this, CanonicalVectorIV);
4095#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
4098 O << Indent <<
"EMIT ";
4100 O <<
" = WIDEN-CANONICAL-INDUCTION ";
4106 auto &Builder = State.
Builder;
4111 ? VectorInit->getType()
4118 auto *One = ConstantInt::get(IdxTy, 1);
4122 auto *LastIdx = Builder.
CreateSub(RuntimeVF, One);
4130 Phi->addIncoming(VectorInit, VectorPH);
4131 State.
set(
this, Phi);
4143#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
4146 O << Indent <<
"FIRST-ORDER-RECURRENCE-PHI ";
4164 bool ScalarPHI = State.
VF.
isScalar() || IsInLoop;
4165 Value *StartV = State.
get(StartVPV, ScalarPHI);
4170 "recipe must be in the vector loop header");
4173 State.
set(
this, Phi, IsInLoop);
4175 Phi->addIncoming(StartV, VectorPH);
4178#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
4181 O << Indent <<
"WIDEN-REDUCTION-PHI ";
4186 if (VFScaleFactor != 1)
4187 O <<
" (VF scaled by 1/" << VFScaleFactor <<
")";
4195 State.
set(
this, VecPhi);
4198#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
4201 O << Indent <<
"WIDEN-PHI ";
4217 Phi->addIncoming(StartMask, VectorPH);
4218 State.
set(
this, Phi);
4221#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
4224 O << Indent <<
"ACTIVE-LANE-MASK-PHI ";
4232#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
4235 O << Indent <<
"EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI ";
static SDValue Widen(SelectionDAG *CurDAG, SDValue N)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
AMDGPU Lower Kernel Arguments
AMDGPU Register Bank Select
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")
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
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
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
loop Loop Strength Reduction
This file provides a LoopVectorizationPlanner class.
mir Rename Register Operands
MachineInstr unsigned OpIdx
uint64_t IntrinsicInst * II
const SmallVectorImpl< MachineOperand > & Cond
This file defines the SmallVector class.
static SymbolRef::Type getType(const Symbol *Sym)
This file contains the declarations of different VPlan-related auxiliary helpers.
static Instruction * createReverseEVL(IRBuilderBase &Builder, Value *Operand, Value *EVL, const Twine &Name)
Use all-true mask for reverse rather than actual mask, as it avoids a dependence w/o affecting the re...
static Value * interleaveVectors(IRBuilderBase &Builder, ArrayRef< Value * > Vals, const Twine &Name)
Return a vector containing interleaved elements from multiple smaller input vectors.
static InstructionCost getCostForIntrinsics(Intrinsic::ID ID, ArrayRef< const VPValue * > Operands, const VPRecipeWithIRFlags &R, ElementCount VF, VPCostContext &Ctx)
Compute the cost for the intrinsic ID with Operands, produced by R.
static Value * createBitOrPointerCast(IRBuilderBase &Builder, Value *V, VectorType *DstVTy, const DataLayout &DL)
static Type * getGEPIndexTy(bool IsScalable, bool IsReverse, bool IsUnitStride, unsigned CurrentPart, IRBuilderBase &Builder)
static void scalarizeInstruction(const Instruction *Instr, VPReplicateRecipe *RepRecipe, const VPLane &Lane, VPTransformState &State)
A helper function to scalarize a single Instruction in the innermost loop.
static Constant * getSignedIntOrFpConstant(Type *Ty, int64_t C)
A helper function that returns an integer or floating-point constant with value C.
static BranchInst * createCondBranch(Value *Cond, VPBasicBlock *VPBB, VPTransformState &State)
Create a conditional branch using Cond branching to the successors of VPBB.
This file contains the declarations of the Vectorization Plan base classes:
static const uint32_t IV[8]
static APInt getAllOnes(unsigned numBits)
Return an APInt of a specified width with all bits set.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
size - Get the array size.
LLVM_ABI void registerAssumption(AssumeInst *CI)
Add an @llvm.assume intrinsic to this function's cache.
static LLVM_ABI Attribute getWithAlignment(LLVMContext &Context, Align Alignment)
Return a uniquified Attribute object that has the specific alignment set.
LLVM Basic Block Representation.
LLVM_ABI const_iterator getFirstInsertionPt() const
Returns an iterator to the first instruction in this block that is suitable for inserting a non-PHI i...
LLVM_ABI InstListType::const_iterator getFirstNonPHIIt() const
Returns an iterator to the first instruction in this block that is not a PHINode instruction.
LLVM_ABI const BasicBlock * getSinglePredecessor() const
Return the predecessor of this block if it has a single predecessor block.
LLVM_ABI const DataLayout & getDataLayout() const
Get the data layout of the module this basic block belongs to.
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
LLVM_ABI const Module * getModule() const
Return the module owning the function this basic block belongs to, or nullptr if the function does no...
Conditional or Unconditional Branch instruction.
void setSuccessor(unsigned idx, BasicBlock *NewSucc)
void addParamAttr(unsigned ArgNo, Attribute::AttrKind Kind)
Adds the attribute to the indicated argument.
This class represents a function call, abstracting a target machine's calling convention.
static LLVM_ABI bool isBitOrNoopPointerCastable(Type *SrcTy, Type *DestTy, const DataLayout &DL)
Check whether a bitcast, inttoptr, or ptrtoint cast between these types is valid and a no-op.
static Type * makeCmpResultType(Type *opnd_type)
Create a result type for fcmp/icmp.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
@ ICMP_UGT
unsigned greater than
@ ICMP_ULT
unsigned less than
static LLVM_ABI StringRef getPredicateName(Predicate P)
This is the shared class of boolean and integer constants.
static ConstantInt * getSigned(IntegerType *Ty, int64_t V)
Return a ConstantInt with the specified value for the specified type.
uint64_t getZExtValue() const
Return the constant as a 64-bit unsigned integer value after it has been zero extended as appropriate...
This is an important base class in LLVM.
This class represents an Operation in the Expression.
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)
constexpr bool isScalar() const
Exactly one element.
Convenience struct for specifying and reasoning about fast-math flags.
void setAllowContract(bool B=true)
bool noSignedZeros() const
void setAllowReciprocal(bool B=true)
bool allowReciprocal() const
LLVM_ABI void print(raw_ostream &O) const
Print fast-math flags to O.
void setNoSignedZeros(bool B=true)
bool allowReassoc() const
Flag queries.
void setNoNaNs(bool B=true)
void setAllowReassoc(bool B=true)
Flag setters.
void setApproxFunc(bool B=true)
void setNoInfs(bool B=true)
bool allowContract() const
Class to represent function types.
Type * getParamType(unsigned i) const
Parameter type accessors.
ArrayRef< Type * > params() const
FunctionType * getFunctionType() const
Returns the FunctionType for me.
bool willReturn() const
Determine if the function will return.
CallingConv::ID getCallingConv() const
getCallingConv()/setCallingConv(CC) - These method get and set the calling convention of this functio...
bool doesNotThrow() const
Determine if the function cannot unwind.
Type * getReturnType() const
Returns the type of the ret val.
bool hasNoUnsignedSignedWrap() const
bool hasNoUnsignedWrap() const
Common base class shared among various IRBuilders.
ConstantInt * getInt1(bool V)
Get a constant value representing either true or false.
Value * CreateInsertElement(Type *VecTy, Value *NewElt, Value *Idx, const Twine &Name="")
Value * CreateInsertValue(Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, const Twine &Name="")
Value * CreateSIToFP(Value *V, Type *DestTy, const Twine &Name="")
Value * CreateExtractElement(Value *Vec, Value *Idx, const Twine &Name="")
LoadInst * CreateAlignedLoad(Type *Ty, Value *Ptr, MaybeAlign Align, const char *Name)
Value * CreateZExtOrTrunc(Value *V, Type *DestTy, const Twine &Name="")
Create a ZExt or Trunc from the integer value V to DestTy.
LLVM_ABI Value * CreateVectorSplice(Value *V1, Value *V2, int64_t Imm, const Twine &Name="")
Return a vector splice intrinsic if using scalable vectors, otherwise return a shufflevector.
LLVM_ABI Value * CreateVectorSplat(unsigned NumElts, Value *V, const Twine &Name="")
Return a vector value that contains.
Value * CreateExtractValue(Value *Agg, ArrayRef< unsigned > Idxs, const Twine &Name="")
ConstantInt * getTrue()
Get the constant value for i1 true.
LLVM_ABI CallInst * CreateMaskedLoad(Type *Ty, Value *Ptr, Align Alignment, Value *Mask, Value *PassThru=nullptr, const Twine &Name="")
Create a call to Masked Load intrinsic.
LLVM_ABI Value * CreateSelect(Value *C, Value *True, Value *False, const Twine &Name="", Instruction *MDFrom=nullptr)
Value * CreateFreeze(Value *V, const Twine &Name="")
IntegerType * getInt32Ty()
Fetch the type representing a 32-bit integer.
Value * CreatePtrAdd(Value *Ptr, Value *Offset, const Twine &Name="", GEPNoWrapFlags NW=GEPNoWrapFlags::none())
Value * CreateCast(Instruction::CastOps Op, Value *V, Type *DestTy, const Twine &Name="", MDNode *FPMathTag=nullptr, FMFSource FMFSource={})
Value * CreateVScale(Type *Ty, const Twine &Name="")
Create a call to llvm.vscale.<Ty>().
BasicBlock * GetInsertBlock() const
void setFastMathFlags(FastMathFlags NewFMF)
Set the fast-math flags to be used with generated fp-math operators.
IntegerType * getInt64Ty()
Fetch the type representing a 64-bit integer.
LLVM_ABI Value * CreateVectorReverse(Value *V, const Twine &Name="")
Return a vector value that contains the vector V reversed.
Value * CreateICmpNE(Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateFCmpFMF(CmpInst::Predicate P, Value *LHS, Value *RHS, FMFSource FMFSource, const Twine &Name="", MDNode *FPMathTag=nullptr)
Value * CreateGEP(Type *Ty, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &Name="", GEPNoWrapFlags NW=GEPNoWrapFlags::none())
ConstantInt * getInt64(uint64_t C)
Get a constant 64-bit value.
Value * CreateNeg(Value *V, const Twine &Name="", bool HasNSW=false)
LLVM_ABI CallInst * CreateOrReduce(Value *Src)
Create a vector int OR reduction intrinsic of the source vector.
LLVM_ABI CallInst * CreateIntrinsic(Intrinsic::ID ID, ArrayRef< Type * > Types, ArrayRef< Value * > Args, FMFSource FMFSource={}, const Twine &Name="")
Create a call to intrinsic ID with Args, mangled using Types.
ConstantInt * getInt32(uint32_t C)
Get a constant 32-bit value.
Value * CreateBitOrPointerCast(Value *V, Type *DestTy, const Twine &Name="")
Value * CreateCmp(CmpInst::Predicate Pred, Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
PHINode * CreatePHI(Type *Ty, unsigned NumReservedValues, const Twine &Name="")
Value * CreateNot(Value *V, const Twine &Name="")
Value * CreateICmpEQ(Value *LHS, Value *RHS, const Twine &Name="")
InstTy * Insert(InstTy *I, const Twine &Name="") const
Insert and return the specified instruction.
Value * CreateCountTrailingZeroElems(Type *ResTy, Value *Mask, bool ZeroIsPoison=true, const Twine &Name="")
Create a call to llvm.experimental_cttz_elts.
Value * CreateSub(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
BranchInst * CreateCondBr(Value *Cond, BasicBlock *True, BasicBlock *False, MDNode *BranchWeights=nullptr, MDNode *Unpredictable=nullptr)
Create a conditional 'br Cond, TrueDest, FalseDest' instruction.
LLVM_ABI Value * CreateNAryOp(unsigned Opc, ArrayRef< Value * > Ops, const Twine &Name="", MDNode *FPMathTag=nullptr)
Create either a UnaryOperator or BinaryOperator depending on Opc.
Value * CreateZExt(Value *V, Type *DestTy, const Twine &Name="", bool IsNonNeg=false)
Value * CreateShuffleVector(Value *V1, Value *V2, Value *Mask, const Twine &Name="")
LLVMContext & getContext() const
LLVM_ABI CallInst * CreateMaskedStore(Value *Val, Value *Ptr, Align Alignment, Value *Mask)
Create a call to Masked Store intrinsic.
Value * CreateAdd(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
ConstantInt * getFalse()
Get the constant value for i1 false.
CallInst * CreateCall(FunctionType *FTy, Value *Callee, ArrayRef< Value * > Args={}, const Twine &Name="", MDNode *FPMathTag=nullptr)
PointerType * getPtrTy(unsigned AddrSpace=0)
Fetch the type representing a pointer.
Value * CreateBinOp(Instruction::BinaryOps Opc, Value *LHS, Value *RHS, const Twine &Name="", MDNode *FPMathTag=nullptr)
Value * CreateLogicalAnd(Value *Cond1, Value *Cond2, const Twine &Name="")
Value * CreateICmpUGE(Value *LHS, Value *RHS, const Twine &Name="")
void SetInsertPoint(BasicBlock *TheBB)
This specifies that created instructions should be appended to the end of the specified block.
StoreInst * CreateAlignedStore(Value *Val, Value *Ptr, MaybeAlign Align, bool isVolatile=false)
LLVM_ABI Value * CreateVectorInterleave(ArrayRef< Value * > Ops, const Twine &Name="")
Value * CreateICmp(CmpInst::Predicate P, Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateOr(Value *LHS, Value *RHS, const Twine &Name="", bool IsDisjoint=false)
LLVM_ABI Value * CreateStepVector(Type *DstType, const Twine &Name="")
Creates a vector of type DstType with the linear sequence <0, 1, ...>
Value * CreateSExtOrTrunc(Value *V, Type *DestTy, const Twine &Name="")
Create a SExt or Trunc from the integer value V to DestTy.
Value * CreateMul(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
LLVM_ABI CallInst * CreateMaskedScatter(Value *Val, Value *Ptrs, Align Alignment, Value *Mask=nullptr)
Create a call to Masked Scatter intrinsic.
LLVM_ABI CallInst * CreateMaskedGather(Type *Ty, Value *Ptrs, Align Alignment, Value *Mask=nullptr, Value *PassThru=nullptr, const Twine &Name="")
Create a call to Masked Gather intrinsic.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
This instruction inserts a single (scalar) element into a VectorType value.
VectorType * getType() const
Overload to return most specific vector type.
static InstructionCost getInvalid(CostType Val=0)
LLVM_ABI InstListType::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
const char * getOpcodeName() const
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
static LLVM_ABI IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
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
void addMetadata(InstTy *NewInst) const
Add metadata (e.g.
This is an important class for using LLVM in a threaded context.
BlockT * getHeader() const
This class emits a version of the loop where run-time checks ensure that may-alias pointers can't ove...
std::pair< MDNode *, MDNode * > getNoAliasMetadataFor(const Instruction *OrigInst) const
Returns a pair containing the alias_scope and noalias metadata nodes for OrigInst,...
LLVM_ABI void print(raw_ostream &OS, const SlotIndexes *=nullptr, bool IsStandalone=true) const
A Module instance is used to store all the information related to an LLVM module.
void addIncoming(Value *V, BasicBlock *BB)
Add an incoming value to the end of the PHI list.
static PHINode * Create(Type *Ty, unsigned NumReservedValues, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructors - NumReservedValues is a hint for the number of incoming edges that this phi node will h...
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
static bool isSignedRecurrenceKind(RecurKind Kind)
Returns true if recurrece kind is a signed redux kind.
unsigned getOpcode() const
static bool isAnyOfRecurrenceKind(RecurKind Kind)
Returns true if the recurrence kind is of the form select(cmp(),x,y) where one of (x,...
static bool isFindLastIVRecurrenceKind(RecurKind Kind)
Returns true if the recurrence kind is of the form select(cmp(),x,y) where one of (x,...
static bool isFindIVRecurrenceKind(RecurKind Kind)
Returns true if the recurrence kind is of the form select(cmp(),x,y) where one of (x,...
static bool isMinMaxRecurrenceKind(RecurKind Kind)
Returns true if the recurrence kind is any min/max kind.
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
const SDValue & getOperand(unsigned Num) const
This class represents the LLVM 'select' instruction.
A vector that has set insertion semantics.
Vector takeVector()
Clear the SetVector and return the underlying vector.
This class provides computation of slot numbers for LLVM Assembly writing.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
bool contains(ConstPtrType Ptr) const
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
reference emplace_back(ArgTypes &&... Args)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
The instances of the Type class are immutable: once they are created, they are never changed.
bool isVectorTy() const
True if this is an instance of VectorType.
bool isPointerTy() const
True if this is an instance of PointerType.
static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)
static LLVM_ABI IntegerType * getIntNTy(LLVMContext &C, unsigned N)
static LLVM_ABI IntegerType * getInt1Ty(LLVMContext &C)
static LLVM_ABI IntegerType * getInt64Ty(LLVMContext &C)
static LLVM_ABI Type * getVoidTy(LLVMContext &C)
bool isStructTy() const
True if this is an instance of StructType.
LLVMContext & getContext() const
Return the LLVMContext in which this type was uniqued.
bool isFloatingPointTy() const
Return true if this is one of the floating-point types.
LLVM_ABI unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
bool isIntegerTy() const
True if this is an instance of IntegerType.
bool isVoidTy() const
Return true if this is 'void'.
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
value_op_iterator value_op_end()
void setOperand(unsigned i, Value *Val)
Value * getOperand(unsigned i) const
value_op_iterator value_op_begin()
void execute(VPTransformState &State) override
Generate the active lane mask phi of the vector loop.
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 & getRecipeList()
Returns a reference to the list of recipes.
void insert(VPRecipeBase *Recipe, iterator InsertPt)
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.
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...
VPBlockBase is the building block of the Hierarchical Control-Flow Graph.
VPRegionBlock * getParent()
const VPBasicBlock * getExitingBasicBlock() const
const VPBlocksTy & getPredecessors() const
void printAsOperand(raw_ostream &OS, bool PrintType=false) const
const VPBlocksTy & getSuccessors() const
InstructionCost computeCost(ElementCount VF, VPCostContext &Ctx) const override
Return the cost of this VPBranchOnMaskRecipe.
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.
VPInstruction * createNaryOp(unsigned Opcode, ArrayRef< VPValue * > Operands, Instruction *Inst=nullptr, const Twine &Name="")
Create an N-ary operation with Opcode, Operands and set Inst as its underlying Instruction.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
This class augments a recipe with a set of VPValues defined by the recipe.
void dump() const
Dump the VPDef to stderr (for debugging).
unsigned getNumDefinedValues() const
Returns the number of values defined by the VPDef.
ArrayRef< VPValue * > definedValues()
Returns an ArrayRef of the values defined by the VPDef.
VPValue * getVPSingleValue()
Returns the only VPValue defined by the VPDef.
VPValue * getVPValue(unsigned I)
Returns the VPValue with index I defined by the VPDef.
unsigned getVPDefID() const
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
VPValue * getStepValue() const
VPValue * getStartValue() const
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
void decompose()
Insert the recipes of the expression back into the VPlan, directly before the current recipe.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
bool mayHaveSideEffects() const
Returns true if this expression contains recipes that may have side effects.
InstructionCost computeCost(ElementCount VF, VPCostContext &Ctx) const override
Compute the cost of this recipe either using a recipe's specialized implementation or using the legac...
bool mayReadOrWriteMemory() const
Returns true if this expression contains recipes that may read from or write to memory.
void execute(VPTransformState &State) override
Produce a vectorized histogram operation.
InstructionCost computeCost(ElementCount VF, VPCostContext &Ctx) const override
Return the cost of this VPHistogramRecipe.
VPValue * getMask() const
Return the mask operand if one was provided, or a null pointer if all lanes should be executed uncond...
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
Class to record and manage LLVM IR flags.
bool flagsValidForOpcode(unsigned Opcode) const
Returns true if the set flags are valid for Opcode.
void printFlags(raw_ostream &O) const
bool hasFastMathFlags() const
Returns true if the recipe has fast-math flags.
LLVM_ABI_FOR_TEST FastMathFlags getFastMathFlags() const
CmpInst::Predicate getPredicate() const
bool hasNoSignedWrap() const
GEPNoWrapFlags getGEPNoWrapFlags() const
bool hasPredicate() const
Returns true if the recipe has a comparison predicate.
DisjointFlagsTy DisjointFlags
bool hasNoUnsignedWrap() const
NonNegFlagsTy NonNegFlags
void applyFlags(Instruction &I) const
Apply the IR flags to I.
A recipe to wrap on original IR instruction not to be modified during execution, except for PHIs.
Instruction & getInstruction() const
void execute(VPTransformState &State) override
The method which generates the output IR instructions that correspond to this VPRecipe,...
void extractLastLaneOfFirstOperand(VPBuilder &Builder)
Update the recipes first operand to the last lane of the operand using Builder.
LLVM_ABI_FOR_TEST InstructionCost computeCost(ElementCount VF, VPCostContext &Ctx) const override
Return the cost of this VPIRInstruction.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
void execute(VPTransformState &State) override
Generate the instruction.
InstructionCost computeCost(ElementCount VF, VPCostContext &Ctx) const override
Return the cost of this VPInstruction.
VPInstruction(unsigned Opcode, ArrayRef< VPValue * > Operands, DebugLoc DL=DebugLoc::getUnknown(), const Twine &Name="")
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).
@ ExtractLane
Extracts a single lane (first operand) from a set of vector operands.
@ ComputeAnyOfResult
Compute the final result of a AnyOf reduction with select(cmp(),x,y), where one of (x,...
@ WideIVStep
Scale the first operand (vector step) by the second operand (scalar-step).
@ ExtractPenultimateElement
@ ResumeForEpilogue
Explicit user for the resume phi of the canonical induction in the main VPlan, used by the epilogue v...
@ FirstOrderRecurrenceSplice
@ ReductionStartVector
Start vector for reductions with 3 operands: the original start value, the identity value for the red...
@ BuildVector
Creates a fixed-width vector containing all operands.
@ BuildStructVector
Given operands of (the same) struct type, creates a struct of fixed- width vectors each containing a ...
@ VScale
Returns the value for vscale.
@ CanonicalIVIncrementForPart
@ CalculateTripCountMinusVF
StringRef getName() const
Returns the symbolic name assigned to the VPInstruction.
unsigned getOpcode() const
bool onlyFirstPartUsed(const VPValue *Op) const override
Returns true if the recipe only uses the first part of operand Op.
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.
bool needsMaskForGaps() const
Return true if the access needs a mask because of the gaps.
InstructionCost computeCost(ElementCount VF, VPCostContext &Ctx) const override
Return the cost of this recipe.
Instruction * getInsertPos() const
const InterleaveGroup< Instruction > * getInterleaveGroup() const
VPValue * getMask() const
Return the mask used by this recipe.
ArrayRef< VPValue * > getStoredValues() const
Return the VPValues stored by this interleave group.
VPValue * getAddr() const
Return the address accessed by this recipe.
VPValue * getEVL() const
The VPValue of the explicit vector length.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
unsigned getNumStoreOperands() const override
Returns the number of stored operands of this interleave group.
void execute(VPTransformState &State) override
Generate the wide load or store, and shuffles.
unsigned getNumStoreOperands() const override
Returns the number of stored operands of this interleave group.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
void execute(VPTransformState &State) override
Generate the wide load or store, and shuffles.
In what follows, the term "input IR" refers to code that is fed into the vectorizer whereas the term ...
static VPLane getLastLaneForVF(const ElementCount &VF)
static VPLane getLaneFromEnd(const ElementCount &VF, unsigned Offset)
static VPLane getFirstLane()
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.
virtual const VPRecipeBase * getAsRecipe() const =0
Return a VPRecipeBase* to the current object.
virtual unsigned getNumIncoming() const
Returns the number of incoming values, also number of incoming blocks.
void removeIncomingValueFor(VPBlockBase *IncomingBlock) const
Removes the incoming value for IncomingBlock, which must be a predecessor.
const VPBasicBlock * getIncomingBlock(unsigned Idx) const
Returns the incoming block with index Idx.
detail::zippy< llvm::detail::zip_first, VPUser::const_operand_range, const_incoming_blocks_range > incoming_values_and_blocks() const
Returns an iterator range over pairs of incoming values and corresponding incoming blocks.
VPValue * getIncomingValue(unsigned Idx) const
Returns the incoming VPValue with index Idx.
void printPhiOperands(raw_ostream &O, VPSlotTracker &SlotTracker) const
Print the recipe.
void execute(VPTransformState &State) override
Generates phi nodes for live-outs (from a replicate region) as needed to retain SSA form.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
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 mayHaveSideEffects() const
Returns true if the recipe may have side-effects.
bool isPhi() const
Returns true for PHI-like recipes.
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...
VPBasicBlock * getParent()
DebugLoc getDebugLoc() const
Returns the debug location of the recipe.
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.
iplist< VPRecipeBase >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
InstructionCost cost(ElementCount VF, VPCostContext &Ctx)
Return the cost of this recipe, taking into account if the cost computation should be skipped and the...
bool isScalarCast() const
Return true if the recipe is a scalar cast.
void removeFromParent()
This method unlinks 'this' from the containing basic block, but does not delete it.
void moveAfter(VPRecipeBase *MovePos)
Unlink this recipe from its current VPBasicBlock and insert it into the VPBasicBlock that MovePos liv...
void execute(VPTransformState &State) override
Generate the reduction in the loop.
VPValue * getEVL() const
The VPValue of the explicit vector length.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
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.
bool isConditional() const
Return true if the in-loop reduction is conditional.
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.
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.
RecurKind getRecurrenceKind() const
Return the recurrence kind for the in-loop reduction.
bool isOrdered() const
Return true if the in-loop reduction is ordered.
VPValue * getChainOp() const
The VPValue of the scalar Chain being accumulated.
void execute(VPTransformState &State) override
Generate the reduction in the loop.
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.
bool isSingleScalar() const
InstructionCost computeCost(ElementCount VF, VPCostContext &Ctx) const override
Return the cost of this VPReplicateRecipe.
unsigned getOpcode() const
bool shouldPack() const
Returns true if the recipe is used by a widened recipe via an intervening VPPredInstPHIRecipe.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
VPValue * getStepValue() const
void execute(VPTransformState &State) override
Generate the scalarized versions of the phi node as needed by their users.
VPSingleDef is a base class for recipes for modeling a sequence of one or more output IR that define ...
Instruction * getUnderlyingInstr()
Returns the underlying instruction.
LLVM_DUMP_METHOD void dump() const
Print this VPSingleDefRecipe to dbgs() (for debugging).
This class can be used to assign names to VPValues.
LLVMContext & getContext()
Return the LLVMContext used by the analysis.
Type * inferScalarType(const VPValue *V)
Infer the type of V. Returns the scalar type of V.
Helper to access the operand that contains the unroll part for this recipe after unrolling.
VPValue * getUnrollPartOperand(const VPUser &U) const
Return the VPValue operand containing the unroll part or null if there is no such operand.
unsigned getUnrollPart(const 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 printOperands(raw_ostream &O, VPSlotTracker &SlotTracker) const
Print the operands to O.
void setOperand(unsigned I, VPValue *New)
unsigned getNumOperands() const
operand_iterator op_begin()
VPValue * getOperand(unsigned N) const
virtual bool onlyFirstLaneUsed(const VPValue *Op) const
Returns true if the VPUser only uses the first lane of operand Op.
void addOperand(VPValue *Operand)
bool isDefinedOutsideLoopRegions() const
Returns true if the VPValue is defined outside any loop.
VPRecipeBase * getDefiningRecipe()
Returns the recipe defining this VPValue or nullptr if it is not defined by a recipe,...
friend class VPExpressionRecipe
void printAsOperand(raw_ostream &OS, VPSlotTracker &Tracker) const
bool hasMoreThanOneUniqueUser() const
Returns true if the value has more than one unique user.
Value * getLiveInIRValue() const
Returns the underlying IR value, if this VPValue is defined outside the scope of VPlan.
Value * getUnderlyingValue() const
Return the underlying Value attached to this VPValue.
void replaceAllUsesWith(VPValue *New)
user_iterator user_begin()
unsigned getNumUsers() const
bool isLiveIn() const
Returns true if this VPValue is a live-in, i.e. defined outside the VPlan.
VPDef * Def
Pointer to the VPDef that defines this VPValue.
void execute(VPTransformState &State) override
The method which generates the output IR instructions that correspond to this VPRecipe,...
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
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,...
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the 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.
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.
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.
void execute(VPTransformState &State) override
Produce widened copies of the cast.
InstructionCost computeCost(ElementCount VF, VPCostContext &Ctx) const override
Return the cost of this VPWidenCastRecipe.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
void execute(VPTransformState &State) override
Generate the gep nodes.
VPValue * getStepValue()
Returns the step value of the induction.
TruncInst * getTruncInst()
Returns the first defined value as TruncInst, if it is one or nullptr otherwise.
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.
bool onlyFirstLaneUsed(const VPValue *Op) const override
Returns true if the VPUser only uses the first lane of operand Op.
Intrinsic::ID getVectorIntrinsicID() const
Return the ID of the intrinsic.
StringRef getIntrinsicName() const
Return to name of the intrinsic as string.
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.
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.
InstructionCost computeCost(ElementCount VF, VPCostContext &Ctx) const override
Return the cost of this VPWidenMemoryRecipe.
bool Consecutive
Whether the accessed addresses are consecutive.
VPValue * getMask() const
Return the mask used by this recipe.
VPValue * getAddr() const
Return the address accessed by this recipe.
bool isReverse() const
Return whether the consecutive loaded/stored addresses are in reverse order.
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.
bool onlyScalarsGenerated(bool IsScalable)
Returns true if only scalar values will be generated.
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....
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
unsigned getOpcode() const
LLVM_ABI_FOR_TEST VPRegionBlock * getVectorLoopRegion()
Returns the VPRegionBlock of the vector loop.
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
LLVM_ABI void setName(const Twine &Name)
Change the name of the value.
LLVM_ABI LLVMContext & getContext() const
All values hold a context through their type.
void mutateType(Type *Ty)
Mutate the type of this Value to be of the specified type.
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
Base class of all SIMD vector types.
ElementCount getElementCount() const
Return an ElementCount instance to represent the (possibly scalable) number of elements in the vector...
static LLVM_ABI VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
Type * getElementType() const
constexpr ScalarTy getFixedValue() const
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 LeafTy divideCoefficientBy(ScalarTy RHS) const
We do not provide the '/' operator here because division for polynomial types does not work in the sa...
const ParentTy * getParent() const
self_iterator getIterator()
base_list_type::iterator iterator
iterator erase(iterator where)
pointer remove(iterator &IT)
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
@ C
The default llvm calling convention, compatible with C.
LLVM_ABI Function * getOrInsertDeclaration(Module *M, ID id, ArrayRef< Type * > Tys={})
Look up the Function declaration of the intrinsic id in the Module M.
LLVM_ABI Intrinsic::ID getDeinterleaveIntrinsicID(unsigned Factor)
Returns the corresponding llvm.vector.deinterleaveN intrinsic for factor N.
LLVM_ABI StringRef getBaseName(ID id)
Return the LLVM name for an intrinsic, without encoded types for overloading, such as "llvm....
specific_intval< false > m_SpecificInt(const APInt &V)
Match a specific integer value or vector with all elements equal to the value.
bool match(Val *V, const Pattern &P)
ThreeOps_match< Cond, LHS, RHS, Instruction::Select > m_Select(const Cond &C, const LHS &L, const RHS &R)
Matches SelectInst.
auto m_LogicalOr()
Matches L || R where L and R are arbitrary values.
auto m_LogicalAnd()
Matches L && R where L and R are arbitrary values.
BinaryOp_match< LHS, RHS, Instruction::Sub > m_Sub(const LHS &L, const RHS &R)
bool isSingleScalar(const VPValue *VPV)
Returns true if VPV is a single scalar, either because it produces the same value for all lanes or on...
bool onlyFirstPartUsed(const VPValue *Def)
Returns true if only the first part of Def is used.
bool onlyFirstLaneUsed(const VPValue *Def)
Returns true if only the first lane of Def is used.
bool onlyScalarValuesUsed(const VPValue *Def)
Returns true if only scalar values of Def are used by all users.
This is an optimization pass for GlobalISel generic memory operations.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
LLVM_ABI Value * createSimpleReduction(IRBuilderBase &B, Value *Src, RecurKind RdxKind)
Create a reduction of the given vector.
LLVM_ABI Value * createFindLastIVReduction(IRBuilderBase &B, Value *Src, RecurKind RdxKind, Value *Start, Value *Sentinel)
Create a reduction of the given vector Src for a reduction of the kind RecurKind::FindLastIV.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
unsigned getLoadStoreAddressSpace(const Value *I)
A helper function that returns the address space of the pointer operand of load or store instruction.
LLVM_ABI Intrinsic::ID getMinMaxReductionIntrinsicOp(Intrinsic::ID RdxID)
Returns the min/max intrinsic used when expanding a min/max reduction.
auto enumerate(FirstRange &&First, RestRanges &&...Rest)
Given two or more input ranges, returns a new range whose values are tuples (A, B,...
const Value * getLoadStorePointerOperand(const Value *V)
A helper function that returns the pointer operand of a load or store instruction.
Value * getRuntimeVF(IRBuilderBase &B, Type *Ty, ElementCount VF)
Return the runtime value for VF.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
void interleaveComma(const Container &c, StreamT &os, UnaryFunctor each_fn)
LLVM_ABI Value * concatenateVectors(IRBuilderBase &Builder, ArrayRef< Value * > Vecs)
Concatenate a list of vectors.
Align getLoadStoreAlignment(const Value *I)
A helper function that returns the alignment of load or store instruction.
LLVM_ABI Value * createMinMaxOp(IRBuilderBase &Builder, RecurKind RK, Value *Left, Value *Right)
Returns a Min/Max operation corresponding to MinMaxRecurrenceKind.
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
LLVM_ABI Constant * createBitMaskForGaps(IRBuilderBase &Builder, unsigned VF, const InterleaveGroup< Instruction > &Group)
Create a mask that filters the members of an interleave group where there are gaps.
LLVM_ABI llvm::SmallVector< int, 16 > createStrideMask(unsigned Start, unsigned Stride, unsigned VF)
Create a stride shuffle mask.
LLVM_ABI llvm::SmallVector< int, 16 > createReplicatedMask(unsigned ReplicationFactor, unsigned VF)
Create a mask with replicated elements.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool none_of(R &&Range, UnaryPredicate P)
Provide wrappers to std::none_of which take ranges instead of having to pass begin/end explicitly.
SmallVector< ValueTypeFromRangeType< R >, Size > to_vector(R &&Range)
Given a range of type R, iterate the entire range and return a SmallVector with elements of the vecto...
Type * toVectorizedTy(Type *Ty, ElementCount EC)
A helper for converting to vectorized types.
cl::opt< unsigned > ForceTargetInstructionCost
auto drop_end(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the last N elements excluded.
bool canVectorizeTy(Type *Ty)
Returns true if Ty is a valid vector element type, void, or an unpacked literal struct where all elem...
LLVM_ABI llvm::SmallVector< int, 16 > createInterleaveMask(unsigned VF, unsigned NumVecs)
Create an interleave shuffle mask.
RecurKind
These are the kinds of recurrences that we support.
@ UMin
Unsigned integer min implemented in terms of select(cmp()).
@ Mul
Product of integers.
@ AnyOf
AnyOf reduction with select(cmp(),x,y) where one of (x,y) is loop invariant, and both x and y are int...
@ SMax
Signed integer max implemented in terms of select(cmp()).
@ SMin
Signed integer min implemented in terms of select(cmp()).
@ Sub
Subtraction of integers.
@ UMax
Unsigned integer max implemented in terms of select(cmp()).
LLVM_ABI bool isVectorIntrinsicWithScalarOpAtArg(Intrinsic::ID ID, unsigned ScalarOpdIdx, const TargetTransformInfo *TTI)
Identifies if the vector form of the intrinsic has a scalar operand.
LLVM_ABI Value * getRecurrenceIdentity(RecurKind K, Type *Tp, FastMathFlags FMF)
Given information about an recurrence kind, return the identity for the @llvm.vector....
DWARFExpression::Operation Op
Value * createStepForVF(IRBuilderBase &B, Type *Ty, ElementCount VF, int64_t Step)
Return a value for Step multiplied by VF.
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.
Type * getLoadStoreType(const Value *I)
A helper function that returns the type of a load or store instruction.
LLVM_ABI Value * createOrderedReduction(IRBuilderBase &B, RecurKind RdxKind, Value *Src, Value *Start)
Create an ordered reduction intrinsic using the given recurrence kind RdxKind.
ArrayRef< Type * > getContainedTypes(Type *const &Ty)
Returns the types contained in Ty.
Type * toVectorTy(Type *Scalar, ElementCount EC)
A helper function for converting Scalar types to vector types.
LLVM_ABI Value * createAnyOfReduction(IRBuilderBase &B, Value *Src, Value *InitVal, PHINode *OrigPhi)
Create a reduction of the given vector Src for a reduction of kind RecurKind::AnyOf.
LLVM_ABI bool isVectorIntrinsicWithOverloadTypeAtArg(Intrinsic::ID ID, int OpdIdx, const TargetTransformInfo *TTI)
Identifies if the vector form of the intrinsic is overloaded on the type of the operand at index OpdI...
This struct is a compact representation of a valid (non-zero power of two) alignment.
Struct to hold various analysis needed for cost computations.
TargetTransformInfo::OperandValueInfo getOperandInfo(VPValue *V) const
Returns the OperandInfo for V, if it is a live-in.
bool skipCostComputation(Instruction *UI, bool IsVector) const
Return true if the cost for UI shouldn't be computed, e.g.
InstructionCost getLegacyCost(Instruction *UI, ElementCount VF) const
Return the cost for UI with VF using the legacy cost model as fallback until computing the cost of al...
TargetTransformInfo::TargetCostKind CostKind
const TargetLibraryInfo & TLI
const TargetTransformInfo & TTI
SmallPtrSet< Instruction *, 8 > SkipCostComputation
void execute(VPTransformState &State) override
Generate the phi nodes.
InstructionCost computeCost(ElementCount VF, VPCostContext &Ctx) const override
Return the cost of this first-order recurrence phi recipe.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
An overlay for VPIRInstructions wrapping PHI nodes enabling convenient use cast/dyn_cast/isa and exec...
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,...
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
void execute(VPTransformState &State) override
Generate the instruction.
A pure-virtual common base class for recipes defining a single VPValue and using IR flags.
std::optional< InstructionCost > getCostForRecipeWithOpcode(unsigned Opcode, ElementCount VF, VPCostContext &Ctx) const
Compute the cost for this recipe for VF, using Opcode and Ctx.
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.
void execute(VPTransformState &State) override
Generate a wide load or gather.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.
bool isInvariantCond() const
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.
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.
InstructionCost computeCost(ElementCount VF, VPCostContext &Ctx) const override
Return the cost of this VPWidenStoreEVLRecipe.
VPValue * getEVL() const
Return the EVL operand.
void execute(VPTransformState &State) override
Generate a wide store or scatter.
VPValue * getStoredValue() const
Return the value stored by this recipe.
void print(raw_ostream &O, const Twine &Indent, VPSlotTracker &SlotTracker) const override
Print the recipe.