diff --git a/mlir/lib/Dialect/Arith/Transforms/EmulateWideInt.cpp b/mlir/lib/Dialect/Arith/Transforms/EmulateWideInt.cpp --- a/mlir/lib/Dialect/Arith/Transforms/EmulateWideInt.cpp +++ b/mlir/lib/Dialect/Arith/Transforms/EmulateWideInt.cpp @@ -627,6 +627,9 @@ "Only power-of-two integers with are supported"); assert(widestIntSupportedByTarget >= 2 && "Integer type too narrow"); + // Allow unknown types. + addConversion([](Type ty) -> Optional { return ty; }); + // Scalar case. addConversion([this](IntegerType ty) -> Optional { unsigned width = ty.getWidth(); diff --git a/mlir/test/Dialect/Arith/emulate-wide-int.mlir b/mlir/test/Dialect/Arith/emulate-wide-int.mlir --- a/mlir/test/Dialect/Arith/emulate-wide-int.mlir +++ b/mlir/test/Dialect/Arith/emulate-wide-int.mlir @@ -10,6 +10,24 @@ 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>