[llvm] [KnownBits] Improve minimum denominator bounds for sdiv (PR #227264)
Eric Ross via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 30 11:49:50 PDT 2026
================
@@ -0,0 +1,20 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6
+; RUN: opt < %s -passes=instcombine -S | FileCheck %s
+
+; The denominator has the pattern 0b??00, so it can be {0, 4, 8, 12}.
+; Division by zero is UB, so the minimum non-zero denominator is 4.
+; The numerator is a negative multiple of 16 in the range [-128, -16].
+; Therefore, the result is in the range [-32, -1], so the top three
+; bits are always set and the final 'and' can be removed.
+define i8 @sdiv_maybe_zero_denominator(i8 %a, i8 %x) {
----------------
ZERICO2005 wrote:
add tests for `i32` as well.
And possibly other tests where the denominator is one of:
`0b0???????` --> 1
`0b0??????0` --> 2
`0b0000000?` --> 1
`0b000000??` --> 1
`0b00000?0?` --> 1
`0b000000?0` --> 2
`0b0?000000` --> 64
https://github.com/llvm/llvm-project/pull/227264
More information about the llvm-commits
mailing list