| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O3 -mavx512fp16 -mavx512vl -ffast-math" } */ |
| 3 |
/* { dg-final { scan-assembler "vrcpsh.*\n.*vmulsh" } } */ |
| 4 |
/* { dg-final { scan-assembler "vrcpph.*\n.*vmulph" } } */ |
| 5 |
/* { dg-final { scan-assembler "vrsqrtsh.*\n.*vmulsh" } } */ |
| 6 |
/* { dg-final { scan-assembler "vrsqrtph.*\n.*vmulph" } } */ |
| 7 |
/* { dg-final { scan-assembler-not "vsqrtsh" } } */ |
| 8 |
/* { dg-final { scan-assembler-not "vsqrtph" } } */ |
| 9 |
/* { dg-final { scan-assembler-not "vdivsh" } } */ |
| 10 |
/* { dg-final { scan-assembler-not "vdivph" } } */ |
| 11 |
|
| 12 |
#define FAST_ATTR \ |
| 13 |
__attribute__((noinline, noclone, optimize("fast-math"), target("recip"))) |
| 14 |
|
| 15 |
_Float16 FAST_ATTR |
| 16 |
scalar_hf_rcp_fast (_Float16 a, _Float16 b) |
| 17 |
{ |
| 18 |
return a / b; |
| 19 |
} |
| 20 |
|
| 21 |
_Float16 FAST_ATTR |
| 22 |
scalar_hf_rsqrt_fast (_Float16 a, _Float16 b) |
| 23 |
{ |
| 24 |
return a / __builtin_sqrtf16 (b); |
| 25 |
} |
| 26 |
|
| 27 |
void FAST_ATTR |
| 28 |
vector_hf_rcp_fast (_Float16 * restrict a, _Float16 * restrict b, |
| 29 |
_Float16 * restrict c, int n) |
| 30 |
{ |
| 31 |
int i; |
| 32 |
for (i = 0; i < n; i++) |
| 33 |
c[i] = a[i] / b[i]; |
| 34 |
} |
| 35 |
|
| 36 |
void FAST_ATTR |
| 37 |
vector_hf_rsqrt_fast (_Float16 * restrict a, _Float16 * restrict b, |
| 38 |
_Float16 * restrict c, int n) |
| 39 |
{ |
| 40 |
int i; |
| 41 |
for (i = 0; i < n; i++) |
| 42 |
c[i] = a[i] / __builtin_sqrtf16(b[i]); |
| 43 |
} |