1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc --mtriple=loongarch32 --mattr=+d < %s | FileCheck %s --check-prefix=LA32
3 ; RUN: llc --mtriple=loongarch64 --mattr=+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(double %a, double %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 double %a, %b
22 define i1 @fcmp_oeq(double %a, double %b) {
23 ; LA32-LABEL: fcmp_oeq:
25 ; LA32-NEXT: fcmp.ceq.d $fcc0, $fa0, $fa1
26 ; LA32-NEXT: movcf2gr $a0, $fcc0
29 ; LA64-LABEL: fcmp_oeq:
31 ; LA64-NEXT: fcmp.ceq.d $fcc0, $fa0, $fa1
32 ; LA64-NEXT: movcf2gr $a0, $fcc0
34 %cmp = fcmp oeq double %a, %b
38 define i1 @fcmp_ogt(double %a, double %b) {
39 ; LA32-LABEL: fcmp_ogt:
41 ; LA32-NEXT: fcmp.clt.d $fcc0, $fa1, $fa0
42 ; LA32-NEXT: movcf2gr $a0, $fcc0
45 ; LA64-LABEL: fcmp_ogt:
47 ; LA64-NEXT: fcmp.clt.d $fcc0, $fa1, $fa0
48 ; LA64-NEXT: movcf2gr $a0, $fcc0
50 %cmp = fcmp ogt double %a, %b
54 define i1 @fcmp_oge(double %a, double %b) {
55 ; LA32-LABEL: fcmp_oge:
57 ; LA32-NEXT: fcmp.cle.d $fcc0, $fa1, $fa0
58 ; LA32-NEXT: movcf2gr $a0, $fcc0
61 ; LA64-LABEL: fcmp_oge:
63 ; LA64-NEXT: fcmp.cle.d $fcc0, $fa1, $fa0
64 ; LA64-NEXT: movcf2gr $a0, $fcc0
66 %cmp = fcmp oge double %a, %b
70 define i1 @fcmp_olt(double %a, double %b) {
71 ; LA32-LABEL: fcmp_olt:
73 ; LA32-NEXT: fcmp.clt.d $fcc0, $fa0, $fa1
74 ; LA32-NEXT: movcf2gr $a0, $fcc0
77 ; LA64-LABEL: fcmp_olt:
79 ; LA64-NEXT: fcmp.clt.d $fcc0, $fa0, $fa1
80 ; LA64-NEXT: movcf2gr $a0, $fcc0
82 %cmp = fcmp olt double %a, %b
86 define i1 @fcmp_ole(double %a, double %b) {
87 ; LA32-LABEL: fcmp_ole:
89 ; LA32-NEXT: fcmp.cle.d $fcc0, $fa0, $fa1
90 ; LA32-NEXT: movcf2gr $a0, $fcc0
93 ; LA64-LABEL: fcmp_ole:
95 ; LA64-NEXT: fcmp.cle.d $fcc0, $fa0, $fa1
96 ; LA64-NEXT: movcf2gr $a0, $fcc0
98 %cmp = fcmp ole double %a, %b
102 define i1 @fcmp_one(double %a, double %b) {
103 ; LA32-LABEL: fcmp_one:
105 ; LA32-NEXT: fcmp.cne.d $fcc0, $fa0, $fa1
106 ; LA32-NEXT: movcf2gr $a0, $fcc0
109 ; LA64-LABEL: fcmp_one:
111 ; LA64-NEXT: fcmp.cne.d $fcc0, $fa0, $fa1
112 ; LA64-NEXT: movcf2gr $a0, $fcc0
114 %cmp = fcmp one double %a, %b
118 define i1 @fcmp_ord(double %a, double %b) {
119 ; LA32-LABEL: fcmp_ord:
121 ; LA32-NEXT: fcmp.cor.d $fcc0, $fa0, $fa1
122 ; LA32-NEXT: movcf2gr $a0, $fcc0
125 ; LA64-LABEL: fcmp_ord:
127 ; LA64-NEXT: fcmp.cor.d $fcc0, $fa0, $fa1
128 ; LA64-NEXT: movcf2gr $a0, $fcc0
130 %cmp = fcmp ord double %a, %b
134 define i1 @fcmp_ueq(double %a, double %b) {
135 ; LA32-LABEL: fcmp_ueq:
137 ; LA32-NEXT: fcmp.cueq.d $fcc0, $fa0, $fa1
138 ; LA32-NEXT: movcf2gr $a0, $fcc0
141 ; LA64-LABEL: fcmp_ueq:
143 ; LA64-NEXT: fcmp.cueq.d $fcc0, $fa0, $fa1
144 ; LA64-NEXT: movcf2gr $a0, $fcc0
146 %cmp = fcmp ueq double %a, %b
150 define i1 @fcmp_ugt(double %a, double %b) {
151 ; LA32-LABEL: fcmp_ugt:
153 ; LA32-NEXT: fcmp.cult.d $fcc0, $fa1, $fa0
154 ; LA32-NEXT: movcf2gr $a0, $fcc0
157 ; LA64-LABEL: fcmp_ugt:
159 ; LA64-NEXT: fcmp.cult.d $fcc0, $fa1, $fa0
160 ; LA64-NEXT: movcf2gr $a0, $fcc0
162 %cmp = fcmp ugt double %a, %b
166 define i1 @fcmp_uge(double %a, double %b) {
167 ; LA32-LABEL: fcmp_uge:
169 ; LA32-NEXT: fcmp.cule.d $fcc0, $fa1, $fa0
170 ; LA32-NEXT: movcf2gr $a0, $fcc0
173 ; LA64-LABEL: fcmp_uge:
175 ; LA64-NEXT: fcmp.cule.d $fcc0, $fa1, $fa0
176 ; LA64-NEXT: movcf2gr $a0, $fcc0
178 %cmp = fcmp uge double %a, %b
182 define i1 @fcmp_ult(double %a, double %b) {
183 ; LA32-LABEL: fcmp_ult:
185 ; LA32-NEXT: fcmp.cult.d $fcc0, $fa0, $fa1
186 ; LA32-NEXT: movcf2gr $a0, $fcc0
189 ; LA64-LABEL: fcmp_ult:
191 ; LA64-NEXT: fcmp.cult.d $fcc0, $fa0, $fa1
192 ; LA64-NEXT: movcf2gr $a0, $fcc0
194 %cmp = fcmp ult double %a, %b
198 define i1 @fcmp_ule(double %a, double %b) {
199 ; LA32-LABEL: fcmp_ule:
201 ; LA32-NEXT: fcmp.cule.d $fcc0, $fa0, $fa1
202 ; LA32-NEXT: movcf2gr $a0, $fcc0
205 ; LA64-LABEL: fcmp_ule:
207 ; LA64-NEXT: fcmp.cule.d $fcc0, $fa0, $fa1
208 ; LA64-NEXT: movcf2gr $a0, $fcc0
210 %cmp = fcmp ule double %a, %b
214 define i1 @fcmp_une(double %a, double %b) {
215 ; LA32-LABEL: fcmp_une:
217 ; LA32-NEXT: fcmp.cune.d $fcc0, $fa0, $fa1
218 ; LA32-NEXT: movcf2gr $a0, $fcc0
221 ; LA64-LABEL: fcmp_une:
223 ; LA64-NEXT: fcmp.cune.d $fcc0, $fa0, $fa1
224 ; LA64-NEXT: movcf2gr $a0, $fcc0
226 %cmp = fcmp une double %a, %b
230 define i1 @fcmp_uno(double %a, double %b) {
231 ; LA32-LABEL: fcmp_uno:
233 ; LA32-NEXT: fcmp.cun.d $fcc0, $fa0, $fa1
234 ; LA32-NEXT: movcf2gr $a0, $fcc0
237 ; LA64-LABEL: fcmp_uno:
239 ; LA64-NEXT: fcmp.cun.d $fcc0, $fa0, $fa1
240 ; LA64-NEXT: movcf2gr $a0, $fcc0
242 %cmp = fcmp uno double %a, %b
246 define i1 @fcmp_true(double %a, double %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 double %a, %b
260 define i1 @fcmp_fast_olt(double %a, double %b, i1 %c) nounwind {
261 ; LA32-LABEL: fcmp_fast_olt:
263 ; LA32-NEXT: movgr2fr.w $fa1, $zero
264 ; LA32-NEXT: movgr2frh.w $fa1, $zero
265 ; LA32-NEXT: fcmp.cle.d $fcc0, $fa1, $fa0
266 ; LA32-NEXT: movcf2gr $a1, $fcc0
267 ; LA32-NEXT: bnez $a1, .LBB16_2
268 ; LA32-NEXT: # %bb.1: # %if.then
270 ; LA32-NEXT: .LBB16_2: # %if.else
271 ; LA32-NEXT: fcmp.clt.d $fcc0, $fa0, $fa1
272 ; LA32-NEXT: movcf2gr $a0, $fcc0
275 ; LA64-LABEL: fcmp_fast_olt:
277 ; LA64-NEXT: movgr2fr.d $fa1, $zero
278 ; LA64-NEXT: fcmp.cle.d $fcc0, $fa1, $fa0
279 ; LA64-NEXT: movcf2gr $a1, $fcc0
280 ; LA64-NEXT: bnez $a1, .LBB16_2
281 ; LA64-NEXT: # %bb.1: # %if.then
283 ; LA64-NEXT: .LBB16_2: # %if.else
284 ; LA64-NEXT: fcmp.clt.d $fcc0, $fa0, $fa1
285 ; LA64-NEXT: movcf2gr $a0, $fcc0
287 %cmp = fcmp fast olt double %a, 0.000000e+00
288 br i1 %cmp, label %if.then, label %if.else
297 define i1 @fcmp_fast_oeq(double %a, double %b, i1 %c) nounwind {
298 ; LA32-LABEL: fcmp_fast_oeq:
300 ; LA32-NEXT: movgr2fr.w $fa1, $zero
301 ; LA32-NEXT: movgr2frh.w $fa1, $zero
302 ; LA32-NEXT: fcmp.ceq.d $fcc0, $fa0, $fa1
303 ; LA32-NEXT: movcf2gr $a1, $fcc0
304 ; LA32-NEXT: xori $a1, $a1, 1
305 ; LA32-NEXT: bnez $a1, .LBB17_2
306 ; LA32-NEXT: # %bb.1: # %if.then
308 ; LA32-NEXT: .LBB17_2: # %if.else
309 ; LA32-NEXT: movcf2gr $a0, $fcc0
312 ; LA64-LABEL: fcmp_fast_oeq:
314 ; LA64-NEXT: movgr2fr.d $fa1, $zero
315 ; LA64-NEXT: fcmp.ceq.d $fcc0, $fa0, $fa1
316 ; LA64-NEXT: movcf2gr $a1, $fcc0
317 ; LA64-NEXT: xori $a1, $a1, 1
318 ; LA64-NEXT: bnez $a1, .LBB17_2
319 ; LA64-NEXT: # %bb.1: # %if.then
321 ; LA64-NEXT: .LBB17_2: # %if.else
322 ; LA64-NEXT: movcf2gr $a0, $fcc0
324 %cmp = fcmp fast oeq double %a, 0.000000e+00
325 br i1 %cmp, label %if.then, label %if.else
334 define i1 @fcmp_fast_ole(double %a, double %b, i1 %c) nounwind {
335 ; LA32-LABEL: fcmp_fast_ole:
337 ; LA32-NEXT: movgr2fr.w $fa1, $zero
338 ; LA32-NEXT: movgr2frh.w $fa1, $zero
339 ; LA32-NEXT: fcmp.clt.d $fcc0, $fa1, $fa0
340 ; LA32-NEXT: bcnez $fcc0, .LBB18_2
341 ; LA32-NEXT: # %bb.1: # %if.then
343 ; LA32-NEXT: .LBB18_2: # %if.else
344 ; LA32-NEXT: fcmp.cle.d $fcc0, $fa0, $fa1
345 ; LA32-NEXT: movcf2gr $a0, $fcc0
348 ; LA64-LABEL: fcmp_fast_ole:
350 ; LA64-NEXT: movgr2fr.d $fa1, $zero
351 ; LA64-NEXT: fcmp.clt.d $fcc0, $fa1, $fa0
352 ; LA64-NEXT: bcnez $fcc0, .LBB18_2
353 ; LA64-NEXT: # %bb.1: # %if.then
355 ; LA64-NEXT: .LBB18_2: # %if.else
356 ; LA64-NEXT: fcmp.cle.d $fcc0, $fa0, $fa1
357 ; LA64-NEXT: movcf2gr $a0, $fcc0
359 %cmp = fcmp fast ole double %a, 0.000000e+00
360 br i1 %cmp, label %if.then, label %if.else