[Mlir-commits] [mlir] b39b805 - [mlir][arith] Mark unknown types legal in WIE

Jakub Kuderski llvmlistbot at llvm.org
Tue Oct 4 12:01:07 PDT 2022


Author: Jakub Kuderski
Date: 2022-10-04T15:00:51-04:00
New Revision: b39b805ad52ca5a843412f2b1ecf11989cddff90

URL: https://github.com/llvm/llvm-project/commit/b39b805ad52ca5a843412f2b1ecf11989cddff90
DIFF: https://github.com/llvm/llvm-project/commit/b39b805ad52ca5a843412f2b1ecf11989cddff90.diff

LOG: [mlir][arith] Mark unknown types legal in WIE

Allow unknown types to pass through without being marked as illegal.

Reviewed By: antiagainst

Differential Revision: https://reviews.llvm.org/D135123

Added: 
    

Modified: 
    mlir/lib/Dialect/Arith/Transforms/EmulateWideInt.cpp
    mlir/test/Dialect/Arith/emulate-wide-int.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/Arith/Transforms/EmulateWideInt.cpp b/mlir/lib/Dialect/Arith/Transforms/EmulateWideInt.cpp
index dae5864af51af..3bec82c5cd03f 100644
--- a/mlir/lib/Dialect/Arith/Transforms/EmulateWideInt.cpp
+++ b/mlir/lib/Dialect/Arith/Transforms/EmulateWideInt.cpp
@@ -627,6 +627,9 @@ arith::WideIntEmulationConverter::WideIntEmulationConverter(
          "Only power-of-two integers with are supported");
   assert(widestIntSupportedByTarget >= 2 && "Integer type too narrow");
 
+  // Allow unknown types.
+  addConversion([](Type ty) -> Optional<Type> { return ty; });
+
   // Scalar case.
   addConversion([this](IntegerType ty) -> Optional<Type> {
     unsigned width = ty.getWidth();

diff  --git a/mlir/test/Dialect/Arith/emulate-wide-int.mlir b/mlir/test/Dialect/Arith/emulate-wide-int.mlir
index 6445ea44cadaf..940b125d66192 100644
--- a/mlir/test/Dialect/Arith/emulate-wide-int.mlir
+++ b/mlir/test/Dialect/Arith/emulate-wide-int.mlir
@@ -10,6 +10,24 @@ func.func @addi_same_i32(%a : i32) -> i32 {
     return %x : i32
 }
 
+// Expect no conversions, index is not sized.
+// CHECK-LABEL: func @addi_same_index
+// CHECK-SAME:    ([[ARG:%.+]]: index) -> index
+// CHECK-NEXT:    [[X:%.+]] = arith.addi [[ARG]], [[ARG]] : index
+// CHECK-NEXT:    return [[X]] : index
+func.func @addi_same_index(%a : index) -> index {
+    %x = arith.addi %a, %a : index
+    return %x : index
+}
+
+// Expect no conversions, f64 is not an integer type.
+// CHECK-LABEL: func @identity_f64
+// CHECK-SAME:    ([[ARG:%.+]]: f64) -> f64
+// CHECK-NEXT:    return [[ARG]] : f64
+func.func @identity_f64(%a : f64) -> f64 {
+    return %a : f64
+}
+
 // Expect no conversions, i32 is supported.
 // CHECK-LABEL: func @addi_same_vector_i32
 // CHECK-SAME:    ([[ARG:%.+]]: vector<2xi32>) -> vector<2xi32>


        


More information about the Mlir-commits mailing list