[Mlir-commits] [mlir] [mlir][arith] Overflow flags propagation in arith canonicalizations. (PR #91646)
Tobias Gysi
llvmlistbot at llvm.org
Fri May 10 00:25:35 PDT 2024
================
@@ -1051,6 +1193,17 @@ func.func @addiMuliToSubiLhsI32(%arg0: i32, %arg1: i32) -> i32 {
return %add : i32
}
+// CHECK-LABEL: @addiMuliToSubiLhsI32Ovf
+// CHECK-SAME: (%[[ARG0:.+]]: i32, %[[ARG1:.+]]: i32)
+// CHECK: %[[SUB:.+]] = arith.subi %[[ARG0]], %[[ARG1]] overflow<nsw, nuw> : i32
+// CHECK: return %[[SUB]]
+func.func @addiMuliToSubiLhsI32Ovf(%arg0: i32, %arg1: i32) -> i32 {
----------------
gysit wrote:
When running this through alive I get a mismatch:
https://alive2.llvm.org/ce/z/8NhXoT
I did enter things manually so apologies if I made a mistake. It seems like the multiplication of 0 with -1 does not result in poison (despite the nuw flag) while sub 0, 1 does result in a unsigned overflow. The result is a bit of a surprise for me but maybe others can shed some light on it?
Could make to run this tests systematically through alive? I did it manually but it could be fairly quick to lower the test input and output to llvm ir and the copy past these overflow flag tests individually into alive. I have more trust in a tool than in my reviewing skills here. What are your takes on this @kuhar @Hardcode84?
https://github.com/llvm/llvm-project/pull/91646
More information about the Mlir-commits
mailing list