1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=sparc-linux-gnu < %s | FileCheck %s -check-prefixes=ALL,V8,V8-OPT
3 ; RUN: llc -mtriple=sparcel-linux-gnu < %s | FileCheck %s -check-prefixes=ALL,V8,V8-OPT
4 ; RUN: llc -mtriple=sparc-linux-gnu -O0 < %s | FileCheck %s -check-prefixes=ALL,V8,V8-UNOPT
5 ; RUN: llc -mtriple=sparc-linux-gnu -mattr=v9 < %s | FileCheck %s -check-prefixes=ALL,V9
6 ; RUN: llc -mtriple=sparc64-unknown-linux < %s | FileCheck %s -check-prefixes=ALL,SPARC64
8 define void @test_load_store(ptr %p, ptr %q) nounwind {
9 ; ALL-LABEL: test_load_store:
11 ; ALL-NEXT: lduh [%o0], %o0
13 ; ALL-NEXT: sth %o0, [%o1]
14 %a = load half, ptr %p
19 define float @test_fpextend_float(ptr %p) nounwind {
20 ; V8-LABEL: test_fpextend_float:
22 ; V8-NEXT: save %sp, -96, %sp
23 ; V8-NEXT: call __gnu_h2f_ieee
24 ; V8-NEXT: lduh [%i0], %o0
28 ; V9-LABEL: test_fpextend_float:
30 ; V9-NEXT: save %sp, -96, %sp
31 ; V9-NEXT: call __gnu_h2f_ieee
32 ; V9-NEXT: lduh [%i0], %o0
36 ; SPARC64-LABEL: test_fpextend_float:
38 ; SPARC64-NEXT: save %sp, -176, %sp
39 ; SPARC64-NEXT: call __gnu_h2f_ieee
40 ; SPARC64-NEXT: lduh [%i0], %o0
42 ; SPARC64-NEXT: restore
43 %a = load half, ptr %p
44 %r = fpext half %a to float
48 define double @test_fpextend_double(ptr %p) nounwind {
49 ; V8-LABEL: test_fpextend_double:
51 ; V8-NEXT: save %sp, -96, %sp
52 ; V8-NEXT: call __gnu_h2f_ieee
53 ; V8-NEXT: lduh [%i0], %o0
54 ; V8-NEXT: fstod %f0, %f0
58 ; V9-LABEL: test_fpextend_double:
60 ; V9-NEXT: save %sp, -96, %sp
61 ; V9-NEXT: call __gnu_h2f_ieee
62 ; V9-NEXT: lduh [%i0], %o0
63 ; V9-NEXT: fstod %f0, %f0
67 ; SPARC64-LABEL: test_fpextend_double:
69 ; SPARC64-NEXT: save %sp, -176, %sp
70 ; SPARC64-NEXT: call __gnu_h2f_ieee
71 ; SPARC64-NEXT: lduh [%i0], %o0
72 ; SPARC64-NEXT: fstod %f0, %f0
74 ; SPARC64-NEXT: restore
75 %a = load half, ptr %p
76 %r = fpext half %a to double
80 define void @test_fpextend_fp128(ptr %p, ptr %out) nounwind {
81 ; V8-OPT-LABEL: test_fpextend_fp128:
83 ; V8-OPT-NEXT: save %sp, -112, %sp
84 ; V8-OPT-NEXT: call __gnu_h2f_ieee
85 ; V8-OPT-NEXT: lduh [%i0], %o0
86 ; V8-OPT-NEXT: st %f0, [%fp+-20]
87 ; V8-OPT-NEXT: add %fp, -16, %i0
88 ; V8-OPT-NEXT: st %i0, [%sp+64]
89 ; V8-OPT-NEXT: call _Q_stoq
90 ; V8-OPT-NEXT: ld [%fp+-20], %o0
91 ; V8-OPT-NEXT: unimp 16
92 ; V8-OPT-NEXT: ldd [%fp+-16], %f0
93 ; V8-OPT-NEXT: ldd [%fp+-8], %f2
94 ; V8-OPT-NEXT: std %f2, [%i1+8]
95 ; V8-OPT-NEXT: std %f0, [%i1]
97 ; V8-OPT-NEXT: restore
99 ; V8-UNOPT-LABEL: test_fpextend_fp128:
101 ; V8-UNOPT-NEXT: save %sp, -112, %sp
102 ; V8-UNOPT-NEXT: call __gnu_h2f_ieee
103 ; V8-UNOPT-NEXT: lduh [%i0], %o0
104 ; V8-UNOPT-NEXT: st %f0, [%fp+-20]
105 ; V8-UNOPT-NEXT: add %fp, -16, %i0
106 ; V8-UNOPT-NEXT: st %i0, [%sp+64]
107 ; V8-UNOPT-NEXT: call _Q_stoq
108 ; V8-UNOPT-NEXT: ld [%fp+-20], %o0
109 ; V8-UNOPT-NEXT: unimp 16
110 ; V8-UNOPT-NEXT: ldd [%fp+-16], %f4
111 ; V8-UNOPT-NEXT: ! implicit-def: $q0
112 ; V8-UNOPT-NEXT: fmovs %f4, %f0
113 ; V8-UNOPT-NEXT: fmovs %f5, %f1
114 ; V8-UNOPT-NEXT: ldd [%fp+-8], %f4
115 ; V8-UNOPT-NEXT: fmovs %f4, %f2
116 ; V8-UNOPT-NEXT: fmovs %f5, %f3
117 ; V8-UNOPT-NEXT: fmovs %f2, %f4
118 ; V8-UNOPT-NEXT: fmovs %f3, %f5
119 ; V8-UNOPT-NEXT: std %f4, [%i1+8]
120 ; V8-UNOPT-NEXT: ! kill: def $d0 killed $d0 killed $q0
121 ; V8-UNOPT-NEXT: std %f0, [%i1]
123 ; V8-UNOPT-NEXT: restore
125 ; V9-LABEL: test_fpextend_fp128:
127 ; V9-NEXT: save %sp, -112, %sp
128 ; V9-NEXT: call __gnu_h2f_ieee
129 ; V9-NEXT: lduh [%i0], %o0
130 ; V9-NEXT: st %f0, [%fp+-20]
131 ; V9-NEXT: add %fp, -16, %i0
132 ; V9-NEXT: st %i0, [%sp+64]
133 ; V9-NEXT: call _Q_stoq
134 ; V9-NEXT: ld [%fp+-20], %o0
136 ; V9-NEXT: ldd [%fp+-16], %f0
137 ; V9-NEXT: ldd [%fp+-8], %f2
138 ; V9-NEXT: std %f2, [%i1+8]
139 ; V9-NEXT: std %f0, [%i1]
143 ; SPARC64-LABEL: test_fpextend_fp128:
145 ; SPARC64-NEXT: save %sp, -192, %sp
146 ; SPARC64-NEXT: call __gnu_h2f_ieee
147 ; SPARC64-NEXT: lduh [%i0], %o0
148 ; SPARC64-NEXT: add %fp, 2031, %o0
149 ; SPARC64-NEXT: fmovs %f0, %f3
150 ; SPARC64-NEXT: call _Qp_stoq
152 ; SPARC64-NEXT: ldd [%fp+2031], %f0
153 ; SPARC64-NEXT: ldd [%fp+2039], %f2
154 ; SPARC64-NEXT: std %f2, [%i1+8]
155 ; SPARC64-NEXT: std %f0, [%i1]
157 ; SPARC64-NEXT: restore
158 %a = load half, ptr %p
159 %r = fpext half %a to fp128
160 store fp128 %r, ptr %out
164 define void @test_fptrunc_float(float %f, ptr %p) nounwind {
165 ; V8-OPT-LABEL: test_fptrunc_float:
167 ; V8-OPT-NEXT: save %sp, -96, %sp
168 ; V8-OPT-NEXT: call __gnu_f2h_ieee
169 ; V8-OPT-NEXT: mov %i0, %o0
170 ; V8-OPT-NEXT: sth %o0, [%i1]
172 ; V8-OPT-NEXT: restore
174 ; V8-UNOPT-LABEL: test_fptrunc_float:
176 ; V8-UNOPT-NEXT: save %sp, -96, %sp
177 ; V8-UNOPT-NEXT: mov %i0, %o0
178 ; V8-UNOPT-NEXT: st %o0, [%fp+-4]
179 ; V8-UNOPT-NEXT: call __gnu_f2h_ieee
180 ; V8-UNOPT-NEXT: ld [%fp+-4], %f0
181 ; V8-UNOPT-NEXT: sth %o0, [%i1]
183 ; V8-UNOPT-NEXT: restore
185 ; V9-LABEL: test_fptrunc_float:
187 ; V9-NEXT: save %sp, -96, %sp
188 ; V9-NEXT: call __gnu_f2h_ieee
189 ; V9-NEXT: mov %i0, %o0
190 ; V9-NEXT: sth %o0, [%i1]
194 ; SPARC64-LABEL: test_fptrunc_float:
196 ; SPARC64-NEXT: save %sp, -176, %sp
197 ; SPARC64-NEXT: call __gnu_f2h_ieee
199 ; SPARC64-NEXT: sth %o0, [%i1]
201 ; SPARC64-NEXT: restore
202 %a = fptrunc float %f to half
203 store half %a, ptr %p
207 define void @test_fptrunc_double(double %d, ptr %p) nounwind {
208 ; V8-OPT-LABEL: test_fptrunc_double:
210 ; V8-OPT-NEXT: save %sp, -112, %sp
211 ; V8-OPT-NEXT: ! kill: def $i1 killed $i1 killed $i0_i1 def $i0_i1
212 ; V8-OPT-NEXT: ! kill: def $i0 killed $i0 killed $i0_i1 def $i0_i1
213 ; V8-OPT-NEXT: std %i0, [%fp+-8]
214 ; V8-OPT-NEXT: ldd [%fp+-8], %f0
215 ; V8-OPT-NEXT: std %f0, [%fp+-16]
216 ; V8-OPT-NEXT: call __truncdfhf2
217 ; V8-OPT-NEXT: ldd [%fp+-16], %o0
218 ; V8-OPT-NEXT: sth %o0, [%i2]
220 ; V8-OPT-NEXT: restore
222 ; V8-UNOPT-LABEL: test_fptrunc_double:
224 ; V8-UNOPT-NEXT: save %sp, -112, %sp
225 ; V8-UNOPT-NEXT: mov %i1, %i3
226 ; V8-UNOPT-NEXT: mov %i0, %i4
227 ; V8-UNOPT-NEXT: ! implicit-def: $i0_i1
228 ; V8-UNOPT-NEXT: mov %i4, %i0
229 ; V8-UNOPT-NEXT: mov %i3, %i1
230 ; V8-UNOPT-NEXT: std %i0, [%fp+-8]
231 ; V8-UNOPT-NEXT: ldd [%fp+-8], %f0
232 ; V8-UNOPT-NEXT: std %f0, [%fp+-16]
233 ; V8-UNOPT-NEXT: ldd [%fp+-16], %i0
234 ; V8-UNOPT-NEXT: mov %i0, %o0
235 ; V8-UNOPT-NEXT: call __truncdfhf2
236 ; V8-UNOPT-NEXT: mov %i1, %o1
237 ; V8-UNOPT-NEXT: sth %o0, [%i2]
239 ; V8-UNOPT-NEXT: restore
241 ; V9-LABEL: test_fptrunc_double:
243 ; V9-NEXT: save %sp, -112, %sp
244 ; V9-NEXT: ! kill: def $i1 killed $i1 killed $i0_i1 def $i0_i1
245 ; V9-NEXT: ! kill: def $i0 killed $i0 killed $i0_i1 def $i0_i1
246 ; V9-NEXT: std %i0, [%fp+-8]
247 ; V9-NEXT: ldd [%fp+-8], %f0
248 ; V9-NEXT: std %f0, [%fp+-16]
249 ; V9-NEXT: call __truncdfhf2
250 ; V9-NEXT: ldd [%fp+-16], %o0
251 ; V9-NEXT: sth %o0, [%i2]
255 ; SPARC64-LABEL: test_fptrunc_double:
257 ; SPARC64-NEXT: save %sp, -176, %sp
258 ; SPARC64-NEXT: call __truncdfhf2
260 ; SPARC64-NEXT: sth %o0, [%i1]
262 ; SPARC64-NEXT: restore
263 %a = fptrunc double %d to half
264 store half %a, ptr %p
268 define void @test_fptrunc_fp128(ptr %dp, ptr %p) nounwind {
269 ; V8-OPT-LABEL: test_fptrunc_fp128:
271 ; V8-OPT-NEXT: save %sp, -104, %sp
272 ; V8-OPT-NEXT: ldd [%i0], %f0
273 ; V8-OPT-NEXT: ldd [%i0+8], %f2
274 ; V8-OPT-NEXT: std %f2, [%sp+100]
275 ; V8-OPT-NEXT: call __trunctfhf2
276 ; V8-OPT-NEXT: std %f0, [%sp+92]
277 ; V8-OPT-NEXT: sth %o0, [%i1]
279 ; V8-OPT-NEXT: restore
281 ; V8-UNOPT-LABEL: test_fptrunc_fp128:
283 ; V8-UNOPT-NEXT: save %sp, -104, %sp
284 ; V8-UNOPT-NEXT: ldd [%i0], %f4
285 ; V8-UNOPT-NEXT: ! implicit-def: $q0
286 ; V8-UNOPT-NEXT: fmovs %f4, %f0
287 ; V8-UNOPT-NEXT: fmovs %f5, %f1
288 ; V8-UNOPT-NEXT: ldd [%i0+8], %f4
289 ; V8-UNOPT-NEXT: fmovs %f4, %f2
290 ; V8-UNOPT-NEXT: fmovs %f5, %f3
291 ; V8-UNOPT-NEXT: fmovs %f2, %f4
292 ; V8-UNOPT-NEXT: fmovs %f3, %f5
293 ; V8-UNOPT-NEXT: std %f4, [%sp+100]
294 ; V8-UNOPT-NEXT: ! kill: def $d0 killed $d0 killed $q0
295 ; V8-UNOPT-NEXT: call __trunctfhf2
296 ; V8-UNOPT-NEXT: std %f0, [%sp+92]
297 ; V8-UNOPT-NEXT: sth %o0, [%i1]
299 ; V8-UNOPT-NEXT: restore
301 ; V9-LABEL: test_fptrunc_fp128:
303 ; V9-NEXT: save %sp, -104, %sp
304 ; V9-NEXT: ldd [%i0], %f0
305 ; V9-NEXT: ldd [%i0+8], %f2
306 ; V9-NEXT: std %f2, [%sp+100]
307 ; V9-NEXT: call __trunctfhf2
308 ; V9-NEXT: std %f0, [%sp+92]
309 ; V9-NEXT: sth %o0, [%i1]
313 ; SPARC64-LABEL: test_fptrunc_fp128:
315 ; SPARC64-NEXT: save %sp, -176, %sp
316 ; SPARC64-NEXT: ldd [%i0], %f0
317 ; SPARC64-NEXT: call __trunctfhf2
318 ; SPARC64-NEXT: ldd [%i0+8], %f2
319 ; SPARC64-NEXT: sth %o0, [%i1]
321 ; SPARC64-NEXT: restore
322 %d = load fp128, ptr %dp
323 %a = fptrunc fp128 %d to half
324 store half %a, ptr %p
328 define void @test_fadd(ptr %p, ptr %q) nounwind {
329 ; V8-OPT-LABEL: test_fadd:
331 ; V8-OPT-NEXT: save %sp, -104, %sp
332 ; V8-OPT-NEXT: call __gnu_h2f_ieee
333 ; V8-OPT-NEXT: lduh [%i0], %o0
334 ; V8-OPT-NEXT: st %f0, [%fp+-8] ! 4-byte Folded Spill
335 ; V8-OPT-NEXT: call __gnu_h2f_ieee
336 ; V8-OPT-NEXT: lduh [%i1], %o0
337 ; V8-OPT-NEXT: ld [%fp+-8], %f1 ! 4-byte Folded Reload
338 ; V8-OPT-NEXT: fadds %f1, %f0, %f0
339 ; V8-OPT-NEXT: st %f0, [%fp+-4]
340 ; V8-OPT-NEXT: call __gnu_f2h_ieee
341 ; V8-OPT-NEXT: ld [%fp+-4], %o0
342 ; V8-OPT-NEXT: sth %o0, [%i0]
344 ; V8-OPT-NEXT: restore
346 ; V8-UNOPT-LABEL: test_fadd:
348 ; V8-UNOPT-NEXT: save %sp, -104, %sp
349 ; V8-UNOPT-NEXT: call __gnu_h2f_ieee
350 ; V8-UNOPT-NEXT: lduh [%i0], %o0
351 ; V8-UNOPT-NEXT: st %f0, [%fp+-8] ! 4-byte Folded Spill
352 ; V8-UNOPT-NEXT: call __gnu_h2f_ieee
353 ; V8-UNOPT-NEXT: lduh [%i1], %o0
354 ; V8-UNOPT-NEXT: fmovs %f0, %f1
355 ; V8-UNOPT-NEXT: ld [%fp+-8], %f0 ! 4-byte Folded Reload
356 ; V8-UNOPT-NEXT: fadds %f0, %f1, %f0
357 ; V8-UNOPT-NEXT: st %f0, [%fp+-4]
358 ; V8-UNOPT-NEXT: call __gnu_f2h_ieee
359 ; V8-UNOPT-NEXT: ld [%fp+-4], %o0
360 ; V8-UNOPT-NEXT: sth %o0, [%i0]
362 ; V8-UNOPT-NEXT: restore
364 ; V9-LABEL: test_fadd:
366 ; V9-NEXT: save %sp, -104, %sp
367 ; V9-NEXT: call __gnu_h2f_ieee
368 ; V9-NEXT: lduh [%i0], %o0
369 ; V9-NEXT: st %f0, [%fp+-8] ! 4-byte Folded Spill
370 ; V9-NEXT: call __gnu_h2f_ieee
371 ; V9-NEXT: lduh [%i1], %o0
372 ; V9-NEXT: ld [%fp+-8], %f1 ! 4-byte Folded Reload
373 ; V9-NEXT: fadds %f1, %f0, %f0
374 ; V9-NEXT: st %f0, [%fp+-4]
375 ; V9-NEXT: call __gnu_f2h_ieee
376 ; V9-NEXT: ld [%fp+-4], %o0
377 ; V9-NEXT: sth %o0, [%i0]
381 ; SPARC64-LABEL: test_fadd:
383 ; SPARC64-NEXT: save %sp, -192, %sp
384 ; SPARC64-NEXT: call __gnu_h2f_ieee
385 ; SPARC64-NEXT: lduh [%i0], %o0
386 ; SPARC64-NEXT: st %f0, [%fp+2043] ! 4-byte Folded Spill
387 ; SPARC64-NEXT: call __gnu_h2f_ieee
388 ; SPARC64-NEXT: lduh [%i1], %o0
389 ; SPARC64-NEXT: ld [%fp+2043], %f1 ! 4-byte Folded Reload
390 ; SPARC64-NEXT: call __gnu_f2h_ieee
391 ; SPARC64-NEXT: fadds %f1, %f0, %f1
392 ; SPARC64-NEXT: sth %o0, [%i0]
394 ; SPARC64-NEXT: restore
395 %a = load half, ptr %p
396 %b = load half, ptr %q
397 %r = fadd half %a, %b
398 store half %r, ptr %p
402 define void @test_fmul(ptr %p, ptr %q) nounwind {
403 ; V8-OPT-LABEL: test_fmul:
405 ; V8-OPT-NEXT: save %sp, -104, %sp
406 ; V8-OPT-NEXT: call __gnu_h2f_ieee
407 ; V8-OPT-NEXT: lduh [%i0], %o0
408 ; V8-OPT-NEXT: st %f0, [%fp+-8] ! 4-byte Folded Spill
409 ; V8-OPT-NEXT: call __gnu_h2f_ieee
410 ; V8-OPT-NEXT: lduh [%i1], %o0
411 ; V8-OPT-NEXT: ld [%fp+-8], %f1 ! 4-byte Folded Reload
412 ; V8-OPT-NEXT: fmuls %f1, %f0, %f0
413 ; V8-OPT-NEXT: st %f0, [%fp+-4]
414 ; V8-OPT-NEXT: call __gnu_f2h_ieee
415 ; V8-OPT-NEXT: ld [%fp+-4], %o0
416 ; V8-OPT-NEXT: sth %o0, [%i0]
418 ; V8-OPT-NEXT: restore
420 ; V8-UNOPT-LABEL: test_fmul:
422 ; V8-UNOPT-NEXT: save %sp, -104, %sp
423 ; V8-UNOPT-NEXT: call __gnu_h2f_ieee
424 ; V8-UNOPT-NEXT: lduh [%i0], %o0
425 ; V8-UNOPT-NEXT: st %f0, [%fp+-8] ! 4-byte Folded Spill
426 ; V8-UNOPT-NEXT: call __gnu_h2f_ieee
427 ; V8-UNOPT-NEXT: lduh [%i1], %o0
428 ; V8-UNOPT-NEXT: fmovs %f0, %f1
429 ; V8-UNOPT-NEXT: ld [%fp+-8], %f0 ! 4-byte Folded Reload
430 ; V8-UNOPT-NEXT: fmuls %f0, %f1, %f0
431 ; V8-UNOPT-NEXT: st %f0, [%fp+-4]
432 ; V8-UNOPT-NEXT: call __gnu_f2h_ieee
433 ; V8-UNOPT-NEXT: ld [%fp+-4], %o0
434 ; V8-UNOPT-NEXT: sth %o0, [%i0]
436 ; V8-UNOPT-NEXT: restore
438 ; V9-LABEL: test_fmul:
440 ; V9-NEXT: save %sp, -104, %sp
441 ; V9-NEXT: call __gnu_h2f_ieee
442 ; V9-NEXT: lduh [%i0], %o0
443 ; V9-NEXT: st %f0, [%fp+-8] ! 4-byte Folded Spill
444 ; V9-NEXT: call __gnu_h2f_ieee
445 ; V9-NEXT: lduh [%i1], %o0
446 ; V9-NEXT: ld [%fp+-8], %f1 ! 4-byte Folded Reload
447 ; V9-NEXT: fmuls %f1, %f0, %f0
448 ; V9-NEXT: st %f0, [%fp+-4]
449 ; V9-NEXT: call __gnu_f2h_ieee
450 ; V9-NEXT: ld [%fp+-4], %o0
451 ; V9-NEXT: sth %o0, [%i0]
455 ; SPARC64-LABEL: test_fmul:
457 ; SPARC64-NEXT: save %sp, -192, %sp
458 ; SPARC64-NEXT: call __gnu_h2f_ieee
459 ; SPARC64-NEXT: lduh [%i0], %o0
460 ; SPARC64-NEXT: st %f0, [%fp+2043] ! 4-byte Folded Spill
461 ; SPARC64-NEXT: call __gnu_h2f_ieee
462 ; SPARC64-NEXT: lduh [%i1], %o0
463 ; SPARC64-NEXT: ld [%fp+2043], %f1 ! 4-byte Folded Reload
464 ; SPARC64-NEXT: call __gnu_f2h_ieee
465 ; SPARC64-NEXT: fmuls %f1, %f0, %f1
466 ; SPARC64-NEXT: sth %o0, [%i0]
468 ; SPARC64-NEXT: restore
469 %a = load half, ptr %p
470 %b = load half, ptr %q
471 %r = fmul half %a, %b
472 store half %r, ptr %p