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 single-precision floating-point values selection after comparison
7 define float @fcmp_false(float %a, float %b, float %x, float %y) {
8 ; LA32-LABEL: fcmp_false:
10 ; LA32-NEXT: fmov.s $fa0, $fa3
13 ; LA64-LABEL: fcmp_false:
15 ; LA64-NEXT: fmov.s $fa0, $fa3
17 %cmp = fcmp false float %a, %b
18 %res = select i1 %cmp, float %x, float %y
22 define float @fcmp_oeq(float %a, float %b, float %x, float %y) {
23 ; LA32-LABEL: fcmp_oeq:
25 ; LA32-NEXT: fcmp.ceq.s $fcc0, $fa0, $fa1
26 ; LA32-NEXT: fsel $fa0, $fa3, $fa2, $fcc0
29 ; LA64-LABEL: fcmp_oeq:
31 ; LA64-NEXT: fcmp.ceq.s $fcc0, $fa0, $fa1
32 ; LA64-NEXT: fsel $fa0, $fa3, $fa2, $fcc0
34 %cmp = fcmp oeq float %a, %b
35 %res = select i1 %cmp, float %x, float %y
39 define float @fcmp_ogt(float %a, float %b, float %x, float %y) {
40 ; LA32-LABEL: fcmp_ogt:
42 ; LA32-NEXT: fcmp.clt.s $fcc0, $fa1, $fa0
43 ; LA32-NEXT: fsel $fa0, $fa3, $fa2, $fcc0
46 ; LA64-LABEL: fcmp_ogt:
48 ; LA64-NEXT: fcmp.clt.s $fcc0, $fa1, $fa0
49 ; LA64-NEXT: fsel $fa0, $fa3, $fa2, $fcc0
51 %cmp = fcmp ogt float %a, %b
52 %res = select i1 %cmp, float %x, float %y
56 define float @fcmp_oge(float %a, float %b, float %x, float %y) {
57 ; LA32-LABEL: fcmp_oge:
59 ; LA32-NEXT: fcmp.cle.s $fcc0, $fa1, $fa0
60 ; LA32-NEXT: fsel $fa0, $fa3, $fa2, $fcc0
63 ; LA64-LABEL: fcmp_oge:
65 ; LA64-NEXT: fcmp.cle.s $fcc0, $fa1, $fa0
66 ; LA64-NEXT: fsel $fa0, $fa3, $fa2, $fcc0
68 %cmp = fcmp oge float %a, %b
69 %res = select i1 %cmp, float %x, float %y
73 define float @fcmp_olt(float %a, float %b, float %x, float %y) {
74 ; LA32-LABEL: fcmp_olt:
76 ; LA32-NEXT: fcmp.clt.s $fcc0, $fa0, $fa1
77 ; LA32-NEXT: fsel $fa0, $fa3, $fa2, $fcc0
80 ; LA64-LABEL: fcmp_olt:
82 ; LA64-NEXT: fcmp.clt.s $fcc0, $fa0, $fa1
83 ; LA64-NEXT: fsel $fa0, $fa3, $fa2, $fcc0
85 %cmp = fcmp olt float %a, %b
86 %res = select i1 %cmp, float %x, float %y
90 define float @fcmp_ole(float %a, float %b, float %x, float %y) {
91 ; LA32-LABEL: fcmp_ole:
93 ; LA32-NEXT: fcmp.cle.s $fcc0, $fa0, $fa1
94 ; LA32-NEXT: fsel $fa0, $fa3, $fa2, $fcc0
97 ; LA64-LABEL: fcmp_ole:
99 ; LA64-NEXT: fcmp.cle.s $fcc0, $fa0, $fa1
100 ; LA64-NEXT: fsel $fa0, $fa3, $fa2, $fcc0
102 %cmp = fcmp ole float %a, %b
103 %res = select i1 %cmp, float %x, float %y
107 define float @fcmp_one(float %a, float %b, float %x, float %y) {
108 ; LA32-LABEL: fcmp_one:
110 ; LA32-NEXT: fcmp.cne.s $fcc0, $fa0, $fa1
111 ; LA32-NEXT: fsel $fa0, $fa3, $fa2, $fcc0
114 ; LA64-LABEL: fcmp_one:
116 ; LA64-NEXT: fcmp.cne.s $fcc0, $fa0, $fa1
117 ; LA64-NEXT: fsel $fa0, $fa3, $fa2, $fcc0
119 %cmp = fcmp one float %a, %b
120 %res = select i1 %cmp, float %x, float %y
124 define float @fcmp_ord(float %a, float %b, float %x, float %y) {
125 ; LA32-LABEL: fcmp_ord:
127 ; LA32-NEXT: fcmp.cor.s $fcc0, $fa0, $fa1
128 ; LA32-NEXT: fsel $fa0, $fa3, $fa2, $fcc0
131 ; LA64-LABEL: fcmp_ord:
133 ; LA64-NEXT: fcmp.cor.s $fcc0, $fa0, $fa1
134 ; LA64-NEXT: fsel $fa0, $fa3, $fa2, $fcc0
136 %cmp = fcmp ord float %a, %b
137 %res = select i1 %cmp, float %x, float %y
141 define float @fcmp_ueq(float %a, float %b, float %x, float %y) {
142 ; LA32-LABEL: fcmp_ueq:
144 ; LA32-NEXT: fcmp.cueq.s $fcc0, $fa0, $fa1
145 ; LA32-NEXT: fsel $fa0, $fa3, $fa2, $fcc0
148 ; LA64-LABEL: fcmp_ueq:
150 ; LA64-NEXT: fcmp.cueq.s $fcc0, $fa0, $fa1
151 ; LA64-NEXT: fsel $fa0, $fa3, $fa2, $fcc0
153 %cmp = fcmp ueq float %a, %b
154 %res = select i1 %cmp, float %x, float %y
158 define float @fcmp_ugt(float %a, float %b, float %x, float %y) {
159 ; LA32-LABEL: fcmp_ugt:
161 ; LA32-NEXT: fcmp.cult.s $fcc0, $fa1, $fa0
162 ; LA32-NEXT: fsel $fa0, $fa3, $fa2, $fcc0
165 ; LA64-LABEL: fcmp_ugt:
167 ; LA64-NEXT: fcmp.cult.s $fcc0, $fa1, $fa0
168 ; LA64-NEXT: fsel $fa0, $fa3, $fa2, $fcc0
170 %cmp = fcmp ugt float %a, %b
171 %res = select i1 %cmp, float %x, float %y
175 define float @fcmp_uge(float %a, float %b, float %x, float %y) {
176 ; LA32-LABEL: fcmp_uge:
178 ; LA32-NEXT: fcmp.cule.s $fcc0, $fa1, $fa0
179 ; LA32-NEXT: fsel $fa0, $fa3, $fa2, $fcc0
182 ; LA64-LABEL: fcmp_uge:
184 ; LA64-NEXT: fcmp.cule.s $fcc0, $fa1, $fa0
185 ; LA64-NEXT: fsel $fa0, $fa3, $fa2, $fcc0
187 %cmp = fcmp uge float %a, %b
188 %res = select i1 %cmp, float %x, float %y
192 define float @fcmp_ult(float %a, float %b, float %x, float %y) {
193 ; LA32-LABEL: fcmp_ult:
195 ; LA32-NEXT: fcmp.cult.s $fcc0, $fa0, $fa1
196 ; LA32-NEXT: fsel $fa0, $fa3, $fa2, $fcc0
199 ; LA64-LABEL: fcmp_ult:
201 ; LA64-NEXT: fcmp.cult.s $fcc0, $fa0, $fa1
202 ; LA64-NEXT: fsel $fa0, $fa3, $fa2, $fcc0
204 %cmp = fcmp ult float %a, %b
205 %res = select i1 %cmp, float %x, float %y
209 define float @fcmp_ule(float %a, float %b, float %x, float %y) {
210 ; LA32-LABEL: fcmp_ule:
212 ; LA32-NEXT: fcmp.cule.s $fcc0, $fa0, $fa1
213 ; LA32-NEXT: fsel $fa0, $fa3, $fa2, $fcc0
216 ; LA64-LABEL: fcmp_ule:
218 ; LA64-NEXT: fcmp.cule.s $fcc0, $fa0, $fa1
219 ; LA64-NEXT: fsel $fa0, $fa3, $fa2, $fcc0
221 %cmp = fcmp ule float %a, %b
222 %res = select i1 %cmp, float %x, float %y
226 define float @fcmp_une(float %a, float %b, float %x, float %y) {
227 ; LA32-LABEL: fcmp_une:
229 ; LA32-NEXT: fcmp.cune.s $fcc0, $fa0, $fa1
230 ; LA32-NEXT: fsel $fa0, $fa3, $fa2, $fcc0
233 ; LA64-LABEL: fcmp_une:
235 ; LA64-NEXT: fcmp.cune.s $fcc0, $fa0, $fa1
236 ; LA64-NEXT: fsel $fa0, $fa3, $fa2, $fcc0
238 %cmp = fcmp une float %a, %b
239 %res = select i1 %cmp, float %x, float %y
243 define float @fcmp_uno(float %a, float %b, float %x, float %y) {
244 ; LA32-LABEL: fcmp_uno:
246 ; LA32-NEXT: fcmp.cun.s $fcc0, $fa0, $fa1
247 ; LA32-NEXT: fsel $fa0, $fa3, $fa2, $fcc0
250 ; LA64-LABEL: fcmp_uno:
252 ; LA64-NEXT: fcmp.cun.s $fcc0, $fa0, $fa1
253 ; LA64-NEXT: fsel $fa0, $fa3, $fa2, $fcc0
255 %cmp = fcmp uno float %a, %b
256 %res = select i1 %cmp, float %x, float %y
260 define float @fcmp_true(float %a, float %b, float %x, float %y) {
261 ; LA32-LABEL: fcmp_true:
263 ; LA32-NEXT: fmov.s $fa0, $fa2
266 ; LA64-LABEL: fcmp_true:
268 ; LA64-NEXT: fmov.s $fa0, $fa2
270 %cmp = fcmp true float %a, %b
271 %res = select i1 %cmp, float %x, float %y