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: | FileCheck -check-prefix=RV32IF %s
4 ; RUN: llc -mtriple=riscv64 -mattr=+f -verify-machineinstrs < %s \
5 ; RUN: | FileCheck -check-prefix=RV64IF %s
7 define i32 @fcmp_false(float %a, float %b) nounwind {
8 ; RV32IF-LABEL: fcmp_false:
10 ; RV32IF-NEXT: mv a0, zero
13 ; RV64IF-LABEL: fcmp_false:
15 ; RV64IF-NEXT: mv a0, zero
17 %1 = fcmp false float %a, %b
18 %2 = zext i1 %1 to i32
22 define i32 @fcmp_oeq(float %a, float %b) nounwind {
23 ; RV32IF-LABEL: fcmp_oeq:
25 ; RV32IF-NEXT: fmv.w.x ft0, a1
26 ; RV32IF-NEXT: fmv.w.x ft1, a0
27 ; RV32IF-NEXT: feq.s a0, ft1, ft0
30 ; RV64IF-LABEL: fcmp_oeq:
32 ; RV64IF-NEXT: fmv.w.x ft0, a1
33 ; RV64IF-NEXT: fmv.w.x ft1, a0
34 ; RV64IF-NEXT: feq.s a0, ft1, ft0
36 %1 = fcmp oeq float %a, %b
37 %2 = zext i1 %1 to i32
41 define i32 @fcmp_ogt(float %a, float %b) nounwind {
42 ; RV32IF-LABEL: fcmp_ogt:
44 ; RV32IF-NEXT: fmv.w.x ft0, a0
45 ; RV32IF-NEXT: fmv.w.x ft1, a1
46 ; RV32IF-NEXT: flt.s a0, ft1, ft0
49 ; RV64IF-LABEL: fcmp_ogt:
51 ; RV64IF-NEXT: fmv.w.x ft0, a0
52 ; RV64IF-NEXT: fmv.w.x ft1, a1
53 ; RV64IF-NEXT: flt.s a0, ft1, ft0
55 %1 = fcmp ogt float %a, %b
56 %2 = zext i1 %1 to i32
60 define i32 @fcmp_oge(float %a, float %b) nounwind {
61 ; RV32IF-LABEL: fcmp_oge:
63 ; RV32IF-NEXT: fmv.w.x ft0, a0
64 ; RV32IF-NEXT: fmv.w.x ft1, a1
65 ; RV32IF-NEXT: fle.s a0, ft1, ft0
68 ; RV64IF-LABEL: fcmp_oge:
70 ; RV64IF-NEXT: fmv.w.x ft0, a0
71 ; RV64IF-NEXT: fmv.w.x ft1, a1
72 ; RV64IF-NEXT: fle.s a0, ft1, ft0
74 %1 = fcmp oge float %a, %b
75 %2 = zext i1 %1 to i32
79 define i32 @fcmp_olt(float %a, float %b) nounwind {
80 ; RV32IF-LABEL: fcmp_olt:
82 ; RV32IF-NEXT: fmv.w.x ft0, a1
83 ; RV32IF-NEXT: fmv.w.x ft1, a0
84 ; RV32IF-NEXT: flt.s a0, ft1, ft0
87 ; RV64IF-LABEL: fcmp_olt:
89 ; RV64IF-NEXT: fmv.w.x ft0, a1
90 ; RV64IF-NEXT: fmv.w.x ft1, a0
91 ; RV64IF-NEXT: flt.s a0, ft1, ft0
93 %1 = fcmp olt float %a, %b
94 %2 = zext i1 %1 to i32
98 define i32 @fcmp_ole(float %a, float %b) nounwind {
99 ; RV32IF-LABEL: fcmp_ole:
101 ; RV32IF-NEXT: fmv.w.x ft0, a1
102 ; RV32IF-NEXT: fmv.w.x ft1, a0
103 ; RV32IF-NEXT: fle.s a0, ft1, ft0
106 ; RV64IF-LABEL: fcmp_ole:
108 ; RV64IF-NEXT: fmv.w.x ft0, a1
109 ; RV64IF-NEXT: fmv.w.x ft1, a0
110 ; RV64IF-NEXT: fle.s a0, ft1, ft0
112 %1 = fcmp ole float %a, %b
113 %2 = zext i1 %1 to i32
117 define i32 @fcmp_one(float %a, float %b) nounwind {
118 ; RV32IF-LABEL: fcmp_one:
120 ; RV32IF-NEXT: fmv.w.x ft0, a0
121 ; RV32IF-NEXT: fmv.w.x ft1, a1
122 ; RV32IF-NEXT: feq.s a0, ft1, ft1
123 ; RV32IF-NEXT: feq.s a1, ft0, ft0
124 ; RV32IF-NEXT: and a0, a1, a0
125 ; RV32IF-NEXT: feq.s a1, ft0, ft1
126 ; RV32IF-NEXT: not a1, a1
127 ; RV32IF-NEXT: seqz a0, a0
128 ; RV32IF-NEXT: xori a0, a0, 1
129 ; RV32IF-NEXT: and a0, a1, a0
132 ; RV64IF-LABEL: fcmp_one:
134 ; RV64IF-NEXT: fmv.w.x ft0, a0
135 ; RV64IF-NEXT: fmv.w.x ft1, a1
136 ; RV64IF-NEXT: feq.s a0, ft1, ft1
137 ; RV64IF-NEXT: feq.s a1, ft0, ft0
138 ; RV64IF-NEXT: and a0, a1, a0
139 ; RV64IF-NEXT: feq.s a1, ft0, ft1
140 ; RV64IF-NEXT: not a1, a1
141 ; RV64IF-NEXT: seqz a0, a0
142 ; RV64IF-NEXT: xori a0, a0, 1
143 ; RV64IF-NEXT: and a0, a1, a0
145 %1 = fcmp one float %a, %b
146 %2 = zext i1 %1 to i32
150 define i32 @fcmp_ord(float %a, float %b) nounwind {
151 ; RV32IF-LABEL: fcmp_ord:
153 ; RV32IF-NEXT: fmv.w.x ft0, a1
154 ; RV32IF-NEXT: feq.s a1, ft0, ft0
155 ; RV32IF-NEXT: fmv.w.x ft0, a0
156 ; RV32IF-NEXT: feq.s a0, ft0, ft0
157 ; RV32IF-NEXT: and a0, a0, a1
158 ; RV32IF-NEXT: seqz a0, a0
159 ; RV32IF-NEXT: xori a0, a0, 1
162 ; RV64IF-LABEL: fcmp_ord:
164 ; RV64IF-NEXT: fmv.w.x ft0, a1
165 ; RV64IF-NEXT: feq.s a1, ft0, ft0
166 ; RV64IF-NEXT: fmv.w.x ft0, a0
167 ; RV64IF-NEXT: feq.s a0, ft0, ft0
168 ; RV64IF-NEXT: and a0, a0, a1
169 ; RV64IF-NEXT: seqz a0, a0
170 ; RV64IF-NEXT: xori a0, a0, 1
172 %1 = fcmp ord float %a, %b
173 %2 = zext i1 %1 to i32
177 define i32 @fcmp_ueq(float %a, float %b) nounwind {
178 ; RV32IF-LABEL: fcmp_ueq:
180 ; RV32IF-NEXT: fmv.w.x ft0, a1
181 ; RV32IF-NEXT: fmv.w.x ft1, a0
182 ; RV32IF-NEXT: feq.s a0, ft1, ft0
183 ; RV32IF-NEXT: feq.s a1, ft0, ft0
184 ; RV32IF-NEXT: feq.s a2, ft1, ft1
185 ; RV32IF-NEXT: and a1, a2, a1
186 ; RV32IF-NEXT: seqz a1, a1
187 ; RV32IF-NEXT: or a0, a0, a1
190 ; RV64IF-LABEL: fcmp_ueq:
192 ; RV64IF-NEXT: fmv.w.x ft0, a1
193 ; RV64IF-NEXT: fmv.w.x ft1, a0
194 ; RV64IF-NEXT: feq.s a0, ft1, ft0
195 ; RV64IF-NEXT: feq.s a1, ft0, ft0
196 ; RV64IF-NEXT: feq.s a2, ft1, ft1
197 ; RV64IF-NEXT: and a1, a2, a1
198 ; RV64IF-NEXT: seqz a1, a1
199 ; RV64IF-NEXT: or a0, a0, a1
201 %1 = fcmp ueq float %a, %b
202 %2 = zext i1 %1 to i32
206 define i32 @fcmp_ugt(float %a, float %b) nounwind {
207 ; RV32IF-LABEL: fcmp_ugt:
209 ; RV32IF-NEXT: fmv.w.x ft0, a1
210 ; RV32IF-NEXT: fmv.w.x ft1, a0
211 ; RV32IF-NEXT: fle.s a0, ft1, ft0
212 ; RV32IF-NEXT: xori a0, a0, 1
215 ; RV64IF-LABEL: fcmp_ugt:
217 ; RV64IF-NEXT: fmv.w.x ft0, a1
218 ; RV64IF-NEXT: fmv.w.x ft1, a0
219 ; RV64IF-NEXT: fle.s a0, ft1, ft0
220 ; RV64IF-NEXT: xori a0, a0, 1
222 %1 = fcmp ugt float %a, %b
223 %2 = zext i1 %1 to i32
227 define i32 @fcmp_uge(float %a, float %b) nounwind {
228 ; RV32IF-LABEL: fcmp_uge:
230 ; RV32IF-NEXT: fmv.w.x ft0, a1
231 ; RV32IF-NEXT: fmv.w.x ft1, a0
232 ; RV32IF-NEXT: flt.s a0, ft1, ft0
233 ; RV32IF-NEXT: xori a0, a0, 1
236 ; RV64IF-LABEL: fcmp_uge:
238 ; RV64IF-NEXT: fmv.w.x ft0, a1
239 ; RV64IF-NEXT: fmv.w.x ft1, a0
240 ; RV64IF-NEXT: flt.s a0, ft1, ft0
241 ; RV64IF-NEXT: xori a0, a0, 1
243 %1 = fcmp uge float %a, %b
244 %2 = zext i1 %1 to i32
248 define i32 @fcmp_ult(float %a, float %b) nounwind {
249 ; RV32IF-LABEL: fcmp_ult:
251 ; RV32IF-NEXT: fmv.w.x ft0, a0
252 ; RV32IF-NEXT: fmv.w.x ft1, a1
253 ; RV32IF-NEXT: fle.s a0, ft1, ft0
254 ; RV32IF-NEXT: xori a0, a0, 1
257 ; RV64IF-LABEL: fcmp_ult:
259 ; RV64IF-NEXT: fmv.w.x ft0, a0
260 ; RV64IF-NEXT: fmv.w.x ft1, a1
261 ; RV64IF-NEXT: fle.s a0, ft1, ft0
262 ; RV64IF-NEXT: xori a0, a0, 1
264 %1 = fcmp ult float %a, %b
265 %2 = zext i1 %1 to i32
269 define i32 @fcmp_ule(float %a, float %b) nounwind {
270 ; RV32IF-LABEL: fcmp_ule:
272 ; RV32IF-NEXT: fmv.w.x ft0, a0
273 ; RV32IF-NEXT: fmv.w.x ft1, a1
274 ; RV32IF-NEXT: flt.s a0, ft1, ft0
275 ; RV32IF-NEXT: xori a0, a0, 1
278 ; RV64IF-LABEL: fcmp_ule:
280 ; RV64IF-NEXT: fmv.w.x ft0, a0
281 ; RV64IF-NEXT: fmv.w.x ft1, a1
282 ; RV64IF-NEXT: flt.s a0, ft1, ft0
283 ; RV64IF-NEXT: xori a0, a0, 1
285 %1 = fcmp ule float %a, %b
286 %2 = zext i1 %1 to i32
290 define i32 @fcmp_une(float %a, float %b) nounwind {
291 ; RV32IF-LABEL: fcmp_une:
293 ; RV32IF-NEXT: fmv.w.x ft0, a1
294 ; RV32IF-NEXT: fmv.w.x ft1, a0
295 ; RV32IF-NEXT: feq.s a0, ft1, ft0
296 ; RV32IF-NEXT: xori a0, a0, 1
299 ; RV64IF-LABEL: fcmp_une:
301 ; RV64IF-NEXT: fmv.w.x ft0, a1
302 ; RV64IF-NEXT: fmv.w.x ft1, a0
303 ; RV64IF-NEXT: feq.s a0, ft1, ft0
304 ; RV64IF-NEXT: xori a0, a0, 1
306 %1 = fcmp une float %a, %b
307 %2 = zext i1 %1 to i32
311 define i32 @fcmp_uno(float %a, float %b) nounwind {
312 ; RV32IF-LABEL: fcmp_uno:
314 ; RV32IF-NEXT: fmv.w.x ft0, a1
315 ; RV32IF-NEXT: feq.s a1, ft0, ft0
316 ; RV32IF-NEXT: fmv.w.x ft0, a0
317 ; RV32IF-NEXT: feq.s a0, ft0, ft0
318 ; RV32IF-NEXT: and a0, a0, a1
319 ; RV32IF-NEXT: seqz a0, a0
322 ; RV64IF-LABEL: fcmp_uno:
324 ; RV64IF-NEXT: fmv.w.x ft0, a1
325 ; RV64IF-NEXT: feq.s a1, ft0, ft0
326 ; RV64IF-NEXT: fmv.w.x ft0, a0
327 ; RV64IF-NEXT: feq.s a0, ft0, ft0
328 ; RV64IF-NEXT: and a0, a0, a1
329 ; RV64IF-NEXT: seqz a0, a0
331 %1 = fcmp uno float %a, %b
332 %2 = zext i1 %1 to i32
336 define i32 @fcmp_true(float %a, float %b) nounwind {
337 ; RV32IF-LABEL: fcmp_true:
339 ; RV32IF-NEXT: addi a0, zero, 1
342 ; RV64IF-LABEL: fcmp_true:
344 ; RV64IF-NEXT: addi a0, zero, 1
346 %1 = fcmp true float %a, %b
347 %2 = zext i1 %1 to i32