1 ; RUN: llc < %s -mtriple aarch64-unknown-unknown -aarch64-neon-syntax=apple -asm-verbose=false -disable-post-ra -frame-pointer=non-leaf | FileCheck %s --check-prefix=CHECK-CVT --check-prefix=CHECK-COMMON
2 ; RUN: llc < %s -mtriple aarch64-unknown-unknown -mattr=+fullfp16 -aarch64-neon-syntax=apple -asm-verbose=false -disable-post-ra -frame-pointer=non-leaf | FileCheck %s --check-prefix=CHECK-COMMON --check-prefix=CHECK-FP16
4 ; RUN: llc < %s -mtriple aarch64-unknown-unknown -aarch64-neon-syntax=apple \
5 ; RUN: -asm-verbose=false -disable-post-ra -frame-pointer=non-leaf -global-isel \
6 ; RUN: -global-isel-abort=2 -pass-remarks-missed=gisel-* 2>&1 | FileCheck %s \
7 ; RUN: --check-prefixes=FALLBACK,GISEL-CVT,GISEL
9 ; RUN: llc < %s -mtriple aarch64-unknown-unknown -mattr=+fullfp16 \
10 ; RUN: -aarch64-neon-syntax=apple -asm-verbose=false -disable-post-ra \
11 ; RUN: -frame-pointer=non-leaf -global-isel -global-isel-abort=2 \
12 ; RUN: -pass-remarks-missed=gisel-* 2>&1 | FileCheck %s \
13 ; RUN: --check-prefixes=FALLBACK-FP16,GISEL-FP16,GISEL
15 target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
17 ; CHECK-CVT-LABEL: test_fadd:
18 ; CHECK-CVT-NEXT: fcvt s1, h1
19 ; CHECK-CVT-NEXT: fcvt s0, h0
20 ; CHECK-CVT-NEXT: fadd s0, s0, s1
21 ; CHECK-CVT-NEXT: fcvt h0, s0
24 ; CHECK-FP16-LABEL: test_fadd:
25 ; CHECK-FP16-NEXT: fadd h0, h0, h1
26 ; CHECK-FP16-NEXT: ret
28 define half @test_fadd(half %a, half %b) #0 {
33 ; CHECK-CVT-LABEL: test_fsub:
34 ; CHECK-CVT-NEXT: fcvt s1, h1
35 ; CHECK-CVT-NEXT: fcvt s0, h0
36 ; CHECK-CVT-NEXT: fsub s0, s0, s1
37 ; CHECK-CVT-NEXT: fcvt h0, s0
40 ; CHECK-FP16-LABEL: test_fsub:
41 ; CHECK-FP16-NEXT: fsub h0, h0, h1
42 ; CHECK-FP16-NEXT: ret
44 define half @test_fsub(half %a, half %b) #0 {
49 ; CHECK-CVT-LABEL: test_fmul:
50 ; CHECK-CVT-NEXT: fcvt s1, h1
51 ; CHECK-CVT-NEXT: fcvt s0, h0
52 ; CHECK-CVT-NEXT: fmul s0, s0, s1
53 ; CHECK-CVT-NEXT: fcvt h0, s0
56 ; CHECK-FP16-LABEL: test_fmul:
57 ; CHECK-FP16-NEXT: fmul h0, h0, h1
58 ; CHECK-FP16-NEXT: ret
60 define half @test_fmul(half %a, half %b) #0 {
65 ; CHECK-CVT-LABEL: test_fmadd:
66 ; CHECK-CVT-NEXT: fcvt s1, h1
67 ; CHECK-CVT-NEXT: fcvt s0, h0
68 ; CHECK-CVT-NEXT: fmul s0, s0, s1
69 ; CHECK-CVT-NEXT: fcvt h0, s0
70 ; CHECK-CVT-NEXT: fcvt s0, h0
71 ; CHECK-CVT-NEXT: fcvt s1, h2
72 ; CHECK-CVT-NEXT: fadd s0, s0, s1
73 ; CHECK-CVT-NEXT: fcvt h0, s0
76 ; CHECK-FP16-LABEL: test_fmadd:
77 ; CHECK-FP16-NEXT: fmadd h0, h0, h1, h2
78 ; CHECK-FP16-NEXT: ret
80 define half @test_fmadd(half %a, half %b, half %c) #0 {
81 %mul = fmul fast half %a, %b
82 %r = fadd fast half %mul, %c
85 ; CHECK-CVT-LABEL: test_fdiv:
86 ; CHECK-CVT-NEXT: fcvt s1, h1
87 ; CHECK-CVT-NEXT: fcvt s0, h0
88 ; CHECK-CVT-NEXT: fdiv s0, s0, s1
89 ; CHECK-CVT-NEXT: fcvt h0, s0
92 ; CHECK-FP16-LABEL: test_fdiv:
93 ; CHECK-FP16-NEXT: fdiv h0, h0, h1
94 ; CHECK-FP16-NEXT: ret
96 define half @test_fdiv(half %a, half %b) #0 {
101 ; CHECK-COMMON-LABEL: test_frem:
102 ; CHECK-COMMON-NEXT: stp x29, x30, [sp, #-16]!
103 ; CHECK-COMMON-NEXT: mov x29, sp
104 ; CHECK-COMMON-NEXT: fcvt s0, h0
105 ; CHECK-COMMON-NEXT: fcvt s1, h1
106 ; CHECK-COMMON-NEXT: bl {{_?}}fmodf
107 ; CHECK-COMMON-NEXT: fcvt h0, s0
108 ; CHECK-COMMON-NEXT: ldp x29, x30, [sp], #16
109 ; CHECK-COMMON-NEXT: ret
110 define half @test_frem(half %a, half %b) #0 {
111 %r = frem half %a, %b
115 ; CHECK-COMMON-LABEL: test_store:
116 ; CHECK-COMMON-NEXT: str h0, [x0]
117 ; CHECK-COMMON-NEXT: ret
118 define void @test_store(half %a, half* %b) #0 {
119 store half %a, half* %b
123 ; CHECK-COMMON-LABEL: test_load:
124 ; CHECK-COMMON-NEXT: ldr h0, [x0]
125 ; CHECK-COMMON-NEXT: ret
126 define half @test_load(half* %a) #0 {
127 %r = load half, half* %a
131 declare half @test_callee(half %a, half %b) #0
133 ; CHECK-COMMON-LABEL: test_call:
134 ; CHECK-COMMON-NEXT: stp x29, x30, [sp, #-16]!
135 ; CHECK-COMMON-NEXT: mov x29, sp
136 ; CHECK-COMMON-NEXT: bl {{_?}}test_callee
137 ; CHECK-COMMON-NEXT: ldp x29, x30, [sp], #16
138 ; CHECK-COMMON-NEXT: ret
139 define half @test_call(half %a, half %b) #0 {
140 %r = call half @test_callee(half %a, half %b)
144 ; CHECK-COMMON-LABEL: test_call_flipped:
145 ; CHECK-COMMON-NEXT: stp x29, x30, [sp, #-16]!
146 ; CHECK-COMMON-NEXT: mov x29, sp
147 ; CHECK-COMMON-NEXT: fmov s2, s0
148 ; CHECK-COMMON-NEXT: fmov s0, s1
149 ; CHECK-COMMON-NEXT: fmov s1, s2
150 ; CHECK-COMMON-NEXT: bl {{_?}}test_callee
151 ; CHECK-COMMON-NEXT: ldp x29, x30, [sp], #16
152 ; CHECK-COMMON-NEXT: ret
153 define half @test_call_flipped(half %a, half %b) #0 {
154 %r = call half @test_callee(half %b, half %a)
158 ; CHECK-COMMON-LABEL: test_tailcall_flipped:
159 ; CHECK-COMMON-NEXT: fmov s2, s0
160 ; CHECK-COMMON-NEXT: fmov s0, s1
161 ; CHECK-COMMON-NEXT: fmov s1, s2
162 ; CHECK-COMMON-NEXT: b {{_?}}test_callee
163 define half @test_tailcall_flipped(half %a, half %b) #0 {
164 %r = tail call half @test_callee(half %b, half %a)
168 ; CHECK-CVT-LABEL: test_select:
169 ; CHECK-CVT-NEXT: fcvt s1, h1
170 ; CHECK-CVT-NEXT: fcvt s0, h0
171 ; CHECK-CVT-NEXT: cmp w0, #0
172 ; CHECK-CVT-NEXT: fcsel s0, s0, s1, ne
173 ; CHECK-CVT-NEXT: fcvt h0, s0
174 ; CHECK-CVT-NEXT: ret
176 ; CHECK-FP16-LABEL: test_select:
177 ; CHECK-FP16-NEXT: cmp w0, #0
178 ; CHECK-FP16-NEXT: fcsel h0, h0, h1, ne
179 ; CHECK-FP16-NEXT: ret
181 define half @test_select(half %a, half %b, i1 zeroext %c) #0 {
182 %r = select i1 %c, half %a, half %b
186 ; CHECK-CVT-LABEL: test_select_cc:
187 ; CHECK-CVT-DAG: fcvt s3, h3
188 ; CHECK-CVT-DAG: fcvt s2, h2
189 ; CHECK-CVT-DAG: fcvt s1, h1
190 ; CHECK-CVT-DAG: fcvt s0, h0
191 ; CHECK-CVT-DAG: fcmp s2, s3
192 ; CHECK-CVT-NEXT: fcsel s0, s0, s1, ne
193 ; CHECK-CVT-NEXT: fcvt h0, s0
194 ; CHECK-CVT-NEXT: ret
196 ; CHECK-FP16-LABEL: test_select_cc:
197 ; CHECK-FP16-NEXT: fcmp h2, h3
198 ; CHECK-FP16-NEXT: fcsel h0, h0, h1, ne
199 ; CHECK-FP16-NEXT: ret
201 define half @test_select_cc(half %a, half %b, half %c, half %d) #0 {
202 %cc = fcmp une half %c, %d
203 %r = select i1 %cc, half %a, half %b
207 ; CHECK-CVT-LABEL: test_select_cc_f32_f16:
208 ; CHECK-CVT-DAG: fcvt s2, h2
209 ; CHECK-CVT-DAG: fcvt s3, h3
210 ; CHECK-CVT-NEXT: fcmp s2, s3
211 ; CHECK-CVT-NEXT: fcsel s0, s0, s1, ne
212 ; CHECK-CVT-NEXT: ret
214 ; CHECK-FP16-LABEL: test_select_cc_f32_f16:
215 ; CHECK-FP16-NEXT: fcmp h2, h3
216 ; CHECK-FP16-NEXT: fcsel s0, s0, s1, ne
217 ; CHECK-FP16-NEXT: ret
219 define float @test_select_cc_f32_f16(float %a, float %b, half %c, half %d) #0 {
220 %cc = fcmp une half %c, %d
221 %r = select i1 %cc, float %a, float %b
225 ; CHECK-CVT-LABEL: test_select_cc_f16_f32:
226 ; CHECK-CVT-DAG: fcvt s0, h0
227 ; CHECK-CVT-DAG: fcvt s1, h1
228 ; CHECK-CVT-DAG: fcmp s2, s3
229 ; CHECK-CVT-NEXT: fcsel s0, s0, s1, ne
230 ; CHECK-CVT-NEXT: fcvt h0, s0
231 ; CHECK-CVT-NEXT: ret
233 ; CHECK-FP16-LABEL: test_select_cc_f16_f32:
234 ; CHECK-FP16-NEXT: fcmp s2, s3
235 ; CHECK-FP16-NEXT: fcsel h0, h0, h1, ne
236 ; CHECK-FP16-NEXT: ret
238 define half @test_select_cc_f16_f32(half %a, half %b, float %c, float %d) #0 {
239 %cc = fcmp une float %c, %d
240 %r = select i1 %cc, half %a, half %b
244 ; CHECK-CVT-LABEL: test_fcmp_une:
245 ; CHECK-CVT-NEXT: fcvt s1, h1
246 ; CHECK-CVT-NEXT: fcvt s0, h0
247 ; CHECK-CVT-NEXT: fcmp s0, s1
248 ; CHECK-CVT-NEXT: cset w0, ne
249 ; CHECK-CVT-NEXT: ret
251 ; CHECK-FP16-LABEL: test_fcmp_une:
252 ; CHECK-FP16-NEXT: fcmp h0, h1
253 ; CHECK-FP16-NEXT: cset w0, ne
254 ; CHECK-FP16-NEXT: ret
256 define i1 @test_fcmp_une(half %a, half %b) #0 {
257 %r = fcmp une half %a, %b
261 ; CHECK-CVT-LABEL: test_fcmp_ueq:
262 ; CHECK-CVT-NEXT: fcvt s1, h1
263 ; CHECK-CVT-NEXT: fcvt s0, h0
264 ; CHECK-CVT-NEXT: fcmp s0, s1
265 ; CHECK-CVT-NEXT: cset [[TRUE:w[0-9]+]], eq
266 ; CHECK-CVT-NEXT: csinc w0, [[TRUE]], wzr, vc
267 ; CHECK-CVT-NEXT: ret
269 ; CHECK-FP16-LABEL: test_fcmp_ueq:
270 ; CHECK-FP16-NEXT: fcmp h0, h1
271 ; CHECK-FP16-NEXT: cset [[TRUE:w[0-9]+]], eq
272 ; CHECK-FP16-NEXT: csinc w0, [[TRUE]], wzr, vc
273 ; CHECK-FP16-NEXT: ret
275 define i1 @test_fcmp_ueq(half %a, half %b) #0 {
276 %r = fcmp ueq half %a, %b
280 ; CHECK-CVT-LABEL: test_fcmp_ugt:
281 ; CHECK-CVT-NEXT: fcvt s1, h1
282 ; CHECK-CVT-NEXT: fcvt s0, h0
283 ; CHECK-CVT-NEXT: fcmp s0, s1
284 ; CHECK-CVT-NEXT: cset w0, hi
285 ; CHECK-CVT-NEXT: ret
287 ; CHECK-FP16-LABEL: test_fcmp_ugt:
288 ; CHECK-FP16-NEXT: fcmp h0, h1
289 ; CHECK-FP16-NEXT: cset w0, hi
290 ; CHECK-FP16-NEXT: ret
292 define i1 @test_fcmp_ugt(half %a, half %b) #0 {
293 %r = fcmp ugt half %a, %b
297 ; CHECK-CVT-LABEL: test_fcmp_uge:
298 ; CHECK-CVT-NEXT: fcvt s1, h1
299 ; CHECK-CVT-NEXT: fcvt s0, h0
300 ; CHECK-CVT-NEXT: fcmp s0, s1
301 ; CHECK-CVT-NEXT: cset w0, pl
302 ; CHECK-CVT-NEXT: ret
304 ; CHECK-FP16-LABEL: test_fcmp_uge:
305 ; CHECK-FP16-NEXT: fcmp h0, h1
306 ; CHECK-FP16-NEXT: cset w0, pl
307 ; CHECK-FP16-NEXT: ret
309 define i1 @test_fcmp_uge(half %a, half %b) #0 {
310 %r = fcmp uge half %a, %b
314 ; CHECK-CVT-LABEL: test_fcmp_ult:
315 ; CHECK-CVT-NEXT: fcvt s1, h1
316 ; CHECK-CVT-NEXT: fcvt s0, h0
317 ; CHECK-CVT-NEXT: fcmp s0, s1
318 ; CHECK-CVT-NEXT: cset w0, lt
319 ; CHECK-CVT-NEXT: ret
321 ; CHECK-FP16-LABEL: test_fcmp_ult:
322 ; CHECK-FP16-NEXT: fcmp h0, h1
323 ; CHECK-FP16-NEXT: cset w0, lt
324 ; CHECK-FP16-NEXT: ret
326 define i1 @test_fcmp_ult(half %a, half %b) #0 {
327 %r = fcmp ult half %a, %b
331 ; CHECK-CVT-LABEL: test_fcmp_ule:
332 ; CHECK-CVT-NEXT: fcvt s1, h1
333 ; CHECK-CVT-NEXT: fcvt s0, h0
334 ; CHECK-CVT-NEXT: fcmp s0, s1
335 ; CHECK-CVT-NEXT: cset w0, le
336 ; CHECK-CVT-NEXT: ret
338 ; CHECK-FP16-LABEL: test_fcmp_ule:
339 ; CHECK-FP16-NEXT: fcmp h0, h1
340 ; CHECK-FP16-NEXT: cset w0, le
341 ; CHECK-FP16-NEXT: ret
343 define i1 @test_fcmp_ule(half %a, half %b) #0 {
344 %r = fcmp ule half %a, %b
348 ; CHECK-CVT-LABEL: test_fcmp_uno:
349 ; CHECK-CVT-NEXT: fcvt s1, h1
350 ; CHECK-CVT-NEXT: fcvt s0, h0
351 ; CHECK-CVT-NEXT: fcmp s0, s1
352 ; CHECK-CVT-NEXT: cset w0, vs
353 ; CHECK-CVT-NEXT: ret
355 ; CHECK-FP16-LABEL: test_fcmp_uno:
356 ; CHECK-FP16-NEXT: fcmp h0, h1
357 ; CHECK-FP16-NEXT: cset w0, vs
358 ; CHECK-FP16-NEXT: ret
360 define i1 @test_fcmp_uno(half %a, half %b) #0 {
361 %r = fcmp uno half %a, %b
365 ; CHECK-CVT-LABEL: test_fcmp_one:
366 ; CHECK-CVT-NEXT: fcvt s1, h1
367 ; CHECK-CVT-NEXT: fcvt s0, h0
368 ; CHECK-CVT-NEXT: fcmp s0, s1
369 ; CHECK-CVT-NEXT: cset [[TRUE:w[0-9]+]], mi
370 ; CHECK-CVT-NEXT: csinc w0, [[TRUE]], wzr, le
371 ; CHECK-CVT-NEXT: ret
373 ; CHECK-FP16-LABEL: test_fcmp_one:
374 ; CHECK-FP16-NEXT: fcmp h0, h1
375 ; CHECK-FP16-NEXT: cset [[TRUE:w[0-9]+]], mi
376 ; CHECK-FP16-NEXT: csinc w0, [[TRUE]], wzr, le
377 ; CHECK-FP16-NEXT: ret
379 define i1 @test_fcmp_one(half %a, half %b) #0 {
380 %r = fcmp one half %a, %b
384 ; CHECK-CVT-LABEL: test_fcmp_oeq:
385 ; CHECK-CVT-NEXT: fcvt s1, h1
386 ; CHECK-CVT-NEXT: fcvt s0, h0
387 ; CHECK-CVT-NEXT: fcmp s0, s1
388 ; CHECK-CVT-NEXT: cset w0, eq
389 ; CHECK-CVT-NEXT: ret
391 ; CHECK-FP16-LABEL: test_fcmp_oeq:
392 ; CHECK-FP16-NEXT: fcmp h0, h1
393 ; CHECK-FP16-NEXT: cset w0, eq
394 ; CHECK-FP16-NEXT: ret
396 define i1 @test_fcmp_oeq(half %a, half %b) #0 {
397 %r = fcmp oeq half %a, %b
401 ; CHECK-CVT-LABEL: test_fcmp_ogt:
402 ; CHECK-CVT-NEXT: fcvt s1, h1
403 ; CHECK-CVT-NEXT: fcvt s0, h0
404 ; CHECK-CVT-NEXT: fcmp s0, s1
405 ; CHECK-CVT-NEXT: cset w0, gt
406 ; CHECK-CVT-NEXT: ret
408 ; CHECK-FP16-LABEL: test_fcmp_ogt:
409 ; CHECK-FP16-NEXT: fcmp h0, h1
410 ; CHECK-FP16-NEXT: cset w0, gt
411 ; CHECK-FP16-NEXT: ret
413 define i1 @test_fcmp_ogt(half %a, half %b) #0 {
414 %r = fcmp ogt half %a, %b
418 ; CHECK-CVT-LABEL: test_fcmp_oge:
419 ; CHECK-CVT-NEXT: fcvt s1, h1
420 ; CHECK-CVT-NEXT: fcvt s0, h0
421 ; CHECK-CVT-NEXT: fcmp s0, s1
422 ; CHECK-CVT-NEXT: cset w0, ge
423 ; CHECK-CVT-NEXT: ret
425 ; CHECK-FP16-LABEL: test_fcmp_oge:
426 ; CHECK-FP16-NEXT: fcmp h0, h1
427 ; CHECK-FP16-NEXT: cset w0, ge
428 ; CHECK-FP16-NEXT: ret
430 define i1 @test_fcmp_oge(half %a, half %b) #0 {
431 %r = fcmp oge half %a, %b
435 ; CHECK-CVT-LABEL: test_fcmp_olt:
436 ; CHECK-CVT-NEXT: fcvt s1, h1
437 ; CHECK-CVT-NEXT: fcvt s0, h0
438 ; CHECK-CVT-NEXT: fcmp s0, s1
439 ; CHECK-CVT-NEXT: cset w0, mi
440 ; CHECK-CVT-NEXT: ret
442 ; CHECK-FP16-LABEL: test_fcmp_olt:
443 ; CHECK-FP16-NEXT: fcmp h0, h1
444 ; CHECK-FP16-NEXT: cset w0, mi
445 ; CHECK-FP16-NEXT: ret
447 define i1 @test_fcmp_olt(half %a, half %b) #0 {
448 %r = fcmp olt half %a, %b
452 ; CHECK-CVT-LABEL: test_fcmp_ole:
453 ; CHECK-CVT-NEXT: fcvt s1, h1
454 ; CHECK-CVT-NEXT: fcvt s0, h0
455 ; CHECK-CVT-NEXT: fcmp s0, s1
456 ; CHECK-CVT-NEXT: cset w0, ls
457 ; CHECK-CVT-NEXT: ret
459 ; CHECK-FP16-LABEL: test_fcmp_ole:
460 ; CHECK-FP16-NEXT: fcmp h0, h1
461 ; CHECK-FP16-NEXT: cset w0, ls
462 ; CHECK-FP16-NEXT: ret
464 define i1 @test_fcmp_ole(half %a, half %b) #0 {
465 %r = fcmp ole half %a, %b
469 ; CHECK-CVT-LABEL: test_fcmp_ord:
470 ; CHECK-CVT-NEXT: fcvt s1, h1
471 ; CHECK-CVT-NEXT: fcvt s0, h0
472 ; CHECK-CVT-NEXT: fcmp s0, s1
473 ; CHECK-CVT-NEXT: cset w0, vc
474 ; CHECK-CVT-NEXT: ret
476 ; CHECK-FP16-LABEL: test_fcmp_ord:
477 ; CHECK-FP16-NEXT: fcmp h0, h1
478 ; CHECK-FP16-NEXT: cset w0, vc
479 ; CHECK-FP16-NEXT: ret
481 define i1 @test_fcmp_ord(half %a, half %b) #0 {
482 %r = fcmp ord half %a, %b
486 ; CHECK-COMMON-LABEL: test_fccmp:
487 ; CHECK-CVT: fcvt s0, h0
488 ; CHECK-CVT-NEXT: fmov s1, #8.00000000
489 ; CHECK-CVT-NEXT: fmov s2, #5.00000000
490 ; CHECK-CVT-NEXT: fcmp s0, s1
491 ; CHECK-CVT-NEXT: cset w8, gt
492 ; CHECK-CVT-NEXT: fcmp s0, s2
493 ; CHECK-CVT-NEXT: cset w9, mi
494 ; CHECK-CVT-NEXT: tst w8, w9
495 ; CHECK-CVT-NEXT: fcsel s0, s0, s2, ne
496 ; CHECK-CVT-NEXT: fcvt h0, s0
497 ; CHECK-CVT-NEXT: str h0, [x0]
498 ; CHECK-CVT-NEXT: ret
499 ; CHECK-FP16: fmov h1, #5.00000000
500 ; CHECK-FP16-NEXT: fcmp h0, h1
501 ; CHECK-FP16-NEXT: fmov h2, #8.00000000
502 ; CHECK-FP16-NEXT: fccmp h0, h2, #4, mi
503 ; CHECK-FP16-NEXT: fcsel h0, h0, h1, gt
504 ; CHECK-FP16-NEXT: str h0, [x0]
505 ; CHECK-FP16-NEXT: ret
507 define void @test_fccmp(half %in, half* %out) {
508 %cmp1 = fcmp ogt half %in, 0xH4800
509 %cmp2 = fcmp olt half %in, 0xH4500
510 %cond = and i1 %cmp1, %cmp2
511 %result = select i1 %cond, half %in, half 0xH4500
512 store half %result, half* %out
516 ; CHECK-CVT-LABEL: test_br_cc:
517 ; CHECK-CVT-NEXT: fcvt s1, h1
518 ; CHECK-CVT-NEXT: fcvt s0, h0
519 ; CHECK-CVT-NEXT: fcmp s0, s1
520 ; CHECK-CVT-NEXT: csel x8, x0, x1, pl
521 ; CHECK-CVT-NEXT: str wzr, [x8]
522 ; CHECK-CVT-NEXT: ret
524 ; CHECK-FP16-LABEL: test_br_cc:
525 ; CHECK-FP16-NEXT: fcmp h0, h1
526 ; CHECK-FP16-NEXT: csel x8, x0, x1, pl
527 ; CHECK-FP16-NEXT: str wzr, [x8]
528 ; CHECK-FP16-NEXT: ret
530 define void @test_br_cc(half %a, half %b, i32* %p1, i32* %p2) #0 {
531 %c = fcmp uge half %a, %b
532 br i1 %c, label %then, label %else
534 store i32 0, i32* %p1
537 store i32 0, i32* %p2
541 ; CHECK-COMMON-LABEL: test_phi:
542 ; CHECK-COMMON: mov x[[PTR:[0-9]+]], x0
543 ; CHECK-COMMON: ldr h[[AB:[0-9]+]], [x0]
544 ; CHECK-COMMON: [[LOOP:LBB[0-9_]+]]:
545 ; CHECK-COMMON: fmov s[[R:[0-9]+]], s[[AB]]
546 ; CHECK-COMMON: ldr h[[AB]], [x[[PTR]]]
547 ; CHECK-COMMON: mov x0, x[[PTR]]
548 ; CHECK-COMMON: bl {{_?}}test_dummy
549 ; CHECK-COMMON: fmov s0, s[[R]]
551 define half @test_phi(half* %p1) #0 {
553 %a = load half, half* %p1
556 %r = phi half [%a, %entry], [%b, %loop]
557 %b = load half, half* %p1
558 %c = call i1 @test_dummy(half* %p1)
559 br i1 %c, label %loop, label %return
564 declare i1 @test_dummy(half* %p1) #0
566 ; CHECK-CVT-LABEL: test_fptosi_i32:
567 ; CHECK-CVT-NEXT: fcvt s0, h0
568 ; CHECK-CVT-NEXT: fcvtzs w0, s0
569 ; CHECK-CVT-NEXT: ret
571 ; CHECK-FP16-LABEL: test_fptosi_i32:
572 ; CHECK-FP16-NEXT: fcvtzs w0, h0
573 ; CHECK-FP16-NEXT: ret
575 define i32 @test_fptosi_i32(half %a) #0 {
576 %r = fptosi half %a to i32
580 ; CHECK-CVT-LABEL: test_fptosi_i64:
581 ; CHECK-CVT-NEXT: fcvt s0, h0
582 ; CHECK-CVT-NEXT: fcvtzs x0, s0
583 ; CHECK-CVT-NEXT: ret
585 ; CHECK-FP16-LABEL: test_fptosi_i64:
586 ; CHECK-FP16-NEXT: fcvtzs x0, h0
587 ; CHECK-FP16-NEXT: ret
589 define i64 @test_fptosi_i64(half %a) #0 {
590 %r = fptosi half %a to i64
594 ; CHECK-CVT-LABEL: test_fptoui_i32:
595 ; CHECK-CVT-NEXT: fcvt s0, h0
596 ; CHECK-CVT-NEXT: fcvtzu w0, s0
597 ; CHECK-CVT-NEXT: ret
599 ; CHECK-FP16-LABEL: test_fptoui_i32:
600 ; CHECK-FP16-NEXT: fcvtzu w0, h0
601 ; CHECK-FP16-NEXT: ret
603 define i32 @test_fptoui_i32(half %a) #0 {
604 %r = fptoui half %a to i32
608 ; CHECK-CVT-LABEL: test_fptoui_i64:
609 ; CHECK-CVT-NEXT: fcvt s0, h0
610 ; CHECK-CVT-NEXT: fcvtzu x0, s0
611 ; CHECK-CVT-NEXT: ret
613 ; CHECK-FP16-LABEL: test_fptoui_i64:
614 ; CHECK-FP16-NEXT: fcvtzu x0, h0
615 ; CHECK-FP16-NEXT: ret
617 define i64 @test_fptoui_i64(half %a) #0 {
618 %r = fptoui half %a to i64
622 ; CHECK-CVT-LABEL: test_uitofp_i32:
623 ; CHECK-CVT-NEXT: ucvtf s0, w0
624 ; CHECK-CVT-NEXT: fcvt h0, s0
625 ; CHECK-CVT-NEXT: ret
627 ; CHECK-FP16-LABEL: test_uitofp_i32:
628 ; CHECK-FP16-NEXT: ucvtf h0, w0
629 ; CHECK-FP16-NEXT: ret
631 define half @test_uitofp_i32(i32 %a) #0 {
632 %r = uitofp i32 %a to half
636 ; CHECK-CVT-LABEL: test_uitofp_i64:
637 ; CHECK-CVT-NEXT: ucvtf s0, x0
638 ; CHECK-CVT-NEXT: fcvt h0, s0
639 ; CHECK-CVT-NEXT: ret
641 ; CHECK-FP16-LABEL: test_uitofp_i64:
642 ; CHECK-FP16-NEXT: ucvtf h0, x0
643 ; CHECK-FP16-NEXT: ret
645 define half @test_uitofp_i64(i64 %a) #0 {
646 %r = uitofp i64 %a to half
650 ; CHECK-CVT-LABEL: test_sitofp_i32:
651 ; CHECK-CVT-NEXT: scvtf s0, w0
652 ; CHECK-CVT-NEXT: fcvt h0, s0
653 ; CHECK-CVT-NEXT: ret
655 ; CHECK-FP16-LABEL: test_sitofp_i32:
656 ; CHECK-FP16-NEXT: scvtf h0, w0
657 ; CHECK-FP16-NEXT: ret
659 define half @test_sitofp_i32(i32 %a) #0 {
660 %r = sitofp i32 %a to half
664 ; CHECK-CVT-LABEL: test_sitofp_i64:
665 ; CHECK-CVT-NEXT: scvtf s0, x0
666 ; CHECK-CVT-NEXT: fcvt h0, s0
667 ; CHECK-CVT-NEXT: ret
669 ; CHECK-FP16-LABEL: test_sitofp_i64:
670 ; CHECK-FP16-NEXT: scvtf h0, x0
671 ; CHECK-FP16-NEXT: ret
672 define half @test_sitofp_i64(i64 %a) #0 {
673 %r = sitofp i64 %a to half
677 ; CHECK-CVT-LABEL: test_uitofp_i32_fadd:
678 ; CHECK-CVT-NEXT: ucvtf s1, w0
679 ; CHECK-CVT-NEXT: fcvt h1, s1
680 ; CHECK-CVT-NEXT: fcvt s0, h0
681 ; CHECK-CVT-NEXT: fcvt s1, h1
682 ; CHECK-CVT-NEXT: fadd s0, s0, s1
683 ; CHECK-CVT-NEXT: fcvt h0, s0
684 ; CHECK-CVT-NEXT: ret
686 ; CHECK-FP16-LABEL: test_uitofp_i32_fadd:
687 ; CHECK-FP16-NEXT: ucvtf h1, w0
688 ; CHECK-FP16-NEXT: fadd h0, h0, h1
689 ; CHECK-FP16-NEXT: ret
691 define half @test_uitofp_i32_fadd(i32 %a, half %b) #0 {
692 %c = uitofp i32 %a to half
693 %r = fadd half %b, %c
697 ; CHECK-CVT-LABEL: test_sitofp_i32_fadd:
698 ; CHECK-CVT-NEXT: scvtf s1, w0
699 ; CHECK-CVT-NEXT: fcvt h1, s1
700 ; CHECK-CVT-NEXT: fcvt s0, h0
701 ; CHECK-CVT-NEXT: fcvt s1, h1
702 ; CHECK-CVT-NEXT: fadd s0, s0, s1
703 ; CHECK-CVT-NEXT: fcvt h0, s0
704 ; CHECK-CVT-NEXT: ret
706 ; CHECK-FP16-LABEL: test_sitofp_i32_fadd:
707 ; CHECK-FP16-NEXT: scvtf h1, w0
708 ; CHECK-FP16-NEXT: fadd h0, h0, h1
709 ; CHECK-FP16-NEXT: ret
711 define half @test_sitofp_i32_fadd(i32 %a, half %b) #0 {
712 %c = sitofp i32 %a to half
713 %r = fadd half %b, %c
717 ; CHECK-COMMON-LABEL: test_fptrunc_float:
718 ; CHECK-COMMON-NEXT: fcvt h0, s0
719 ; CHECK-COMMON-NEXT: ret
721 define half @test_fptrunc_float(float %a) #0 {
722 %r = fptrunc float %a to half
726 ; CHECK-COMMON-LABEL: test_fptrunc_double:
727 ; CHECK-COMMON-NEXT: fcvt h0, d0
728 ; CHECK-COMMON-NEXT: ret
729 define half @test_fptrunc_double(double %a) #0 {
730 %r = fptrunc double %a to half
734 ; CHECK-COMMON-LABEL: test_fpext_float:
735 ; CHECK-COMMON-NEXT: fcvt s0, h0
736 ; CHECK-COMMON-NEXT: ret
737 define float @test_fpext_float(half %a) #0 {
738 %r = fpext half %a to float
742 ; CHECK-COMMON-LABEL: test_fpext_double:
743 ; CHECK-COMMON-NEXT: fcvt d0, h0
744 ; CHECK-COMMON-NEXT: ret
745 define double @test_fpext_double(half %a) #0 {
746 %r = fpext half %a to double
751 ; CHECK-COMMON-LABEL: test_bitcast_halftoi16:
752 ; CHECK-COMMON-NEXT: fmov w0, s0
753 ; CHECK-COMMON-NEXT: ret
754 define i16 @test_bitcast_halftoi16(half %a) #0 {
755 %r = bitcast half %a to i16
759 ; CHECK-COMMON-LABEL: test_bitcast_i16tohalf:
760 ; CHECK-COMMON-NEXT: fmov s0, w0
761 ; CHECK-COMMON-NEXT: ret
762 define half @test_bitcast_i16tohalf(i16 %a) #0 {
763 %r = bitcast i16 %a to half
768 declare half @llvm.sqrt.f16(half %a) #0
769 declare half @llvm.powi.f16.i32(half %a, i32 %b) #0
770 declare half @llvm.sin.f16(half %a) #0
771 declare half @llvm.cos.f16(half %a) #0
772 declare half @llvm.pow.f16(half %a, half %b) #0
773 declare half @llvm.exp.f16(half %a) #0
774 declare half @llvm.exp2.f16(half %a) #0
775 declare half @llvm.log.f16(half %a) #0
776 declare half @llvm.log10.f16(half %a) #0
777 declare half @llvm.log2.f16(half %a) #0
778 declare half @llvm.fma.f16(half %a, half %b, half %c) #0
779 declare half @llvm.fabs.f16(half %a) #0
780 declare half @llvm.minnum.f16(half %a, half %b) #0
781 declare half @llvm.maxnum.f16(half %a, half %b) #0
782 declare half @llvm.copysign.f16(half %a, half %b) #0
783 declare half @llvm.floor.f16(half %a) #0
784 declare half @llvm.ceil.f16(half %a) #0
785 declare half @llvm.trunc.f16(half %a) #0
786 declare half @llvm.rint.f16(half %a) #0
787 declare half @llvm.nearbyint.f16(half %a) #0
788 declare half @llvm.round.f16(half %a) #0
789 declare half @llvm.roundeven.f16(half %a) #0
790 declare half @llvm.fmuladd.f16(half %a, half %b, half %c) #0
791 declare half @llvm.aarch64.neon.frecpe.f16(half %a) #0
792 declare half @llvm.aarch64.neon.frecpx.f16(half %a) #0
793 declare half @llvm.aarch64.neon.frsqrte.f16(half %a) #0
795 ; FALLBACK-NOT: remark:{{.*}}test_sqrt
796 ; FALLBACK-FP16-NOT: remark:{{.*}}test_sqrt
798 ; CHECK-CVT-LABEL: test_sqrt:
799 ; CHECK-CVT-NEXT: fcvt s0, h0
800 ; CHECK-CVT-NEXT: fsqrt s0, s0
801 ; CHECK-CVT-NEXT: fcvt h0, s0
802 ; CHECK-CVT-NEXT: ret
804 ; CHECK-FP16-LABEL: test_sqrt:
805 ; CHECK-FP16-NEXT: fsqrt h0, h0
806 ; CHECK-FP16-NEXT: ret
808 ; GISEL-CVT-LABEL: test_sqrt:
809 ; GISEL-CVT-NEXT: fcvt s0, h0
810 ; GISEL-CVT-NEXT: fsqrt s0, s0
811 ; GISEL-CVT-NEXT: fcvt h0, s0
812 ; GISEL-CVT-NEXT: ret
814 ; GISEL-FP16-LABEL: test_sqrt:
815 ; GISEL-FP16-NEXT: fsqrt h0, h0
816 ; GISEL-FP16-NEXT: ret
818 define half @test_sqrt(half %a) #0 {
819 %r = call half @llvm.sqrt.f16(half %a)
823 ; CHECK-COMMON-LABEL: test_powi:
824 ; CHECK-COMMON-NEXT: stp x29, x30, [sp, #-16]!
825 ; CHECK-COMMON-NEXT: mov x29, sp
826 ; CHECK-COMMON-NEXT: fcvt s0, h0
827 ; CHECK-COMMON-NEXT: bl {{_?}}__powisf2
828 ; CHECK-COMMON-NEXT: fcvt h0, s0
829 ; CHECK-COMMON-NEXT: ldp x29, x30, [sp], #16
830 ; CHECK-COMMON-NEXT: ret
831 define half @test_powi(half %a, i32 %b) #0 {
832 %r = call half @llvm.powi.f16.i32(half %a, i32 %b)
836 ; FALLBACK-NOT: remark:{{.*}}test_sin
837 ; FALLBACK-FP16-NOT: remark:{{.*}}test_sin
839 ; CHECK-COMMON-LABEL: test_sin:
840 ; CHECK-COMMON-NEXT: stp x29, x30, [sp, #-16]!
841 ; CHECK-COMMON-NEXT: mov x29, sp
842 ; CHECK-COMMON-NEXT: fcvt s0, h0
843 ; CHECK-COMMON-NEXT: bl {{_?}}sinf
844 ; CHECK-COMMON-NEXT: fcvt h0, s0
845 ; CHECK-COMMON-NEXT: ldp x29, x30, [sp], #16
846 ; CHECK-COMMON-NEXT: ret
848 ; GISEL-LABEL: test_sin:
849 ; GISEL-NEXT: stp x29, x30, [sp, #-16]!
850 ; GISEL-NEXT: mov x29, sp
851 ; GISEL-NEXT: fcvt s0, h0
852 ; GISEL-NEXT: bl {{_?}}sinf
853 ; GISEL-NEXT: fcvt h0, s0
854 ; GISEL-NEXT: ldp x29, x30, [sp], #16
856 define half @test_sin(half %a) #0 {
857 %r = call half @llvm.sin.f16(half %a)
861 ; FALLBACK-NOT: remark:{{.*}}test_cos
862 ; FALLBACK-FP16-NOT: remark:{{.*}}test_cos
864 ; CHECK-COMMON-LABEL: test_cos:
865 ; CHECK-COMMON-NEXT: stp x29, x30, [sp, #-16]!
866 ; CHECK-COMMON-NEXT: mov x29, sp
867 ; CHECK-COMMON-NEXT: fcvt s0, h0
868 ; CHECK-COMMON-NEXT: bl {{_?}}cosf
869 ; CHECK-COMMON-NEXT: fcvt h0, s0
870 ; CHECK-COMMON-NEXT: ldp x29, x30, [sp], #16
871 ; CHECK-COMMON-NEXT: ret
873 ; GISEL-LABEL: test_cos:
874 ; GISEL-NEXT: stp x29, x30, [sp, #-16]!
875 ; GISEL-NEXT: mov x29, sp
876 ; GISEL-NEXT: fcvt s0, h0
877 ; GISEL-NEXT: bl {{_?}}cosf
878 ; GISEL-NEXT: fcvt h0, s0
879 ; GISEL-NEXT: ldp x29, x30, [sp], #16
881 define half @test_cos(half %a) #0 {
882 %r = call half @llvm.cos.f16(half %a)
886 ; CHECK-COMMON-LABEL: test_pow:
887 ; CHECK-COMMON-NEXT: stp x29, x30, [sp, #-16]!
888 ; CHECK-COMMON-NEXT: mov x29, sp
889 ; CHECK-COMMON-NEXT: fcvt s0, h0
890 ; CHECK-COMMON-NEXT: fcvt s1, h1
891 ; CHECK-COMMON-NEXT: bl {{_?}}powf
892 ; CHECK-COMMON-NEXT: fcvt h0, s0
893 ; CHECK-COMMON-NEXT: ldp x29, x30, [sp], #16
894 ; CHECK-COMMON-NEXT: ret
895 define half @test_pow(half %a, half %b) #0 {
896 %r = call half @llvm.pow.f16(half %a, half %b)
900 ; FALLBACK-NOT: remark:{{.*}}test_exp
901 ; FALLBACK-FP16-NOT: remark:{{.*}}test_exp
903 ; CHECK-COMMON-LABEL: test_exp:
904 ; CHECK-COMMON-NEXT: stp x29, x30, [sp, #-16]!
905 ; CHECK-COMMON-NEXT: mov x29, sp
906 ; CHECK-COMMON-NEXT: fcvt s0, h0
907 ; CHECK-COMMON-NEXT: bl {{_?}}expf
908 ; CHECK-COMMON-NEXT: fcvt h0, s0
909 ; CHECK-COMMON-NEXT: ldp x29, x30, [sp], #16
910 ; CHECK-COMMON-NEXT: ret
912 ; GISEL-LABEL: test_exp:
913 ; GISEL-NEXT: stp x29, x30, [sp, #-16]!
914 ; GISEL-NEXT: mov x29, sp
915 ; GISEL-NEXT: fcvt s0, h0
916 ; GISEL-NEXT: bl {{_?}}expf
917 ; GISEL-NEXT: fcvt h0, s0
918 ; GISEL-NEXT: ldp x29, x30, [sp], #16
920 define half @test_exp(half %a) #0 {
921 %r = call half @llvm.exp.f16(half %a)
925 ; CHECK-COMMON-LABEL: test_exp2:
926 ; CHECK-COMMON-NEXT: stp x29, x30, [sp, #-16]!
927 ; CHECK-COMMON-NEXT: mov x29, sp
928 ; CHECK-COMMON-NEXT: fcvt s0, h0
929 ; CHECK-COMMON-NEXT: bl {{_?}}exp2f
930 ; CHECK-COMMON-NEXT: fcvt h0, s0
931 ; CHECK-COMMON-NEXT: ldp x29, x30, [sp], #16
932 ; CHECK-COMMON-NEXT: ret
934 ; GISEL-LABEL: test_exp2:
935 ; GISEL-NEXT: stp x29, x30, [sp, #-16]!
936 ; GISEL-NEXT: mov x29, sp
937 ; GISEL-NEXT: fcvt s0, h0
938 ; GISEL-NEXT: bl {{_?}}exp2f
939 ; GISEL-NEXT: fcvt h0, s0
940 ; GISEL-NEXT: ldp x29, x30, [sp], #16
942 define half @test_exp2(half %a) #0 {
943 %r = call half @llvm.exp2.f16(half %a)
947 ; FALLBACK-NOT: remark:{{.*}}test_log
948 ; FALLBACK-FP16-NOT: remark:{{.*}}test_log
950 ; CHECK-COMMON-LABEL: test_log:
951 ; CHECK-COMMON-NEXT: stp x29, x30, [sp, #-16]!
952 ; CHECK-COMMON-NEXT: mov x29, sp
953 ; CHECK-COMMON-NEXT: fcvt s0, h0
954 ; CHECK-COMMON-NEXT: bl {{_?}}logf
955 ; CHECK-COMMON-NEXT: fcvt h0, s0
956 ; CHECK-COMMON-NEXT: ldp x29, x30, [sp], #16
957 ; CHECK-COMMON-NEXT: ret
959 ; GISEL-LABEL: test_log:
960 ; GISEL: stp x29, x30, [sp, #-16]!
961 ; GISEL-NEXT: mov x29, sp
962 ; GISEL-NEXT: fcvt s0, h0
963 ; GISEL-NEXT: bl {{_?}}logf
964 ; GISEL-NEXT: fcvt h0, s0
965 ; GISEL-NEXT: ldp x29, x30, [sp], #16
968 define half @test_log(half %a) #0 {
969 %r = call half @llvm.log.f16(half %a)
973 ; FALLBACK-NOT: remark:{{.*}}test_log10
974 ; FALLBACK-FP16-NOT: remark:{{.*}}test_log10
976 ; CHECK-COMMON-LABEL: test_log10:
977 ; CHECK-COMMON-NEXT: stp x29, x30, [sp, #-16]!
978 ; CHECK-COMMON-NEXT: mov x29, sp
979 ; CHECK-COMMON-NEXT: fcvt s0, h0
980 ; CHECK-COMMON-NEXT: bl {{_?}}log10f
981 ; CHECK-COMMON-NEXT: fcvt h0, s0
982 ; CHECK-COMMON-NEXT: ldp x29, x30, [sp], #16
983 ; CHECK-COMMON-NEXT: ret
985 ; GISEL-LABEL: test_log10:
986 ; GISEL-NEXT: stp x29, x30, [sp, #-16]!
987 ; GISEL-NEXT: mov x29, sp
988 ; GISEL-NEXT: fcvt s0, h0
989 ; GISEL-NEXT: bl {{_?}}log10f
990 ; GISEL-NEXT: fcvt h0, s0
991 ; GISEL-NEXT: ldp x29, x30, [sp], #16
994 define half @test_log10(half %a) #0 {
995 %r = call half @llvm.log10.f16(half %a)
999 ; FALLBACK-NOT: remark:{{.*}}test_log2
1000 ; FALLBACK-FP16-NOT: remark:{{.*}}test_log2
1002 ; CHECK-COMMON-LABEL: test_log2:
1003 ; CHECK-COMMON-NEXT: stp x29, x30, [sp, #-16]!
1004 ; CHECK-COMMON-NEXT: mov x29, sp
1005 ; CHECK-COMMON-NEXT: fcvt s0, h0
1006 ; CHECK-COMMON-NEXT: bl {{_?}}log2f
1007 ; CHECK-COMMON-NEXT: fcvt h0, s0
1008 ; CHECK-COMMON-NEXT: ldp x29, x30, [sp], #16
1009 ; CHECK-COMMON-NEXT: ret
1011 ; GISEL-LABEL: test_log2:
1012 ; GISEL-NEXT: stp x29, x30, [sp, #-16]!
1013 ; GISEL-NEXT: mov x29, sp
1014 ; GISEL-NEXT: fcvt s0, h0
1015 ; GISEL-NEXT: bl {{_?}}log2f
1016 ; GISEL-NEXT: fcvt h0, s0
1017 ; GISEL-NEXT: ldp x29, x30, [sp], #16
1020 define half @test_log2(half %a) #0 {
1021 %r = call half @llvm.log2.f16(half %a)
1025 ; CHECK-CVT-LABEL: test_fma:
1026 ; CHECK-CVT-NEXT: fcvt s2, h2
1027 ; CHECK-CVT-NEXT: fcvt s1, h1
1028 ; CHECK-CVT-NEXT: fcvt s0, h0
1029 ; CHECK-CVT-NEXT: fmadd s0, s0, s1, s2
1030 ; CHECK-CVT-NEXT: fcvt h0, s0
1031 ; CHECK-CVT-NEXT: ret
1033 ; CHECK-FP16-LABEL: test_fma:
1034 ; CHECK-FP16-NEXT: fmadd h0, h0, h1, h2
1035 ; CHECK-FP16-NEXT: ret
1037 define half @test_fma(half %a, half %b, half %c) #0 {
1038 %r = call half @llvm.fma.f16(half %a, half %b, half %c)
1042 ; CHECK-CVT-LABEL: test_fabs:
1043 ; CHECK-CVT-NEXT: fcvt s0, h0
1044 ; CHECK-CVT-NEXT: fabs s0, s0
1045 ; CHECK-CVT-NEXT: fcvt h0, s0
1046 ; CHECK-CVT-NEXT: ret
1048 ; CHECK-FP16-LABEL: test_fabs:
1049 ; CHECK-FP16-NEXT: fabs h0, h0
1050 ; CHECK-FP16-NEXT: ret
1052 ; FALLBACK-NOT: remark:{{.*}}test_fabs
1053 ; FALLBACK-FP16-NOT: remark:{{.*}}test_fabs
1055 ; GISEL-CVT-LABEL: test_fabs:
1056 ; GISEL-CVT-NEXT: fcvt s0, h0
1057 ; GISEL-CVT-NEXT: fabs s0, s0
1058 ; GISEL-CVT-NEXT: fcvt h0, s0
1059 ; GISEL-CVT-NEXT: ret
1061 ; GISEL-FP16-LABEL: test_fabs:
1062 ; GISEL-FP16-NEXT: fabs h0, h0
1063 ; GISEL-FP16-NEXT: ret
1065 define half @test_fabs(half %a) #0 {
1066 %r = call half @llvm.fabs.f16(half %a)
1070 ; CHECK-CVT-LABEL: test_minnum:
1071 ; CHECK-CVT-NEXT: fcvt s1, h1
1072 ; CHECK-CVT-NEXT: fcvt s0, h0
1073 ; CHECK-CVT-NEXT: fminnm s0, s0, s1
1074 ; CHECK-CVT-NEXT: fcvt h0, s0
1075 ; CHECK-CVT-NEXT: ret
1077 ; CHECK-FP16-LABEL: test_minnum:
1078 ; CHECK-FP16-NEXT: fminnm h0, h0, h1
1079 ; CHECK-FP16-NEXT: ret
1081 define half @test_minnum(half %a, half %b) #0 {
1082 %r = call half @llvm.minnum.f16(half %a, half %b)
1086 ; CHECK-CVT-LABEL: test_maxnum:
1087 ; CHECK-CVT-NEXT: fcvt s1, h1
1088 ; CHECK-CVT-NEXT: fcvt s0, h0
1089 ; CHECK-CVT-NEXT: fmaxnm s0, s0, s1
1090 ; CHECK-CVT-NEXT: fcvt h0, s0
1091 ; CHECK-CVT-NEXT: ret
1093 ; CHECK-FP16-LABEL: test_maxnum:
1094 ; CHECK-FP16-NEXT: fmaxnm h0, h0, h1
1095 ; CHECK-FP16-NEXT: ret
1097 define half @test_maxnum(half %a, half %b) #0 {
1098 %r = call half @llvm.maxnum.f16(half %a, half %b)
1102 ; CHECK-CVT-LABEL: test_copysign:
1103 ; CHECK-CVT-NEXT: fcvt s1, h1
1104 ; CHECK-CVT-NEXT: fcvt s0, h0
1105 ; CHECK-CVT-NEXT: movi.4s v2, #128, lsl #24
1106 ; CHECK-CVT-NEXT: bit.16b v0, v1, v2
1107 ; CHECK-CVT-NEXT: fcvt h0, s0
1108 ; CHECK-CVT-NEXT: ret
1110 ; CHECK-FP16-LABEL: test_copysign:
1111 ; CHECK-FP16-NEXT: movi.8h v2, #128, lsl #8
1112 ; CHECK-FP16-NEXT: bit.16b v0, v1, v2
1113 ; CHECK-FP16-NEXT: ret
1115 define half @test_copysign(half %a, half %b) #0 {
1116 %r = call half @llvm.copysign.f16(half %a, half %b)
1120 ; CHECK-CVT-LABEL: test_copysign_f32:
1121 ; CHECK-CVT-NEXT: fcvt s0, h0
1122 ; CHECK-CVT-NEXT: movi.4s v2, #128, lsl #24
1123 ; CHECK-CVT-NEXT: bit.16b v0, v1, v2
1124 ; CHECK-CVT-NEXT: fcvt h0, s0
1125 ; CHECK-CVT-NEXT: ret
1127 ; CHECK-FP16-LABEL: test_copysign_f32:
1128 ; CHECK-FP16-NEXT: fcvt h1, s1
1129 ; CHECK-FP16-NEXT: movi.8h v2, #128, lsl #8
1130 ; CHECK-FP16-NEXT: bit.16b v0, v1, v2
1131 ; CHECK-FP16-NEXT: ret
1133 define half @test_copysign_f32(half %a, float %b) #0 {
1134 %tb = fptrunc float %b to half
1135 %r = call half @llvm.copysign.f16(half %a, half %tb)
1139 ; CHECK-CVT-LABEL: test_copysign_f64:
1140 ; CHECK-CVT-NEXT: fcvt s1, d1
1141 ; CHECK-CVT-NEXT: fcvt s0, h0
1142 ; CHECK-CVT-NEXT: movi.4s v2, #128, lsl #24
1143 ; CHECK-CVT-NEXT: bit.16b v0, v1, v2
1144 ; CHECK-CVT-NEXT: fcvt h0, s0
1145 ; CHECK-CVT-NEXT: ret
1147 ; CHECK-FP16-LABEL: test_copysign_f64:
1148 ; CHECK-FP16-NEXT: fcvt h1, d1
1149 ; CHECK-FP16-NEXT: movi.8h v2, #128, lsl #8
1150 ; CHECK-FP16-NEXT: bit.16b v0, v1, v2
1151 ; CHECK-FP16-NEXT: ret
1153 define half @test_copysign_f64(half %a, double %b) #0 {
1154 %tb = fptrunc double %b to half
1155 %r = call half @llvm.copysign.f16(half %a, half %tb)
1159 ; Check that the FP promotion will use a truncating FP_ROUND, so we can fold
1160 ; away the (fpext (fp_round <result>)) here.
1162 ; CHECK-CVT-LABEL: test_copysign_extended:
1163 ; CHECK-CVT-NEXT: fcvt s1, h1
1164 ; CHECK-CVT-NEXT: fcvt s0, h0
1165 ; CHECK-CVT-NEXT: movi.4s v2, #128, lsl #24
1166 ; CHECK-CVT-NEXT: bit.16b v0, v1, v2
1167 ; CHECK-CVT-NEXT: ret
1169 ; CHECK-FP16-LABEL: test_copysign_extended:
1170 ; CHECK-FP16-NEXT: movi.8h v2, #128, lsl #8
1171 ; CHECK-FP16-NEXT: bit.16b v0, v1, v2
1172 ; CHECK-FP16-NEXT: fcvt s0, h0
1173 ; CHECK-FP16-NEXT: ret
1175 define float @test_copysign_extended(half %a, half %b) #0 {
1176 %r = call half @llvm.copysign.f16(half %a, half %b)
1177 %xr = fpext half %r to float
1181 ; CHECK-CVT-LABEL: test_floor:
1182 ; CHECK-CVT-NEXT: fcvt [[FLOAT32:s[0-9]+]], h0
1183 ; CHECK-CVT-NEXT: frintm [[INT32:s[0-9]+]], [[FLOAT32]]
1184 ; CHECK-CVT-NEXT: fcvt h0, [[INT32]]
1185 ; CHECK-CVT-NEXT: ret
1187 ; CHECK-FP16-LABEL: test_floor:
1188 ; CHECK-FP16-NEXT: frintm h0, h0
1189 ; CHECK-FP16-NEXT: ret
1191 ; FALLBACK-NOT: remark:{{.*}}test_floor
1192 ; FALLBACK-FP16-NOT: remark:{{.*}}test_floor
1194 ; GISEL-CVT-LABEL: test_floor:
1195 ; GISEL-CVT-NEXT: fcvt [[FLOAT32:s[0-9]+]], h0
1196 ; GISEL-CVT-NEXT: frintm [[INT32:s[0-9]+]], [[FLOAT32]]
1197 ; GISEL-CVT-NEXT: fcvt h0, [[INT32]]
1198 ; GISEL-CVT-NEXT: ret
1200 ; GISEL-FP16-LABEL: test_floor:
1201 ; GISEL-FP16-NEXT: frintm h0, h0
1202 ; GISEL-FP16-NEXT: ret
1204 define half @test_floor(half %a) #0 {
1205 %r = call half @llvm.floor.f16(half %a)
1209 ; CHECK-CVT-LABEL: test_ceil:
1210 ; CHECK-CVT-NEXT: fcvt [[FLOAT32:s[0-9]+]], h0
1211 ; CHECK-CVT-NEXT: frintp [[INT32:s[0-9]+]], [[FLOAT32]]
1212 ; CHECK-CVT-NEXT: fcvt h0, [[INT32]]
1213 ; CHECK-CVT-NEXT: ret
1215 ; CHECK-FP16-LABEL: test_ceil:
1216 ; CHECK-FP16-NEXT: frintp h0, h0
1217 ; CHECK-FP16-NEXT: ret
1219 ; FALLBACK-NOT: remark:{{.*}}test_ceil
1220 ; FALLBACK-FP16-NOT: remark:{{.*}}test_ceil
1222 ; GISEL-CVT-LABEL: test_ceil:
1223 ; GISEL-CVT-NEXT: fcvt [[FLOAT32:s[0-9]+]], h0
1224 ; GISEL-CVT-NEXT: frintp [[INT32:s[0-9]+]], [[FLOAT32]]
1225 ; GISEL-CVT-NEXT: fcvt h0, [[INT32]]
1226 ; GISEL-CVT-NEXT: ret
1228 ; GISEL-FP16-LABEL: test_ceil:
1229 ; GISEL-FP16-NEXT: frintp h0, h0
1230 ; GISEL-FP16-NEXT: ret
1231 define half @test_ceil(half %a) #0 {
1232 %r = call half @llvm.ceil.f16(half %a)
1236 ; CHECK-CVT-LABEL: test_trunc:
1237 ; CHECK-CVT-NEXT: fcvt [[FLOAT32:s[0-9]+]], h0
1238 ; CHECK-CVT-NEXT: frintz [[INT32:s[0-9]+]], [[FLOAT32]]
1239 ; CHECK-CVT-NEXT: fcvt h0, [[INT32]]
1240 ; CHECK-CVT-NEXT: ret
1242 ; CHECK-FP16-LABEL: test_trunc:
1243 ; CHECK-FP16-NEXT: frintz h0, h0
1244 ; CHECK-FP16-NEXT: ret
1246 define half @test_trunc(half %a) #0 {
1247 %r = call half @llvm.trunc.f16(half %a)
1251 ; CHECK-CVT-LABEL: test_rint:
1252 ; CHECK-CVT-NEXT: fcvt s0, h0
1253 ; CHECK-CVT-NEXT: frintx s0, s0
1254 ; CHECK-CVT-NEXT: fcvt h0, s0
1255 ; CHECK-CVT-NEXT: ret
1257 ; CHECK-FP16-LABEL: test_rint:
1258 ; CHECK-FP16-NEXT: frintx h0, h0
1259 ; CHECK-FP16-NEXT: ret
1261 define half @test_rint(half %a) #0 {
1262 %r = call half @llvm.rint.f16(half %a)
1266 ; CHECK-CVT-LABEL: test_nearbyint:
1267 ; CHECK-CVT-NEXT: fcvt s0, h0
1268 ; CHECK-CVT-NEXT: frinti s0, s0
1269 ; CHECK-CVT-NEXT: fcvt h0, s0
1270 ; CHECK-CVT-NEXT: ret
1272 ; CHECK-FP16-LABEL: test_nearbyint:
1273 ; CHECK-FP16-NEXT: frinti h0, h0
1274 ; CHECK-FP16-NEXT: ret
1276 define half @test_nearbyint(half %a) #0 {
1277 %r = call half @llvm.nearbyint.f16(half %a)
1281 ; CHECK-CVT-LABEL: test_round:
1282 ; CHECK-CVT-NEXT: fcvt [[FLOAT32:s[0-9]+]], h0
1283 ; CHECK-CVT-NEXT: frinta [[INT32:s[0-9]+]], [[FLOAT32]]
1284 ; CHECK-CVT-NEXT: fcvt h0, [[INT32]]
1285 ; CHECK-CVT-NEXT: ret
1287 ; GISEL-CVT-LABEL: test_round:
1288 ; GISEL-CVT-NEXT: fcvt [[FLOAT32:s[0-9]+]], h0
1289 ; GISEL-CVT-NEXT: frinta [[INT32:s[0-9]+]], [[FLOAT32]]
1290 ; GISEL-CVT-NEXT: fcvt h0, [[INT32]]
1291 ; GISEL-CVT-NEXT: ret
1294 ; CHECK-FP16-LABEL: test_round:
1295 ; CHECK-FP16-NEXT: frinta h0, h0
1296 ; CHECK-FP16-NEXT: ret
1298 ; GISEL-FP16-LABEL: test_round:
1299 ; GISEL-FP16-NEXT: frinta h0, h0
1300 ; GISEL-FP16-NEXT: ret
1302 define half @test_round(half %a) #0 {
1303 %r = call half @llvm.round.f16(half %a)
1307 ; CHECK-CVT-LABEL: test_roundeven:
1308 ; CHECK-CVT-NEXT: fcvt [[FLOAT32:s[0-9]+]], h0
1309 ; CHECK-CVT-NEXT: frintn [[INT32:s[0-9]+]], [[FLOAT32]]
1310 ; CHECK-CVT-NEXT: fcvt h0, [[INT32]]
1311 ; CHECK-CVT-NEXT: ret
1313 ; GISEL-CVT-LABEL: test_roundeven:
1314 ; GISEL-CVT-NEXT: fcvt [[FLOAT32:s[0-9]+]], h0
1315 ; GISEL-CVT-NEXT: frintn [[INT32:s[0-9]+]], [[FLOAT32]]
1316 ; GISEL-CVT-NEXT: fcvt h0, [[INT32]]
1317 ; GISEL-CVT-NEXT: ret
1320 ; CHECK-FP16-LABEL: test_roundeven:
1321 ; CHECK-FP16-NEXT: frintn h0, h0
1322 ; CHECK-FP16-NEXT: ret
1324 ; GISEL-FP16-LABEL: test_roundeven:
1325 ; GISEL-FP16-NEXT: frintn h0, h0
1326 ; GISEL-FP16-NEXT: ret
1328 define half @test_roundeven(half %a) #0 {
1329 %r = call half @llvm.roundeven.f16(half %a)
1333 ; CHECK-CVT-LABEL: test_fmuladd:
1334 ; CHECK-CVT-NEXT: fcvt s1, h1
1335 ; CHECK-CVT-NEXT: fcvt s0, h0
1336 ; CHECK-CVT-NEXT: fmul s0, s0, s1
1337 ; CHECK-CVT-NEXT: fcvt h0, s0
1338 ; CHECK-CVT-NEXT: fcvt s0, h0
1339 ; CHECK-CVT-NEXT: fcvt s1, h2
1340 ; CHECK-CVT-NEXT: fadd s0, s0, s1
1341 ; CHECK-CVT-NEXT: fcvt h0, s0
1342 ; CHECK-CVT-NEXT: ret
1344 ; CHECK-FP16-LABEL: test_fmuladd:
1345 ; CHECK-FP16-NEXT: fmadd h0, h0, h1, h2
1346 ; CHECK-FP16-NEXT: ret
1348 define half @test_fmuladd(half %a, half %b, half %c) #0 {
1349 %r = call half @llvm.fmuladd.f16(half %a, half %b, half %c)
1353 ; CHECK-FP16-LABEL: test_vrecpeh_f16:
1354 ; CHECK-FP16-NEXT: frecpe h0, h0
1355 ; CHECK-FP16-NEXT: ret
1357 define half @test_vrecpeh_f16(half %a) #0 {
1358 %r = call half @llvm.aarch64.neon.frecpe.f16(half %a)
1362 ; CHECK-FP16-LABEL: test_vrecpxh_f16:
1363 ; CHECK-FP16-NEXT: frecpx h0, h0
1364 ; CHECK-FP16-NEXT: ret
1366 define half @test_vrecpxh_f16(half %a) #0 {
1367 %r = call half @llvm.aarch64.neon.frecpx.f16(half %a)
1371 ; CHECK-FP16-LABEL: test_vrsqrteh_f16:
1372 ; CHECK-FP16-NEXT: frsqrte h0, h0
1373 ; CHECK-FP16-NEXT: ret
1375 define half @test_vrsqrteh_f16(half %a) #0 {
1376 %r = call half @llvm.aarch64.neon.frsqrte.f16(half %a)
1380 attributes #0 = { nounwind }