63 WideCanIV->getDebugLoc(), Builder));
64 WideCanIV->eraseFromParent();
81 WideCanIV->replaceAllUsesWith(WidenIV);
82 WideCanIV->eraseFromParent();
91 if (PHICost > BroadcastCost)
100 unsigned RegClass =
TTI.getRegisterClassForType(
true, VecTy);
112 WideCanIV->getNoWrapFlags(), WideCanIV->getDebugLoc());
113 NewWideIV->insertBefore(&*Header->getFirstNonPhi());
114 WideCanIV->replaceAllUsesWith(NewWideIV);
115 WideCanIV->eraseFromParent();
149 DebugLoc DL = CanonicalIVIncrement->getDebugLoc();
160 auto *EntryIncrement =
162 {StartV, VF}, {},
DL,
"index.part.next");
168 {EntryIncrement, TC, ALMMultiplier},
DL,
169 "active.lane.mask.entry");
176 LaneMaskPhi->insertBefore(*HeaderVPBB, HeaderVPBB->begin());
181 Builder.setInsertPoint(OriginalTerminator);
182 auto *InLoopIncrement = Builder.createOverflowingOp(
184 {CanonicalIVIncrement, &Plan.
getVF()}, {},
DL);
186 {InLoopIncrement, TC, ALMMultiplier},
DL,
187 "active.lane.mask.next");
188 LaneMaskPhi->addBackedgeValue(ALM);
192 auto *NotMask = Builder.createNot(ALM,
DL);
199 VPlan &Plan,
bool UseActiveLaneMask,
bool UseActiveLaneMaskForControlFlow) {
205 if (UseActiveLaneMaskForControlFlow) {
211 VPBuilder Builder(Header, Header->getFirstNonPhi());
216 if (UseActiveLaneMask) {
219 Mask = Builder.createNaryOp(
221 {WideCanonicalIV, Plan.
getTripCount(), ALMMultiplier},
nullptr,
278 AddOp = Instruction::Add;
279 MulOp = Instruction::Mul;
281 AddOp =
ID.getInductionOpcode();
282 MulOp = Instruction::FMul;
290 Step = Builder.createScalarCast(Instruction::Trunc, Step, Ty,
DL);
291 Start = Builder.createScalarCast(Instruction::Trunc, Start, Ty,
DL);
300 Init = Builder.createWidenCast(Instruction::UIToFP,
Init, StepTy);
305 Init = Builder.createNaryOp(MulOp, {
Init, SplatStep}, Flags);
306 Init = Builder.createNaryOp(AddOp, {SplatStart,
Init}, Flags,
324 if (R->getParent()->getEnclosingLoopRegion())
325 Builder.setInsertPoint(R->getParent(), std::next(R->getIterator()));
330 VF = Builder.createScalarCast(Instruction::CastOps::UIToFP, VF, StepTy,
333 VF = Builder.createScalarZExtOrTrunc(VF, StepTy,
DL);
335 Inc = Builder.createNaryOp(MulOp, {Step, VF}, Flags);
342 auto *
Next = Builder.createNaryOp(AddOp, {Prev, Inc}, Flags,
345 WidePHI->addIncoming(
Next);
372 VPlan *Plan = R->getParent()->getPlan();
373 VPValue *Start = R->getStartValue();
374 VPValue *Step = R->getStepValue();
377 assert(R->getInductionDescriptor().getKind() ==
379 "Not a pointer induction according to InductionDescriptor!");
380 assert(R->getScalarType()->isPointerTy() &&
"Unexpected type.");
382 "Recipe should have been replaced");
388 VPPhi *ScalarPtrPhi = Builder.createScalarPhi(Start,
DL,
"pointer.phi");
392 Builder.setInsertPoint(R->getParent(), R->getParent()->getFirstNonPhi());
395 Offset = Builder.createOverflowingOp(Instruction::Mul, {
Offset, Step});
397 Builder.createWidePtrAdd(ScalarPtrPhi,
Offset,
DL,
"vector.gep");
398 R->replaceAllUsesWith(PtrAdd);
403 VF = Builder.createScalarZExtOrTrunc(VF, StepTy,
DL);
404 VPValue *Inc = Builder.createOverflowingOp(Instruction::Mul, {Step, VF});
407 Builder.createPtrAdd(ScalarPtrPhi, Inc,
DL,
"ptr.ind");
414 VPValue *Start = R->getStartValue();
415 VPValue *Step = R->getStepValue();
416 VPValue *Index = R->getIndex();
419 ? Builder.createScalarSExtOrTrunc(
421 : Builder.createScalarCast(Instruction::SIToFP, Index, StepTy,
423 switch (R->getInductionKind()) {
425 assert(Index->getScalarType() == Start->getScalarType() &&
426 "Index type does not match StartValue type");
427 return R->replaceAllUsesWith(Builder.createAdd(
428 Start, Builder.createOverflowingOp(Instruction::Mul, {Index, Step})));
431 return R->replaceAllUsesWith(Builder.createPtrAdd(
432 Start, Builder.createOverflowingOp(Instruction::Mul, {Index, Step})));
437 (FPBinOp->
getOpcode() == Instruction::FAdd ||
438 FPBinOp->
getOpcode() == Instruction::FSub) &&
439 "Original BinOp should be defined for FP induction");
441 VPValue *
FMul = Builder.createNaryOp(Instruction::FMul, {Step, Index}, FMF);
442 return R->replaceAllUsesWith(
443 Builder.createNaryOp(FPBinOp->
getOpcode(), {Start, FMul}, FMF));
456 if (!R->isReplicator())
460 R->dissolveToCFGLoop();
481 assert(Br->getNumOperands() == 2 &&
482 "BranchOnTwoConds must have exactly 2 conditions");
486 assert(Successors.size() == 3 &&
487 "BranchOnTwoConds must have exactly 3 successors");
492 VPValue *Cond0 = Br->getOperand(0);
493 VPValue *Cond1 = Br->getOperand(1);
500 if (Succ0 == Succ1) {
502 VPValue *Combined = Builder.createOr(Cond0, Cond1,
DL);
506 Br->eraseFromParent();
511 !BrOnTwoCondsBB->
getParent() &&
"regions must already be dissolved");
524 Br->eraseFromParent();
535 WidenIVR->eraseFromParent();
544 WidenIVR, Plan, Builder);
545 WidenIVR->replaceAllUsesWith(PtrAdd);
546 WidenIVR->eraseFromParent();
550 WidenIVR->eraseFromParent();
556 DerivedIVR->eraseFromParent();
561 VPValue *CanIV = WideCanIV->getCanonicalIV();
563 VPValue *Step = WideCanIV->getStepValue();
566 "Expected unroller to have materialized step for UF != 1");
571 Step = Builder.createAdd(
574 Builder.createAdd(CanIV, Step, WideCanIV->getDebugLoc(),
"vec.iv",
575 WideCanIV->getNoWrapFlags());
577 WideCanIV->eraseFromParent();
584 for (
unsigned I = 1;
I != Blend->getNumIncomingValues(); ++
I)
585 Select = Builder.createSelect(Blend->getMask(
I),
586 Blend->getIncomingValue(
I),
Select,
587 R.getDebugLoc(),
"predphi", *Blend);
588 Blend->replaceAllUsesWith(
Select);
589 Blend->eraseFromParent();
594 if (!VEPR->getOffset()) {
596 "Expected unroller to have materialized offset for UF != 1");
597 VEPR->materializeOffset();
604 Expr->eraseFromParent();
614 for (
VPValue *
Op : LastActiveL->operands()) {
615 VPValue *NotMask = Builder.createNot(
Op, LastActiveL->getDebugLoc());
620 VPValue *FirstInactiveLane = Builder.createFirstActiveLane(
621 NotMasks, LastActiveL->getDebugLoc(),
"first.inactive.lane");
627 Builder.createSub(FirstInactiveLane, One,
628 LastActiveL->getDebugLoc(),
"last.active.lane");
631 LastActiveL->eraseFromParent();
639 "Unmasked MaskedCond should be simplified earlier");
640 VPI->replaceAllUsesWith(Builder.createNaryOp(
642 VPI->eraseFromParent();
652 Instruction::Add, VPI->operands(), VPI->getNoWrapFlags(),
654 VPI->replaceAllUsesWith(
Add);
655 VPI->eraseFromParent();
663 DebugLoc DL = BranchOnCountInst->getDebugLoc();
666 BranchOnCountInst->eraseFromParent();
681 ? Instruction::UIToFP
682 : Instruction::Trunc;
683 VectorStep = Builder.createWidenCast(CastOp, VectorStep, IVTy);
689 Builder.createWidenCast(Instruction::Trunc, ScalarStep, IVTy);
695 MulOpc = Instruction::FMul;
696 Flags = VPI->getFastMathFlagsOrNone();
698 MulOpc = Instruction::Mul;
703 MulOpc, {VectorStep, ScalarStep}, Flags, R.getDebugLoc());
705 VPI->replaceAllUsesWith(VectorStep);
706 VPI->eraseFromParent();
727 for (
VPValue *VPV : VPValues) {
735 if (
User->usesScalars(VPV))
738 HoistPoint = HoistBlock->
begin();
742 "All users must be in the vector preheader or dominated by it");
747 VPV->replaceUsesWithIf(Broadcast,
748 [VPV, Broadcast](
VPUser &U,
unsigned Idx) {
749 return Broadcast != &U && !U.usesScalars(VPV);
757 assert(Plan.
hasVF(BestVF) &&
"BestVF is not available in Plan");
758 assert(Plan.
hasUF(BestUF) &&
"BestUF is not available in Plan");
821 auto UsesVectorOrInsideReplicateRegion = [DefR, LoopRegion](
VPUser *U) {
823 return !U->usesScalars(DefR) || ParentRegion != LoopRegion;
825 if (
none_of(DefR->users(), UsesVectorOrInsideReplicateRegion))
835 DefR->replaceUsesWithIf(
836 BuildVector, [BuildVector, &UsesVectorOrInsideReplicateRegion](
838 return &U != BuildVector && UsesVectorOrInsideReplicateRegion(&U);
852 for (
VPValue *Def : R.definedValues()) {
862 unsigned NumFirstLaneUsers =
count_if(Def->users(), [&Def](
VPUser *U) {
863 return U->usesFirstLaneOnly(Def);
865 if (!NumFirstLaneUsers || NumFirstLaneUsers == Def->getNumUsers())
872 Unpack->insertAfter(&R);
873 Def->replaceUsesWithIf(Unpack, [&Def](
VPUser &U,
unsigned) {
874 return U.usesFirstLaneOnly(Def);
883 bool RequiresScalarEpilogue,
VPValue *Step,
884 std::optional<uint64_t> MaxRuntimeStep) {
896 "Step VPBB must dominate VectorPHVPBB");
898 InsertPt = std::next(StepR->getIterator());
900 VPBuilder Builder(VectorPHVPBB, InsertPt);
906 if (!RequiresScalarEpilogue &&
match(TC,
m_APInt(TCVal)) && MaxRuntimeStep &&
907 TCVal->
urem(*MaxRuntimeStep) == 0) {
919 TC = Builder.createAdd(
930 Builder.createNaryOp(Instruction::URem, {TC, Step},
939 if (RequiresScalarEpilogue) {
941 "requiring scalar epilogue is not supported with fail folding");
944 R = Builder.createSelect(IsZero, Step, R);
958 "VF and VFxUF must be materialized together");
970 Builder.createElementCount(TCTy, VFEC * Plan.
getConcreteUF());
977 VPValue *RuntimeVF = Builder.createElementCount(TCTy, VFEC);
981 BC, [&VF](
VPUser &U,
unsigned) {
return !U.usesScalars(&VF); });
985 VPValue *MulByUF = Builder.createOverflowingOp(
999 assert(IncomingAliasMask &&
"Expected an alias mask!");
1009 if (
Check.NeedsFreeze) {
1019 Intrinsic::loop_dependence_war_mask,
1023 AliasMask = Builder.createAnd(AliasMask, WARMask);
1025 AliasMask = WARMask;
1030 VPValue *NumActive = Builder.createNaryOp(
1033 VPValue *ClampedVF = Builder.createScalarZExtOrTrunc(
1059 VPValue *DistanceToMax = Builder.createSub(MaxUIntTripCount, TripCount);
1067 VPValue *TripCountCheck = Builder.createICmp(
1070 VPValue *
Cond = Builder.createOr(IsScalar, TripCountCheck,
DL);
1081 "Clamped VF not supported with interleaving");
1089 VPBuilder Builder(Entry, Entry->begin());
1101 if (!ExpSCEV || ExpSCEV->user_empty())
1103 Builder.setInsertPoint(ExpSCEV);
1112 ExpSCEV->eraseFromParent();
1121 BasicBlock *EntryBB = Entry->getIRBasicBlock();
1128 const SCEV *Expr = ExpSCEV->getSCEV();
1131 ExpandedSCEVs[Expr] = Res;
1136 ExpSCEV->eraseFromParent();
1139 "all VPExpandSCEVRecipes must have been expanded");
1142 auto EI = Entry->begin();
1152 return ExpandedSCEVs;
1167 "must have a BranchOnCond");
1170 if (VF.
isScalable() && VScaleForTuning.has_value())
1171 VectorStep *= *VScaleForTuning;
1172 assert(VectorStep > 0 &&
"trip count should not be zero");
1176 MiddleTerm->setMetadata(LLVMContext::MD_prof, BranchWeights);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
AMDGPU Register Bank Select
This file implements a class to represent arbitrary precision integral constant values and operations...
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static const Function * getParent(const Value *V)
static cl::opt< OutputCostKind > CostKind("cost-kind", cl::desc("Target cost kind"), cl::init(OutputCostKind::RecipThroughput), cl::values(clEnumValN(OutputCostKind::RecipThroughput, "throughput", "Reciprocal throughput"), clEnumValN(OutputCostKind::Latency, "latency", "Instruction latency"), clEnumValN(OutputCostKind::CodeSize, "code-size", "Code size"), clEnumValN(OutputCostKind::SizeAndLatency, "size-latency", "Code size and latency"), clEnumValN(OutputCostKind::All, "all", "Print all cost kinds")))
static std::pair< Value *, APInt > getMask(Value *WideMask, unsigned Factor, ElementCount LeafValueEC)
This file provides a LoopVectorizationPlanner class.
const SmallVectorImpl< MachineOperand > & Cond
static bool dominates(InstrPosIndexes &PosIndexes, const MachineInstr &A, const MachineInstr &B)
This file defines the SmallPtrSet class.
This file implements dominator tree analysis for a single level of a VPlan's H-CFG.
This file contains the declarations of different VPlan-related auxiliary helpers.
static VPActiveLaneMaskPHIRecipe * addVPLaneMaskPhiAndUpdateExitBranch(VPlan &Plan)
static void expandVPDerivedIV(VPDerivedIVRecipe *R)
Expand a VPDerivedIVRecipe into executable recipes.
static void expandVPWidenIntOrFpInduction(VPWidenIntOrFpInductionRecipe *WidenIVR)
Expand a VPWidenIntOrFpInduction into executable recipes, for the initial value, phi and backedge val...
static void expandVPWidenPointerInduction(VPWidenPointerInductionRecipe *R)
Expand a VPWidenPointerInductionRecipe into executable recipes, for the initial value,...
This file contains the declarations of the Vectorization Plan base classes:
static const uint32_t IV[8]
Class for arbitrary precision integers.
LLVM_ABI APInt urem(const APInt &RHS) const
Unsigned remainder operation.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
LLVM Basic Block Representation.
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction; assumes that the block is well-formed.
@ ICMP_ULT
unsigned less than
@ ICMP_ULE
unsigned less or equal
LLVM_ABI IntegerType * getIndexType(LLVMContext &C, unsigned AddressSpace) const
Returns the type of a GEP index in AddressSpace.
static DebugLoc getCompilerGenerated()
static DebugLoc getUnknown()
bool dominates(const DomTreeNodeBase< NodeT > *A, const DomTreeNodeBase< NodeT > *B) const
dominates - Returns true iff A dominates B.
Utility class for floating point operations which can have information about relaxed accuracy require...
FastMathFlags getFastMathFlags() const
Convenience function for getting all the fast-math flags.
Convenience struct for specifying and reasoning about fast-math flags.
A struct for saving information about induction variables.
static LLVM_ABI InductionDescriptor getCanonicalIntInduction(Type *Ty, ScalarEvolution &SE)
Returns the canonical integer induction for type Ty with start = 0 and step = 1.
@ IK_NoInduction
Not an induction variable.
@ IK_FpInduction
Floating point induction variable.
@ IK_PtrInduction
Pointer induction var. Step = C.
@ IK_IntInduction
Integer induction variable. Step = C.
static LLVM_ABI IntegerType * get(LLVMContext &C, unsigned NumBits)
This static method is the primary way of constructing an IntegerType.
LLVM_ABI MDNode * createBranchWeights(uint32_t TrueWeight, uint32_t FalseWeight, bool IsExpected=false)
Return metadata containing two branch weights.
unsigned getOpcode() const
Return the opcode for this Instruction or ConstantExpr.
An interface layer with SCEV used to manage how we see SCEV expressions for values in the context of ...
ScalarEvolution * getSE() const
Returns the ScalarEvolution analysis used.
This class uses information about analyze scalars to rewrite expressions in canonical form.
LLVM_ABI Value * expandCodeFor(SCEVUse SH, Type *Ty, BasicBlock::iterator I)
Insert code to directly compute the specified SCEV expression into the program.
This class represents an analyzed expression in the program.
LLVM_ABI Type * getType() const
Return the LLVM type of this SCEV expression.
The main scalar evolution driver.
LLVM_ABI const SCEV * getUDivExpr(SCEVUse LHS, SCEVUse RHS)
Get a canonical unsigned division expression, or something simpler if possible.
LLVM_ABI const SCEV * getSCEV(Value *V)
Return a SCEV expression for the full generality of the specified expression.
LLVM_ABI const SCEV * getElementCount(Type *Ty, ElementCount EC, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap)
LLVM_ABI const SCEV * getMulExpr(SmallVectorImpl< SCEVUse > &Ops, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap, unsigned Depth=0)
Get a canonical multiply expression, or something simpler if possible.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
The instances of the Type class are immutable: once they are created, they are never changed.
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
bool isStructTy() const
True if this is an instance of StructType.
LLVM_ABI unsigned getScalarSizeInBits() const LLVM_READONLY
If this is a vector type, return the getPrimitiveSizeInBits value for the element type.
static LLVM_ABI IntegerType * getInt1Ty(LLVMContext &C)
bool isFloatingPointTy() const
Return true if this is one of the floating-point types.
bool isIntegerTy() const
True if this is an instance of IntegerType.
A recipe for generating the active lane mask for the vector loop that is used to predicate the vector...
VPBasicBlock serves as the leaf of the Hierarchical Control-Flow Graph.
RecipeListTy::iterator iterator
Instruction iterators...
iterator begin()
Recipe iterator methods.
VPRecipeBase * getTerminator()
If the block has multiple successors, return the branch recipe terminating the block.
VPBlockBase is the building block of the Hierarchical Control-Flow Graph.
VPRegionBlock * getParent()
const VPBasicBlock * getExitingBasicBlock() const
const std::string & getName() const
const VPBasicBlock * getEntryBasicBlock() const
VPBlockBase * getSingleSuccessor() const
const VPBlocksTy & getSuccessors() const
static auto blocksAs(T &&Range)
Return an iterator range over Range with each block cast to BlockTy.
static void connectBlocks(VPBlockBase *From, VPBlockBase *To, unsigned PredIdx=-1u, unsigned SuccIdx=-1u)
Connect VPBlockBases From and To bi-directionally.
static void disconnectBlocks(VPBlockBase *From, VPBlockBase *To)
Disconnect VPBlockBases From and To bi-directionally.
static auto blocksOnly(T &&Range)
Return an iterator range over Range which only includes BlockTy blocks.
VPlan-based builder utility analogous to IRBuilder.
VPWidenPHIRecipe * createWidenPhi(ArrayRef< VPValue * > IncomingValues, DebugLoc DL=DebugLoc::getUnknown(), const Twine &Name="")
VPInstruction * createNaryOp(unsigned Opcode, ArrayRef< VPValue * > Operands, Instruction *Inst=nullptr, const VPIRFlags &Flags={}, const VPIRMetadata &MD={}, DebugLoc DL=DebugLoc::getUnknown(), const Twine &Name="", Type *ResultTy=nullptr)
Create an N-ary operation with Opcode, Operands and set Inst as its underlying Instruction.
A recipe for converting the input value IV value to the corresponding value of an IV with different s...
Template specialization of the standard LLVM dominator tree utility for VPBlockBases.
Class to record and manage LLVM IR flags.
static VPIRFlags getDefaultFlags(unsigned Opcode)
Returns default flags for Opcode for opcodes that support it, asserts otherwise.
void dropPoisonGeneratingFlags()
Drop all poison-generating flags.
static LLVM_ABI_FOR_TEST VPIRInstruction * create(Instruction &I)
Create a new VPIRPhi for \I , if it is a PHINode, otherwise create a VPIRInstruction.
This is a concrete Recipe that models a single VPlan-level instruction.
@ Unpack
Extracts all lanes from its (non-scalable) vector operand.
@ 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 ...
@ CanonicalIVIncrementForPart
void addIncoming(VPValue *IncomingV)
Append IncomingV as an incoming value to the phi-like recipe.
VPRecipeBase is a base class modeling a sequence of one or more output IR instructions.
VPBasicBlock * getParent()
DebugLoc getDebugLoc() const
Returns the debug location of the recipe.
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.
Type * getScalarType() const
Returns the scalar type of this VPRecipeValue.
VPRegionBlock represents a collection of VPBasicBlocks and VPRegionBlocks which form a Single-Entry-S...
const VPBlockBase * getEntry() const
VPRegionValue * getUsedHeaderMask() const
Return the header mask if it exists and is used, or null otherwise.
VPInstruction * getOrCreateCanonicalIVIncrement()
Get the canonical IV increment instruction if it exists.
Type * getCanonicalIVType() const
Return the type of the canonical IV for loop regions.
void clearCanonicalIVNUW(VPInstruction *Increment)
Unsets NUW for the canonical IV increment Increment, for loop regions.
VPRegionValue * getCanonicalIV()
Return the canonical induction variable of the region, null for replicating regions.
VPReplicateRecipe replicates a given instruction producing multiple scalar copies of the original sca...
Lightweight SCEV-to-VPlan expander.
VPValue * tryToExpand(const SCEV *S)
Try to expand S into recipes and live-ins using the builder.
A recipe for handling phi nodes of integer and floating-point inductions, producing their scalar valu...
A symbolic live-in VPValue, used for values like vector trip count, VF, and VFxUF.
bool isMaterialized() const
Returns true if this value has been materialized.
This class augments VPValue with operands which provide the inverse def-use edges from VPValue's user...
This is the base class of the VPlan Def/Use graph, used for modeling the data flow into,...
Type * getScalarType() const
Returns the scalar type of this VPValue, dispatching based on the concrete subclass.
Value * getLiveInIRValue() const
Return the underlying IR value for a VPIRValue.
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.
void setUnderlyingValue(Value *Val)
void replaceAllUsesWith(VPValue *New)
void replaceUsesWithIf(VPValue *New, llvm::function_ref< bool(VPUser &U, unsigned Idx)> ShouldReplace)
Go through the uses list for this VPValue and make each use point to New if the callback ShouldReplac...
A Recipe for widening the canonical induction variable of the vector loop.
VPIRValue * getStartValue() const
Returns the start value of the induction.
VPValue * getStepValue()
Returns the step value of the induction.
const InductionDescriptor & getInductionDescriptor() const
Returns the induction descriptor for the recipe.
A recipe for handling phi nodes of integer and floating-point inductions, producing their vector valu...
VPValue * getSplatVFValue() const
If the recipe has been unrolled, return the VPValue for the induction increment, otherwise return nul...
VPValue * getLastUnrolledPartOperand()
Returns the VPValue representing the value of this induction at the last unrolled part,...
A recipe for widening vector intrinsics.
VPlan models a candidate for vectorization, encoding various decisions take to produce efficient outp...
bool hasVF(ElementCount VF) const
const DataLayout & getDataLayout() const
LLVMContext & getContext() const
VPBasicBlock * getEntry()
bool hasScalableVF() const
VPValue * getTripCount() const
The trip count of the original loop.
VPValue * getOrCreateBackedgeTakenCount()
The backedge taken count of the original loop.
VPSymbolicValue & getVFxUF()
Returns VF * UF of the vector loop region.
auto getLiveIns() const
Return the list of live-in VPValues available in the VPlan.
bool hasUF(unsigned UF) const
VPIRValue * getPoison(Type *Ty)
Return a VPIRValue wrapping a poison value of type Ty.
VPSymbolicValue & getVectorTripCount()
The vector trip count.
VPValue * getBackedgeTakenCount() const
VPIRValue * getOrAddLiveIn(Value *V)
Gets the live-in VPIRValue for V or adds a new live-in (if none exists yet) for V.
VPIRValue * getZero(Type *Ty)
Return a VPIRValue wrapping the null value of type Ty.
LLVM_ABI_FOR_TEST VPRegionBlock * getVectorLoopRegion()
Returns the VPRegionBlock of the vector loop.
unsigned getConcreteUF() const
Returns the concrete UF of the plan, after unrolling.
void resetTripCount(VPValue *NewTripCount)
Resets the trip count for the VPlan.
VPBasicBlock * getMiddleBlock()
Returns the 'middle' block of the plan, that is the block that selects whether to execute the scalar ...
VPBasicBlock * createVPBasicBlock(const Twine &Name, VPRecipeBase *Recipe=nullptr)
Create a new VPBasicBlock with Name and containing Recipe if present.
VPBasicBlock * getVectorPreheader() const
Returns the preheader of the vector loop region, if one exists, or null otherwise.
bool hasScalarVFOnly() const
VPBasicBlock * getScalarPreheader() const
Return the VPBasicBlock for the preheader of the scalar loop.
bool hasTailFolded() const
Returns true if the vector loop region is tail-folded.
VPSymbolicValue & getVF()
Returns the VF of the vector loop region.
bool hasScalarTail() const
Returns true if the scalar tail may execute after the vector loop, i.e.
VPIRValue * getConstantInt(Type *Ty, uint64_t Val, bool IsSigned=false)
Return a VPIRValue wrapping a ConstantInt with the given type and value.
LLVM Value Representation.
iterator_range< user_iterator > users()
static LLVM_ABI VectorType * get(Type *ElementType, ElementCount EC)
This static method is the primary way to construct an VectorType.
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.
self_iterator getIterator()
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
ap_match< APInt > m_APInt(const APInt *&Res)
Match a ConstantInt or splatted ConstantVector, binding the specified pointer to the contained APInt.
bool match(Val *V, const Pattern &P)
cst_pred_ty< is_one > m_One()
Match an integer 1 or a vector with all elements equal to 1.
VPInstruction_match< VPInstruction::BranchOnTwoConds > m_BranchOnTwoConds()
canonical_widen_iv_match m_CanonicalWidenIV()
VPInstruction_match< VPInstruction::BranchOnCount > m_BranchOnCount()
auto m_VPValue()
Match an arbitrary VPValue and ignore it.
VPRecipeBase * findUserOf(VPValue *V, const MatchT &P)
If V is used by a recipe matching pattern P, return it.
match_bind< VPInstruction > m_VPInstruction(VPInstruction *&V)
Match a VPInstruction, capturing if we match.
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...
VPValue * getOrCreateVPValueForSCEVExpr(VPlan &Plan, const SCEV *Expr)
Get or create a VPValue that corresponds to the expansion of Expr.
bool onlyFirstLaneUsed(const VPValue *Def)
Returns true if only the first lane of Def is used.
VPValue * findIncomingAliasMask(const VPlan &Plan)
Finds the incoming alias-mask within the vector preheader.
VPScalarIVStepsRecipe * createScalarIVSteps(VPlan &Plan, InductionDescriptor::InductionKind Kind, Instruction::BinaryOps InductionOpcode, FPMathOperator *FPBinOp, Instruction *TruncI, VPIRValue *StartV, VPValue *Step, DebugLoc DL, VPBuilder &Builder)
Create a scalar-iv-steps recipe over Plan's canonical IV for an induction of Kind with InductionOpcod...
bool doesGeneratePerAllLanes(const VPRecipeBase *R)
Returns true if R produces scalar values for all VF lanes.
bool onlyScalarValuesUsed(const VPValue *Def)
Returns true if only scalar values of Def are used by all users.
VPValue * scalarizeVPWidenPointerInduction(VPWidenPointerInductionRecipe *PtrIV, VPlan &Plan, VPBuilder &Builder)
Scalarize a VPWidenPointerInductionRecipe by replacing it with a PtrAdd (IndStart,...
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
void append_range(Container &C, Range &&R)
Wrapper function to append range R to container C.
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
iterator_range< df_iterator< VPBlockShallowTraversalWrapper< VPBlockBase * > > > vp_depth_first_shallow(VPBlockBase *G)
Returns an iterator range to traverse the graph starting at G in depth-first order.
iterator_range< df_iterator< VPBlockDeepTraversalWrapper< VPBlockBase * > > > vp_depth_first_deep(VPBlockBase *G)
Returns an iterator range to traverse the graph starting at G in depth-first order while traversing t...
SmallVector< VPRegisterUsage, 8 > calculateRegisterUsageForPlan(VPlan &Plan, ArrayRef< ElementCount > VFs, const TargetTransformInfo &TTI, const SmallPtrSetImpl< const Value * > &ValuesToIgnore)
Estimate the register usage for Plan and vectorization factors in VFs by calculating the highest numb...
detail::concat_range< ValueT, RangeTs... > concat(RangeTs &&...Ranges)
Returns a concatenated range across two or more ranges.
auto dyn_cast_or_null(const Y &Val)
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...
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
auto drop_end(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the last N elements excluded.
@ Mul
Product of integers.
DWARFExpression::Operation Op
auto make_second_range(ContainerTy &&c)
Given a container of pairs, return a range over the second elements.
auto count_if(R &&Range, UnaryPredicate P)
Wrapper function around std::count_if to count the number of times an element satisfying a given pred...
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Next
constexpr detail::IsaCheckPredicate< Types... > IsaPred
Function object wrapper for the llvm::isa type check.
A struct that represents some properties of the register usage of a loop.
SmallMapVector< unsigned, unsigned, 4 > MaxLocalUsers
Holds the maximum number of concurrent live intervals in the loop.
InstructionCost spillCost(const TargetTransformInfo &TTI, TargetTransformInfo::TargetCostKind CostKind, unsigned OverrideMaxNumRegs=0) const
Calculate the estimated cost of any spills due to using more registers than the number available for ...