[Mlir-commits] [mlir] [mlir][arith] Fix overflow bug in arith::CeilDivSIOp::fold (PR #90947)

Mehdi Amini llvmlistbot at llvm.org
Tue May 7 09:32:10 PDT 2024


================
@@ -587,10 +587,11 @@ def Arith_CeilDivSIOp : Arith_IntBinaryOp<"ceildivsi",
   let description = [{
     Signed integer division. Rounds towards positive infinity, i.e. `7 / -2 = -3`.
 
-    Divison by zero, or signed division overflow (minimum value divided by -1) 
-    is undefined behavior. When applied to `vector` and `tensor` values, the 
-    behavior is undefined if _any_ of its elements are divided by zero or has a 
-    signed division overflow.
+    Divison by zero, or signed division overflow (minimum value divided by -1)
+    is undefined behavior. While dividing minimum value by a value != -1 shouldn't
+    overflow, the current implementation treats it as such. When applied to `vector`
----------------
joker-eph wrote:

The sentence makes it look like dividing minimum value by a value != -1 is undefined behavior, I don't believe this is the intent.

I am not sure what you're trying to document here? Implementation details of the folder aren't relevant to the op semantics I believe.

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


More information about the Mlir-commits mailing list