| 1 |
/* { dg-do run { target avx512fp16 } } */ |
| 2 |
/* { dg-options "-O2 -mavx512fp16 -mavx512dq" } */ |
| 3 |
|
| 4 |
|
| 5 |
#define AVX512FP16 |
| 6 |
#include "avx512fp16-helper.h" |
| 7 |
|
| 8 |
#define N_ELEMS 8 |
| 9 |
|
| 10 |
void NOINLINE |
| 11 |
emulate_scalef_sh(V512 * dest, V512 op1, V512 op2, |
| 12 |
__mmask8 k, int zero_mask) |
| 13 |
{ |
| 14 |
V512 v1, v2, v3, v4, v5, v6, v7, v8; |
| 15 |
int i; |
| 16 |
|
| 17 |
unpack_ph_2twops(op1, &v1, &v2); |
| 18 |
unpack_ph_2twops(op2, &v3, &v4); |
| 19 |
unpack_ph_2twops(*dest, &v7, &v8); |
| 20 |
|
| 21 |
if ((k&1) || !k) |
| 22 |
v5.f32[0] = v1.f32[0] * powf(2.0f, floorf(v3.f32[0])); |
| 23 |
else if (zero_mask) |
| 24 |
v5.f32[0] = 0; |
| 25 |
else |
| 26 |
v5.f32[0] = v7.f32[0]; |
| 27 |
|
| 28 |
for (i = 1; i < 8; i++) |
| 29 |
v5.f32[i] = v1.f32[i]; |
| 30 |
|
| 31 |
*dest = pack_twops_2ph(v5, v6); |
| 32 |
} |
| 33 |
|
| 34 |
void |
| 35 |
test_512 (void) |
| 36 |
{ |
| 37 |
V512 res; |
| 38 |
V512 exp; |
| 39 |
|
| 40 |
init_src(); |
| 41 |
emulate_scalef_sh(&exp, src1, src2, 0x1, 0); |
| 42 |
res.xmmh[0] = _mm_scalef_round_sh(src1.xmmh[0], src2.xmmh[0], (0x00 | 0x08)); |
| 43 |
check_results(&res, &exp, N_ELEMS, "_mm_scalef_round_sh"); |
| 44 |
|
| 45 |
init_dest(&res, &exp); |
| 46 |
emulate_scalef_sh(&exp, src1, src2, 0x1, 0); |
| 47 |
res.xmmh[0] = _mm_mask_scalef_round_sh(res.xmmh[0], 0x1, src1.xmmh[0], src2.xmmh[0], (0x00 | 0x08)); |
| 48 |
check_results(&res, &exp, N_ELEMS, "_mm_mask_scalef_round_sh"); |
| 49 |
|
| 50 |
emulate_scalef_sh(&exp, src1, src2, 0x3, 1); |
| 51 |
res.xmmh[0] = _mm_maskz_scalef_round_sh(0x3, src1.xmmh[0], src2.xmmh[0], (0x00 | 0x08)); |
| 52 |
check_results(&res, &exp, N_ELEMS, "_mm_maskz_scalef_round_sh"); |
| 53 |
|
| 54 |
if (n_errs != 0) { |
| 55 |
abort (); |
| 56 |
} |
| 57 |
} |
| 58 |
|