| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-options "-mavxneconvert -mf16c -O2" } */ |
| 3 |
/* { dg-require-effective-target avxneconvert } */ |
| 4 |
#define AVXNECONVERT |
| 5 |
#include <stdint.h> |
| 6 |
|
| 7 |
#ifndef CHECK |
| 8 |
#define CHECK "avx-check.h" |
| 9 |
#endif |
| 10 |
|
| 11 |
#ifndef TEST |
| 12 |
#define TEST avx_test |
| 13 |
#endif |
| 14 |
|
| 15 |
#include CHECK |
| 16 |
|
| 17 |
typedef union |
| 18 |
{ |
| 19 |
uint32_t int32; |
| 20 |
float flt; |
| 21 |
} float_int_t; |
| 22 |
|
| 23 |
typedef union |
| 24 |
{ |
| 25 |
__m128h x; |
| 26 |
uint32_t a[4]; |
| 27 |
} union128h; |
| 28 |
|
| 29 |
typedef union |
| 30 |
{ |
| 31 |
__m256h x; |
| 32 |
uint32_t a[8]; |
| 33 |
} union256h; |
| 34 |
|
| 35 |
void TEST (void) |
| 36 |
{ |
| 37 |
union128 dst_128; |
| 38 |
union256 dst_256; |
| 39 |
float res_ref_128[4], res_ref_256[8], fp32; |
| 40 |
uint16_t fp16; |
| 41 |
union128h src_128h; |
| 42 |
union256h src_256h; |
| 43 |
|
| 44 |
for (int i = 0; i < 4; i++) |
| 45 |
{ |
| 46 |
fp32 = (float) 3 * i + 5 + i * 0.5; |
| 47 |
fp16 = _cvtss_sh (fp32, 0); |
| 48 |
src_128h.a[i] = fp16 << 16; |
| 49 |
res_ref_128[i] = fp32; |
| 50 |
dst_128.a[i] = 117; |
| 51 |
} |
| 52 |
for (int i = 0; i < 8; i++) |
| 53 |
{ |
| 54 |
fp32 = (float) 3 * i + 5 + i * 0.5; |
| 55 |
fp16 = _cvtss_sh (fp32, 0); |
| 56 |
src_256h.a[i] = fp16 << 16; |
| 57 |
res_ref_256[i] = fp32; |
| 58 |
dst_256.a[i] = 117; |
| 59 |
} |
| 60 |
dst_128.x = _mm_cvtneoph_ps (&src_128h.x); |
| 61 |
dst_256.x = _mm256_cvtneoph_ps (&src_256h.x); |
| 62 |
if (check_union128 (dst_128, res_ref_128)) |
| 63 |
abort(); |
| 64 |
if (check_union256 (dst_256, res_ref_256)) |
| 65 |
abort(); |
| 66 |
} |