23 #define DEBUG_TYPE "VPlanPredicator" 43 EdgeType ET = getEdgeTypeBetween(PredBB, CurrBB);
44 VPValue *IntermediateVal =
nullptr;
46 case EdgeType::TRUE_EDGE:
48 IntermediateVal = CBV;
51 case EdgeType::FALSE_EDGE:
60 return Builder.
createAnd(BP, IntermediateVal);
62 return IntermediateVal;
85 VPValue *VPlanPredicator::genPredicateTree(std::list<VPValue *> &Worklist) {
91 while (Worklist.size() >= 2) {
93 VPValue *LHS = Worklist.front();
95 VPValue *RHS = Worklist.front();
102 Worklist.push_back(Or);
105 assert(Worklist.size() == 1 &&
"Expected 1 item in worklist");
108 VPValue *Root = Worklist.front();
116 VPlanPredicator::EdgeType
117 VPlanPredicator::getEdgeTypeBetween(
VPBlockBase *FromBlock,
121 if (SuccBlock == ToBlock) {
122 assert(Count < 2 &&
"Switch not supported currently");
123 return (Count == 0) ? EdgeType::TRUE_EDGE : EdgeType::FALSE_EDGE;
133 void VPlanPredicator::createOrPropagatePredicates(
VPBlockBase *CurrBlock,
144 std::list<VPValue *> IncomingPredicates;
159 VPValue *IncomingPredicate =
nullptr;
160 unsigned NumPredSuccsNoBE =
165 if (NumPredSuccsNoBE == 1)
166 IncomingPredicate = PredBlock->getPredicate();
167 else if (NumPredSuccsNoBE == 2) {
169 assert(isa<VPBasicBlock>(PredBlock) &&
"Only BBs have multiple exits");
171 getOrCreateNotPredicate(cast<VPBasicBlock>(PredBlock), CurrBB);
175 if (IncomingPredicate)
176 IncomingPredicates.push_back(IncomingPredicate);
187 void VPlanPredicator::predicateRegionRec(
VPRegionBlock *Region) {
196 assert(!isa<VPRegionBlock>(Block) &&
"Nested region not expected");
197 createOrPropagatePredicates(Block, Region);
207 void VPlanPredicator::linearizeRegionRec(
VPRegionBlock *Region) {
213 assert(!isa<VPRegionBlock>(CurrBlock) &&
"Nested region not expected");
221 LLVM_DEBUG(
dbgs() <<
"Linearizing: " << PrevBlock->getName() <<
"->" 222 << CurrBlock->
getName() <<
"\n");
224 PrevBlock->clearSuccessors();
229 PrevBlock = CurrBlock;
236 predicateRegionRec(cast<VPRegionBlock>(Plan.
getEntry()));
239 linearizeRegionRec(cast<VPRegionBlock>(Plan.
getEntry()));
243 : Plan(Plan), VPLI(&(Plan.getVPLoopInfo())) {
const std::string & getName() const
This class represents lattice values for constants.
VPlan models a candidate for vectorization, encoding various decisions take to produce efficient outp...
static bool isBackEdge(const VPBlockBase *FromBlock, const VPBlockBase *ToBlock, const VPLoopInfo *VPLI)
Returns true if the edge FromBlock -> ToBlock is a back-edge.
void recalculate(ParentType &Func)
recalculate - compute a dominator tree for the given function
VPRegionBlock represents a collection of VPBasicBlocks and VPRegionBlocks which form a Single-Entry-S...
void setPredicate(VPValue *Pred)
void clearPredecessors()
Remove all the predecessor of this block.
VPValue * createNot(VPValue *Operand)
const VPBasicBlock * getEntryBasicBlock() const
static unsigned countSuccessorsNoBE(VPBlockBase *PredBlock, VPLoopInfo *VPLI)
Count and return the number of succesors of PredBlock excluding any backedges.
const VPBlockBase * getExit() const
iterator begin()
Recipe iterator methods.
This file contains the declarations of the Vectorization Plan base classes:
void predicate(void)
Predicate Plan's HCFG.
static void connectBlocks(VPBlockBase *From, VPBlockBase *To)
Connect VPBlockBases From and To bi-directionally.
VPBasicBlock serves as the leaf of the Hierarchical Control-Flow Graph.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
static bool blockIsLoopLatch(const VPBlockBase *Block, const VPLoopInfo *VPLInfo)
Returns true if Block is a loop latch.
This file defines the VPlanPredicator class which contains the public interfaces to predicate and lin...
VPlanPredicator(VPlan &Plan)
VPBlockBase is the building block of the Hierarchical Control-Flow Graph.
const VPBlocksTy & getSuccessors() const
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
const VPBlockBase * getEntry() const
VPValue * createOr(VPValue *LHS, VPValue *RHS)
bool isLoopHeader(const BlockT *BB) const
bool dominates(const DomTreeNodeBase< NodeT > *A, const DomTreeNodeBase< NodeT > *B) const
dominates - Returns true iff A dominates B.
const VPBlocksTy & getPredecessors() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
VPValue * createAnd(VPValue *LHS, VPValue *RHS)
void setInsertPoint(VPBasicBlock *TheBB)
This specifies that created VPInstructions should be appended to the end of the specified block...