9#ifndef LLVM_TRANSFORMS_VECTORIZE_VPLANUTILS_H
10#define LLVM_TRANSFORMS_VECTORIZE_VPLANUTILS_H
46 if (
auto *Rep = dyn_cast<VPReplicateRecipe>(VPV))
47 return Rep->isUniform();
48 if (isa<VPWidenGEPRecipe, VPDerivedIVRecipe>(VPV))
51 if (
auto *VPI = dyn_cast<VPInstruction>(VPV))
52 return VPI->isSingleScalar() || VPI->isVectorToScalar() ||
56 if (
auto *
IV = dyn_cast<VPDerivedIVRecipe>(VPV))
60 return isa<VPExpandSCEVRecipe>(VPV);
91 "Can't insert new block with predecessors or successors.");
108 "Can't insert new block with predecessors or successors.");
126 "Can't insert IfTrue with successors.");
128 "Can't insert IfFalse with successors.");
143 unsigned PredIdx = -1u,
unsigned SuccIdx = -1u) {
145 "Can't connect two block with different parents");
146 assert((SuccIdx != -1u ||
From->getNumSuccessors() < 2) &&
147 "Blocks can't have more than two successors.");
149 From->appendSuccessor(To);
151 From->getSuccessors()[SuccIdx] = To;
154 To->appendPredecessor(
From);
162 assert(To &&
"Successor to disconnect is null.");
163 From->removeSuccessor(To);
164 To->removePredecessor(
From);
171 Pred->replaceSuccessor(Old, New);
173 Succ->replacePredecessor(Old, New);
182 template <
typename BlockTy,
typename T>
185 using BaseTy = std::conditional_t<std::is_const<BlockTy>::value,
195 return cast<BlockTy>(&
Block);
206 auto &Successors =
From->getSuccessors();
209 "must have single between From and To");
210 unsigned SuccIdx = std::distance(Successors.begin(),
find(Successors, To));
212 std::distance(Predecessors.begin(),
find(Predecessors,
From));
BlockVerifier::State From
std::pair< BasicBlock *, unsigned > BlockTy
A pair of (basic block, score).
ConstantRange Range(APInt(BitWidth, Low), APInt(BitWidth, High))
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file contains the declarations of the Vectorization Plan base classes:
static const uint32_t IV[8]
This class represents an analyzed expression in the program.
The main scalar evolution driver.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
VPBlockBase is the building block of the Hierarchical Control-Flow Graph.
VPRegionBlock * getParent()
iterator_range< VPBlockBase ** > predecessors()
iterator_range< VPBlockBase ** > successors()
void setPredecessors(ArrayRef< VPBlockBase * > NewPreds)
Set each VPBasicBlock in NewPreds as predecessor of this VPBlockBase.
const VPBlocksTy & getPredecessors() const
void clearSuccessors()
Remove all the successors of this block.
void setTwoSuccessors(VPBlockBase *IfTrue, VPBlockBase *IfFalse)
Set two given VPBlockBases IfTrue and IfFalse to be the two successors of this VPBlockBase.
void clearPredecessors()
Remove all the predecessor of this block.
void setParent(VPRegionBlock *P)
const VPBlocksTy & getSuccessors() const
Class that provides utilities for VPBlockBases in VPlan.
static auto blocksOnly(const T &Range)
Return an iterator range over Range which only includes BlockTy blocks.
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 insertTwoBlocksAfter(VPBlockBase *IfTrue, VPBlockBase *IfFalse, VPBlockBase *BlockPtr)
Insert disconnected VPBlockBases IfTrue and IfFalse after BlockPtr.
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 void reassociateBlocks(VPBlockBase *Old, VPBlockBase *New)
Reassociate all the blocks connected to Old so that they now point to New.
static void insertBlockBefore(VPBlockBase *NewBlock, VPBlockBase *BlockPtr)
Insert disconnected block NewBlock before Blockptr.
bool isDefinedOutsideLoopRegions() const
Returns true if the VPValue is defined outside any loop region.
VPRecipeBase * getDefiningRecipe()
Returns the recipe defining this VPValue or nullptr if it is not defined by a recipe,...
VPlan models a candidate for vectorization, encoding various decisions take to produce efficient outp...
bool isUniformAfterVectorization(const VPValue *VPV)
Returns true if VPV is uniform after vectorization.
VPValue * getOrCreateVPValueForSCEVExpr(VPlan &Plan, const SCEV *Expr, ScalarEvolution &SE)
Get or create a VPValue that corresponds to the expansion of Expr.
bool isUniformAcrossVFsAndUFs(VPValue *V)
Checks if V is uniform across all VF lanes and UF parts.
bool onlyFirstPartUsed(const VPValue *Def)
Returns true if only the first part of Def is used.
const SCEV * getSCEVExprForVPValue(VPValue *V, ScalarEvolution &SE)
Return the SCEV expression for V.
bool onlyFirstLaneUsed(const VPValue *Def)
Returns true if only the first lane of Def is used.
bool isHeaderMask(const VPValue *V, VPlan &Plan)
Return true if V is a header mask in Plan.
This is an optimization pass for GlobalISel generic memory operations.
auto find(R &&Range, const T &Val)
Provide wrappers to std::find which take ranges instead of having to pass begin/end explicitly.
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
auto map_range(ContainerTy &&C, FuncTy F)
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< filter_iterator< detail::IterOfRange< RangeT >, PredicateT > > make_filter_range(RangeT &&Range, PredicateT Pred)
Convenience function that takes a range of elements and a predicate, and return a new filter_iterator...
auto count(R &&Range, const E &Element)
Wrapper function around std::count to count the number of times an element Element occurs in the give...