[llvm] [SCEV] Preserve nuw on scaled recurrence start values. (PR #227458)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 30 00:51:59 PDT 2026


================
@@ -0,0 +1,254 @@
+; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 6
+; RUN: opt -passes='print<scalar-evolution>' -disable-output %s 2>&1 | FileCheck %s
+
+define i32 @scaled_nuw(ptr %dst, i32 %a, i32 %b, i32 %n, i1 %c) {
+; CHECK-LABEL: 'scaled_nuw'
+; CHECK-NEXT:  Classifying expressions for: @scaled_nuw
+; CHECK-NEXT:    %iv = phi i32 [ %a, %ph ], [ %iv.next, %loop ]
+; CHECK-NEXT:    --> {%a,+,1}<nuw><%loop> U: full-set S: full-set Exits: (-1 + %n) LoopDispositions: { %loop: Computable }
+; CHECK-NEXT:    %index = mul nuw i32 %iv, %b
+; CHECK-NEXT:    --> {(%a * %b),+,%b}<nuw><%loop> U: full-set S: full-set Exits: ((-1 + %n) * %b) LoopDispositions: { %loop: Computable }
+; CHECK-NEXT:    %wide = zext i32 %index to i64
+; CHECK-NEXT:    --> {(zext i32 (%a * %b) to i64),+,(zext i32 %b to i64)}<nuw><%loop> U: [0,-4294967295) S: [0,-4294967295) Exits: ((zext i32 (%a * %b) to i64) + ((zext i32 (-1 + (-1 * %a) + %n) to i64) * (zext i32 %b to i64))<u nuw>)<u nuw> LoopDispositions: { %loop: Computable }
----------------
nikic wrote:

I only see `<u nuw>`s on exit values here. I expected to see it on some addrec start values?

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


More information about the llvm-commits mailing list