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

Andrzej WarzyƄski llvmlistbot at llvm.org
Fri May 3 04:18:52 PDT 2024


================
@@ -701,22 +701,34 @@ OpFoldResult arith::CeilDivSIOp::fold(FoldAdaptor adaptor) {
           // Both positive, return ceil(a, b).
           return signedCeilNonnegInputs(a, b, overflowOrDiv0);
         }
+
+        bool overflowNegA = false;
+        bool overflowNegB = false;
----------------
banach-space wrote:

Not quite, it's more like this:
```cpp
         bool overflowNegA = false;       // Overflow for "-a"
         bool overflowNegB = false;       // Overflow for "-b"
         bool overflowDiv = false;        // Overflow for "div(lhs, rhs)"
         bool overflowNegDiv = false;     // Overflow for "-div(..., ...)"
```

As in, there's a separate flag for every arithmetic operation that may follow. Also, at this point we already know that `b != 0`.

I might be missing sth, so please correct me if I'm wrong.

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


More information about the Mlir-commits mailing list