[Transforms] Silence a warning in SROA.cpp (NFC)
[llvm-project.git] / flang / test / Lower / Intrinsics / ble.f90
blob1c996a963e43090c01639ce7114eec37d2142ebf
1 ! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s
2 ! RUN: %flang_fc1 -emit-fir -flang-deprecated-no-hlfir %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)
7 integer :: a, b
8 logical :: c
9 ! CHECK: %[[A_VAL:.*]] = fir.load %[[A]] : !fir.ref<i32>
10 ! CHECK: %[[B_VAL:.*]] = fir.load %[[B]] : !fir.ref<i32>
11 c = ble(a, b)
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
21 logical :: c
22 ! CHECK: %[[A_VAL:.*]] = fir.load %[[A]] : !fir.ref<i8>
23 ! CHECK: %[[B_VAL:.*]] = fir.load %[[B]] : !fir.ref<i8>
24 c = ble(a, b)
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
34 logical :: c
35 ! CHECK: %[[A_VAL:.*]] = fir.load %[[A]] : !fir.ref<i16>
36 ! CHECK: %[[B_VAL:.*]] = fir.load %[[B]] : !fir.ref<i16>
37 c = ble(a, b)
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
47 logical :: c
48 ! CHECK: %[[A_VAL:.*]] = fir.load %[[A]] : !fir.ref<i32>
49 ! CHECK: %[[B_VAL:.*]] = fir.load %[[B]] : !fir.ref<i32>
50 c = ble(a, b)
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
60 logical :: c
61 ! CHECK: %[[A_VAL:.*]] = fir.load %[[A]] : !fir.ref<i64>
62 ! CHECK: %[[B_VAL:.*]] = fir.load %[[B]] : !fir.ref<i64>
63 c = ble(a, b)
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
73 logical :: c
74 ! CHECK: %[[A_VAL:.*]] = fir.load %[[A]] : !fir.ref<i128>
75 ! CHECK: %[[B_VAL:.*]] = fir.load %[[B]] : !fir.ref<i128>
76 c = ble(a, b)
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)
85 integer(kind=2) :: a
86 integer(kind=4) :: b
87 logical :: c
88 ! CHECK: %[[A_VAL:.*]] = fir.load %[[A]] : !fir.ref<i16>
89 ! CHECK: %[[B_VAL:.*]] = fir.load %[[B]] : !fir.ref<i32>
90 c = ble(a, b)
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)
100 integer(kind=4) :: a
101 integer(kind=2) :: b
102 logical :: c
103 ! CHECK: %[[A_VAL:.*]] = fir.load %[[A]] : !fir.ref<i32>
104 ! CHECK: %[[B_VAL:.*]] = fir.load %[[B]] : !fir.ref<i16>
105 c = ble(a, b)
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)
115 integer(kind=2) :: a
116 logical :: c
117 ! CHECK: %[[A_VAL:.*]] = fir.load %[[A]] : !fir.ref<i16>
118 ! CHECK: %[[B_VAL:.*]] = arith.constant 42 : i32
119 c = ble(a, 42_4)
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)
129 integer(kind=4) :: a
130 logical :: c
131 ! CHECK: %[[A_VAL:.*]] = fir.load %[[A]] : !fir.ref<i32>
132 ! CHECK: %[[B_VAL:.*]] = arith.constant 42 : i16
133 c = ble(a, 42_2)
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)
143 logical :: c
144 c = ble(-1_2, -1_4)
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)
153 logical :: c
154 c = ble(-1_4, -1_2)
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