1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=+f -verify-machineinstrs < %s \
3 ; RUN: -target-abi=ilp32f | FileCheck %s
4 ; RUN: llc -mtriple=riscv64 -mattr=+f -verify-machineinstrs < %s \
5 ; RUN: -target-abi=lp64f | FileCheck %s
7 define float @select_fcmp_false(float %a, float %b) nounwind {
8 ; CHECK-LABEL: select_fcmp_false:
10 ; CHECK-NEXT: fmv.s fa0, fa1
12 %1 = fcmp false float %a, %b
13 %2 = select i1 %1, float %a, float %b
17 define float @select_fcmp_oeq(float %a, float %b) nounwind {
18 ; CHECK-LABEL: select_fcmp_oeq:
20 ; CHECK-NEXT: feq.s a0, fa0, fa1
21 ; CHECK-NEXT: bnez a0, .LBB1_2
22 ; CHECK-NEXT: # %bb.1:
23 ; CHECK-NEXT: fmv.s fa0, fa1
24 ; CHECK-NEXT: .LBB1_2:
26 %1 = fcmp oeq float %a, %b
27 %2 = select i1 %1, float %a, float %b
31 define float @select_fcmp_ogt(float %a, float %b) nounwind {
32 ; CHECK-LABEL: select_fcmp_ogt:
34 ; CHECK-NEXT: flt.s a0, fa1, fa0
35 ; CHECK-NEXT: bnez a0, .LBB2_2
36 ; CHECK-NEXT: # %bb.1:
37 ; CHECK-NEXT: fmv.s fa0, fa1
38 ; CHECK-NEXT: .LBB2_2:
40 %1 = fcmp ogt float %a, %b
41 %2 = select i1 %1, float %a, float %b
45 define float @select_fcmp_oge(float %a, float %b) nounwind {
46 ; CHECK-LABEL: select_fcmp_oge:
48 ; CHECK-NEXT: fle.s a0, fa1, fa0
49 ; CHECK-NEXT: bnez a0, .LBB3_2
50 ; CHECK-NEXT: # %bb.1:
51 ; CHECK-NEXT: fmv.s fa0, fa1
52 ; CHECK-NEXT: .LBB3_2:
54 %1 = fcmp oge float %a, %b
55 %2 = select i1 %1, float %a, float %b
59 define float @select_fcmp_olt(float %a, float %b) nounwind {
60 ; CHECK-LABEL: select_fcmp_olt:
62 ; CHECK-NEXT: flt.s a0, fa0, fa1
63 ; CHECK-NEXT: bnez a0, .LBB4_2
64 ; CHECK-NEXT: # %bb.1:
65 ; CHECK-NEXT: fmv.s fa0, fa1
66 ; CHECK-NEXT: .LBB4_2:
68 %1 = fcmp olt float %a, %b
69 %2 = select i1 %1, float %a, float %b
73 define float @select_fcmp_ole(float %a, float %b) nounwind {
74 ; CHECK-LABEL: select_fcmp_ole:
76 ; CHECK-NEXT: fle.s a0, fa0, fa1
77 ; CHECK-NEXT: bnez a0, .LBB5_2
78 ; CHECK-NEXT: # %bb.1:
79 ; CHECK-NEXT: fmv.s fa0, fa1
80 ; CHECK-NEXT: .LBB5_2:
82 %1 = fcmp ole float %a, %b
83 %2 = select i1 %1, float %a, float %b
87 define float @select_fcmp_one(float %a, float %b) nounwind {
88 ; CHECK-LABEL: select_fcmp_one:
90 ; CHECK-NEXT: flt.s a0, fa0, fa1
91 ; CHECK-NEXT: flt.s a1, fa1, fa0
92 ; CHECK-NEXT: or a0, a1, a0
93 ; CHECK-NEXT: bnez a0, .LBB6_2
94 ; CHECK-NEXT: # %bb.1:
95 ; CHECK-NEXT: fmv.s fa0, fa1
96 ; CHECK-NEXT: .LBB6_2:
98 %1 = fcmp one float %a, %b
99 %2 = select i1 %1, float %a, float %b
103 define float @select_fcmp_ord(float %a, float %b) nounwind {
104 ; CHECK-LABEL: select_fcmp_ord:
106 ; CHECK-NEXT: feq.s a0, fa1, fa1
107 ; CHECK-NEXT: feq.s a1, fa0, fa0
108 ; CHECK-NEXT: and a0, a1, a0
109 ; CHECK-NEXT: bnez a0, .LBB7_2
110 ; CHECK-NEXT: # %bb.1:
111 ; CHECK-NEXT: fmv.s fa0, fa1
112 ; CHECK-NEXT: .LBB7_2:
114 %1 = fcmp ord float %a, %b
115 %2 = select i1 %1, float %a, float %b
119 define float @select_fcmp_ueq(float %a, float %b) nounwind {
120 ; CHECK-LABEL: select_fcmp_ueq:
122 ; CHECK-NEXT: flt.s a0, fa0, fa1
123 ; CHECK-NEXT: flt.s a1, fa1, fa0
124 ; CHECK-NEXT: or a0, a1, a0
125 ; CHECK-NEXT: beqz a0, .LBB8_2
126 ; CHECK-NEXT: # %bb.1:
127 ; CHECK-NEXT: fmv.s fa0, fa1
128 ; CHECK-NEXT: .LBB8_2:
130 %1 = fcmp ueq float %a, %b
131 %2 = select i1 %1, float %a, float %b
135 define float @select_fcmp_ugt(float %a, float %b) nounwind {
136 ; CHECK-LABEL: select_fcmp_ugt:
138 ; CHECK-NEXT: fle.s a0, fa0, fa1
139 ; CHECK-NEXT: beqz a0, .LBB9_2
140 ; CHECK-NEXT: # %bb.1:
141 ; CHECK-NEXT: fmv.s fa0, fa1
142 ; CHECK-NEXT: .LBB9_2:
144 %1 = fcmp ugt float %a, %b
145 %2 = select i1 %1, float %a, float %b
149 define float @select_fcmp_uge(float %a, float %b) nounwind {
150 ; CHECK-LABEL: select_fcmp_uge:
152 ; CHECK-NEXT: flt.s a0, fa0, fa1
153 ; CHECK-NEXT: beqz a0, .LBB10_2
154 ; CHECK-NEXT: # %bb.1:
155 ; CHECK-NEXT: fmv.s fa0, fa1
156 ; CHECK-NEXT: .LBB10_2:
158 %1 = fcmp uge float %a, %b
159 %2 = select i1 %1, float %a, float %b
163 define float @select_fcmp_ult(float %a, float %b) nounwind {
164 ; CHECK-LABEL: select_fcmp_ult:
166 ; CHECK-NEXT: fle.s a0, fa1, fa0
167 ; CHECK-NEXT: beqz a0, .LBB11_2
168 ; CHECK-NEXT: # %bb.1:
169 ; CHECK-NEXT: fmv.s fa0, fa1
170 ; CHECK-NEXT: .LBB11_2:
172 %1 = fcmp ult float %a, %b
173 %2 = select i1 %1, float %a, float %b
177 define float @select_fcmp_ule(float %a, float %b) nounwind {
178 ; CHECK-LABEL: select_fcmp_ule:
180 ; CHECK-NEXT: flt.s a0, fa1, fa0
181 ; CHECK-NEXT: beqz a0, .LBB12_2
182 ; CHECK-NEXT: # %bb.1:
183 ; CHECK-NEXT: fmv.s fa0, fa1
184 ; CHECK-NEXT: .LBB12_2:
186 %1 = fcmp ule float %a, %b
187 %2 = select i1 %1, float %a, float %b
191 define float @select_fcmp_une(float %a, float %b) nounwind {
192 ; CHECK-LABEL: select_fcmp_une:
194 ; CHECK-NEXT: feq.s a0, fa0, fa1
195 ; CHECK-NEXT: beqz a0, .LBB13_2
196 ; CHECK-NEXT: # %bb.1:
197 ; CHECK-NEXT: fmv.s fa0, fa1
198 ; CHECK-NEXT: .LBB13_2:
200 %1 = fcmp une float %a, %b
201 %2 = select i1 %1, float %a, float %b
205 define float @select_fcmp_uno(float %a, float %b) nounwind {
206 ; CHECK-LABEL: select_fcmp_uno:
208 ; CHECK-NEXT: feq.s a0, fa1, fa1
209 ; CHECK-NEXT: feq.s a1, fa0, fa0
210 ; CHECK-NEXT: and a0, a1, a0
211 ; CHECK-NEXT: beqz a0, .LBB14_2
212 ; CHECK-NEXT: # %bb.1:
213 ; CHECK-NEXT: fmv.s fa0, fa1
214 ; CHECK-NEXT: .LBB14_2:
216 %1 = fcmp uno float %a, %b
217 %2 = select i1 %1, float %a, float %b
221 define float @select_fcmp_true(float %a, float %b) nounwind {
222 ; CHECK-LABEL: select_fcmp_true:
225 %1 = fcmp true float %a, %b
226 %2 = select i1 %1, float %a, float %b
230 ; Ensure that ISel succeeds for a select+fcmp that has an i32 result type.
231 define i32 @i32_select_fcmp_oeq(float %a, float %b, i32 %c, i32 %d) nounwind {
232 ; CHECK-LABEL: i32_select_fcmp_oeq:
234 ; CHECK-NEXT: feq.s a2, fa0, fa1
235 ; CHECK-NEXT: bnez a2, .LBB16_2
236 ; CHECK-NEXT: # %bb.1:
237 ; CHECK-NEXT: mv a0, a1
238 ; CHECK-NEXT: .LBB16_2:
240 %1 = fcmp oeq float %a, %b
241 %2 = select i1 %1, i32 %c, i32 %d
245 define i32 @select_fcmp_oeq_1_2(float %a, float %b) {
246 ; CHECK-LABEL: select_fcmp_oeq_1_2:
248 ; CHECK-NEXT: feq.s a0, fa0, fa1
249 ; CHECK-NEXT: li a1, 2
250 ; CHECK-NEXT: sub a0, a1, a0
252 %1 = fcmp fast oeq float %a, %b
253 %2 = select i1 %1, i32 1, i32 2
257 define signext i32 @select_fcmp_uge_negone_zero(float %a, float %b) nounwind {
258 ; CHECK-LABEL: select_fcmp_uge_negone_zero:
260 ; CHECK-NEXT: fle.s a0, fa0, fa1
261 ; CHECK-NEXT: addi a0, a0, -1
263 %1 = fcmp ugt float %a, %b
264 %2 = select i1 %1, i32 -1, i32 0
268 define signext i32 @select_fcmp_uge_1_2(float %a, float %b) nounwind {
269 ; CHECK-LABEL: select_fcmp_uge_1_2:
271 ; CHECK-NEXT: fle.s a0, fa0, fa1
272 ; CHECK-NEXT: addi a0, a0, 1
274 %1 = fcmp ugt float %a, %b
275 %2 = select i1 %1, i32 1, i32 2