1 /* { dg-do compile } */
2 /* { dg-require-effective-target arm_v8_2a_fp16_scalar_ok } */
3 /* { dg-options "-O2 -std=c11" } */
4 /* { dg-add-options arm_v8_2a_fp16_scalar } */
5
6 /* Test compiler use of FP16 instructions. */
7 #include <arm_fp16.h>
8
9 float16_t
test_mov_imm_1(float16_t a)10 test_mov_imm_1 (float16_t a)
11 {
12 return 1.0;
13 }
14
15 float16_t
test_mov_imm_2(float16_t a)16 test_mov_imm_2 (float16_t a)
17 {
18 float16_t b = 1.0;
19 return b;
20 }
21
22 float16_t
test_vmov_imm_3(float16_t a)23 test_vmov_imm_3 (float16_t a)
24 {
25 float16_t b = 1.0;
26 return vaddh_f16 (a, b);
27 }
28
29 float16_t
test_vmov_imm_4(float16_t a)30 test_vmov_imm_4 (float16_t a)
31 {
32 return vaddh_f16 (a, 1.0);
33 }
34
35 /* { dg-final { scan-assembler-times {vmov.f16\ts[0-9]+, #1\.0e\+0} 4 } }
36 { dg-final { scan-assembler-times {vadd.f16\ts[0-9]+, s[0-9]+, s[0-9]+} 2 } } */
37
38 float16_t
test_vmla_1(float16_t a,float16_t b,float16_t c)39 test_vmla_1 (float16_t a, float16_t b, float16_t c)
40 {
41 return vaddh_f16 (vmulh_f16 (a, b), c);
42 }
43 /* { dg-final { scan-assembler-times {vmla\.f16\ts[0-9]+, s[0-9]+, s[0-9]+} 1 } } */
44
45 float16_t
test_vmla_2(float16_t a,float16_t b,float16_t c)46 test_vmla_2 (float16_t a, float16_t b, float16_t c)
47 {
48 return vsubh_f16 (vmulh_f16 (vnegh_f16 (a), b), c);
49 }
50 /* { dg-final { scan-assembler-times {vnmla\.f16\ts[0-9]+, s[0-9]+, s[0-9]+} 1 } } */
51
52 float16_t
test_vmls_1(float16_t a,float16_t b,float16_t c)53 test_vmls_1 (float16_t a, float16_t b, float16_t c)
54 {
55 return vsubh_f16 (c, vmulh_f16 (a, b));
56 }
57
58 float16_t
test_vmls_2(float16_t a,float16_t b,float16_t c)59 test_vmls_2 (float16_t a, float16_t b, float16_t c)
60 {
61 return vsubh_f16 (a, vmulh_f16 (b, c));
62 }
63 /* { dg-final { scan-assembler-times {vmls\.f16} 2 } } */
64
65 float16_t
test_vnmls_1(float16_t a,float16_t b,float16_t c)66 test_vnmls_1 (float16_t a, float16_t b, float16_t c)
67 {
68 return vsubh_f16 (vmulh_f16 (a, b), c);
69 }
70 /* { dg-final { scan-assembler-times {vnmls\.f16\ts[0-9]+, s[0-9]+, s[0-9]+} 1 } } */
71
72