diff --git a/mlir/test/Dialect/Arith/canonicalize.mlir b/mlir/test/Dialect/Arith/canonicalize.mlir --- a/mlir/test/Dialect/Arith/canonicalize.mlir +++ b/mlir/test/Dialect/Arith/canonicalize.mlir @@ -431,21 +431,39 @@ // CHECK-LABEL: @indexCastFold // CHECK: %[[res:.*]] = arith.constant -2 : index // CHECK: return %[[res]] -func.func @indexCastFold(%arg0: i8) -> index { +func.func @indexCastFold() -> index { %c-2 = arith.constant -2 : i8 %idx = arith.index_cast %c-2 : i8 to index return %idx : index } +// CHECK-LABEL: @indexCastFoldIndexToInt +// CHECK: %[[res:.*]] = arith.constant 1 : i32 +// CHECK: return %[[res]] +func.func @indexCastFoldIndexToInt() -> i32 { + %c1 = arith.constant 1 : index + %int = arith.index_cast %c1 : index to i32 + return %int : i32 +} + // CHECK-LABEL: @indexCastUIFold // CHECK: %[[res:.*]] = arith.constant 254 : index // CHECK: return %[[res]] -func.func @indexCastUIFold(%arg0: i8) -> index { +func.func @indexCastUIFold() -> index { %c-2 = arith.constant -2 : i8 %idx = arith.index_castui %c-2 : i8 to index return %idx : index } +// CHECK-LABEL: @indexCastUIFoldIndexToInt +// CHECK: %[[res:.*]] = arith.constant 1 : i32 +// CHECK: return %[[res]] +func.func @indexCastUIFoldIndexToInt() -> i32 { + %c1 = arith.constant 1 : index + %int = arith.index_castui %c1 : index to i32 + return %int : i32 +} + // CHECK-LABEL: @signExtendConstant // CHECK: %[[cres:.+]] = arith.constant -2 : i16 // CHECK: return %[[cres]]