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: and a0, a1, a0
130 ; RV64IF-LABEL: fcmp_one:
132 ; RV64IF-NEXT: fmv.w.x ft0, a0
133 ; RV64IF-NEXT: fmv.w.x ft1, a1
134 ; RV64IF-NEXT: feq.s a0, ft1, ft1
135 ; RV64IF-NEXT: feq.s a1, ft0, ft0
136 ; RV64IF-NEXT: and a0, a1, a0
137 ; RV64IF-NEXT: feq.s a1, ft0, ft1
138 ; RV64IF-NEXT: not a1, a1
139 ; RV64IF-NEXT: and a0, a1, a0
141 %1 = fcmp one float %a, %b
142 %2 = zext i1 %1 to i32
146 define i32 @fcmp_ord(float %a, float %b) nounwind {
147 ; RV32IF-LABEL: fcmp_ord:
149 ; RV32IF-NEXT: fmv.w.x ft0, a0
150 ; RV32IF-NEXT: fmv.w.x ft1, a1
151 ; RV32IF-NEXT: feq.s a0, ft1, ft1
152 ; RV32IF-NEXT: feq.s a1, ft0, ft0
153 ; RV32IF-NEXT: and a0, a1, a0
156 ; RV64IF-LABEL: fcmp_ord:
158 ; RV64IF-NEXT: fmv.w.x ft0, a0
159 ; RV64IF-NEXT: fmv.w.x ft1, a1
160 ; RV64IF-NEXT: feq.s a0, ft1, ft1
161 ; RV64IF-NEXT: feq.s a1, ft0, ft0
162 ; RV64IF-NEXT: and a0, a1, a0
164 %1 = fcmp ord float %a, %b
165 %2 = zext i1 %1 to i32
169 define i32 @fcmp_ueq(float %a, float %b) nounwind {
170 ; RV32IF-LABEL: fcmp_ueq:
172 ; RV32IF-NEXT: fmv.w.x ft0, a1
173 ; RV32IF-NEXT: fmv.w.x ft1, a0
174 ; RV32IF-NEXT: feq.s a0, ft1, ft0
175 ; RV32IF-NEXT: feq.s a1, ft0, ft0
176 ; RV32IF-NEXT: feq.s a2, ft1, ft1
177 ; RV32IF-NEXT: and a1, a2, a1
178 ; RV32IF-NEXT: seqz a1, a1
179 ; RV32IF-NEXT: or a0, a0, a1
182 ; RV64IF-LABEL: fcmp_ueq:
184 ; RV64IF-NEXT: fmv.w.x ft0, a1
185 ; RV64IF-NEXT: fmv.w.x ft1, a0
186 ; RV64IF-NEXT: feq.s a0, ft1, ft0
187 ; RV64IF-NEXT: feq.s a1, ft0, ft0
188 ; RV64IF-NEXT: feq.s a2, ft1, ft1
189 ; RV64IF-NEXT: and a1, a2, a1
190 ; RV64IF-NEXT: seqz a1, a1
191 ; RV64IF-NEXT: or a0, a0, a1
193 %1 = fcmp ueq float %a, %b
194 %2 = zext i1 %1 to i32
198 define i32 @fcmp_ugt(float %a, float %b) nounwind {
199 ; RV32IF-LABEL: fcmp_ugt:
201 ; RV32IF-NEXT: fmv.w.x ft0, a1
202 ; RV32IF-NEXT: fmv.w.x ft1, a0
203 ; RV32IF-NEXT: fle.s a0, ft1, ft0
204 ; RV32IF-NEXT: xori a0, a0, 1
207 ; RV64IF-LABEL: fcmp_ugt:
209 ; RV64IF-NEXT: fmv.w.x ft0, a1
210 ; RV64IF-NEXT: fmv.w.x ft1, a0
211 ; RV64IF-NEXT: fle.s a0, ft1, ft0
212 ; RV64IF-NEXT: xori a0, a0, 1
214 %1 = fcmp ugt float %a, %b
215 %2 = zext i1 %1 to i32
219 define i32 @fcmp_uge(float %a, float %b) nounwind {
220 ; RV32IF-LABEL: fcmp_uge:
222 ; RV32IF-NEXT: fmv.w.x ft0, a1
223 ; RV32IF-NEXT: fmv.w.x ft1, a0
224 ; RV32IF-NEXT: flt.s a0, ft1, ft0
225 ; RV32IF-NEXT: xori a0, a0, 1
228 ; RV64IF-LABEL: fcmp_uge:
230 ; RV64IF-NEXT: fmv.w.x ft0, a1
231 ; RV64IF-NEXT: fmv.w.x ft1, a0
232 ; RV64IF-NEXT: flt.s a0, ft1, ft0
233 ; RV64IF-NEXT: xori a0, a0, 1
235 %1 = fcmp uge float %a, %b
236 %2 = zext i1 %1 to i32
240 define i32 @fcmp_ult(float %a, float %b) nounwind {
241 ; RV32IF-LABEL: fcmp_ult:
243 ; RV32IF-NEXT: fmv.w.x ft0, a0
244 ; RV32IF-NEXT: fmv.w.x ft1, a1
245 ; RV32IF-NEXT: fle.s a0, ft1, ft0
246 ; RV32IF-NEXT: xori a0, a0, 1
249 ; RV64IF-LABEL: fcmp_ult:
251 ; RV64IF-NEXT: fmv.w.x ft0, a0
252 ; RV64IF-NEXT: fmv.w.x ft1, a1
253 ; RV64IF-NEXT: fle.s a0, ft1, ft0
254 ; RV64IF-NEXT: xori a0, a0, 1
256 %1 = fcmp ult float %a, %b
257 %2 = zext i1 %1 to i32
261 define i32 @fcmp_ule(float %a, float %b) nounwind {
262 ; RV32IF-LABEL: fcmp_ule:
264 ; RV32IF-NEXT: fmv.w.x ft0, a0
265 ; RV32IF-NEXT: fmv.w.x ft1, a1
266 ; RV32IF-NEXT: flt.s a0, ft1, ft0
267 ; RV32IF-NEXT: xori a0, a0, 1
270 ; RV64IF-LABEL: fcmp_ule:
272 ; RV64IF-NEXT: fmv.w.x ft0, a0
273 ; RV64IF-NEXT: fmv.w.x ft1, a1
274 ; RV64IF-NEXT: flt.s a0, ft1, ft0
275 ; RV64IF-NEXT: xori a0, a0, 1
277 %1 = fcmp ule float %a, %b
278 %2 = zext i1 %1 to i32
282 define i32 @fcmp_une(float %a, float %b) nounwind {
283 ; RV32IF-LABEL: fcmp_une:
285 ; RV32IF-NEXT: fmv.w.x ft0, a1
286 ; RV32IF-NEXT: fmv.w.x ft1, a0
287 ; RV32IF-NEXT: feq.s a0, ft1, ft0
288 ; RV32IF-NEXT: xori a0, a0, 1
291 ; RV64IF-LABEL: fcmp_une:
293 ; RV64IF-NEXT: fmv.w.x ft0, a1
294 ; RV64IF-NEXT: fmv.w.x ft1, a0
295 ; RV64IF-NEXT: feq.s a0, ft1, ft0
296 ; RV64IF-NEXT: xori a0, a0, 1
298 %1 = fcmp une float %a, %b
299 %2 = zext i1 %1 to i32
303 define i32 @fcmp_uno(float %a, float %b) nounwind {
304 ; RV32IF-LABEL: fcmp_uno:
306 ; RV32IF-NEXT: fmv.w.x ft0, a0
307 ; RV32IF-NEXT: fmv.w.x ft1, a1
308 ; RV32IF-NEXT: feq.s a0, ft1, ft1
309 ; RV32IF-NEXT: feq.s a1, ft0, ft0
310 ; RV32IF-NEXT: and a0, a1, a0
311 ; RV32IF-NEXT: seqz a0, a0
314 ; RV64IF-LABEL: fcmp_uno:
316 ; RV64IF-NEXT: fmv.w.x ft0, a0
317 ; RV64IF-NEXT: fmv.w.x ft1, a1
318 ; RV64IF-NEXT: feq.s a0, ft1, ft1
319 ; RV64IF-NEXT: feq.s a1, ft0, ft0
320 ; RV64IF-NEXT: and a0, a1, a0
321 ; RV64IF-NEXT: seqz a0, a0
323 %1 = fcmp uno float %a, %b
324 %2 = zext i1 %1 to i32
328 define i32 @fcmp_true(float %a, float %b) nounwind {
329 ; RV32IF-LABEL: fcmp_true:
331 ; RV32IF-NEXT: addi a0, zero, 1
334 ; RV64IF-LABEL: fcmp_true:
336 ; RV64IF-NEXT: addi a0, zero, 1
338 %1 = fcmp true float %a, %b
339 %2 = zext i1 %1 to i32