[Mlir-commits] [mlir] [mlir][arith] Add `overflow<zero>` to `arith.remsi` (PR #237021)
Andrzej Warzyński
llvmlistbot at llvm.org
Sun Nov 1 04:22:53 PST 2026
================
@@ -820,16 +820,25 @@ def Arith_RemSIOp : Arith_IntBinaryOp<"remsi",
Signed integer division remainder. Treats the leading bit as sign, i.e. `6 %
-2 = 0`.
- Division by zero is undefined behavior. When applied to `vector` and
- `tensor` values, the behavior is undefined if _any_ elements are divided by
- zero.
+ Division by zero, or signed division overflow (the minimum signed value
+ divided by -1), is undefined behavior. The remainder itself does not
+ overflow, but this permits lowering to instructions that compute both the
+ quotient and remainder. When applied to `vector` and `tensor` values, the
+ behavior is undefined if _any_ element encounters either case.
+
+ With `overflow<zero>`, the remainder of the minimum signed value divided by
----------------
banach-space wrote:
`overflow<zero>` is a very generic name, yet it's used for a very specific case and only for one op. I would try something less generic and more descriptive instead:
* `zero_for_neg_one_divisor`
Effectively, this attribute is to inject a runtime check when the divisor is `-1`. IIUC, the "overflow" happens only when LHS is INT_MIN?
Naming is hard 🤷🏻
https://github.com/llvm/llvm-project/pull/237021
More information about the Mlir-commits
mailing list