[Mlir-commits] [mlir] [mlir][arith] Handle unsigned moduli in int-range optimizations (PR #224933)

Ivan Butygin llvmlistbot at llvm.org
Wed Sep 30 03:48:19 PDT 2026


Hardcode84 wrote:

AI agent found a counterexample, when `index` type is lowered to 32 bit integers:
```mlir
func.func @index_rem(%arg: index) -> index {
  %mask = arith.constant 255 : index
  %divisor = arith.constant -9223372036854775805 : index // 2^63 + 3
  %x = arith.andi %arg, %mask : index
  %r = arith.remui %x, %divisor : index
  return %r : index
}
```

but it relies on the fact current index lowering just silently truncates oversized constants, which is by itself looks fishy to me.

CC @krzysz00 

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


More information about the Mlir-commits mailing list