[llvm] [VPlan] Preserve WideIVStep wrap-flags (PR #191284)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 17 08:05:54 PDT 2026
================
@@ -6110,7 +6110,7 @@ define void @test_optimized_cast_induction_feeding_first_order_recurrence(i64 %n
; UNROLL-NO-IC-NEXT: [[BROADCAST_SPLAT:%.*]] = shufflevector <2 x i32> [[BROADCAST_SPLATINSERT]], <2 x i32> poison, <2 x i32> zeroinitializer
; UNROLL-NO-IC-NEXT: [[DOTCAST:%.*]] = trunc i64 [[N_VEC]] to i32
; UNROLL-NO-IC-NEXT: [[IND_END:%.*]] = mul i32 [[DOTCAST]], [[STEP]]
-; UNROLL-NO-IC-NEXT: [[TMP17:%.*]] = mul <2 x i32> splat (i32 2), [[BROADCAST_SPLAT]]
+; UNROLL-NO-IC-NEXT: [[TMP17:%.*]] = mul nsw <2 x i32> splat (i32 2), [[BROADCAST_SPLAT]]
----------------
lukel97 wrote:
Actually maybe it doesn't hold for tail folded loops. I thought that this logic below would have sufficed but now I see it's only for canonical IVs.
```
if (cast<VPWidenIntOrFpInductionRecipe>(IV)->isCanonical())
IVFlags = VPIRFlags::WrapFlagsTy(/*NUW=*/true, /*NSW=*/false);
```
E.g. if we have VF = 4, TC = 2, IV type = i8, step = 100. The original loop could have `%iv.next = add nsw i8 %iv, 100` and not overflow. But `%wide.iv = mul nsw i8 4, 100` would overflow.
https://github.com/llvm/llvm-project/pull/191284
More information about the llvm-commits
mailing list