[llvm] [NFC][LoopVectorize] Make replaceVPBBWithIRVPBB more efficient (PR #111514)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 14 00:35:48 PDT 2024
================
@@ -556,6 +556,26 @@ class VPBlockBase {
return getEnclosingBlockWithPredecessors()->getSinglePredecessor();
}
+ /// This function replaces one predecessor with another, useful when
+ /// trying to replace an old block in the CFG with a new one.
+ void replacePredecessor(VPBlockBase *Old, VPBlockBase *New) {
+ auto I = find(Predecessors, Old);
+ assert(I != Predecessors.end());
+ assert(Old->getParent() == New->getParent() &&
+ "replaced predecessor must have the same parent");
+ *I = New;
----------------
david-arm wrote:
Hmm, but if we go down that route then surely we should also care about setting the successor of `New` to `this` as well so that we leave it in a valid state? I guess if this function was private then it wouldn't be part of the interface so it wouldn't matter as much. If we do the extra work here as you suggest, then this patch becomes less about efficiency and more about retaining ordering, which is fine but then I probably ought to change the title!
https://github.com/llvm/llvm-project/pull/111514
More information about the llvm-commits
mailing list