File tree Expand file tree Collapse file tree 3 files changed +17
-11
lines changed
llvm/lib/Transforms/Vectorize Expand file tree Collapse file tree 3 files changed +17
-11
lines changed Original file line number Diff line number Diff line change @@ -320,6 +320,20 @@ class VPBlockBase {
320320 std::swap (Successors[0 ], Successors[1 ]);
321321 }
322322
323+ // / Returns the index for \p Pred in the blocks predecessors list.
324+ unsigned getIndexForPredecessor (const VPBlockBase *Pred) const {
325+ assert (count (Predecessors, Pred) == 1 &&
326+ " must have Pred exactly once in Predecessors" );
327+ return std::distance (Predecessors.begin (), find (Predecessors, Pred));
328+ }
329+
330+ // / Returns the index for \p Succ in the blocks successor list.
331+ unsigned getIndexForSuccessor (const VPBlockBase *Succ) const {
332+ assert (count (Successors, Succ) == 1 &&
333+ " must have Succ exactly once in Successors" );
334+ return std::distance (Successors.begin (), find (Successors, Succ));
335+ }
336+
323337 // / The method which generates the output IR that correspond to this
324338 // / VPBlockBase, thereby "executing" the VPlan.
325339 virtual void execute (VPTransformState *State) = 0;
Original file line number Diff line number Diff line change @@ -1852,10 +1852,7 @@ static void removeBranchOnCondTrue(VPlan &Plan) {
18521852 continue ;
18531853
18541854 VPBasicBlock *RemovedSucc = cast<VPBasicBlock>(VPBB->getSuccessors ()[1 ]);
1855- const auto &Preds = RemovedSucc->getPredecessors ();
1856- assert (count (Preds, VPBB) == 1 &&
1857- " There must be a single edge between VPBB and its successor" );
1858- unsigned DeadIdx = std::distance (Preds.begin (), find (Preds, VPBB));
1855+ unsigned DeadIdx = RemovedSucc->getIndexForPredecessor (VPBB);
18591856
18601857 // Values coming from VPBB into ResumePhi recipes of RemoveSucc are removed
18611858 // from these recipes.
Original file line number Diff line number Diff line change @@ -232,13 +232,8 @@ class VPBlockUtils {
232232 // / single edge between \p From and \p To.
233233 static void insertOnEdge (VPBlockBase *From, VPBlockBase *To,
234234 VPBlockBase *BlockPtr) {
235- auto &Successors = From->getSuccessors ();
236- auto &Predecessors = To->getPredecessors ();
237- assert (count (Successors, To) == 1 && count (Predecessors, From) == 1 &&
238- " must have single between From and To" );
239- unsigned SuccIdx = std::distance (Successors.begin (), find (Successors, To));
240- unsigned PredIx =
241- std::distance (Predecessors.begin (), find (Predecessors, From));
235+ unsigned SuccIdx = From->getIndexForSuccessor (To);
236+ unsigned PredIx = To->getIndexForPredecessor (From);
242237 VPBlockUtils::connectBlocks (From, BlockPtr, -1 , SuccIdx);
243238 VPBlockUtils::connectBlocks (BlockPtr, To, PredIx, -1 );
244239 }
You can’t perform that action at this time.
0 commit comments