[llvm] [VPlan] Replace VPRegionBlock with explicit CFG before execute (NFCI). (PR #117506)

via llvm-commits llvm-commits at lists.llvm.org
Tue May 13 14:38:33 PDT 2025


================
@@ -420,12 +433,17 @@ void VPBasicBlock::connectToPredecessors(VPTransformState &State) {
   if (ParentLoop && !State.LI->getLoopFor(NewBB))
     ParentLoop->addBasicBlockToLoop(NewBB, *State.LI);
 
+  auto Preds = to_vector(getHierarchicalPredecessors());
+  if (VPBlockUtils::isHeader(this, State.VPDT)) {
+    // There's no block yet for the latch, don't try to connect it yet.
+    Preds = {Preds[0]};
+  }
+
   // Hook up the new basic block to its predecessors.
-  for (VPBlockBase *PredVPBlock : getHierarchicalPredecessors()) {
+  for (VPBlockBase *PredVPBlock : Preds) {
     VPBasicBlock *PredVPBB = PredVPBlock->getExitingBasicBlock();
     auto &PredVPSuccessors = PredVPBB->getHierarchicalSuccessors();
-    BasicBlock *PredBB = CFG.VPBB2IRBB[PredVPBB];
-
+    BasicBlock *PredBB = CFG.VPBB2IRBB.lookup(PredVPBB);
     assert(PredBB && "Predecessor basic-block not found building successor.");
----------------
ayalz wrote:

nit: can alternatively introduce an `assert(CFG.VPBB2IRBB.contains(PredVPBB) && ...` before the `CFG.VPBB2IRBB[PredVPBB]`.

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


More information about the llvm-commits mailing list