25#define DEBUG_TYPE "vplan"
28using namespace VPlanPatternMatch;
32class PlainCFGBuilder {
40 std::unique_ptr<VPlan> Plan;
61 bool isExternalDef(
Value *Val);
68 : TheLoop(Lp), LI(LI), Plan(std::make_unique<VPlan>(Lp)) {}
71 std::unique_ptr<VPlan> buildPlainCFG();
81 VPBBPreds.
push_back(getOrCreateVPBB(Pred));
86 return L && BB == L->getHeader();
90void PlainCFGBuilder::fixHeaderPhis() {
91 for (
auto *Phi : PhisToFix) {
92 assert(IRDef2VPValue.count(Phi) &&
"Missing VPInstruction for PHINode.");
94 assert(isa<VPPhi>(VPVal) &&
"Expected VPPhi for phi node.");
95 auto *PhiR = cast<VPPhi>(VPVal);
96 assert(PhiR->getNumOperands() == 0 &&
"Expected VPPhi with no operands.");
98 "Expected Phi in header block.");
100 "header phi must have exactly 2 operands");
103 getOrCreateVPOperand(
Phi->getIncomingValueForBlock(Pred)));
110 if (
auto *VPBB = BB2VPBB.lookup(BB)) {
129bool PlainCFGBuilder::isExternalDef(
Value *Val) {
137 return !TheLoop->contains(Inst);
145VPValue *PlainCFGBuilder::getOrCreateVPOperand(
Value *IRVal) {
146 auto VPValIt = IRDef2VPValue.find(IRVal);
147 if (VPValIt != IRDef2VPValue.end())
150 return VPValIt->second;
159 assert(isExternalDef(IRVal) &&
"Expected external definition as operand.");
163 VPValue *NewVPVal = Plan->getOrAddLiveIn(IRVal);
164 IRDef2VPValue[IRVal] = NewVPVal;
171void PlainCFGBuilder::createVPInstructionsForVPBB(
VPBasicBlock *VPBB,
173 VPIRBuilder.setInsertPoint(VPBB);
180 assert(!IRDef2VPValue.count(Inst) &&
181 "Instruction shouldn't have been visited.");
183 if (
auto *Br = dyn_cast<BranchInst>(Inst)) {
186 if (Br->isConditional()) {
187 VPValue *
Cond = getOrCreateVPOperand(Br->getCondition());
195 if (
auto *SI = dyn_cast<SwitchInst>(Inst)) {
197 for (
auto Case :
SI->cases())
198 Ops.
push_back(getOrCreateVPOperand(Case.getCaseValue()));
199 VPIRBuilder.createNaryOp(Instruction::Switch, Ops, Inst);
204 if (
auto *Phi = dyn_cast<PHINode>(Inst)) {
208 NewR = VPIRBuilder.createScalarPhi({},
Phi->getDebugLoc(),
"vec.phi");
213 PhisToFix.push_back(Phi);
218 for (
unsigned I = 0;
I !=
Phi->getNumOperands(); ++
I) {
219 VPPredToIncomingValue[BB2VPBB[
Phi->getIncomingBlock(
I)]] =
220 getOrCreateVPOperand(
Phi->getIncomingValue(
I));
224 VPPredToIncomingValue.
lookup(Pred->getExitingBasicBlock()));
235 NewR = cast<VPInstruction>(
236 VPIRBuilder.createNaryOp(Inst->
getOpcode(), VPOperands, Inst));
239 IRDef2VPValue[Inst] = NewR;
244std::unique_ptr<VPlan> PlainCFGBuilder::buildPlainCFG() {
248 BB2VPBB[ExitVPBB->getIRBasicBlock()] = ExitVPBB;
259 BasicBlock *ThePreheaderBB = TheLoop->getLoopPreheader();
261 "Unexpected loop preheader");
262 for (
auto &
I : *ThePreheaderBB) {
263 if (
I.getType()->isVoidTy())
265 IRDef2VPValue[&
I] = Plan->getOrAddLiveIn(&
I);
275 setVPBBPredsFromBB(VPBB, BB);
278 createVPInstructionsForVPBB(VPBB, BB);
285 getOrCreateVPBB(
SI->getDefaultDest())};
286 for (
auto Case :
SI->cases())
287 Succs.
push_back(getOrCreateVPBB(Case.getCaseSuccessor()));
297 assert(BI->isConditional() && NumSuccs == 2 && BI->isConditional() &&
298 "block must have conditional branch with 2 successors");
307 for (
auto *EB : Plan->getExitBlocks())
308 setVPBBPredsFromBB(EB, EB->getIRBasicBlock());
315 Plan->getEntry()->setOneSuccessor(getOrCreateVPBB(TheLoop->getHeader()));
316 Plan->getEntry()->setPlan(&*Plan);
323 for (
auto *EB : Plan->getExitBlocks()) {
325 auto *PhiR = cast<VPIRPhi>(&R);
327 assert(PhiR->getNumOperands() == 0 &&
328 "no phi operands should be added yet");
331 getOrCreateVPOperand(
Phi.getIncomingValueForBlock(Pred)));
336 return std::move(Plan);
349 if (Preds.
size() != 2)
352 auto *PreheaderVPBB = Preds[0];
353 auto *LatchVPBB = Preds[1];
354 if (!VPDT.
dominates(PreheaderVPBB, HeaderVPB) ||
358 if (!VPDT.
dominates(PreheaderVPBB, HeaderVPB) ||
365 for (
VPRecipeBase &R : cast<VPBasicBlock>(HeaderVPB)->phis())
375 if (LatchVPBB->getSingleSuccessor() ||
376 LatchVPBB->getSuccessors()[0] != HeaderVPB)
379 assert(LatchVPBB->getNumSuccessors() == 2 &&
"Must have 2 successors");
380 auto *Term = cast<VPBasicBlock>(LatchVPBB)->getTerminator();
383 "terminator must be a BranchOnCond");
385 Not->insertBefore(Term);
386 Term->setOperand(0, Not);
387 LatchVPBB->swapSuccessors();
400 assert(LatchExitVPB &&
"Latch expected to be left with a single successor");
410 R->setEntry(HeaderVPB);
411 R->setExiting(LatchVPBB);
423 Value *StartIdx = ConstantInt::get(IdxTy, 0);
428 HeaderVPBB->
insert(CanonicalIVPHI, HeaderVPBB->
begin());
433 if (!LatchVPBB->
empty() &&
444 Instruction::Add, {CanonicalIVPHI, &Plan.
getVFxUF()}, {
true,
false},
DL,
446 CanonicalIVPHI->
addOperand(CanonicalIVIncrement);
459 if (EB->getSinglePredecessor() != MiddleVPBB)
463 auto *ExitIRI = cast<VPIRPhi>(&R);
464 for (
unsigned Idx = 0;
Idx != ExitIRI->getNumIncoming(); ++
Idx) {
465 VPRecipeBase *Inc = ExitIRI->getIncomingValue(
Idx)->getDefiningRecipe();
468 assert(ExitIRI->getNumOperands() == 1 &&
469 ExitIRI->getParent()->getSinglePredecessor() == MiddleVPBB &&
470 "exit values from early exits must be fixed when branch to "
471 "early-exit is added");
472 ExitIRI->extractLastLaneOfFirstOperand(
B);
485 auto *LatchVPBB = cast<VPBasicBlock>(HeaderVPBB->getPredecessors()[1]);
495 if (LatchVPBB->getNumSuccessors() == 2) {
500 LatchVPBB->swapSuccessors();
509 assert(!isa<SCEVCouldNotCompute>(BackedgeTakenCountSCEV) &&
510 "Invalid backedge-taken count");
513 InductionTy, TheLoop);
531std::unique_ptr<VPlan>
534 PlainCFGBuilder Builder(TheLoop, &LI);
535 std::unique_ptr<VPlan> VPlan0 = Builder.buildPlainCFG();
541 bool HasUncountableEarlyExit) {
542 auto *MiddleVPBB = cast<VPBasicBlock>(
544 auto *LatchVPBB = cast<VPBasicBlock>(MiddleVPBB->getSinglePredecessor());
545 VPBlockBase *HeaderVPB = cast<VPBasicBlock>(LatchVPBB->getSuccessors()[1]);
552 [[maybe_unused]]
bool HandledUncountableEarlyExit =
false;
555 if (Pred == MiddleVPBB)
557 if (HasUncountableEarlyExit) {
558 assert(!HandledUncountableEarlyExit &&
559 "can handle exactly one uncountable early exit");
561 cast<VPBasicBlock>(HeaderVPB), LatchVPBB);
562 HandledUncountableEarlyExit =
true;
565 cast<VPIRPhi>(&R)->removeIncomingValueFor(Pred);
567 cast<VPBasicBlock>(Pred)->getTerminator()->eraseFromParent();
572 assert((!HasUncountableEarlyExit || HandledUncountableEarlyExit) &&
573 "missed an uncountable exit that must be handled");
577 bool RequiresScalarEpilogueCheck,
579 auto *MiddleVPBB = cast<VPBasicBlock>(
584 if (MiddleVPBB->getNumSuccessors() == 1) {
586 "must have ScalarPH as single successor");
590 assert(MiddleVPBB->getNumSuccessors() == 2 &&
"must have 2 successors");
607 auto *LatchVPBB = cast<VPBasicBlock>(MiddleVPBB->getSinglePredecessor());
608 DebugLoc LatchDL = LatchVPBB->getTerminator()->getDebugLoc();
611 if (!RequiresScalarEpilogueCheck)
630 TopRegion->
setName(
"vector loop");
640 bool AddBranchWeights) {
653 for (
VPRecipeBase &R : cast<VPBasicBlock>(ScalarPH)->phis()) {
654 assert(isa<VPPhi>(&R) &&
"Phi expected to be VPPhi");
655 assert(cast<VPPhi>(&R)->getNumIncoming() == NumPredecessors - 1 &&
656 "must have incoming values for all operands");
657 R.addOperand(R.getOperand(NumPredecessors - 2));
664 if (AddBranchWeights) {
668 Term->addMetadata(LLVMContext::MD_prof, BranchWeights);
674 ElementCount MinProfitableTripCount,
bool RequiresScalarEpilogue,
675 bool TailFolded,
bool CheckNeededWithTailFolding,
Loop *OrigLoop,
688 auto GetMinTripCount = [&]() ->
const SCEV * {
697 const SCEV *MinProfitableTripCountSCEV =
699 return SE.
getUMaxExpr(MinProfitableTripCountSCEV, VFxUF);
705 const SCEV *Step = GetMinTripCount();
707 if (CheckNeededWithTailFolding) {
714 TripCountTy, cast<IntegerType>(TripCountTy)->
getMask()));
716 Instruction::Sub, {MaxUIntTripCount, TripCountVPV},
736 TripCountCheck = Plan.
getTrue();
743 CmpPred, TripCountVPV, MinTripCountVPV,
DL,
"min.iters.check");
752 Term->addMetadata(LLVMContext::MD_prof, BranchWeights);
758 auto *MinMaxR = dyn_cast<VPRecipeWithIRFlags>(
759 RedPhiR->getBackedgeValue()->getDefiningRecipe());
763 auto *RepR = dyn_cast<VPReplicateRecipe>(MinMaxR);
764 if (!isa<VPWidenIntrinsicRecipe>(MinMaxR) &&
765 !(RepR && isa<IntrinsicInst>(RepR->getUnderlyingInstr())))
772 assert(((isa<VPWidenIntrinsicRecipe>(MinMaxR) &&
773 cast<VPWidenIntrinsicRecipe>(MinMaxR)->getVectorIntrinsicID() ==
775 (RepR && cast<IntrinsicInst>(RepR->getUnderlyingInstr())
776 ->getIntrinsicID() == RdxIntrinsicId)) &&
777 "Intrinsic did not match recurrence kind");
780 if (MinMaxR->getOperand(0) == RedPhiR)
781 return MinMaxR->getOperand(1);
783 assert(MinMaxR->getOperand(1) == RedPhiR &&
784 "Reduction phi operand expected");
785 return MinMaxR->getOperand(0);
790 bool HasUnsupportedPhi =
false;
792 if (isa<VPCanonicalIVPHIRecipe, VPWidenIntOrFpInductionRecipe>(&R))
794 auto *Cur = dyn_cast<VPReductionPHIRecipe>(&R);
797 HasUnsupportedPhi =
true;
806 HasUnsupportedPhi =
true;
821 VPValue *MinMaxOp = GetMinMaxCompareValue(RedPhiR);
827 "unsupported reduction");
838 auto *VPBB = cast<VPBasicBlock>(VPB);
839 for (
auto &R : *VPBB) {
840 if (R.mayWriteToMemory() &&
848 auto *LatchExitingBranch = cast<VPInstruction>(LatchVPBB->
getTerminator());
850 "Unexpected terminator");
851 auto *IsLatchExitTaken =
853 LatchExitingBranch->getOperand(1));
858 Builder.
createNaryOp(Instruction::Or, {AnyNaN, IsLatchExitTaken});
864 auto *RdxResult = find_singleton<VPSingleDefRecipe>(
866 auto *VPI = dyn_cast<VPInstruction>(U);
867 if (VPI && VPI->getOpcode() == VPInstruction::ComputeReductionResult)
882 for (
auto &R : ScalarPH->phis()) {
883 auto *ResumeR = cast<VPPhi>(&R);
884 VPValue *VecV = ResumeR->getOperand(0);
885 if (VecV == RdxResult)
887 if (
auto *DerivedIV = dyn_cast<VPDerivedIVRecipe>(VecV)) {
888 if (DerivedIV->getNumUsers() == 1 &&
893 DerivedIV->setOperand(1, NewSel);
900 LLVM_DEBUG(
dbgs() <<
"Found resume phi we cannot update for VPlan with "
901 "FMaxNum/FMinNum reduction.\n");
908 auto *MiddleTerm = MiddleVPBB->getTerminator();
910 VPValue *MiddleCond = MiddleTerm->getOperand(0);
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
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 std::pair< Value *, APInt > getMask(Value *WideMask, unsigned Factor, ElementCount LeafValueEC)
This file provides a LoopVectorizationPlanner class.
static constexpr uint32_t MinItersBypassWeights[]
static DebugLoc getDebugLoc(MachineBasicBlock::instr_iterator FirstMI, MachineBasicBlock::instr_iterator LastMI)
Return the first found DebugLoc that has a DILocation, given a range of instructions.
const SmallVectorImpl< MachineOperand > & Cond
static void createLoopRegion(VPlan &Plan, VPBlockBase *HeaderVPB)
Create a new VPRegionBlock for the loop starting at HeaderVPB.
static bool isHeaderBB(BasicBlock *BB, Loop *L)
static void addInitialSkeleton(VPlan &Plan, Type *InductionTy, DebugLoc IVDL, PredicatedScalarEvolution &PSE, Loop *TheLoop)
static void addCanonicalIVRecipes(VPlan &Plan, VPBasicBlock *HeaderVPBB, VPBasicBlock *LatchVPBB, Type *IdxTy, DebugLoc DL)
static bool canonicalHeaderAndLatch(VPBlockBase *HeaderVPB, const VPDominatorTree &VPDT)
Checks if HeaderVPB is a loop header block in the plain CFG; that is, it has exactly 2 predecessors (...
static constexpr uint32_t CheckBypassWeights[]
static void createExtractsForLiveOuts(VPlan &Plan, VPBasicBlock *MiddleVPBB)
Creates extracts for values in Plan defined in a loop region and used outside a loop region.
This file implements dominator tree analysis for a single level of a VPlan's H-CFG.
static std::optional< unsigned > getOpcode(ArrayRef< VPValue * > Values)
Returns the opcode of Values or ~0 if they do not all agree.
This file contains the declarations of the Vectorization Plan base classes:
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 Basic Block Representation.
LLVM_ABI iterator_range< filter_iterator< BasicBlock::const_iterator, std::function< bool(const Instruction &)> > > instructionsWithoutDebug(bool SkipPseudoOp=true) const
Return a const iterator range over the instructions in the block, skipping any debug instructions.
LLVM_ABI const BasicBlock * getSingleSuccessor() const
Return the successor of this block if it has a single successor.
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...
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
@ ICMP_ULT
unsigned less than
@ ICMP_ULE
unsigned less or equal
@ FCMP_UNO
1 0 0 0 True if unordered: isnan(X) | isnan(Y)
Predicate getInversePredicate() const
For example, EQ -> NE, UGT -> ULE, SLT -> SGE, OEQ -> UNE, UGT -> OLE, OLT -> UGE,...
static LLVM_ABI ConstantInt * getTrue(LLVMContext &Context)
This class represents an Operation in the Expression.
static DebugLoc getUnknown()
ValueT lookup(const_arg_type_t< KeyT > Val) const
lookup - Return the entry for the specified key, or a default constructed value if no such entry exis...
bool dominates(const DomTreeNodeBase< NodeT > *A, const DomTreeNodeBase< NodeT > *B) const
dominates - Returns true iff A dominates B.
void recalculate(ParentType &Func)
recalculate - compute a dominator tree for the given function
LLVM_ABI unsigned getNumSuccessors() const LLVM_READONLY
Return the number of successors that this instruction has.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
Wrapper class to LoopBlocksDFS that provides a standard begin()/end() interface for the DFS reverse p...
Represents a single loop in the control flow graph.
LLVM_ABI MDNode * createBranchWeights(uint32_t TrueWeight, uint32_t FalseWeight, bool IsExpected=false)
Return metadata containing two branch weights.
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.
LLVM_ABI const SCEV * getSymbolicMaxBackedgeTakenCount()
Get the (predicated) symbolic max backedge count for the analyzed loop.
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 * getUMaxExpr(const SCEV *LHS, const SCEV *RHS)
LLVM_ABI const SCEV * getTripCountFromExitCount(const SCEV *ExitCount)
A version of getTripCountFromExitCount below which always picks an evaluation type which can not resu...
LLVM_ABI const SCEV * getElementCount(Type *Ty, ElementCount EC, SCEV::NoWrapFlags Flags=SCEV::FlagAnyWrap)
LLVM_ABI const SCEV * applyLoopGuards(const SCEV *Expr, const Loop *L)
Try to apply information from loop guards for L to Expr.
LLVM_ABI bool isKnownPredicate(CmpPredicate Pred, const SCEV *LHS, const SCEV *RHS)
Test if the given expression is known to satisfy the condition described by Pred, LHS,...
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.
The instances of the Type class are immutable: once they are created, they are never changed.
static LLVM_ABI IntegerType * getInt1Ty(LLVMContext &C)
VPBasicBlock serves as the leaf of the Hierarchical Control-Flow Graph.
iterator begin()
Recipe iterator methods.
iterator_range< iterator > phis()
Returns an iterator range over the PHI-like recipes in the block.
iterator getFirstNonPhi()
Return the position of the first non-phi node recipe in the block.
VPRecipeBase * getTerminator()
If the block has multiple successors, return the branch recipe terminating the block.
const VPRecipeBase & back() const
void insert(VPRecipeBase *Recipe, iterator InsertPt)
VPBlockBase is the building block of the Hierarchical Control-Flow Graph.
void setSuccessors(ArrayRef< VPBlockBase * > NewSuccs)
Set each VPBasicBlock in NewSuccss as successor of this VPBlockBase.
const VPBasicBlock * getExitingBasicBlock() const
void setName(const Twine &newName)
void swapSuccessors()
Swap successors of the block. The block must have exactly 2 successors.
size_t getNumPredecessors() const
void setPredecessors(ArrayRef< VPBlockBase * > NewPreds)
Set each VPBasicBlock in NewPreds as predecessor of this VPBlockBase.
const VPBlocksTy & getPredecessors() const
void setTwoSuccessors(VPBlockBase *IfTrue, VPBlockBase *IfFalse)
Set two given VPBlockBases IfTrue and IfFalse to be the two successors of this VPBlockBase.
VPBlockBase * getSinglePredecessor() const
void swapPredecessors()
Swap predecessors of the block.
const VPBasicBlock * getEntryBasicBlock() const
void setOneSuccessor(VPBlockBase *Successor)
Set a given VPBlockBase Successor as the single successor of this VPBlockBase.
void setParent(VPRegionBlock *P)
VPBlockBase * getSingleSuccessor() const
const VPBlocksTy & getSuccessors() const
static void insertBlockAfter(VPBlockBase *NewBlock, VPBlockBase *BlockPtr)
Insert disconnected VPBlockBase NewBlock after BlockPtr.
static void insertOnEdge(VPBlockBase *From, VPBlockBase *To, VPBlockBase *BlockPtr)
Inserts BlockPtr on the edge between From and To.
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.
VPlan-based builder utility analogous to IRBuilder.
VPInstruction * createNot(VPValue *Operand, DebugLoc DL=DebugLoc::getUnknown(), const Twine &Name="")
VPInstruction * createSelect(VPValue *Cond, VPValue *TrueVal, VPValue *FalseVal, DebugLoc DL=DebugLoc::getUnknown(), const Twine &Name="", std::optional< FastMathFlags > FMFs=std::nullopt)
VPBasicBlock::iterator getInsertPoint() const
VPInstruction * createFCmp(CmpInst::Predicate Pred, VPValue *A, VPValue *B, DebugLoc DL=DebugLoc::getUnknown(), const Twine &Name="")
Create a new FCmp VPInstruction with predicate Pred and operands A and B.
VPInstruction * createOverflowingOp(unsigned Opcode, ArrayRef< VPValue * > Operands, VPRecipeWithIRFlags::WrapFlagsTy WrapFlags, DebugLoc DL=DebugLoc::getUnknown(), const Twine &Name="")
VPInstruction * createICmp(CmpInst::Predicate Pred, VPValue *A, VPValue *B, DebugLoc DL=DebugLoc::getUnknown(), const Twine &Name="")
Create a new ICmp VPInstruction with predicate Pred and operands A and B.
VPInstruction * createAnd(VPValue *LHS, VPValue *RHS, DebugLoc DL=DebugLoc::getUnknown(), const Twine &Name="")
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.
VPExpandSCEVRecipe * createExpandSCEV(const SCEV *Expr)
void setInsertPoint(VPBasicBlock *TheBB)
This specifies that created VPInstructions should be appended to the end of the specified block.
Canonical scalar induction phi of the vector loop.
Template specialization of the standard LLVM dominator tree utility for VPBlockBases.
A special type of VPBasicBlock that wraps an existing IR basic block.
This is a concrete Recipe that models a single VPlan-level instruction.
VPRecipeBase is a base class modeling a sequence of one or more output IR instructions.
DebugLoc getDebugLoc() const
Returns the debug location of the recipe.
iplist< VPRecipeBase >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
void moveAfter(VPRecipeBase *MovePos)
Unlink this recipe from its current VPBasicBlock and insert it into the VPBasicBlock that MovePos liv...
A recipe for handling reduction phis.
RecurKind getRecurrenceKind() const
Returns the recurrence kind of the reduction.
VPRegionBlock represents a collection of VPBasicBlocks and VPRegionBlocks which form a Single-Entry-S...
VPSingleDef is a base class for recipes for modeling a sequence of one or more output IR that define ...
This class augments VPValue with operands which provide the inverse def-use edges from VPValue's user...
void setOperand(unsigned I, VPValue *New)
VPValue * getOperand(unsigned N) const
void addOperand(VPValue *Operand)
void setUnderlyingValue(Value *Val)
VPlan models a candidate for vectorization, encoding various decisions take to produce efficient outp...
LLVMContext & getContext() const
VPBasicBlock * getEntry()
VPRegionBlock * createVPRegionBlock(VPBlockBase *Entry, VPBlockBase *Exiting, const std::string &Name="", bool IsReplicator=false)
Create a new VPRegionBlock with Entry, Exiting and Name.
VPValue & getVectorTripCount()
The vector trip count.
VPValue & getVFxUF()
Returns VF * UF of the vector loop region.
VPValue * getTripCount() const
The trip count of the original loop.
VPValue * getTrue()
Return a VPValue wrapping i1 true.
ArrayRef< VPIRBasicBlock * > getExitBlocks() const
Return an ArrayRef containing VPIRBasicBlocks wrapping the exit blocks of the original scalar loop.
LLVM_ABI_FOR_TEST VPRegionBlock * getVectorLoopRegion()
Returns the VPRegionBlock of the vector loop.
void setTripCount(VPValue *NewTripCount)
Set the trip count assuming it is currently null; if it is not - use resetTripCount().
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.
LLVM_ABI_FOR_TEST VPIRBasicBlock * createVPIRBasicBlock(BasicBlock *IRBB)
Create a VPIRBasicBlock from IRBB containing VPIRInstructions for all instructions in IRBB,...
VPValue * getFalse()
Return a VPValue wrapping i1 false.
VPValue * getOrAddLiveIn(Value *V)
Gets the live-in VPValue for V or adds a new live-in (if none exists yet) for V.
VPBasicBlock * getScalarPreheader() const
Return the VPBasicBlock for the preheader of the scalar loop.
VPCanonicalIVPHIRecipe * getCanonicalIV()
Returns the canonical induction recipe of the vector loop.
VPIRBasicBlock * getScalarHeader() const
Return the VPIRBasicBlock wrapping the header of the scalar loop.
VPBasicBlock * getVectorPreheader()
Returns the preheader of the vector loop region, if one exists, or null otherwise.
bool hasScalarTail() const
Returns true if the scalar tail may execute after the vector loop.
LLVM Value Representation.
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
constexpr ScalarTy getKnownMinValue() const
Returns the minimum value this quantity can represent.
bool match(Val *V, const Pattern &P)
VPInstruction_match< VPInstruction::BranchOnCount, Op0_t, Op1_t > m_BranchOnCount(const Op0_t &Op0, const Op1_t &Op1)
class_match< VPValue > m_VPValue()
Match an arbitrary VPValue and ignore it.
VPInstruction_match< VPInstruction::BranchOnCond, Op0_t > m_BranchOnCond(const Op0_t &Op0)
NodeAddr< PhiNode * > Phi
VPValue * getOrCreateVPValueForSCEVExpr(VPlan &Plan, const SCEV *Expr)
Get or create a VPValue that corresponds to the expansion of Expr.
const SCEV * getSCEVExprForVPValue(VPValue *V, ScalarEvolution &SE)
Return the SCEV expression for V.
This is an optimization pass for GlobalISel generic memory operations.
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.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
auto succ_size(const MachineBasicBlock *BB)
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...
iterator_range< po_iterator< VPBlockShallowTraversalWrapper< VPBlockBase * > > > vp_post_order_shallow(VPBlockBase *G)
Returns an iterator range to traverse the graph starting at G in post order.
RecurKind
These are the kinds of recurrences that we support.
@ FMaxNum
FP max with llvm.maxnum semantics including NaNs.
@ FMinNum
FP min with llvm.minnum semantics including NaNs.
auto predecessors(const MachineBasicBlock *BB)
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.