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 {
320
320
std::swap (Successors[0 ], Successors[1 ]);
321
321
}
322
322
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
+
323
337
// / The method which generates the output IR that correspond to this
324
338
// / VPBlockBase, thereby "executing" the VPlan.
325
339
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) {
1852
1852
continue ;
1853
1853
1854
1854
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);
1859
1856
1860
1857
// Values coming from VPBB into ResumePhi recipes of RemoveSucc are removed
1861
1858
// from these recipes.
Original file line number Diff line number Diff line change @@ -232,13 +232,8 @@ class VPBlockUtils {
232
232
// / single edge between \p From and \p To.
233
233
static void insertOnEdge (VPBlockBase *From, VPBlockBase *To,
234
234
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);
242
237
VPBlockUtils::connectBlocks (From, BlockPtr, -1 , SuccIdx);
243
238
VPBlockUtils::connectBlocks (BlockPtr, To, PredIx, -1 );
244
239
}
You can’t perform that action at this time.
0 commit comments