[llvm] [SCEV] Simplify `udiv` equality comparisons against 0 (PR #218084)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 25 01:59:28 PDT 2026
================
@@ -0,0 +1,233 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: -p --version 6
+; RUN: opt < %s -S -passes='loop(indvars)' | FileCheck %s --check-prefix=INDVARS
+
+define i1 @quotient_eq_zero(i64 %a, i64 %b) {
+; INDVARS-LABEL: define i1 @quotient_eq_zero(i64 %a, i64 %b) {
+; INDVARS-NEXT: entry:
+; INDVARS-NEXT: %q = udiv i64 %a, %b
+; INDVARS-NEXT: %guard = icmp eq i64 %q, 0
+; INDVARS-NEXT: br i1 %guard, label %loop.preheader, label %exit
+; INDVARS: loop.preheader:
+; INDVARS-NEXT: br label %loop
+; INDVARS: loop:
+; INDVARS-NEXT: br i1 false, label %loop, label %exit.loopexit
+; INDVARS: exit.loopexit:
+; INDVARS-NEXT: %cmp.lcssa = phi i1 [ true, %loop ]
+; INDVARS-NEXT: br label %exit
+; INDVARS: exit:
+; INDVARS-NEXT: %result = phi i1 [ false, %entry ], [ %cmp.lcssa, %exit.loopexit ]
+; INDVARS-NEXT: ret i1 %result
+;
+entry:
+ %q = udiv i64 %a, %b
+ %guard = icmp eq i64 %q, 0
+ br i1 %guard, label %loop, label %exit
+
+loop:
+ %same = phi i64 [ %a, %entry ], [ %same.next, %loop ]
+ %cmp = icmp ult i64 %same, %b
+ %same.next = add i64 %a, 0
----------------
nikic wrote:
These tests look very weird with this IV that always takes the same value. It's not really clear to me what this is actually testing.
https://github.com/llvm/llvm-project/pull/218084
More information about the llvm-commits
mailing list