Skip to content

Commit c4d84e1

Browse files
committed
[VPlan] Use replaceSuccessor/replacePredecessor in insertBlock (NFC).
Use replaceSuccessor/replacePredecessor in insertBlockAfter/insertBlockBefore. This preserves the predecessor order, which in turns is needed to not invalidate existing phi recipes. At the moment this is NFC, but enables additional uses in the future.
1 parent d1c7fa8 commit c4d84e1

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

llvm/lib/Transforms/Vectorize/VPlanUtils.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,10 @@ class VPBlockUtils {
9090
NewBlock->setParent(BlockPtr->getParent());
9191
SmallVector<VPBlockBase *> Succs(BlockPtr->successors());
9292
for (VPBlockBase *Succ : Succs) {
93-
disconnectBlocks(BlockPtr, Succ);
94-
connectBlocks(NewBlock, Succ);
93+
Succ->replacePredecessor(BlockPtr, NewBlock);
94+
NewBlock->appendSuccessor(Succ);
9595
}
96+
BlockPtr->clearSuccessors();
9697
connectBlocks(BlockPtr, NewBlock);
9798
}
9899

@@ -106,9 +107,10 @@ class VPBlockUtils {
106107
"Can't insert new block with predecessors or successors.");
107108
NewBlock->setParent(BlockPtr->getParent());
108109
for (VPBlockBase *Pred : to_vector(BlockPtr->predecessors())) {
109-
disconnectBlocks(Pred, BlockPtr);
110-
connectBlocks(Pred, NewBlock);
110+
Pred->replaceSuccessor(BlockPtr, NewBlock);
111+
NewBlock->appendPredecessor(Pred);
111112
}
113+
BlockPtr->clearPredecessors();
112114
connectBlocks(NewBlock, BlockPtr);
113115
}
114116

0 commit comments

Comments
 (0)