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