[llvm] [SCEV] Add implied-cond-ge-via-gt test coverage (PR #225024)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 21 00:36:32 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-analysis
Author: Ramkumar Ramachandra (artagnon)
<details>
<summary>Changes</summary>
Add test coverage for a very obscure codepath in howManyLT.
---
Full diff: https://github.com/llvm/llvm-project/pull/225024.diff
1 Files Affected:
- (added) llvm/test/Analysis/ScalarEvolution/implied-cond-ge-via-gt-minus-one.ll (+42)
``````````diff
diff --git a/llvm/test/Analysis/ScalarEvolution/implied-cond-ge-via-gt-minus-one.ll b/llvm/test/Analysis/ScalarEvolution/implied-cond-ge-via-gt-minus-one.ll
new file mode 100644
index 0000000000000..349ded886383d
--- /dev/null
+++ b/llvm/test/Analysis/ScalarEvolution/implied-cond-ge-via-gt-minus-one.ll
@@ -0,0 +1,42 @@
+; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 6
+; RUN: opt -disable-output -passes="print<scalar-evolution>" \
+; RUN: -scalar-evolution-classify-expressions=0 %s 2>&1 | FileCheck %s
+
+; Test for proving X >= Y from a guard of the form X > Y - 1.
+
+define i32 @guarded_nested_loop(i32 %start, i32 %rhs, i32 %end) {
+; CHECK-LABEL: 'guarded_nested_loop'
+; CHECK-NEXT: Determining loop execution counts for: @guarded_nested_loop
+; CHECK-NEXT: Loop %inner: backedge-taken count is ({(1 + (-1 * %start) + %rhs),+,-1}<%outer> /u 2)
+; CHECK-NEXT: Loop %inner: constant max backedge-taken count is i32 2147483647
+; CHECK-NEXT: Loop %inner: symbolic max backedge-taken count is ({(1 + (-1 * %start) + %rhs),+,-1}<%outer> /u 2)
+; CHECK-NEXT: Loop %inner: Trip multiple is 1
+; CHECK-NEXT: Loop %outer: backedge-taken count is (-1 + (-1 * %start) + %end)
+; CHECK-NEXT: Loop %outer: constant max backedge-taken count is i32 -1
+; CHECK-NEXT: Loop %outer: symbolic max backedge-taken count is (-1 + (-1 * %start) + %end)
+; CHECK-NEXT: Loop %outer: Trip multiple is 1
+;
+entry:
+ br label %outer
+
+outer:
+ %outer.iv = phi i32 [ %start, %entry ], [ %outer.iv.next, %outer.latch ]
+ %before = sub i32 %outer.iv, 1
+ %guard = icmp ugt i32 %rhs, %before
+ br i1 %guard, label %inner, label %outer.latch
+
+inner:
+ %iv = phi i32 [ %outer.iv, %outer ], [ %iv.next, %inner ]
+ %iv.next = add nuw i32 %iv, 2
+ %ec = icmp ult i32 %iv, %rhs
+ br i1 %ec, label %inner, label %outer.latch
+
+outer.latch:
+ %res = phi i32 [ %outer.iv, %outer ], [ %iv, %inner ]
+ %outer.iv.next = add i32 %outer.iv, 1
+ %ec.outer = icmp ne i32 %outer.iv.next, %end
+ br i1 %ec.outer, label %outer, label %exit
+
+exit:
+ ret i32 %res
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/225024
More information about the llvm-commits
mailing list