26#define DEBUG_TYPE "vplan"
33class PlainCFGBuilder {
41 std::unique_ptr<VPlan> Plan;
62 bool isExternalDef(
Value *Val);
69 : TheLoop(Lp), LI(LI), Plan(std::make_unique<VPlan>(Lp)) {}
72 std::unique_ptr<VPlan> buildPlainCFG();
82 VPBBPreds.
push_back(getOrCreateVPBB(Pred));
87 return L && BB == L->getHeader();
91void PlainCFGBuilder::fixHeaderPhis() {
92 for (
auto *Phi : PhisToFix) {
93 assert(IRDef2VPValue.
count(Phi) &&
"Missing VPInstruction for PHINode.");
94 VPValue *VPVal = IRDef2VPValue[
Phi];
97 assert(PhiR->getNumOperands() == 0 &&
"Expected VPPhi with no operands.");
99 "Expected Phi in header block.");
101 "header phi must have exactly 2 operands");
104 getOrCreateVPOperand(
Phi->getIncomingValueForBlock(Pred)));
110VPBasicBlock *PlainCFGBuilder::getOrCreateVPBB(BasicBlock *BB) {
111 if (
auto *VPBB = BB2VPBB.lookup(BB)) {
118 LLVM_DEBUG(
dbgs() <<
"Creating VPBasicBlock for " << Name <<
"\n");
119 VPBasicBlock *VPBB = Plan->createVPBasicBlock(Name);
130bool PlainCFGBuilder::isExternalDef(
Value *Val) {
146VPValue *PlainCFGBuilder::getOrCreateVPOperand(
Value *IRVal) {
147 auto VPValIt = IRDef2VPValue.
find(IRVal);
148 if (VPValIt != IRDef2VPValue.
end())
151 return VPValIt->second;
160 assert(isExternalDef(IRVal) &&
"Expected external definition as operand.");
164 VPValue *NewVPVal = Plan->getOrAddLiveIn(IRVal);
165 IRDef2VPValue[IRVal] = NewVPVal;
172void PlainCFGBuilder::createVPInstructionsForVPBB(VPBasicBlock *VPBB,
182 "Instruction shouldn't have been visited.");
187 if (Br->isConditional()) {
188 VPValue *
Cond = getOrCreateVPOperand(Br->getCondition());
198 if (
SI->getNumCases() == 0)
201 for (
auto Case :
SI->cases())
202 Ops.push_back(getOrCreateVPOperand(Case.getCaseValue()));
207 VPSingleDefRecipe *NewR;
217 PhisToFix.push_back(Phi);
221 DenseMap<const VPBasicBlock *, VPValue *> VPPredToIncomingValue;
222 for (
unsigned I = 0;
I !=
Phi->getNumOperands(); ++
I) {
223 VPPredToIncomingValue[BB2VPBB[
Phi->getIncomingBlock(
I)]] =
224 getOrCreateVPOperand(
Phi->getIncomingValue(
I));
228 VPPredToIncomingValue.
lookup(Pred->getExitingBasicBlock()));
239 CI->getType(), CI->getDebugLoc());
248 IRDef2VPValue[Inst] = NewR;
253std::unique_ptr<VPlan> PlainCFGBuilder::buildPlainCFG() {
256 for (VPIRBasicBlock *ExitVPBB : Plan->getExitBlocks())
257 BB2VPBB[ExitVPBB->getIRBasicBlock()] = ExitVPBB;
270 "Unexpected loop preheader");
271 for (
auto &
I : *ThePreheaderBB) {
272 if (
I.getType()->isVoidTy())
274 IRDef2VPValue[&
I] = Plan->getOrAddLiveIn(&
I);
277 LoopBlocksRPO RPO(TheLoop);
280 for (BasicBlock *BB : RPO) {
282 VPBasicBlock *VPBB = getOrCreateVPBB(BB);
284 setVPBBPredsFromBB(VPBB, BB);
287 createVPInstructionsForVPBB(VPBB, BB);
294 getOrCreateVPBB(
SI->getDefaultDest())};
295 for (
auto Case :
SI->cases())
296 Succs.
push_back(getOrCreateVPBB(Case.getCaseSuccessor()));
306 assert(BI->isConditional() && NumSuccs == 2 && BI->isConditional() &&
307 "block must have conditional branch with 2 successors");
311 VPBasicBlock *Successor0 = getOrCreateVPBB(IRSucc0);
312 VPBasicBlock *Successor1 = getOrCreateVPBB(IRSucc1);
316 for (
auto *EB : Plan->getExitBlocks())
317 setVPBBPredsFromBB(EB, EB->getIRBasicBlock());
324 Plan->getEntry()->setOneSuccessor(getOrCreateVPBB(TheLoop->
getHeader()));
325 Plan->getEntry()->setPlan(&*Plan);
332 for (
auto *EB : Plan->getExitBlocks()) {
333 for (VPRecipeBase &R : EB->phis()) {
335 PHINode &
Phi = PhiR->getIRPhi();
336 assert(PhiR->getNumOperands() == 0 &&
337 "no phi operands should be added yet");
338 for (BasicBlock *Pred :
predecessors(EB->getIRBasicBlock()))
340 getOrCreateVPOperand(
Phi.getIncomingValueForBlock(Pred)));
345 return std::move(Plan);
358 if (Preds.
size() != 2)
361 auto *PreheaderVPBB = Preds[0];
362 auto *LatchVPBB = Preds[1];
363 if (!VPDT.
dominates(PreheaderVPBB, HeaderVPB) ||
367 if (!VPDT.
dominates(PreheaderVPBB, HeaderVPB) ||
384 if (LatchVPBB->getSingleSuccessor() ||
385 LatchVPBB->getSuccessors()[0] != HeaderVPB)
388 assert(LatchVPBB->getNumSuccessors() == 2 &&
"Must have 2 successors");
392 "terminator must be a BranchOnCond");
394 Not->insertBefore(Term);
395 Term->setOperand(0, Not);
396 LatchVPBB->swapSuccessors();
409 assert(LatchExitVPB &&
"Latch expected to be left with a single successor");
419 R->setEntry(HeaderVPB);
420 R->setExiting(LatchVPBB);
432 Value *StartIdx = ConstantInt::get(IdxTy, 0);
437 HeaderVPBB->
insert(CanonicalIVPHI, HeaderVPBB->
begin());
451 auto *CanonicalIVIncrement = Builder.createOverflowingOp(
452 Instruction::Add, {CanonicalIVPHI, &Plan.
getVFxUF()}, {
true,
false},
DL,
454 CanonicalIVPHI->addOperand(CanonicalIVIncrement);
467 if (EB->getSinglePredecessor() != MiddleVPBB)
472 for (
unsigned Idx = 0; Idx != ExitIRI->getNumIncoming(); ++Idx) {
473 VPRecipeBase *Inc = ExitIRI->getIncomingValue(Idx)->getDefiningRecipe();
476 assert(ExitIRI->getNumOperands() == 1 &&
477 ExitIRI->getParent()->getSinglePredecessor() == MiddleVPBB &&
478 "exit values from early exits must be fixed when branch to "
479 "early-exit is added");
480 ExitIRI->extractLastLaneOfFirstOperand(
B);
502 if (LatchVPBB->getNumSuccessors() == 2) {
507 LatchVPBB->swapSuccessors();
517 "Invalid backedge-taken count");
520 InductionTy, TheLoop);
538std::unique_ptr<VPlan>
541 PlainCFGBuilder Builder(TheLoop, &LI);
542 std::unique_ptr<VPlan> VPlan0 = Builder.buildPlainCFG();
548 bool HasUncountableEarlyExit) {
559 [[maybe_unused]]
bool HandledUncountableEarlyExit =
false;
562 if (Pred == MiddleVPBB)
564 if (HasUncountableEarlyExit) {
565 assert(!HandledUncountableEarlyExit &&
566 "can handle exactly one uncountable early exit");
569 HandledUncountableEarlyExit =
true;
579 assert((!HasUncountableEarlyExit || HandledUncountableEarlyExit) &&
580 "missed an uncountable exit that must be handled");
584 bool RequiresScalarEpilogueCheck,
591 if (MiddleVPBB->getNumSuccessors() == 1) {
593 "must have ScalarPH as single successor");
597 assert(MiddleVPBB->getNumSuccessors() == 2 &&
"must have 2 successors");
615 DebugLoc LatchDL = LatchVPBB->getTerminator()->getDebugLoc();
618 if (!RequiresScalarEpilogueCheck)
635 TopRegion->
setName(
"vector loop");
645 bool AddBranchWeights) {
661 "must have incoming values for all operands");
662 R.addOperand(R.getOperand(NumPredecessors - 2));
671 if (AddBranchWeights) {
675 Term->addMetadata(LLVMContext::MD_prof, BranchWeights);
681 ElementCount MinProfitableTripCount,
bool RequiresScalarEpilogue,
682 bool TailFolded,
bool CheckNeededWithTailFolding,
Loop *OrigLoop,
695 auto GetMinTripCount = [&]() ->
const SCEV * {
704 const SCEV *MinProfitableTripCountSCEV =
706 return SE.
getUMaxExpr(MinProfitableTripCountSCEV, VFxUF);
712 const SCEV *Step = GetMinTripCount();
714 if (CheckNeededWithTailFolding) {
722 VPValue *DistanceToMax = Builder.createNaryOp(
723 Instruction::Sub, {MaxUIntTripCount, TripCountVPV},
730 Builder.createExpandSCEV(Step),
DL);
743 TripCountCheck = Plan.
getTrue();
748 VPValue *MinTripCountVPV = Builder.createExpandSCEV(Step);
749 TripCountCheck = Builder.createICmp(
750 CmpPred, TripCountVPV, MinTripCountVPV,
DL,
"min.iters.check");
759 Term->addMetadata(LLVMContext::MD_prof, BranchWeights);
765 bool RequiresScalarEpilogue,
ElementCount EpilogueVF,
unsigned EpilogueUF,
766 unsigned MainLoopStep,
unsigned EpilogueLoopStep,
ScalarEvolution &SE) {
779 auto *CheckMinIters = Builder.createICmp(
790 unsigned EstimatedSkipCount = std::min(MainLoopStep, EpilogueLoopStep);
791 const uint32_t Weights[] = {EstimatedSkipCount,
792 MainLoopStep - EstimatedSkipCount};
796 Branch->addMetadata(LLVMContext::MD_prof, BranchWeights);
802 RedPhiR->getBackedgeValue()->getDefiningRecipe());
819 ->getIntrinsicID() == RdxIntrinsicId)) &&
820 "Intrinsic did not match recurrence kind");
823 if (MinMaxR->getOperand(0) == RedPhiR)
824 return MinMaxR->getOperand(1);
826 assert(MinMaxR->getOperand(1) == RedPhiR &&
827 "Reduction phi operand expected");
828 return MinMaxR->getOperand(0);
833 MinMaxNumReductionsToHandle;
834 bool HasUnsupportedPhi =
false;
841 HasUnsupportedPhi =
true;
845 Cur->getRecurrenceKind())) {
846 HasUnsupportedPhi =
true;
850 VPValue *MinMaxOp = GetMinMaxCompareValue(Cur);
854 MinMaxNumReductionsToHandle.
emplace_back(Cur, MinMaxOp);
857 if (MinMaxNumReductionsToHandle.
empty())
875 for (
auto &R : *VPBB) {
883 VPValue *AllNaNLanes =
nullptr;
885 for (
const auto &[
_, MinMaxOp] : MinMaxNumReductionsToHandle) {
888 AllNaNLanes = AllNaNLanes ? LatchBuilder.
createOr(AllNaNLanes, RedNaNLanes)
896 for (
const auto &[RedPhiR,
_] : MinMaxNumReductionsToHandle) {
898 RedPhiR->getRecurrenceKind()) &&
899 "unsupported reduction");
905 auto *VPI = dyn_cast<VPInstruction>(U);
906 if (VPI && VPI->getOpcode() == VPInstruction::ComputeReductionResult)
911 auto *NewSel = MiddleBuilder.
createSelect(AnyNaNLane, RedPhiR,
912 RdxResult->getOperand(1));
914 assert(!RdxResults.
contains(RdxResult) &&
"RdxResult already used");
915 RdxResults.
insert(RdxResult);
920 "Unexpected terminator");
921 auto *IsLatchExitTaken = LatchBuilder.
createICmp(
923 LatchExitingBranch->getOperand(1));
925 Instruction::Or, {AnyNaNLane, IsLatchExitTaken});
934 VPValue *VecV = ResumeR->getOperand(0);
938 if (DerivedIV->getNumUsers() == 1 &&
944 DerivedIV->setOperand(1, NewSel);
951 LLVM_DEBUG(
dbgs() <<
"Found resume phi we cannot update for VPlan with "
952 "FMaxNum/FMinNum reduction.\n");
962 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")
static std::pair< Value *, APInt > getMask(Value *WideMask, unsigned Factor, ElementCount LeafValueEC)
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
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 DebugLoc that has line number information, 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 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...
iterator find(const_arg_type_t< KeyT > Val)
size_type count(const_arg_type_t< KeyT > Val) const
Return 1 if the specified key is in the map, 0 otherwise.
bool dominates(const DomTreeNodeBase< NodeT > *A, const DomTreeNodeBase< NodeT > *B) const
dominates - Returns true iff A dominates B.
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.
bool contains(const LoopT *L) const
Return true if the specified loop is contained within in this loop.
BlockT * getHeader() const
BlockT * getLoopPreheader() const
If there is a preheader for this loop, return it.
LoopT * getLoopFor(const BlockT *BB) const
Return the inner most loop that BB lives in.
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.
static bool isFPMinMaxNumRecurrenceKind(RecurKind Kind)
Returns true if the recurrence kind is a floating-point minnum/maxnum kind.
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,...
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.
The instances of the Type class are immutable: once they are created, they are never changed.
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 * createOr(VPValue *LHS, VPValue *RHS, DebugLoc DL=DebugLoc::getUnknown(), const Twine &Name="")
VPInstruction * createScalarCast(Instruction::CastOps Opcode, VPValue *Op, Type *ResultTy, DebugLoc DL, const VPIRFlags &Flags={}, const VPIRMetadata &Metadata={})
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.
VPPhi * createScalarPhi(ArrayRef< VPValue * > IncomingValues, DebugLoc DL, 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.
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.
VPRegionBlock represents a collection of VPBasicBlocks and VPRegionBlocks which form a Single-Entry-S...
VPCanonicalIVPHIRecipe * getCanonicalIV()
Returns the canonical induction recipe of the region.
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)
void addOperand(VPValue *Operand)
This is the base class of the VPlan Def/Use graph, used for modeling the data flow into,...
void setUnderlyingValue(Value *Val)
VPlan models a candidate for vectorization, encoding various decisions take to produce efficient outp...
LLVMContext & getContext() const
VPBasicBlock * getEntry()
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.
VPValue * getConstantInt(Type *Ty, uint64_t Val, bool IsSigned=false)
Return a VPValue wrapping a ConstantInt with the given type and value.
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.
VPRegionBlock * createLoopRegion(const std::string &Name="", VPBlockBase *Entry=nullptr, VPBlockBase *Exiting=nullptr)
Create a new loop region with Name and entry and exiting blocks set to Entry and Exiting respectively...
VPBasicBlock * getScalarPreheader() const
Return the VPBasicBlock for the preheader of the scalar 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.
Type * getType() const
All values are typed, get the type of this value.
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.
@ BasicBlock
Various leaf nodes.
bool match(Val *V, const Pattern &P)
VPInstruction_match< VPInstruction::BranchOnCount > m_BranchOnCount()
class_match< VPValue > m_VPValue()
Match an arbitrary VPValue and ignore it.
VPInstruction_match< VPInstruction::BranchOnCond > m_BranchOnCond()
NodeAddr< PhiNode * > Phi
friend class Instruction
Iterator for Instructions in a `BasicBlock.
VPValue * getOrCreateVPValueForSCEVExpr(VPlan &Plan, const SCEV *Expr)
Get or create a VPValue that corresponds to the expansion of Expr.
const SCEV * getSCEVExprForVPValue(const VPValue *V, ScalarEvolution &SE, const Loop *L=nullptr)
Return the SCEV expression for V.
This is an optimization pass for GlobalISel generic memory operations.
FunctionAddr VTableAddr Value
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
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.
FunctionAddr VTableAddr Count
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...
T * find_singleton(R &&Range, Predicate P, bool AllowRepeats=false)
Return the single value in Range that satisfies P(<member of Range> *, AllowRepeats)->T * returning n...
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
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.
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...
@ FMaxNum
FP max with llvm.maxnum semantics including NaNs.
DWARFExpression::Operation Op
ArrayRef(const T &OneElt) -> ArrayRef< T >
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
auto predecessors(const MachineBasicBlock *BB)
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.