[Mlir-commits] [mlir] 216787c - [mlir][arith] Add tests for i0 canonicalization (#89665)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sun Apr 28 10:26:35 PDT 2024
Author: Théo Degioanni
Date: 2024-04-28T19:26:31+02:00
New Revision: 216787cffc4a864e0effb165c1c32b92328a0a06
URL: https://github.com/llvm/llvm-project/commit/216787cffc4a864e0effb165c1c32b92328a0a06
DIFF: https://github.com/llvm/llvm-project/commit/216787cffc4a864e0effb165c1c32b92328a0a06.diff
LOG: [mlir][arith] Add tests for i0 canonicalization (#89665)
Before #87193, the canonicalizer in arith crashed when attempting signed
extension on an i0 value. To hopefully avoid it happening again, this PR
introduces tests for canonicalization of arith operations with i0
values, focusing on operations related to bit width or signedness.
Added:
Modified:
mlir/test/Dialect/Arith/canonicalize.mlir
Removed:
################################################################################
diff --git a/mlir/test/Dialect/Arith/canonicalize.mlir b/mlir/test/Dialect/Arith/canonicalize.mlir
index 6c4193bc06ca2d..f7ce2123a93c68 100644
--- a/mlir/test/Dialect/Arith/canonicalize.mlir
+++ b/mlir/test/Dialect/Arith/canonicalize.mlir
@@ -2831,6 +2831,87 @@ func.func @unsignedExtendConstantResource() -> tensor<i16> {
return %ext : tensor<i16>
}
+// CHECK-LABEL: @extsi_i0
+// CHECK: %[[ZERO:.*]] = arith.constant 0 : i16
+// CHECK: return %[[ZERO]] : i16
+func.func @extsi_i0() -> i16 {
+ %c0 = arith.constant 0 : i0
+ %extsi = arith.extsi %c0 : i0 to i16
+ return %extsi : i16
+}
+
+// CHECK-LABEL: @extui_i0
+// CHECK: %[[ZERO:.*]] = arith.constant 0 : i16
+// CHECK: return %[[ZERO]] : i16
+func.func @extui_i0() -> i16 {
+ %c0 = arith.constant 0 : i0
+ %extui = arith.extui %c0 : i0 to i16
+ return %extui : i16
+}
+
+// CHECK-LABEL: @trunc_i0
+// CHECK: %[[ZERO:.*]] = arith.constant 0 : i0
+// CHECK: return %[[ZERO]] : i0
+func.func @trunc_i0() -> i0 {
+ %cFF = arith.constant 0xFF : i8
+ %trunc = arith.trunci %cFF : i8 to i0
+ return %trunc : i0
+}
+
+// CHECK-LABEL: @shli_i0
+// CHECK: %[[ZERO:.*]] = arith.constant 0 : i0
+// CHECK: return %[[ZERO]] : i0
+func.func @shli_i0() -> i0 {
+ %c0 = arith.constant 0 : i0
+ %shli = arith.shli %c0, %c0 : i0
+ return %shli : i0
+}
+
+// CHECK-LABEL: @shrsi_i0
+// CHECK: %[[ZERO:.*]] = arith.constant 0 : i0
+// CHECK: return %[[ZERO]] : i0
+func.func @shrsi_i0() -> i0 {
+ %c0 = arith.constant 0 : i0
+ %shrsi = arith.shrsi %c0, %c0 : i0
+ return %shrsi : i0
+}
+
+// CHECK-LABEL: @shrui_i0
+// CHECK: %[[ZERO:.*]] = arith.constant 0 : i0
+// CHECK: return %[[ZERO]] : i0
+func.func @shrui_i0() -> i0 {
+ %c0 = arith.constant 0 : i0
+ %shrui = arith.shrui %c0, %c0 : i0
+ return %shrui : i0
+}
+
+// CHECK-LABEL: @maxsi_i0
+// CHECK: %[[ZERO:.*]] = arith.constant 0 : i0
+// CHECK: return %[[ZERO]] : i0
+func.func @maxsi_i0() -> i0 {
+ %c0 = arith.constant 0 : i0
+ %maxsi = arith.maxsi %c0, %c0 : i0
+ return %maxsi : i0
+}
+
+// CHECK-LABEL: @minsi_i0
+// CHECK: %[[ZERO:.*]] = arith.constant 0 : i0
+// CHECK: return %[[ZERO]] : i0
+func.func @minsi_i0() -> i0 {
+ %c0 = arith.constant 0 : i0
+ %minsi = arith.minsi %c0, %c0 : i0
+ return %minsi : i0
+}
+
+// CHECK-LABEL: @mulsi_extended_i0
+// CHECK: %[[ZERO:.*]] = arith.constant 0 : i0
+// CHECK: return %[[ZERO]], %[[ZERO]] : i0
+func.func @mulsi_extended_i0() -> (i0, i0) {
+ %c0 = arith.constant 0 : i0
+ %mulsi_extended:2 = arith.mulsi_extended %c0, %c0 : i0
+ return %mulsi_extended#0, %mulsi_extended#1 : i0, i0
+}
+
{-#
dialect_resources: {
builtin: {
More information about the Mlir-commits
mailing list