| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-Ofast -mavx512fp16 -mavx512vl" } */ |
| 3 |
|
| 4 |
typedef _Float16 v8hf __attribute__ ((__vector_size__ (16))); |
| 5 |
typedef _Float16 v16hf __attribute__ ((__vector_size__ (32))); |
| 6 |
|
| 7 |
void |
| 8 |
foo1 (_Float16* __restrict pa, _Float16* __restrict pb, |
| 9 |
_Float16* __restrict pc, _Float16* __restrict pd) |
| 10 |
{ |
| 11 |
for (int i = 0; i != 8; i++) |
| 12 |
pd[i] = pa[i] * pb[i] + pc[i]; |
| 13 |
} |
| 14 |
|
| 15 |
/* { dg-final { scan-assembler-times "vfmadd132ph\[^\n\r\]*xmm\[0-9\]" 1 } } */ |
| 16 |
|
| 17 |
void |
| 18 |
foo2 (_Float16* __restrict pa, _Float16* __restrict pb, |
| 19 |
_Float16* __restrict pc, _Float16* __restrict pd) |
| 20 |
{ |
| 21 |
for (int i = 0; i != 8; i++) |
| 22 |
pd[i] = -pa[i] * pb[i] + pc[i]; |
| 23 |
} |
| 24 |
|
| 25 |
/* { dg-final { scan-assembler-times "vfnmadd132ph\[^\n\r\]*xmm\[0-9\]" 1 } } */ |
| 26 |
|
| 27 |
void |
| 28 |
foo3 (_Float16* __restrict pa, _Float16* __restrict pb, |
| 29 |
_Float16* __restrict pc, _Float16* __restrict pd) |
| 30 |
{ |
| 31 |
for (int i = 0; i != 8; i++) |
| 32 |
pd[i] = pa[i] * pb[i] - pc[i]; |
| 33 |
} |
| 34 |
|
| 35 |
/* { dg-final { scan-assembler-times "vfmsub132ph\[^\n\r\]*xmm\[0-9\]" 1 } } */ |
| 36 |
|
| 37 |
void |
| 38 |
foo4 (_Float16* __restrict pa, _Float16* __restrict pb, |
| 39 |
_Float16* __restrict pc, _Float16* __restrict pd) |
| 40 |
{ |
| 41 |
for (int i = 0; i != 8; i++) |
| 42 |
pd[i] = -pa[i] * pb[i] - pc[i]; |
| 43 |
} |
| 44 |
|
| 45 |
/* { dg-final { scan-assembler-times "vfnmsub132ph\[^\n\r\]*xmm\[0-9\]" 1 } } */ |