1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc --mtriple=loongarch32 --mattr=+f,-d < %s | FileCheck %s --check-prefix=LA32
3 ; RUN: llc --mtriple=loongarch64 --mattr=+f,-d < %s | FileCheck %s --check-prefix=LA64
5 ;; Test the 'fcmp' LLVM IR: https://llvm.org/docs/LangRef.html#fcmp-instruction
8 define i1 @fcmp_false(float %a, float %b) {
9 ; LA32-LABEL: fcmp_false:
11 ; LA32-NEXT: move $a0, $zero
14 ; LA64-LABEL: fcmp_false:
16 ; LA64-NEXT: move $a0, $zero
18 %cmp = fcmp false float %a, %b
22 define i1 @fcmp_oeq(float %a, float %b) {
23 ; LA32-LABEL: fcmp_oeq:
25 ; LA32-NEXT: fcmp.ceq.s $fcc0, $fa0, $fa1
26 ; LA32-NEXT: movcf2gr $a0, $fcc0
29 ; LA64-LABEL: fcmp_oeq:
31 ; LA64-NEXT: fcmp.ceq.s $fcc0, $fa0, $fa1
32 ; LA64-NEXT: movcf2gr $a0, $fcc0
34 %cmp = fcmp oeq float %a, %b
38 define i1 @fcmp_ogt(float %a, float %b) {
39 ; LA32-LABEL: fcmp_ogt:
41 ; LA32-NEXT: fcmp.clt.s $fcc0, $fa1, $fa0
42 ; LA32-NEXT: movcf2gr $a0, $fcc0
45 ; LA64-LABEL: fcmp_ogt:
47 ; LA64-NEXT: fcmp.clt.s $fcc0, $fa1, $fa0
48 ; LA64-NEXT: movcf2gr $a0, $fcc0
50 %cmp = fcmp ogt float %a, %b
54 define i1 @fcmp_oge(float %a, float %b) {
55 ; LA32-LABEL: fcmp_oge:
57 ; LA32-NEXT: fcmp.cle.s $fcc0, $fa1, $fa0
58 ; LA32-NEXT: movcf2gr $a0, $fcc0
61 ; LA64-LABEL: fcmp_oge:
63 ; LA64-NEXT: fcmp.cle.s $fcc0, $fa1, $fa0
64 ; LA64-NEXT: movcf2gr $a0, $fcc0
66 %cmp = fcmp oge float %a, %b
70 define i1 @fcmp_olt(float %a, float %b) {
71 ; LA32-LABEL: fcmp_olt:
73 ; LA32-NEXT: fcmp.clt.s $fcc0, $fa0, $fa1
74 ; LA32-NEXT: movcf2gr $a0, $fcc0
77 ; LA64-LABEL: fcmp_olt:
79 ; LA64-NEXT: fcmp.clt.s $fcc0, $fa0, $fa1
80 ; LA64-NEXT: movcf2gr $a0, $fcc0
82 %cmp = fcmp olt float %a, %b
86 define i1 @fcmp_ole(float %a, float %b) {
87 ; LA32-LABEL: fcmp_ole:
89 ; LA32-NEXT: fcmp.cle.s $fcc0, $fa0, $fa1
90 ; LA32-NEXT: movcf2gr $a0, $fcc0
93 ; LA64-LABEL: fcmp_ole:
95 ; LA64-NEXT: fcmp.cle.s $fcc0, $fa0, $fa1
96 ; LA64-NEXT: movcf2gr $a0, $fcc0
98 %cmp = fcmp ole float %a, %b
102 define i1 @fcmp_one(float %a, float %b) {
103 ; LA32-LABEL: fcmp_one:
105 ; LA32-NEXT: fcmp.cne.s $fcc0, $fa0, $fa1
106 ; LA32-NEXT: movcf2gr $a0, $fcc0
109 ; LA64-LABEL: fcmp_one:
111 ; LA64-NEXT: fcmp.cne.s $fcc0, $fa0, $fa1
112 ; LA64-NEXT: movcf2gr $a0, $fcc0
114 %cmp = fcmp one float %a, %b
118 define i1 @fcmp_ord(float %a, float %b) {
119 ; LA32-LABEL: fcmp_ord:
121 ; LA32-NEXT: fcmp.cor.s $fcc0, $fa0, $fa1
122 ; LA32-NEXT: movcf2gr $a0, $fcc0
125 ; LA64-LABEL: fcmp_ord:
127 ; LA64-NEXT: fcmp.cor.s $fcc0, $fa0, $fa1
128 ; LA64-NEXT: movcf2gr $a0, $fcc0
130 %cmp = fcmp ord float %a, %b
134 define i1 @fcmp_ueq(float %a, float %b) {
135 ; LA32-LABEL: fcmp_ueq:
137 ; LA32-NEXT: fcmp.cueq.s $fcc0, $fa0, $fa1
138 ; LA32-NEXT: movcf2gr $a0, $fcc0
141 ; LA64-LABEL: fcmp_ueq:
143 ; LA64-NEXT: fcmp.cueq.s $fcc0, $fa0, $fa1
144 ; LA64-NEXT: movcf2gr $a0, $fcc0
146 %cmp = fcmp ueq float %a, %b
150 define i1 @fcmp_ugt(float %a, float %b) {
151 ; LA32-LABEL: fcmp_ugt:
153 ; LA32-NEXT: fcmp.cult.s $fcc0, $fa1, $fa0
154 ; LA32-NEXT: movcf2gr $a0, $fcc0
157 ; LA64-LABEL: fcmp_ugt:
159 ; LA64-NEXT: fcmp.cult.s $fcc0, $fa1, $fa0
160 ; LA64-NEXT: movcf2gr $a0, $fcc0
162 %cmp = fcmp ugt float %a, %b
166 define i1 @fcmp_uge(float %a, float %b) {
167 ; LA32-LABEL: fcmp_uge:
169 ; LA32-NEXT: fcmp.cule.s $fcc0, $fa1, $fa0
170 ; LA32-NEXT: movcf2gr $a0, $fcc0
173 ; LA64-LABEL: fcmp_uge:
175 ; LA64-NEXT: fcmp.cule.s $fcc0, $fa1, $fa0
176 ; LA64-NEXT: movcf2gr $a0, $fcc0
178 %cmp = fcmp uge float %a, %b
182 define i1 @fcmp_ult(float %a, float %b) {
183 ; LA32-LABEL: fcmp_ult:
185 ; LA32-NEXT: fcmp.cult.s $fcc0, $fa0, $fa1
186 ; LA32-NEXT: movcf2gr $a0, $fcc0
189 ; LA64-LABEL: fcmp_ult:
191 ; LA64-NEXT: fcmp.cult.s $fcc0, $fa0, $fa1
192 ; LA64-NEXT: movcf2gr $a0, $fcc0
194 %cmp = fcmp ult float %a, %b
198 define i1 @fcmp_ule(float %a, float %b) {
199 ; LA32-LABEL: fcmp_ule:
201 ; LA32-NEXT: fcmp.cule.s $fcc0, $fa0, $fa1
202 ; LA32-NEXT: movcf2gr $a0, $fcc0
205 ; LA64-LABEL: fcmp_ule:
207 ; LA64-NEXT: fcmp.cule.s $fcc0, $fa0, $fa1
208 ; LA64-NEXT: movcf2gr $a0, $fcc0
210 %cmp = fcmp ule float %a, %b
214 define i1 @fcmp_une(float %a, float %b) {
215 ; LA32-LABEL: fcmp_une:
217 ; LA32-NEXT: fcmp.cune.s $fcc0, $fa0, $fa1
218 ; LA32-NEXT: movcf2gr $a0, $fcc0
221 ; LA64-LABEL: fcmp_une:
223 ; LA64-NEXT: fcmp.cune.s $fcc0, $fa0, $fa1
224 ; LA64-NEXT: movcf2gr $a0, $fcc0
226 %cmp = fcmp une float %a, %b
230 define i1 @fcmp_uno(float %a, float %b) {
231 ; LA32-LABEL: fcmp_uno:
233 ; LA32-NEXT: fcmp.cun.s $fcc0, $fa0, $fa1
234 ; LA32-NEXT: movcf2gr $a0, $fcc0
237 ; LA64-LABEL: fcmp_uno:
239 ; LA64-NEXT: fcmp.cun.s $fcc0, $fa0, $fa1
240 ; LA64-NEXT: movcf2gr $a0, $fcc0
242 %cmp = fcmp uno float %a, %b
246 define i1 @fcmp_true(float %a, float %b) {
247 ; LA32-LABEL: fcmp_true:
249 ; LA32-NEXT: ori $a0, $zero, 1
252 ; LA64-LABEL: fcmp_true:
254 ; LA64-NEXT: ori $a0, $zero, 1
256 %cmp = fcmp true float %a, %b
260 define i1 @fcmp_fast_olt(float %a, float %b, i1 %c) nounwind {
261 ; LA32-LABEL: fcmp_fast_olt:
263 ; LA32-NEXT: movgr2fr.w $fa1, $zero
264 ; LA32-NEXT: fcmp.cle.s $fcc0, $fa1, $fa0
265 ; LA32-NEXT: movcf2gr $a1, $fcc0
266 ; LA32-NEXT: bnez $a1, .LBB16_2
267 ; LA32-NEXT: # %bb.1: # %if.then
269 ; LA32-NEXT: .LBB16_2: # %if.else
270 ; LA32-NEXT: fcmp.clt.s $fcc0, $fa0, $fa1
271 ; LA32-NEXT: movcf2gr $a0, $fcc0
274 ; LA64-LABEL: fcmp_fast_olt:
276 ; LA64-NEXT: movgr2fr.w $fa1, $zero
277 ; LA64-NEXT: fcmp.cle.s $fcc0, $fa1, $fa0
278 ; LA64-NEXT: movcf2gr $a1, $fcc0
279 ; LA64-NEXT: bnez $a1, .LBB16_2
280 ; LA64-NEXT: # %bb.1: # %if.then
282 ; LA64-NEXT: .LBB16_2: # %if.else
283 ; LA64-NEXT: fcmp.clt.s $fcc0, $fa0, $fa1
284 ; LA64-NEXT: movcf2gr $a0, $fcc0
286 %cmp = fcmp fast olt float %a, 0.000000e+00
287 br i1 %cmp, label %if.then, label %if.else
296 define i1 @fcmp_fast_oeq(float %a, float %b, i1 %c) nounwind {
297 ; LA32-LABEL: fcmp_fast_oeq:
299 ; LA32-NEXT: movgr2fr.w $fa1, $zero
300 ; LA32-NEXT: fcmp.ceq.s $fcc0, $fa0, $fa1
301 ; LA32-NEXT: movcf2gr $a1, $fcc0
302 ; LA32-NEXT: xori $a1, $a1, 1
303 ; LA32-NEXT: bnez $a1, .LBB17_2
304 ; LA32-NEXT: # %bb.1: # %if.then
306 ; LA32-NEXT: .LBB17_2: # %if.else
307 ; LA32-NEXT: movcf2gr $a0, $fcc0
310 ; LA64-LABEL: fcmp_fast_oeq:
312 ; LA64-NEXT: movgr2fr.w $fa1, $zero
313 ; LA64-NEXT: fcmp.ceq.s $fcc0, $fa0, $fa1
314 ; LA64-NEXT: movcf2gr $a1, $fcc0
315 ; LA64-NEXT: xori $a1, $a1, 1
316 ; LA64-NEXT: bnez $a1, .LBB17_2
317 ; LA64-NEXT: # %bb.1: # %if.then
319 ; LA64-NEXT: .LBB17_2: # %if.else
320 ; LA64-NEXT: movcf2gr $a0, $fcc0
322 %cmp = fcmp fast oeq float %a, 0.000000e+00
323 br i1 %cmp, label %if.then, label %if.else
332 define i1 @fcmp_fast_ole(float %a, float %b, i1 %c) nounwind {
333 ; LA32-LABEL: fcmp_fast_ole:
335 ; LA32-NEXT: movgr2fr.w $fa1, $zero
336 ; LA32-NEXT: fcmp.clt.s $fcc0, $fa1, $fa0
337 ; LA32-NEXT: bcnez $fcc0, .LBB18_2
338 ; LA32-NEXT: # %bb.1: # %if.then
340 ; LA32-NEXT: .LBB18_2: # %if.else
341 ; LA32-NEXT: fcmp.cle.s $fcc0, $fa0, $fa1
342 ; LA32-NEXT: movcf2gr $a0, $fcc0
345 ; LA64-LABEL: fcmp_fast_ole:
347 ; LA64-NEXT: movgr2fr.w $fa1, $zero
348 ; LA64-NEXT: fcmp.clt.s $fcc0, $fa1, $fa0
349 ; LA64-NEXT: bcnez $fcc0, .LBB18_2
350 ; LA64-NEXT: # %bb.1: # %if.then
352 ; LA64-NEXT: .LBB18_2: # %if.else
353 ; LA64-NEXT: fcmp.cle.s $fcc0, $fa0, $fa1
354 ; LA64-NEXT: movcf2gr $a0, $fcc0
356 %cmp = fcmp fast ole float %a, 0.000000e+00
357 br i1 %cmp, label %if.then, label %if.else