[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
Fri Dec 8 06:25:47 PST 2023


elhewaty wrote:

I tried to handle negative divisors, but they don't change:
```
define i1 @srem_sgt_test(i16 %x) {
; CHECK-LABEL: @srem_sgt_test(
; CHECK-NEXT:    [[Y:%.*]] = srem i16 [[X:%.*]], 2259
; CHECK-NEXT:    [[CMP:%.*]] = icmp sgt i16 [[Y]], -2258
; CHECK-NEXT:    ret i1 [[CMP]]
;
  %Cplus1 = add i16 -2259, 1
  %y = srem i16 %x, -2259
  %cmp = icmp sgt i16 %y, %Cplus1
  ret i1 %cmp
}
```

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


More information about the llvm-commits mailing list