@@ -12,13 +12,14 @@ subroutine shifta1_test(a, b, c)
12
12
! CHECK: %[[B_VAL:.*]] = fir.load %[[B]] : !fir.ref<i32>
13
13
c = shifta(a, b)
14
14
! CHECK: %[[C_BITS:.*]] = arith.constant 8 : i8
15
- ! CHECK: %[[C_0:.*]] = arith.constant 0 : i8
16
15
! CHECK: %[[B_CONV:.*]] = fir.convert %[[B_VAL]] : (i32) -> i8
17
- ! CHECK: %[[UNDER:.*]] = arith.cmpi slt, %[[B_CONV]], %[[C_0]] : i8
18
- ! CHECK: %[[OVER:.*]] = arith.cmpi sge, %[[B_CONV]], %[[C_BITS]] : i8
19
- ! CHECK: %[[INVALID:.*]] = arith.ori %[[UNDER]], %[[OVER]] : i1
20
- ! CHECK: %[[SHIFT:.*]] = arith.shrsi %[[A_VAL]], %[[B_CONV]] : i8
21
- ! CHECK: %[[RES:.*]] = arith.select %[[INVALID]], %[[C_0]], %[[SHIFT]] : i8
16
+ ! CHECK: %[[SHIFT_IS_BITWIDTH:.*]] = arith.cmpi eq, %[[B_CONV]], %[[C_BITS]] : i8
17
+ ! CHECK: %[[C0:.*]] = arith.constant 0 : i8
18
+ ! CHECK: %[[CM1:.*]] = arith.constant -1 : i8
19
+ ! CHECK: %[[IS_NEG:.*]] = arith.cmpi slt, %[[A_VAL]], %[[C0]] : i8
20
+ ! CHECK: %[[RES:.*]] = arith.select %[[IS_NEG]], %[[CM1]], %[[C0]] : i8
21
+ ! CHECK: %[[SHIFTED:.*]] = arith.shrsi %[[A_VAL]], %[[B_CONV]] : i8
22
+ ! CHECK: %{{.*}} = arith.select %[[SHIFT_IS_BITWIDTH]], %[[RES]], %[[SHIFTED]] : i8
22
23
end subroutine shifta1_test
23
24
24
25
! CHECK-LABEL: shifta2_test
@@ -32,13 +33,14 @@ subroutine shifta2_test(a, b, c)
32
33
! CHECK: %[[B_VAL:.*]] = fir.load %[[B]] : !fir.ref<i32>
33
34
c = shifta(a, b)
34
35
! CHECK: %[[C_BITS:.*]] = arith.constant 16 : i16
35
- ! CHECK: %[[C_0:.*]] = arith.constant 0 : i16
36
36
! CHECK: %[[B_CONV:.*]] = fir.convert %[[B_VAL]] : (i32) -> i16
37
- ! CHECK: %[[UNDER:.*]] = arith.cmpi slt, %[[B_CONV]], %[[C_0]] : i16
38
- ! CHECK: %[[OVER:.*]] = arith.cmpi sge, %[[B_CONV]], %[[C_BITS]] : i16
39
- ! CHECK: %[[INVALID:.*]] = arith.ori %[[UNDER]], %[[OVER]] : i1
40
- ! CHECK: %[[SHIFT:.*]] = arith.shrsi %[[A_VAL]], %[[B_CONV]] : i16
41
- ! CHECK: %[[RES:.*]] = arith.select %[[INVALID]], %[[C_0]], %[[SHIFT]] : i16
37
+ ! CHECK: %[[SHIFT_IS_BITWIDTH:.*]] = arith.cmpi eq, %[[B_CONV]], %[[C_BITS]] : i16
38
+ ! CHECK: %[[C0:.*]] = arith.constant 0 : i16
39
+ ! CHECK: %[[CM1:.*]] = arith.constant -1 : i16
40
+ ! CHECK: %[[IS_NEG:.*]] = arith.cmpi slt, %[[A_VAL]], %[[C0]] : i16
41
+ ! CHECK: %[[RES:.*]] = arith.select %[[IS_NEG]], %[[CM1]], %[[C0]] : i16
42
+ ! CHECK: %[[SHIFTED:.*]] = arith.shrsi %[[A_VAL]], %[[B_CONV]] : i16
43
+ ! CHECK: %{{.*}} = arith.select %[[SHIFT_IS_BITWIDTH]], %[[RES]], %[[SHIFTED]] : i16
42
44
end subroutine shifta2_test
43
45
44
46
! CHECK-LABEL: shifta4_test
@@ -52,12 +54,13 @@ subroutine shifta4_test(a, b, c)
52
54
! CHECK: %[[B_VAL:.*]] = fir.load %[[B]] : !fir.ref<i32>
53
55
c = shifta(a, b)
54
56
! CHECK: %[[C_BITS:.*]] = arith.constant 32 : i32
55
- ! CHECK: %[[C_0:.*]] = arith.constant 0 : i32
56
- ! CHECK: %[[UNDER:.*]] = arith.cmpi slt, %[[B_VAL]], %[[C_0]] : i32
57
- ! CHECK: %[[OVER:.*]] = arith.cmpi sge, %[[B_VAL]], %[[C_BITS]] : i32
58
- ! CHECK: %[[INVALID:.*]] = arith.ori %[[UNDER]], %[[OVER]] : i1
59
- ! CHECK: %[[SHIFT:.*]] = arith.shrsi %[[A_VAL]], %[[B_VAL]] : i32
60
- ! CHECK: %[[RES:.*]] = arith.select %[[INVALID]], %[[C_0]], %[[SHIFT]] : i32
57
+ ! CHECK: %[[SHIFT_IS_BITWIDTH:.*]] = arith.cmpi eq, %[[B_VAL]], %[[C_BITS]] : i32
58
+ ! CHECK: %[[C0:.*]] = arith.constant 0 : i32
59
+ ! CHECK: %[[CM1:.*]] = arith.constant -1 : i32
60
+ ! CHECK: %[[IS_NEG:.*]] = arith.cmpi slt, %[[A_VAL]], %[[C0]] : i32
61
+ ! CHECK: %[[RES:.*]] = arith.select %[[IS_NEG]], %[[CM1]], %[[C0]] : i32
62
+ ! CHECK: %[[SHIFTED:.*]] = arith.shrsi %[[A_VAL]], %[[B_VAL]] : i32
63
+ ! CHECK: %{{.*}} = arith.select %[[SHIFT_IS_BITWIDTH]], %[[RES]], %[[SHIFTED]] : i32
61
64
end subroutine shifta4_test
62
65
63
66
! CHECK-LABEL: shifta8_test
@@ -71,13 +74,14 @@ subroutine shifta8_test(a, b, c)
71
74
! CHECK: %[[B_VAL:.*]] = fir.load %[[B]] : !fir.ref<i32>
72
75
c = shifta(a, b)
73
76
! CHECK: %[[C_BITS:.*]] = arith.constant 64 : i64
74
- ! CHECK: %[[C_0:.*]] = arith.constant 0 : i64
75
77
! CHECK: %[[B_CONV:.*]] = fir.convert %[[B_VAL]] : (i32) -> i64
76
- ! CHECK: %[[UNDER:.*]] = arith.cmpi slt, %[[B_CONV]], %[[C_0]] : i64
77
- ! CHECK: %[[OVER:.*]] = arith.cmpi sge, %[[B_CONV]], %[[C_BITS]] : i64
78
- ! CHECK: %[[INVALID:.*]] = arith.ori %[[UNDER]], %[[OVER]] : i1
79
- ! CHECK: %[[SHIFT:.*]] = arith.shrsi %[[A_VAL]], %[[B_CONV]] : i64
80
- ! CHECK: %[[RES:.*]] = arith.select %[[INVALID]], %[[C_0]], %[[SHIFT]] : i64
78
+ ! CHECK: %[[SHIFT_IS_BITWIDTH:.*]] = arith.cmpi eq, %[[B_CONV]], %[[C_BITS]] : i64
79
+ ! CHECK: %[[C0:.*]] = arith.constant 0 : i64
80
+ ! CHECK: %[[CM1:.*]] = arith.constant -1 : i64
81
+ ! CHECK: %[[IS_NEG:.*]] = arith.cmpi slt, %[[A_VAL]], %[[C0]] : i64
82
+ ! CHECK: %[[RES:.*]] = arith.select %[[IS_NEG]], %[[CM1]], %[[C0]] : i64
83
+ ! CHECK: %[[SHIFTED:.*]] = arith.shrsi %[[A_VAL]], %[[B_CONV]] : i64
84
+ ! CHECK: %{{.*}} = arith.select %[[SHIFT_IS_BITWIDTH]], %[[RES]], %[[SHIFTED]] : i64
81
85
end subroutine shifta8_test
82
86
83
87
! CHECK-LABEL: shifta16_test
@@ -91,11 +95,12 @@ subroutine shifta16_test(a, b, c)
91
95
! CHECK: %[[B_VAL:.*]] = fir.load %[[B]] : !fir.ref<i32>
92
96
c = shifta(a, b)
93
97
! CHECK: %[[C_BITS:.*]] = arith.constant 128 : i128
94
- ! CHECK: %[[C_0:.*]] = arith.constant 0 : i128
95
98
! CHECK: %[[B_CONV:.*]] = fir.convert %[[B_VAL]] : (i32) -> i128
96
- ! CHECK: %[[UNDER:.*]] = arith.cmpi slt, %[[B_CONV]], %[[C_0]] : i128
97
- ! CHECK: %[[OVER:.*]] = arith.cmpi sge, %[[B_CONV]], %[[C_BITS]] : i128
98
- ! CHECK: %[[INVALID:.*]] = arith.ori %[[UNDER]], %[[OVER]] : i1
99
- ! CHECK: %[[SHIFT:.*]] = arith.shrsi %[[A_VAL]], %[[B_CONV]] : i128
100
- ! CHECK: %[[RES:.*]] = arith.select %[[INVALID]], %[[C_0]], %[[SHIFT]] : i128
99
+ ! CHECK: %[[SHIFT_IS_BITWIDTH:.*]] = arith.cmpi eq, %[[B_CONV]], %[[C_BITS]] : i128
100
+ ! CHECK: %[[C0:.*]] = arith.constant 0 : i128
101
+ ! CHECK: %[[CM1:.*]] = arith.constant {{.*}} : i128
102
+ ! CHECK: %[[IS_NEG:.*]] = arith.cmpi slt, %[[A_VAL]], %[[C0]] : i128
103
+ ! CHECK: %[[RES:.*]] = arith.select %[[IS_NEG]], %[[CM1]], %[[C0]] : i128
104
+ ! CHECK: %[[SHIFTED:.*]] = arith.shrsi %[[A_VAL]], %[[B_CONV]] : i128
105
+ ! CHECK: %{{.*}} = arith.select %[[SHIFT_IS_BITWIDTH]], %[[RES]], %[[SHIFTED]] : i128
101
106
end subroutine shifta16_test
0 commit comments