[llvm] [SCEV] Use signed form of samesign compares when it tightens exit limits (PR #223514)

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 14 13:50:00 PDT 2026


================
@@ -445,28 +445,23 @@ define void @le_from_int_min_no_nuw_nsw(i32 %M, i32 %N) {
 ; CHECK-NEXT:  Determining loop execution counts for: @le_from_int_min_no_nuw_nsw
 ; CHECK-NEXT:  Loop %loop: <multiple exits> Unpredictable backedge-taken count.
 ; CHECK-NEXT:    exit count for loop: ***COULDNOTCOMPUTE***
-; CHECK-NEXT:    predicated exit count for loop: (-2147483648 + (2147483648 umax (1 + (zext i32 %M to i64))<nuw><nsw>))<nsw>
+; CHECK-NEXT:    predicated exit count for loop: (2147483649 + (sext i32 %M to i64))<nsw>
 ; CHECK-NEXT:     Predicates:
----------------
efriedma-quic wrote:

If one form requires a predicate and the other doesn't, that seems like a pretty strong signal we should prefer the form without a predicate. Maybe worth adding a check?

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


More information about the llvm-commits mailing list