1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
2 ; RUN: llc -mtriple=riscv32 -mattr=+zfbfmin -verify-machineinstrs \
3 ; RUN: -target-abi ilp32f < %s | FileCheck %s
4 ; RUN: llc -mtriple=riscv64 -mattr=+zfbfmin -verify-machineinstrs \
5 ; RUN: -target-abi lp64f < %s | FileCheck %s
7 define bfloat @select_fcmp_false(bfloat %a, bfloat %b) nounwind {
8 ; CHECK-LABEL: select_fcmp_false:
10 ; CHECK-NEXT: fmv.s fa0, fa1
12 %1 = fcmp false bfloat %a, %b
13 %2 = select i1 %1, bfloat %a, bfloat %b
17 define bfloat @select_fcmp_oeq(bfloat %a, bfloat %b) nounwind {
18 ; CHECK-LABEL: select_fcmp_oeq:
20 ; CHECK-NEXT: fcvt.s.bf16 fa5, fa1
21 ; CHECK-NEXT: fcvt.s.bf16 fa4, fa0
22 ; CHECK-NEXT: feq.s a0, fa4, fa5
23 ; CHECK-NEXT: bnez a0, .LBB1_2
24 ; CHECK-NEXT: # %bb.1:
25 ; CHECK-NEXT: fmv.s fa0, fa1
26 ; CHECK-NEXT: .LBB1_2:
28 %1 = fcmp oeq bfloat %a, %b
29 %2 = select i1 %1, bfloat %a, bfloat %b
33 define bfloat @select_fcmp_ogt(bfloat %a, bfloat %b) nounwind {
34 ; CHECK-LABEL: select_fcmp_ogt:
36 ; CHECK-NEXT: fcvt.s.bf16 fa5, fa0
37 ; CHECK-NEXT: fcvt.s.bf16 fa4, fa1
38 ; CHECK-NEXT: flt.s a0, fa4, fa5
39 ; CHECK-NEXT: bnez a0, .LBB2_2
40 ; CHECK-NEXT: # %bb.1:
41 ; CHECK-NEXT: fmv.s fa0, fa1
42 ; CHECK-NEXT: .LBB2_2:
44 %1 = fcmp ogt bfloat %a, %b
45 %2 = select i1 %1, bfloat %a, bfloat %b
49 define bfloat @select_fcmp_oge(bfloat %a, bfloat %b) nounwind {
50 ; CHECK-LABEL: select_fcmp_oge:
52 ; CHECK-NEXT: fcvt.s.bf16 fa5, fa0
53 ; CHECK-NEXT: fcvt.s.bf16 fa4, fa1
54 ; CHECK-NEXT: fle.s a0, fa4, fa5
55 ; CHECK-NEXT: bnez a0, .LBB3_2
56 ; CHECK-NEXT: # %bb.1:
57 ; CHECK-NEXT: fmv.s fa0, fa1
58 ; CHECK-NEXT: .LBB3_2:
60 %1 = fcmp oge bfloat %a, %b
61 %2 = select i1 %1, bfloat %a, bfloat %b
65 define bfloat @select_fcmp_olt(bfloat %a, bfloat %b) nounwind {
66 ; CHECK-LABEL: select_fcmp_olt:
68 ; CHECK-NEXT: fcvt.s.bf16 fa5, fa1
69 ; CHECK-NEXT: fcvt.s.bf16 fa4, fa0
70 ; CHECK-NEXT: flt.s a0, fa4, fa5
71 ; CHECK-NEXT: bnez a0, .LBB4_2
72 ; CHECK-NEXT: # %bb.1:
73 ; CHECK-NEXT: fmv.s fa0, fa1
74 ; CHECK-NEXT: .LBB4_2:
76 %1 = fcmp olt bfloat %a, %b
77 %2 = select i1 %1, bfloat %a, bfloat %b
81 define bfloat @select_fcmp_ole(bfloat %a, bfloat %b) nounwind {
82 ; CHECK-LABEL: select_fcmp_ole:
84 ; CHECK-NEXT: fcvt.s.bf16 fa5, fa1
85 ; CHECK-NEXT: fcvt.s.bf16 fa4, fa0
86 ; CHECK-NEXT: fle.s a0, fa4, fa5
87 ; CHECK-NEXT: bnez a0, .LBB5_2
88 ; CHECK-NEXT: # %bb.1:
89 ; CHECK-NEXT: fmv.s fa0, fa1
90 ; CHECK-NEXT: .LBB5_2:
92 %1 = fcmp ole bfloat %a, %b
93 %2 = select i1 %1, bfloat %a, bfloat %b
97 define bfloat @select_fcmp_one(bfloat %a, bfloat %b) nounwind {
98 ; CHECK-LABEL: select_fcmp_one:
100 ; CHECK-NEXT: fcvt.s.bf16 fa5, fa1
101 ; CHECK-NEXT: fcvt.s.bf16 fa4, fa0
102 ; CHECK-NEXT: flt.s a0, fa4, fa5
103 ; CHECK-NEXT: flt.s a1, fa5, fa4
104 ; CHECK-NEXT: or a0, a1, a0
105 ; CHECK-NEXT: bnez a0, .LBB6_2
106 ; CHECK-NEXT: # %bb.1:
107 ; CHECK-NEXT: fmv.s fa0, fa1
108 ; CHECK-NEXT: .LBB6_2:
110 %1 = fcmp one bfloat %a, %b
111 %2 = select i1 %1, bfloat %a, bfloat %b
115 define bfloat @select_fcmp_ord(bfloat %a, bfloat %b) nounwind {
116 ; CHECK-LABEL: select_fcmp_ord:
118 ; CHECK-NEXT: fcvt.s.bf16 fa5, fa1
119 ; CHECK-NEXT: feq.s a0, fa5, fa5
120 ; CHECK-NEXT: fcvt.s.bf16 fa5, fa0
121 ; CHECK-NEXT: feq.s a1, fa5, fa5
122 ; CHECK-NEXT: and a0, a1, a0
123 ; CHECK-NEXT: bnez a0, .LBB7_2
124 ; CHECK-NEXT: # %bb.1:
125 ; CHECK-NEXT: fmv.s fa0, fa1
126 ; CHECK-NEXT: .LBB7_2:
128 %1 = fcmp ord bfloat %a, %b
129 %2 = select i1 %1, bfloat %a, bfloat %b
133 define bfloat @select_fcmp_ueq(bfloat %a, bfloat %b) nounwind {
134 ; CHECK-LABEL: select_fcmp_ueq:
136 ; CHECK-NEXT: fcvt.s.bf16 fa5, fa1
137 ; CHECK-NEXT: fcvt.s.bf16 fa4, fa0
138 ; CHECK-NEXT: flt.s a0, fa4, fa5
139 ; CHECK-NEXT: flt.s a1, fa5, fa4
140 ; CHECK-NEXT: or a0, a1, a0
141 ; CHECK-NEXT: beqz a0, .LBB8_2
142 ; CHECK-NEXT: # %bb.1:
143 ; CHECK-NEXT: fmv.s fa0, fa1
144 ; CHECK-NEXT: .LBB8_2:
146 %1 = fcmp ueq bfloat %a, %b
147 %2 = select i1 %1, bfloat %a, bfloat %b
151 define bfloat @select_fcmp_ugt(bfloat %a, bfloat %b) nounwind {
152 ; CHECK-LABEL: select_fcmp_ugt:
154 ; CHECK-NEXT: fcvt.s.bf16 fa5, fa1
155 ; CHECK-NEXT: fcvt.s.bf16 fa4, fa0
156 ; CHECK-NEXT: fle.s a0, fa4, fa5
157 ; CHECK-NEXT: beqz a0, .LBB9_2
158 ; CHECK-NEXT: # %bb.1:
159 ; CHECK-NEXT: fmv.s fa0, fa1
160 ; CHECK-NEXT: .LBB9_2:
162 %1 = fcmp ugt bfloat %a, %b
163 %2 = select i1 %1, bfloat %a, bfloat %b
167 define bfloat @select_fcmp_uge(bfloat %a, bfloat %b) nounwind {
168 ; CHECK-LABEL: select_fcmp_uge:
170 ; CHECK-NEXT: fcvt.s.bf16 fa5, fa1
171 ; CHECK-NEXT: fcvt.s.bf16 fa4, fa0
172 ; CHECK-NEXT: flt.s a0, fa4, fa5
173 ; CHECK-NEXT: beqz a0, .LBB10_2
174 ; CHECK-NEXT: # %bb.1:
175 ; CHECK-NEXT: fmv.s fa0, fa1
176 ; CHECK-NEXT: .LBB10_2:
178 %1 = fcmp uge bfloat %a, %b
179 %2 = select i1 %1, bfloat %a, bfloat %b
183 define bfloat @select_fcmp_ult(bfloat %a, bfloat %b) nounwind {
184 ; CHECK-LABEL: select_fcmp_ult:
186 ; CHECK-NEXT: fcvt.s.bf16 fa5, fa0
187 ; CHECK-NEXT: fcvt.s.bf16 fa4, fa1
188 ; CHECK-NEXT: fle.s a0, fa4, fa5
189 ; CHECK-NEXT: beqz a0, .LBB11_2
190 ; CHECK-NEXT: # %bb.1:
191 ; CHECK-NEXT: fmv.s fa0, fa1
192 ; CHECK-NEXT: .LBB11_2:
194 %1 = fcmp ult bfloat %a, %b
195 %2 = select i1 %1, bfloat %a, bfloat %b
199 define bfloat @select_fcmp_ule(bfloat %a, bfloat %b) nounwind {
200 ; CHECK-LABEL: select_fcmp_ule:
202 ; CHECK-NEXT: fcvt.s.bf16 fa5, fa0
203 ; CHECK-NEXT: fcvt.s.bf16 fa4, fa1
204 ; CHECK-NEXT: flt.s a0, fa4, fa5
205 ; CHECK-NEXT: beqz a0, .LBB12_2
206 ; CHECK-NEXT: # %bb.1:
207 ; CHECK-NEXT: fmv.s fa0, fa1
208 ; CHECK-NEXT: .LBB12_2:
210 %1 = fcmp ule bfloat %a, %b
211 %2 = select i1 %1, bfloat %a, bfloat %b
215 define bfloat @select_fcmp_une(bfloat %a, bfloat %b) nounwind {
216 ; CHECK-LABEL: select_fcmp_une:
218 ; CHECK-NEXT: fcvt.s.bf16 fa5, fa1
219 ; CHECK-NEXT: fcvt.s.bf16 fa4, fa0
220 ; CHECK-NEXT: feq.s a0, fa4, fa5
221 ; CHECK-NEXT: beqz a0, .LBB13_2
222 ; CHECK-NEXT: # %bb.1:
223 ; CHECK-NEXT: fmv.s fa0, fa1
224 ; CHECK-NEXT: .LBB13_2:
226 %1 = fcmp une bfloat %a, %b
227 %2 = select i1 %1, bfloat %a, bfloat %b
231 define bfloat @select_fcmp_uno(bfloat %a, bfloat %b) nounwind {
232 ; CHECK-LABEL: select_fcmp_uno:
234 ; CHECK-NEXT: fcvt.s.bf16 fa5, fa1
235 ; CHECK-NEXT: feq.s a0, fa5, fa5
236 ; CHECK-NEXT: fcvt.s.bf16 fa5, fa0
237 ; CHECK-NEXT: feq.s a1, fa5, fa5
238 ; CHECK-NEXT: and a0, a1, a0
239 ; CHECK-NEXT: beqz a0, .LBB14_2
240 ; CHECK-NEXT: # %bb.1:
241 ; CHECK-NEXT: fmv.s fa0, fa1
242 ; CHECK-NEXT: .LBB14_2:
244 %1 = fcmp uno bfloat %a, %b
245 %2 = select i1 %1, bfloat %a, bfloat %b
249 define bfloat @select_fcmp_true(bfloat %a, bfloat %b) nounwind {
250 ; CHECK-LABEL: select_fcmp_true:
253 %1 = fcmp true bfloat %a, %b
254 %2 = select i1 %1, bfloat %a, bfloat %b
258 ; Ensure that ISel succeeds for a select+fcmp that has an i32 result type.
259 define i32 @i32_select_fcmp_oeq(bfloat %a, bfloat %b, i32 %c, i32 %d) nounwind {
260 ; CHECK-LABEL: i32_select_fcmp_oeq:
262 ; CHECK-NEXT: fcvt.s.bf16 fa5, fa1
263 ; CHECK-NEXT: fcvt.s.bf16 fa4, fa0
264 ; CHECK-NEXT: feq.s a2, fa4, fa5
265 ; CHECK-NEXT: bnez a2, .LBB16_2
266 ; CHECK-NEXT: # %bb.1:
267 ; CHECK-NEXT: mv a0, a1
268 ; CHECK-NEXT: .LBB16_2:
270 %1 = fcmp oeq bfloat %a, %b
271 %2 = select i1 %1, i32 %c, i32 %d
275 define i32 @select_fcmp_oeq_1_2(bfloat %a, bfloat %b) {
276 ; CHECK-LABEL: select_fcmp_oeq_1_2:
278 ; CHECK-NEXT: fcvt.s.bf16 fa5, fa1
279 ; CHECK-NEXT: fcvt.s.bf16 fa4, fa0
280 ; CHECK-NEXT: feq.s a0, fa4, fa5
281 ; CHECK-NEXT: li a1, 2
282 ; CHECK-NEXT: sub a0, a1, a0
284 %1 = fcmp fast oeq bfloat %a, %b
285 %2 = select i1 %1, i32 1, i32 2
289 define signext i32 @select_fcmp_uge_negone_zero(bfloat %a, bfloat %b) nounwind {
290 ; CHECK-LABEL: select_fcmp_uge_negone_zero:
292 ; CHECK-NEXT: fcvt.s.bf16 fa5, fa1
293 ; CHECK-NEXT: fcvt.s.bf16 fa4, fa0
294 ; CHECK-NEXT: fle.s a0, fa4, fa5
295 ; CHECK-NEXT: addi a0, a0, -1
297 %1 = fcmp ugt bfloat %a, %b
298 %2 = select i1 %1, i32 -1, i32 0
302 define signext i32 @select_fcmp_uge_1_2(bfloat %a, bfloat %b) nounwind {
303 ; CHECK-LABEL: select_fcmp_uge_1_2:
305 ; CHECK-NEXT: fcvt.s.bf16 fa5, fa1
306 ; CHECK-NEXT: fcvt.s.bf16 fa4, fa0
307 ; CHECK-NEXT: fle.s a0, fa4, fa5
308 ; CHECK-NEXT: addi a0, a0, 1
310 %1 = fcmp ugt bfloat %a, %b
311 %2 = select i1 %1, i32 1, i32 2