1- // RUN: mlir-opt --arith-int-range-narrowing="int-bitwidths-supported=32" %s | FileCheck %s
1+ // RUN: mlir-opt --arith-int-range-narrowing="int-bitwidths-supported=1,8,16,24, 32" %s | FileCheck %s
22
33// Do not truncate negative values
44// CHECK-LABEL: func @test_addi_neg
@@ -14,10 +14,10 @@ func.func @test_addi_neg() -> index {
1414// CHECK-LABEL: func @test_addi
1515// CHECK: %[[A:.*]] = test.with_bounds {smax = 5 : index, smin = 4 : index, umax = 5 : index, umin = 4 : index} : index
1616// CHECK: %[[B:.*]] = test.with_bounds {smax = 7 : index, smin = 6 : index, umax = 7 : index, umin = 6 : index} : index
17- // CHECK: %[[A_CASTED:.*]] = arith.index_castui %[[A]] : index to i32
18- // CHECK: %[[B_CASTED:.*]] = arith.index_castui %[[B]] : index to i32
19- // CHECK: %[[RES:.*]] = arith.addi %[[A_CASTED]], %[[B_CASTED]] : i32
20- // CHECK: %[[RES_CASTED:.*]] = arith.index_castui %[[RES]] : i32 to index
17+ // CHECK: %[[A_CASTED:.*]] = arith.index_castui %[[A]] : index to i8
18+ // CHECK: %[[B_CASTED:.*]] = arith.index_castui %[[B]] : index to i8
19+ // CHECK: %[[RES:.*]] = arith.addi %[[A_CASTED]], %[[B_CASTED]] : i8
20+ // CHECK: %[[RES_CASTED:.*]] = arith.index_castui %[[RES]] : i8 to index
2121// CHECK: return %[[RES_CASTED]] : index
2222func.func @test_addi () -> index {
2323 %0 = test.with_bounds { umin = 4 : index , umax = 5 : index , smin = 4 : index , smax = 5 : index } : index
@@ -30,10 +30,10 @@ func.func @test_addi() -> index {
3030// CHECK-LABEL: func @test_addi_i64
3131// CHECK: %[[A:.*]] = test.with_bounds {smax = 5 : i64, smin = 4 : i64, umax = 5 : i64, umin = 4 : i64} : i64
3232// CHECK: %[[B:.*]] = test.with_bounds {smax = 7 : i64, smin = 6 : i64, umax = 7 : i64, umin = 6 : i64} : i64
33- // CHECK: %[[A_CASTED:.*]] = arith.trunci %[[A]] : i64 to i32
34- // CHECK: %[[B_CASTED:.*]] = arith.trunci %[[B]] : i64 to i32
35- // CHECK: %[[RES:.*]] = arith.addi %[[A_CASTED]], %[[B_CASTED]] : i32
36- // CHECK: %[[RES_CASTED:.*]] = arith.extui %[[RES]] : i32 to i64
33+ // CHECK: %[[A_CASTED:.*]] = arith.trunci %[[A]] : i64 to i8
34+ // CHECK: %[[B_CASTED:.*]] = arith.trunci %[[B]] : i64 to i8
35+ // CHECK: %[[RES:.*]] = arith.addi %[[A_CASTED]], %[[B_CASTED]] : i8
36+ // CHECK: %[[RES_CASTED:.*]] = arith.extui %[[RES]] : i8 to i64
3737// CHECK: return %[[RES_CASTED]] : i64
3838func.func @test_addi_i64 () -> i64 {
3939 %0 = test.with_bounds { umin = 4 : i64 , umax = 5 : i64 , smin = 4 : i64 , smax = 5 : i64 } : i64
@@ -45,9 +45,9 @@ func.func @test_addi_i64() -> i64 {
4545// CHECK-LABEL: func @test_cmpi
4646// CHECK: %[[A:.*]] = test.with_bounds {smax = 10 : index, smin = 0 : index, umax = 10 : index, umin = 0 : index} : index
4747// CHECK: %[[B:.*]] = test.with_bounds {smax = 10 : index, smin = 0 : index, umax = 10 : index, umin = 0 : index} : index
48- // CHECK: %[[A_CASTED:.*]] = arith.index_castui %[[A]] : index to i32
49- // CHECK: %[[B_CASTED:.*]] = arith.index_castui %[[B]] : index to i32
50- // CHECK: %[[RES:.*]] = arith.cmpi slt, %[[A_CASTED]], %[[B_CASTED]] : i32
48+ // CHECK: %[[A_CASTED:.*]] = arith.index_castui %[[A]] : index to i8
49+ // CHECK: %[[B_CASTED:.*]] = arith.index_castui %[[B]] : index to i8
50+ // CHECK: %[[RES:.*]] = arith.cmpi slt, %[[A_CASTED]], %[[B_CASTED]] : i8
5151// CHECK: return %[[RES]] : i1
5252func.func @test_cmpi () -> i1 {
5353 %0 = test.with_bounds { umin = 0 : index , umax = 10 : index , smin = 0 : index , smax = 10 : index } : index
0 commit comments