1 ! RUN: bbc -emit-fir %s -o - | FileCheck %s
2 ! RUN: %flang_fc1 -emit-fir %s -o - | FileCheck %s
4 ! CHECK-LABEL: ble_test
5 ! CHECK-SAME: %[[A:.*]]: !fir.ref<i32>{{.*}}, %[[B:.*]]: !fir.ref<i32>{{.*}}, %[[C:.*]]: !fir.ref<!fir.logical<4>>{{.*}}
6 subroutine ble_test(a
, b
, c
)
9 ! CHECK: %[[A_VAL:.*]] = fir.load %[[A]] : !fir.ref<i32>
10 ! CHECK: %[[B_VAL:.*]] = fir.load %[[B]] : !fir.ref<i32>
12 ! CHECK: %[[C_CMP:.*]] = arith.cmpi ule, %[[A_VAL]], %[[B_VAL]] : i32
13 ! CHECK: %[[C_VAL:.*]] = fir.convert %[[C_CMP]] : (i1) -> !fir.logical<4>
14 ! CHECK: fir.store %[[C_VAL]] to %[[C]] : !fir.ref<!fir.logical<4>>
15 end subroutine ble_test
17 ! CHECK-LABEL: ble_test1
18 ! CHECK-SAME: %[[A:.*]]: !fir.ref<i8>{{.*}}, %[[B:.*]]: !fir.ref<i8>{{.*}}, %[[C:.*]]: !fir.ref<!fir.logical<4>>{{.*}}
19 subroutine ble_test1(a
, b
, c
)
20 integer(kind
=1) :: a
, b
22 ! CHECK: %[[A_VAL:.*]] = fir.load %[[A]] : !fir.ref<i8>
23 ! CHECK: %[[B_VAL:.*]] = fir.load %[[B]] : !fir.ref<i8>
25 ! CHECK: %[[C_CMP:.*]] = arith.cmpi ule, %[[A_VAL]], %[[B_VAL]] : i8
26 ! CHECK: %[[C_VAL:.*]] = fir.convert %[[C_CMP]] : (i1) -> !fir.logical<4>
27 ! CHECK: fir.store %[[C_VAL]] to %[[C]] : !fir.ref<!fir.logical<4>>
28 end subroutine ble_test1
30 ! CHECK-LABEL: ble_test2
31 ! CHECK-SAME: %[[A:.*]]: !fir.ref<i16>{{.*}}, %[[B:.*]]: !fir.ref<i16>{{.*}}, %[[C:.*]]: !fir.ref<!fir.logical<4>>{{.*}}
32 subroutine ble_test2(a
, b
, c
)
33 integer(kind
=2) :: a
, b
35 ! CHECK: %[[A_VAL:.*]] = fir.load %[[A]] : !fir.ref<i16>
36 ! CHECK: %[[B_VAL:.*]] = fir.load %[[B]] : !fir.ref<i16>
38 ! CHECK: %[[C_CMP:.*]] = arith.cmpi ule, %[[A_VAL]], %[[B_VAL]] : i16
39 ! CHECK: %[[C_VAL:.*]] = fir.convert %[[C_CMP]] : (i1) -> !fir.logical<4>
40 ! CHECK: fir.store %[[C_VAL]] to %[[C]] : !fir.ref<!fir.logical<4>>
41 end subroutine ble_test2
43 ! CHECK-LABEL: ble_test3
44 ! CHECK-SAME: %[[A:.*]]: !fir.ref<i32>{{.*}}, %[[B:.*]]: !fir.ref<i32>{{.*}}, %[[C:.*]]: !fir.ref<!fir.logical<4>>{{.*}}
45 subroutine ble_test3(a
, b
, c
)
46 integer(kind
=4) :: a
, b
48 ! CHECK: %[[A_VAL:.*]] = fir.load %[[A]] : !fir.ref<i32>
49 ! CHECK: %[[B_VAL:.*]] = fir.load %[[B]] : !fir.ref<i32>
51 ! CHECK: %[[C_CMP:.*]] = arith.cmpi ule, %[[A_VAL]], %[[B_VAL]] : i32
52 ! CHECK: %[[C_VAL:.*]] = fir.convert %[[C_CMP]] : (i1) -> !fir.logical<4>
53 ! CHECK: fir.store %[[C_VAL]] to %[[C]] : !fir.ref<!fir.logical<4>>
54 end subroutine ble_test3
56 ! CHECK-LABEL: ble_test4
57 ! CHECK-SAME: %[[A:.*]]: !fir.ref<i64>{{.*}}, %[[B:.*]]: !fir.ref<i64>{{.*}}, %[[C:.*]]: !fir.ref<!fir.logical<4>>{{.*}}
58 subroutine ble_test4(a
, b
, c
)
59 integer(kind
=8) :: a
, b
61 ! CHECK: %[[A_VAL:.*]] = fir.load %[[A]] : !fir.ref<i64>
62 ! CHECK: %[[B_VAL:.*]] = fir.load %[[B]] : !fir.ref<i64>
64 ! CHECK: %[[C_CMP:.*]] = arith.cmpi ule, %[[A_VAL]], %[[B_VAL]] : i64
65 ! CHECK: %[[C_VAL:.*]] = fir.convert %[[C_CMP]] : (i1) -> !fir.logical<4>
66 ! CHECK: fir.store %[[C_VAL]] to %[[C]] : !fir.ref<!fir.logical<4>>
67 end subroutine ble_test4
69 ! CHECK-LABEL: ble_test5
70 ! CHECK-SAME: %[[A:.*]]: !fir.ref<i128>{{.*}}, %[[B:.*]]: !fir.ref<i128>{{.*}}, %[[C:.*]]: !fir.ref<!fir.logical<4>>{{.*}}
71 subroutine ble_test5(a
, b
, c
)
72 integer(kind
=16) :: a
, b
74 ! CHECK: %[[A_VAL:.*]] = fir.load %[[A]] : !fir.ref<i128>
75 ! CHECK: %[[B_VAL:.*]] = fir.load %[[B]] : !fir.ref<i128>
77 ! CHECK: %[[C_CMP:.*]] = arith.cmpi ule, %[[A_VAL]], %[[B_VAL]] : i128
78 ! CHECK: %[[C_VAL:.*]] = fir.convert %[[C_CMP]] : (i1) -> !fir.logical<4>
79 ! CHECK: fir.store %[[C_VAL]] to %[[C]] : !fir.ref<!fir.logical<4>>
80 end subroutine ble_test5
82 ! CHECK-LABEL: ble_test6
83 ! CHECK-SAME: %[[A:.*]]: !fir.ref<i16>{{.*}}, %[[B:.*]]: !fir.ref<i32>{{.*}}, %[[C:.*]]: !fir.ref<!fir.logical<4>>{{.*}}
84 subroutine ble_test6(a
, b
, c
)
88 ! CHECK: %[[A_VAL:.*]] = fir.load %[[A]] : !fir.ref<i16>
89 ! CHECK: %[[B_VAL:.*]] = fir.load %[[B]] : !fir.ref<i32>
91 ! CHECK: %[[A_EXT:.*]] = arith.extui %[[A_VAL]] : i16 to i32
92 ! CHECK: %[[C_CMP:.*]] = arith.cmpi ule, %[[A_EXT]], %[[B_VAL]] : i32
93 ! CHECK: %[[C_VAL:.*]] = fir.convert %[[C_CMP]] : (i1) -> !fir.logical<4>
94 ! CHECK: fir.store %[[C_VAL]] to %[[C]] : !fir.ref<!fir.logical<4>>
95 end subroutine ble_test6
97 ! CHECK-LABEL: ble_test7
98 ! CHECK-SAME: %[[A:.*]]: !fir.ref<i32>{{.*}}, %[[B:.*]]: !fir.ref<i16>{{.*}}, %[[C:.*]]: !fir.ref<!fir.logical<4>>{{.*}}
99 subroutine ble_test7(a
, b
, c
)
103 ! CHECK: %[[A_VAL:.*]] = fir.load %[[A]] : !fir.ref<i32>
104 ! CHECK: %[[B_VAL:.*]] = fir.load %[[B]] : !fir.ref<i16>
106 ! CHECK: %[[B_EXT:.*]] = arith.extui %[[B_VAL]] : i16 to i32
107 ! CHECK: %[[C_CMP:.*]] = arith.cmpi ule, %[[A_VAL]], %[[B_EXT]] : i32
108 ! CHECK: %[[C_VAL:.*]] = fir.convert %[[C_CMP]] : (i1) -> !fir.logical<4>
109 ! CHECK: fir.store %[[C_VAL]] to %[[C]] : !fir.ref<!fir.logical<4>>
110 end subroutine ble_test7
112 ! CHECK-LABEL: ble_test8
113 ! CHECK-SAME: %[[A:.*]]: !fir.ref<i16>{{.*}}, %[[C:.*]]: !fir.ref<!fir.logical<4>>{{.*}}
114 subroutine ble_test8(a
, c
)
117 ! CHECK: %[[A_VAL:.*]] = fir.load %[[A]] : !fir.ref<i16>
118 ! CHECK: %[[B_VAL:.*]] = arith.constant 42 : i32
120 ! CHECK: %[[A_EXT:.*]] = arith.extui %[[A_VAL]] : i16 to i32
121 ! CHECK: %[[C_CMP:.*]] = arith.cmpi ule, %[[A_EXT]], %[[B_VAL]] : i32
122 ! CHECK: %[[C_VAL:.*]] = fir.convert %[[C_CMP]] : (i1) -> !fir.logical<4>
123 ! CHECK: fir.store %[[C_VAL]] to %[[C]] : !fir.ref<!fir.logical<4>>
124 end subroutine ble_test8
126 ! CHECK-LABEL: ble_test9
127 ! CHECK-SAME: %[[A:.*]]: !fir.ref<i32>{{.*}}, %[[C:.*]]: !fir.ref<!fir.logical<4>>{{.*}}
128 subroutine ble_test9(a
, c
)
131 ! CHECK: %[[A_VAL:.*]] = fir.load %[[A]] : !fir.ref<i32>
132 ! CHECK: %[[B_VAL:.*]] = arith.constant 42 : i16
134 ! CHECK: %[[B_EXT:.*]] = arith.extui %[[B_VAL]] : i16 to i32
135 ! CHECK: %[[C_CMP:.*]] = arith.cmpi ule, %[[A_VAL]], %[[B_EXT]] : i32
136 ! CHECK: %[[C_VAL:.*]] = fir.convert %[[C_CMP]] : (i1) -> !fir.logical<4>
137 ! CHECK: fir.store %[[C_VAL]] to %[[C]] : !fir.ref<!fir.logical<4>>
138 end subroutine ble_test9
140 ! CHECK-LABEL: ble_test10
141 ! CHECK-SAME: %[[C:.*]]: !fir.ref<!fir.logical<4>>{{.*}}
142 subroutine ble_test10(c
)
145 ! CHECK: %[[R:.*]] = arith.constant true
146 ! CHECK: %[[V:.*]] = fir.convert %[[R]] : (i1) -> !fir.logical<4>
147 ! CHECK: fir.store %[[V]] to %[[C]] : !fir.ref<!fir.logical<4>>
148 end subroutine ble_test10
150 ! CHECK-LABEL: ble_test11
151 ! CHECK-SAME: %[[C:.*]]: !fir.ref<!fir.logical<4>>{{.*}}
152 subroutine ble_test11(c
)
155 ! CHECK: %[[R:.*]] = arith.constant false
156 ! CHECK: %[[V:.*]] = fir.convert %[[R]] : (i1) -> !fir.logical<4>
157 ! CHECK: fir.store %[[V]] to %[[C]] : !fir.ref<!fir.logical<4>>
158 end subroutine ble_test11