[llvm] [VPlan] Simplify Plan's entry in removeBranchOnConst. (PR #154510)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 1 05:54:17 PDT 2025


================
@@ -7377,6 +7387,16 @@ DenseMap<const SCEV *, Value *> LoopVectorizationPlanner::executePlan(
       addRuntimeUnrollDisableMetaData(L);
   }
 
+  if (BestVPlan.getScalarPreheader()->getNumPredecessors() == 0) {
+    // If the original loop became unreachable, we need to delete it.
----------------
fhahn wrote:

Yep, unfortunately we cannot do this when the VPIRBasicBlock for the scalar preheader gets executed, as we only execute reachable VPBBs.

I moved it for now to VPlan::execute. Unfortunately doing in the destructor of VPIRBasicBlock won't work either, because we need access to LoopInfo.

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


More information about the llvm-commits mailing list