[llvm] [NFC][LoopVectorize] Make replaceVPBBWithIRVPBB more efficient (PR #111514)
Paul Walker via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 10 05:18:11 PDT 2024
================
@@ -1005,12 +1005,14 @@ static void replaceVPBBWithIRVPBB(VPBasicBlock *VPBB, BasicBlock *IRBB) {
R.moveBefore(*IRVPBB, IRVPBB->end());
}
VPBlockBase *PredVPBB = VPBB->getSinglePredecessor();
- VPBlockUtils::disconnectBlocks(PredVPBB, VPBB);
- VPBlockUtils::connectBlocks(PredVPBB, IRVPBB);
- for (auto *Succ : to_vector(VPBB->getSuccessors())) {
- VPBlockUtils::connectBlocks(IRVPBB, Succ);
- VPBlockUtils::disconnectBlocks(VPBB, Succ);
- }
+ PredVPBB->replaceSuccessor(VPBB, IRVPBB);
+ IRVPBB->setPredecessors({PredVPBB});
----------------
paulwalker-arm wrote:
Can you be sure that for all future uses of this function `IRVPBB`'s predecessors and successors can be replaced? Would it be safer to append them as was done previously?
>From a structural point of view `VPBlockUtils` looks to be the place for managing VPBB linkage (I see a range of insert methods along with the (dis)connect method you're replacing) so in keeping with this perhaps add `VPBlockUtils::reassociateBlock(Keep, Old, New)` that calls onto `replaceSuccessor` and `replacePredecessor`.
https://github.com/llvm/llvm-project/pull/111514
More information about the llvm-commits
mailing list