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

Andrzej WarzyƄski llvmlistbot at llvm.org
Sun May 5 07:22:56 PDT 2024


================
@@ -478,6 +478,32 @@ func.func @simple_arith.ceildivsi() -> (i32, i32, i32, i32, i32) {
 
 // -----
 
+// CHECK-LABEL: func @simple_arith.ceildivsi_overflow
+func.func @simple_arith.ceildivsi_overflow() -> (i8, i16, i32) {
+  // The negative values below are MININTs for the corresponding bit-width. The
+  // folder will try to negate them (so that the division operartes on two
+  // positive numbers), but that would cause overflow (negating MININT
+  // overflows). Hence folding should not happen and the original ceildivsi is
+  // preserved.
+
+  // CHECK-COUNT-3:  arith.ceildivsi
----------------
banach-space wrote:

Happy to update this, no harm in being more thorough.

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


More information about the Mlir-commits mailing list