[llvm] [LV] Fold middle-block branch in post-dissolution removeBranchOnConst. (PR #204243)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 20 07:26:43 PDT 2026


================
@@ -7785,16 +7816,22 @@ static void connectEpilogueVectorLoop(VPlan &EpiPlan, Loop *L,
   DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Eager);
 
   // Helper to redirect an edge from \p BB to \p VecEpilogueIterationCountCheck
-  // to \p NewSucc instead, updating the DomTree.
+  // to \p NewSucc instead, updating the DomTree. No-op if \p BB doesn't branch
+  // there (e.g. its check folded by removeBranchOnConst).
   auto RedirectEdge = [&](BasicBlock *BB, BasicBlock *NewSucc) {
+    if (!is_contained(successors(BB), VecEpilogueIterationCountCheck))
+      return;
----------------
artagnon wrote:

Will this ever happen? I thought we guarded it with isa CondBrInst below?

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


More information about the llvm-commits mailing list