| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-options "-O2 -mavx512dq" } */ |
| 3 |
/* { dg-require-effective-target avx512dq } */ |
| 4 |
|
| 5 |
#define AVX512DQ |
| 6 |
#include "avx512f-helper.h" |
| 7 |
#include <string.h> |
| 8 |
|
| 9 |
#define SIZE (AVX512F_LEN / 64) |
| 10 |
#include "avx512f-mask-type.h" |
| 11 |
|
| 12 |
#define IMM 0x23 |
| 13 |
|
| 14 |
void |
| 15 |
CALC (float *r, float *s) |
| 16 |
{ |
| 17 |
int i; |
| 18 |
|
| 19 |
memcpy (&r[1], &s[1], 2 * sizeof(float)); |
| 20 |
|
| 21 |
for (i = 0; i < 2; i++) |
| 22 |
{ |
| 23 |
float tmp = (int) (4 * s[i]) / 4.0; |
| 24 |
r[i] = s[i] - tmp; |
| 25 |
} |
| 26 |
} |
| 27 |
|
| 28 |
void |
| 29 |
TEST (void) |
| 30 |
{ |
| 31 |
printf("\nsize = %d\n\n", SIZE); |
| 32 |
|
| 33 |
union128 res1, res2, res3, res4, res5, res6; |
| 34 |
union128 s1, s2, src; |
| 35 |
float res_ref[4]; |
| 36 |
MASK_TYPE mask = MASK_VALUE; |
| 37 |
int j; |
| 38 |
|
| 39 |
for (j = 0; j < 4; j++) |
| 40 |
{ |
| 41 |
s1.a[j] = j / 123.456; |
| 42 |
s2.a[j] = j / 123.456; |
| 43 |
res_ref[j] = j / 123.456; |
| 44 |
res1.a[j] = DEFAULT_VALUE; |
| 45 |
res2.a[j] = DEFAULT_VALUE; |
| 46 |
res3.a[j] = DEFAULT_VALUE; |
| 47 |
res4.a[j] = DEFAULT_VALUE; |
| 48 |
res5.a[j] = DEFAULT_VALUE; |
| 49 |
res6.a[j] = DEFAULT_VALUE; |
| 50 |
} |
| 51 |
|
| 52 |
res1.x = _mm_reduce_ss (s1.x, s2.x, IMM); |
| 53 |
res2.x = _mm_mask_reduce_ss (s1.x, mask, s1.x, s2.x, IMM); |
| 54 |
res3.x = _mm_maskz_reduce_ss (mask, s1.x, s2.x, IMM); |
| 55 |
res4.x = _mm_reduce_round_ss (s1.x, s2.x, IMM, _MM_FROUND_TO_NEAREST_INT |
| 56 |
| _MM_FROUND_NO_EXC); |
| 57 |
res5.x = _mm_mask_reduce_round_ss (s1.x, mask, s1.x, s2.x, |
| 58 |
IMM, _MM_FROUND_TO_NEAREST_INT |
| 59 |
| _MM_FROUND_NO_EXC); |
| 60 |
res6.x = _mm_maskz_reduce_round_ss (mask, s1.x, s2.x, IMM, |
| 61 |
_MM_FROUND_TO_NEAREST_INT |
| 62 |
| _MM_FROUND_NO_EXC); |
| 63 |
|
| 64 |
CALC (res_ref, s2.a); |
| 65 |
|
| 66 |
if (check_union128 (res1, res_ref)) |
| 67 |
abort (); |
| 68 |
|
| 69 |
if (check_union128 (res4, res_ref)) |
| 70 |
abort (); |
| 71 |
|
| 72 |
MASK_MERGE () (res_ref, mask, 1); |
| 73 |
|
| 74 |
if (check_union128 (res2, res_ref)) |
| 75 |
abort (); |
| 76 |
|
| 77 |
if (check_union128 (res5, res_ref)) |
| 78 |
abort (); |
| 79 |
|
| 80 |
MASK_ZERO () (res_ref, mask, 1); |
| 81 |
|
| 82 |
if (check_union128 (res3, res_ref)) |
| 83 |
abort (); |
| 84 |
|
| 85 |
if (check_union128 (res6, res_ref)) |
| 86 |
abort (); |
| 87 |
|
| 88 |
} |