[llvm] [NFC][LoopVectorize] Make replaceVPBBWithIRVPBB more efficient (PR #111514)

David Sherwood via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 15 02:20:41 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:

Sure, no problem. I just added a new commit as I realised the the public `reassociateBlocks` interface was leaving `Old` and `New` in an invalid state. Hopefully, this now addresses your concern!

https://github.com/llvm/llvm-project/pull/111514


More information about the llvm-commits mailing list