[llvm] [VPlan] - Generalize dead cycle removal in removeDeadRecipes. (PR #213632)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 30 23:42:56 PDT 2026


================
@@ -687,6 +687,32 @@ static void removeRedundantInductionCasts(VPlan &Plan) {
   }
 }
 
+/// If R is a phi-like recipe starting a dead cycle of recipes, erase all
+/// reachable recipes of the dead cycle.
+static void tryToRemoveDeadCycle(VPRecipeBase *R) {
+  auto *PhiR = dyn_cast<VPSingleDefRecipe>(R);
+  if (!PhiR || !isa<VPPhi, VPReductionPHIRecipe>(R))
----------------
fhahn wrote:

@pawan-nirpal-031 I think something like the test below should cover the truncated induction crash




```
; opt -p loop-vectorize -force-vector-width=4 -force-vector-interleave=2 
define i8 @dead_truncated_induction() {
entry:
  br label %loop

loop:
  %iv = phi i32 [ 0, %entry ], [ %iv.next, %loop ]
  %iv.2 = phi i32 [ 0, %entry ], [ %add, %loop ]
  %add = add i32 %iv.2, 256
  %trunc = trunc i32 %iv.2 to i8
  %iv.next = add i32 %iv, 1
  %ec = icmp ugt i32 %iv, 100
  br i1 %ec, label %exit, label %loop

exit:
  %res = phi i8 [ %trunc, %loop ]
  ret i8 %res
}
```

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


More information about the llvm-commits mailing list