[llvm] Simplify `(a % b) lt/ge (b-1)` into `(a % b) eq/ne (b-1)` (PR #72504)

via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 4 02:48:55 PST 2023


elhewaty wrote:

@dtcxzyw @nikic, sorry for my late reply. from my understanding, we should add this optimization, but handle only constants integer scalars, I have a question here how can we make sure that the tests work fine as `match(Value, m_APInt())` doesn't work with `@llvm.assume()`? should we add tests with constant scalars only (use integer constants, and splat vectors)?
for example:
```
%Cminus1 = add i32 1074977277, -1
  %y = srem i32 %x, 1074977277
  %cmp = icmp slt i32 %y, %Cminus1
  ret i1 %cmp
``` 

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


More information about the llvm-commits mailing list