File tree Expand file tree Collapse file tree 2 files changed +11
-9
lines changed
llvm/lib/Transforms/Vectorize Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -843,15 +843,14 @@ void VPRegionBlock::dissolveToCFGLoop() {
843843
844844 VPBlockBase *Preheader = getSinglePredecessor ();
845845 auto *ExitingLatch = cast<VPBasicBlock>(getExiting ());
846- VPBlockBase *Middle = getSingleSuccessor ();
846+
847847 VPBlockUtils::disconnectBlocks (Preheader, this );
848- VPBlockUtils::disconnectBlocks (this , Middle);
849848
850849 for (VPBlockBase *VPB : vp_depth_first_shallow (Entry))
851850 VPB->setParent (getParent ());
852851
853852 VPBlockUtils::connectBlocks (Preheader, Header);
854- VPBlockUtils::connectBlocks (ExitingLatch, Middle );
853+ VPBlockUtils::transferSuccessors ( this , ExitingLatch );
855854 VPBlockUtils::connectBlocks (ExitingLatch, Header);
856855}
857856
Original file line number Diff line number Diff line change @@ -116,12 +116,7 @@ class VPBlockUtils {
116116 NewBlock->getPredecessors ().empty () &&
117117 " Can't insert new block with predecessors or successors." );
118118 NewBlock->setParent (BlockPtr->getParent ());
119- SmallVector<VPBlockBase *> Succs (BlockPtr->successors ());
120- for (VPBlockBase *Succ : Succs) {
121- Succ->replacePredecessor (BlockPtr, NewBlock);
122- NewBlock->appendSuccessor (Succ);
123- }
124- BlockPtr->clearSuccessors ();
119+ transferSuccessors (BlockPtr, NewBlock);
125120 connectBlocks (BlockPtr, NewBlock);
126121 }
127122
@@ -205,6 +200,14 @@ class VPBlockUtils {
205200 Old->clearSuccessors ();
206201 }
207202
203+ // / Transfer successors from \p Old to \p New. \p New must have no successors.
204+ static void transferSuccessors (VPBlockBase *Old, VPBlockBase *New) {
205+ for (auto *Succ : Old->getSuccessors ())
206+ Succ->replacePredecessor (Old, New);
207+ New->setSuccessors (Old->getSuccessors ());
208+ Old->clearSuccessors ();
209+ }
210+
208211 // / Return an iterator range over \p Range which only includes \p BlockTy
209212 // / blocks. The accesses are casted to \p BlockTy.
210213 template <typename BlockTy, typename T>
You can’t perform that action at this time.
0 commit comments