1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
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 define void @test_load_store(ptr %p, ptr %q) nounwind {
6 ; LA32-LABEL: test_load_store:
8 ; LA32-NEXT: ld.h $a0, $a0, 0
9 ; LA32-NEXT: st.h $a0, $a1, 0
12 ; LA64-LABEL: test_load_store:
14 ; LA64-NEXT: ld.h $a0, $a0, 0
15 ; LA64-NEXT: st.h $a0, $a1, 0
17 %a = load half, ptr %p
22 define float @test_fpextend_float(ptr %p) nounwind {
23 ; LA32-LABEL: test_fpextend_float:
25 ; LA32-NEXT: ld.hu $a0, $a0, 0
26 ; LA32-NEXT: b %plt(__gnu_h2f_ieee)
28 ; LA64-LABEL: test_fpextend_float:
30 ; LA64-NEXT: ld.hu $a0, $a0, 0
31 ; LA64-NEXT: b %plt(__gnu_h2f_ieee)
32 %a = load half, ptr %p
33 %r = fpext half %a to float
37 define double @test_fpextend_double(ptr %p) nounwind {
38 ; LA32-LABEL: test_fpextend_double:
40 ; LA32-NEXT: addi.w $sp, $sp, -16
41 ; LA32-NEXT: st.w $ra, $sp, 12 # 4-byte Folded Spill
42 ; LA32-NEXT: ld.hu $a0, $a0, 0
43 ; LA32-NEXT: bl %plt(__gnu_h2f_ieee)
44 ; LA32-NEXT: fcvt.d.s $fa0, $fa0
45 ; LA32-NEXT: ld.w $ra, $sp, 12 # 4-byte Folded Reload
46 ; LA32-NEXT: addi.w $sp, $sp, 16
49 ; LA64-LABEL: test_fpextend_double:
51 ; LA64-NEXT: addi.d $sp, $sp, -16
52 ; LA64-NEXT: st.d $ra, $sp, 8 # 8-byte Folded Spill
53 ; LA64-NEXT: ld.hu $a0, $a0, 0
54 ; LA64-NEXT: bl %plt(__gnu_h2f_ieee)
55 ; LA64-NEXT: fcvt.d.s $fa0, $fa0
56 ; LA64-NEXT: ld.d $ra, $sp, 8 # 8-byte Folded Reload
57 ; LA64-NEXT: addi.d $sp, $sp, 16
59 %a = load half, ptr %p
60 %r = fpext half %a to double
64 define void @test_fptrunc_float(float %f, ptr %p) nounwind {
65 ; LA32-LABEL: test_fptrunc_float:
67 ; LA32-NEXT: addi.w $sp, $sp, -16
68 ; LA32-NEXT: st.w $ra, $sp, 12 # 4-byte Folded Spill
69 ; LA32-NEXT: st.w $fp, $sp, 8 # 4-byte Folded Spill
70 ; LA32-NEXT: move $fp, $a0
71 ; LA32-NEXT: bl %plt(__gnu_f2h_ieee)
72 ; LA32-NEXT: st.h $a0, $fp, 0
73 ; LA32-NEXT: ld.w $fp, $sp, 8 # 4-byte Folded Reload
74 ; LA32-NEXT: ld.w $ra, $sp, 12 # 4-byte Folded Reload
75 ; LA32-NEXT: addi.w $sp, $sp, 16
78 ; LA64-LABEL: test_fptrunc_float:
80 ; LA64-NEXT: addi.d $sp, $sp, -16
81 ; LA64-NEXT: st.d $ra, $sp, 8 # 8-byte Folded Spill
82 ; LA64-NEXT: st.d $fp, $sp, 0 # 8-byte Folded Spill
83 ; LA64-NEXT: move $fp, $a0
84 ; LA64-NEXT: bl %plt(__gnu_f2h_ieee)
85 ; LA64-NEXT: st.h $a0, $fp, 0
86 ; LA64-NEXT: ld.d $fp, $sp, 0 # 8-byte Folded Reload
87 ; LA64-NEXT: ld.d $ra, $sp, 8 # 8-byte Folded Reload
88 ; LA64-NEXT: addi.d $sp, $sp, 16
90 %a = fptrunc float %f to half
95 define void @test_fptrunc_double(double %d, ptr %p) nounwind {
96 ; LA32-LABEL: test_fptrunc_double:
98 ; LA32-NEXT: addi.w $sp, $sp, -16
99 ; LA32-NEXT: st.w $ra, $sp, 12 # 4-byte Folded Spill
100 ; LA32-NEXT: st.w $fp, $sp, 8 # 4-byte Folded Spill
101 ; LA32-NEXT: move $fp, $a0
102 ; LA32-NEXT: bl %plt(__truncdfhf2)
103 ; LA32-NEXT: st.h $a0, $fp, 0
104 ; LA32-NEXT: ld.w $fp, $sp, 8 # 4-byte Folded Reload
105 ; LA32-NEXT: ld.w $ra, $sp, 12 # 4-byte Folded Reload
106 ; LA32-NEXT: addi.w $sp, $sp, 16
109 ; LA64-LABEL: test_fptrunc_double:
111 ; LA64-NEXT: addi.d $sp, $sp, -16
112 ; LA64-NEXT: st.d $ra, $sp, 8 # 8-byte Folded Spill
113 ; LA64-NEXT: st.d $fp, $sp, 0 # 8-byte Folded Spill
114 ; LA64-NEXT: move $fp, $a0
115 ; LA64-NEXT: bl %plt(__truncdfhf2)
116 ; LA64-NEXT: st.h $a0, $fp, 0
117 ; LA64-NEXT: ld.d $fp, $sp, 0 # 8-byte Folded Reload
118 ; LA64-NEXT: ld.d $ra, $sp, 8 # 8-byte Folded Reload
119 ; LA64-NEXT: addi.d $sp, $sp, 16
121 %a = fptrunc double %d to half
122 store half %a, ptr %p
126 define half @test_fadd_reg(half %a, half %b) nounwind {
127 ; LA32-LABEL: test_fadd_reg:
129 ; LA32-NEXT: addi.w $sp, $sp, -32
130 ; LA32-NEXT: st.w $ra, $sp, 28 # 4-byte Folded Spill
131 ; LA32-NEXT: fst.d $fs0, $sp, 16 # 8-byte Folded Spill
132 ; LA32-NEXT: fst.d $fs1, $sp, 8 # 8-byte Folded Spill
133 ; LA32-NEXT: fmov.s $fs0, $fa0
134 ; LA32-NEXT: fmov.s $fa0, $fa1
135 ; LA32-NEXT: bl %plt(__gnu_f2h_ieee)
136 ; LA32-NEXT: bl %plt(__gnu_h2f_ieee)
137 ; LA32-NEXT: fmov.s $fs1, $fa0
138 ; LA32-NEXT: fmov.s $fa0, $fs0
139 ; LA32-NEXT: bl %plt(__gnu_f2h_ieee)
140 ; LA32-NEXT: bl %plt(__gnu_h2f_ieee)
141 ; LA32-NEXT: fadd.s $fa0, $fa0, $fs1
142 ; LA32-NEXT: fld.d $fs1, $sp, 8 # 8-byte Folded Reload
143 ; LA32-NEXT: fld.d $fs0, $sp, 16 # 8-byte Folded Reload
144 ; LA32-NEXT: ld.w $ra, $sp, 28 # 4-byte Folded Reload
145 ; LA32-NEXT: addi.w $sp, $sp, 32
148 ; LA64-LABEL: test_fadd_reg:
150 ; LA64-NEXT: addi.d $sp, $sp, -32
151 ; LA64-NEXT: st.d $ra, $sp, 24 # 8-byte Folded Spill
152 ; LA64-NEXT: fst.d $fs0, $sp, 16 # 8-byte Folded Spill
153 ; LA64-NEXT: fst.d $fs1, $sp, 8 # 8-byte Folded Spill
154 ; LA64-NEXT: fmov.s $fs0, $fa0
155 ; LA64-NEXT: fmov.s $fa0, $fa1
156 ; LA64-NEXT: bl %plt(__gnu_f2h_ieee)
157 ; LA64-NEXT: bl %plt(__gnu_h2f_ieee)
158 ; LA64-NEXT: fmov.s $fs1, $fa0
159 ; LA64-NEXT: fmov.s $fa0, $fs0
160 ; LA64-NEXT: bl %plt(__gnu_f2h_ieee)
161 ; LA64-NEXT: bl %plt(__gnu_h2f_ieee)
162 ; LA64-NEXT: fadd.s $fa0, $fa0, $fs1
163 ; LA64-NEXT: fld.d $fs1, $sp, 8 # 8-byte Folded Reload
164 ; LA64-NEXT: fld.d $fs0, $sp, 16 # 8-byte Folded Reload
165 ; LA64-NEXT: ld.d $ra, $sp, 24 # 8-byte Folded Reload
166 ; LA64-NEXT: addi.d $sp, $sp, 32
168 %r = fadd half %a, %b
172 define void @test_fadd_mem(ptr %p, ptr %q) nounwind {
173 ; LA32-LABEL: test_fadd_mem:
175 ; LA32-NEXT: addi.w $sp, $sp, -32
176 ; LA32-NEXT: st.w $ra, $sp, 28 # 4-byte Folded Spill
177 ; LA32-NEXT: st.w $fp, $sp, 24 # 4-byte Folded Spill
178 ; LA32-NEXT: st.w $s0, $sp, 20 # 4-byte Folded Spill
179 ; LA32-NEXT: fst.d $fs0, $sp, 8 # 8-byte Folded Spill
180 ; LA32-NEXT: move $fp, $a1
181 ; LA32-NEXT: move $s0, $a0
182 ; LA32-NEXT: ld.hu $a0, $a0, 0
183 ; LA32-NEXT: bl %plt(__gnu_h2f_ieee)
184 ; LA32-NEXT: fmov.s $fs0, $fa0
185 ; LA32-NEXT: ld.hu $a0, $fp, 0
186 ; LA32-NEXT: bl %plt(__gnu_h2f_ieee)
187 ; LA32-NEXT: fadd.s $fa0, $fs0, $fa0
188 ; LA32-NEXT: bl %plt(__gnu_f2h_ieee)
189 ; LA32-NEXT: st.h $a0, $s0, 0
190 ; LA32-NEXT: fld.d $fs0, $sp, 8 # 8-byte Folded Reload
191 ; LA32-NEXT: ld.w $s0, $sp, 20 # 4-byte Folded Reload
192 ; LA32-NEXT: ld.w $fp, $sp, 24 # 4-byte Folded Reload
193 ; LA32-NEXT: ld.w $ra, $sp, 28 # 4-byte Folded Reload
194 ; LA32-NEXT: addi.w $sp, $sp, 32
197 ; LA64-LABEL: test_fadd_mem:
199 ; LA64-NEXT: addi.d $sp, $sp, -32
200 ; LA64-NEXT: st.d $ra, $sp, 24 # 8-byte Folded Spill
201 ; LA64-NEXT: st.d $fp, $sp, 16 # 8-byte Folded Spill
202 ; LA64-NEXT: st.d $s0, $sp, 8 # 8-byte Folded Spill
203 ; LA64-NEXT: fst.d $fs0, $sp, 0 # 8-byte Folded Spill
204 ; LA64-NEXT: move $fp, $a1
205 ; LA64-NEXT: move $s0, $a0
206 ; LA64-NEXT: ld.hu $a0, $a0, 0
207 ; LA64-NEXT: bl %plt(__gnu_h2f_ieee)
208 ; LA64-NEXT: fmov.s $fs0, $fa0
209 ; LA64-NEXT: ld.hu $a0, $fp, 0
210 ; LA64-NEXT: bl %plt(__gnu_h2f_ieee)
211 ; LA64-NEXT: fadd.s $fa0, $fs0, $fa0
212 ; LA64-NEXT: bl %plt(__gnu_f2h_ieee)
213 ; LA64-NEXT: st.h $a0, $s0, 0
214 ; LA64-NEXT: fld.d $fs0, $sp, 0 # 8-byte Folded Reload
215 ; LA64-NEXT: ld.d $s0, $sp, 8 # 8-byte Folded Reload
216 ; LA64-NEXT: ld.d $fp, $sp, 16 # 8-byte Folded Reload
217 ; LA64-NEXT: ld.d $ra, $sp, 24 # 8-byte Folded Reload
218 ; LA64-NEXT: addi.d $sp, $sp, 32
220 %a = load half, ptr %p
221 %b = load half, ptr %q
222 %r = fadd half %a, %b
223 store half %r, ptr %p
227 define half @test_fmul_reg(half %a, half %b) nounwind {
228 ; LA32-LABEL: test_fmul_reg:
230 ; LA32-NEXT: addi.w $sp, $sp, -32
231 ; LA32-NEXT: st.w $ra, $sp, 28 # 4-byte Folded Spill
232 ; LA32-NEXT: fst.d $fs0, $sp, 16 # 8-byte Folded Spill
233 ; LA32-NEXT: fst.d $fs1, $sp, 8 # 8-byte Folded Spill
234 ; LA32-NEXT: fmov.s $fs0, $fa0
235 ; LA32-NEXT: fmov.s $fa0, $fa1
236 ; LA32-NEXT: bl %plt(__gnu_f2h_ieee)
237 ; LA32-NEXT: bl %plt(__gnu_h2f_ieee)
238 ; LA32-NEXT: fmov.s $fs1, $fa0
239 ; LA32-NEXT: fmov.s $fa0, $fs0
240 ; LA32-NEXT: bl %plt(__gnu_f2h_ieee)
241 ; LA32-NEXT: bl %plt(__gnu_h2f_ieee)
242 ; LA32-NEXT: fmul.s $fa0, $fa0, $fs1
243 ; LA32-NEXT: fld.d $fs1, $sp, 8 # 8-byte Folded Reload
244 ; LA32-NEXT: fld.d $fs0, $sp, 16 # 8-byte Folded Reload
245 ; LA32-NEXT: ld.w $ra, $sp, 28 # 4-byte Folded Reload
246 ; LA32-NEXT: addi.w $sp, $sp, 32
249 ; LA64-LABEL: test_fmul_reg:
251 ; LA64-NEXT: addi.d $sp, $sp, -32
252 ; LA64-NEXT: st.d $ra, $sp, 24 # 8-byte Folded Spill
253 ; LA64-NEXT: fst.d $fs0, $sp, 16 # 8-byte Folded Spill
254 ; LA64-NEXT: fst.d $fs1, $sp, 8 # 8-byte Folded Spill
255 ; LA64-NEXT: fmov.s $fs0, $fa0
256 ; LA64-NEXT: fmov.s $fa0, $fa1
257 ; LA64-NEXT: bl %plt(__gnu_f2h_ieee)
258 ; LA64-NEXT: bl %plt(__gnu_h2f_ieee)
259 ; LA64-NEXT: fmov.s $fs1, $fa0
260 ; LA64-NEXT: fmov.s $fa0, $fs0
261 ; LA64-NEXT: bl %plt(__gnu_f2h_ieee)
262 ; LA64-NEXT: bl %plt(__gnu_h2f_ieee)
263 ; LA64-NEXT: fmul.s $fa0, $fa0, $fs1
264 ; LA64-NEXT: fld.d $fs1, $sp, 8 # 8-byte Folded Reload
265 ; LA64-NEXT: fld.d $fs0, $sp, 16 # 8-byte Folded Reload
266 ; LA64-NEXT: ld.d $ra, $sp, 24 # 8-byte Folded Reload
267 ; LA64-NEXT: addi.d $sp, $sp, 32
269 %r = fmul half %a, %b
273 define void @test_fmul_mem(ptr %p, ptr %q) nounwind {
274 ; LA32-LABEL: test_fmul_mem:
276 ; LA32-NEXT: addi.w $sp, $sp, -32
277 ; LA32-NEXT: st.w $ra, $sp, 28 # 4-byte Folded Spill
278 ; LA32-NEXT: st.w $fp, $sp, 24 # 4-byte Folded Spill
279 ; LA32-NEXT: st.w $s0, $sp, 20 # 4-byte Folded Spill
280 ; LA32-NEXT: fst.d $fs0, $sp, 8 # 8-byte Folded Spill
281 ; LA32-NEXT: move $fp, $a1
282 ; LA32-NEXT: move $s0, $a0
283 ; LA32-NEXT: ld.hu $a0, $a0, 0
284 ; LA32-NEXT: bl %plt(__gnu_h2f_ieee)
285 ; LA32-NEXT: fmov.s $fs0, $fa0
286 ; LA32-NEXT: ld.hu $a0, $fp, 0
287 ; LA32-NEXT: bl %plt(__gnu_h2f_ieee)
288 ; LA32-NEXT: fmul.s $fa0, $fs0, $fa0
289 ; LA32-NEXT: bl %plt(__gnu_f2h_ieee)
290 ; LA32-NEXT: st.h $a0, $s0, 0
291 ; LA32-NEXT: fld.d $fs0, $sp, 8 # 8-byte Folded Reload
292 ; LA32-NEXT: ld.w $s0, $sp, 20 # 4-byte Folded Reload
293 ; LA32-NEXT: ld.w $fp, $sp, 24 # 4-byte Folded Reload
294 ; LA32-NEXT: ld.w $ra, $sp, 28 # 4-byte Folded Reload
295 ; LA32-NEXT: addi.w $sp, $sp, 32
298 ; LA64-LABEL: test_fmul_mem:
300 ; LA64-NEXT: addi.d $sp, $sp, -32
301 ; LA64-NEXT: st.d $ra, $sp, 24 # 8-byte Folded Spill
302 ; LA64-NEXT: st.d $fp, $sp, 16 # 8-byte Folded Spill
303 ; LA64-NEXT: st.d $s0, $sp, 8 # 8-byte Folded Spill
304 ; LA64-NEXT: fst.d $fs0, $sp, 0 # 8-byte Folded Spill
305 ; LA64-NEXT: move $fp, $a1
306 ; LA64-NEXT: move $s0, $a0
307 ; LA64-NEXT: ld.hu $a0, $a0, 0
308 ; LA64-NEXT: bl %plt(__gnu_h2f_ieee)
309 ; LA64-NEXT: fmov.s $fs0, $fa0
310 ; LA64-NEXT: ld.hu $a0, $fp, 0
311 ; LA64-NEXT: bl %plt(__gnu_h2f_ieee)
312 ; LA64-NEXT: fmul.s $fa0, $fs0, $fa0
313 ; LA64-NEXT: bl %plt(__gnu_f2h_ieee)
314 ; LA64-NEXT: st.h $a0, $s0, 0
315 ; LA64-NEXT: fld.d $fs0, $sp, 0 # 8-byte Folded Reload
316 ; LA64-NEXT: ld.d $s0, $sp, 8 # 8-byte Folded Reload
317 ; LA64-NEXT: ld.d $fp, $sp, 16 # 8-byte Folded Reload
318 ; LA64-NEXT: ld.d $ra, $sp, 24 # 8-byte Folded Reload
319 ; LA64-NEXT: addi.d $sp, $sp, 32
321 %a = load half, ptr %p
322 %b = load half, ptr %q
323 %r = fmul half %a, %b
324 store half %r, ptr %p