[llvm] [SCEV] Urem identification from X - C*X/uC (PR #210778)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 14 02:46:36 PDT 2026
================
@@ -0,0 +1,26 @@
+; RUN: opt -passes='print<scalar-evolution>' -disable-output %s 2>&1 | FileCheck %s
+
+; X - C*(X u/ C) folds to (X u% C) for power-of-two C, surfacing range [0, C-1].
+
+; CHECK-LABEL: 'pow2_matches'
+; CHECK: %r = sub i32 %x, %m
+; CHECK-NEXT: --> (zext i2 (trunc i32 %x to i2) to i32) U: [0,4)
+define i32 @pow2_matches(i32 %x) {
+ %d = udiv i32 %x, 4
+ %m = mul i32 %d, 4
----------------
fhahn wrote:
can you also add a test with negative constant
https://github.com/llvm/llvm-project/pull/210778
More information about the llvm-commits
mailing list