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 @@ -640,6 +640,11 @@ return None; }); + // IndexType is not sized, do not emulate. + addConversion([](IndexType ty) -> Optional { return ty; }); + // FlatType is not an integer type, do not emulate. + addConversion([](FloatType ty) -> Optional { return ty; }); + // Vector case. addConversion([this](VectorType ty) -> Optional { auto intTy = ty.getElementType().dyn_cast(); 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 @addi_same_f64 +// CHECK-SAME: ([[ARG:%.+]]: f64) -> f64 +// CHECK-NEXT: return [[ARG]] : f64 +func.func @addi_same_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>