| 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 |
|
| 8 |
#define SIZE (AVX512F_LEN / 32) |
| 9 |
#include "avx512f-mask-type.h" |
| 10 |
#define IMM 0x02 |
| 11 |
|
| 12 |
void |
| 13 |
CALC (float *s1, float *s2, float *r) |
| 14 |
{ |
| 15 |
int i; |
| 16 |
|
| 17 |
for (i = 0; i < SIZE; i++) |
| 18 |
{ |
| 19 |
if (s1[i] < -s2[i]) |
| 20 |
r[i] = -s2[i]; |
| 21 |
else if (s1[i] > s2[i]) |
| 22 |
r[i] = s2[i]; |
| 23 |
else |
| 24 |
r[i] = s1[i]; |
| 25 |
} |
| 26 |
} |
| 27 |
|
| 28 |
void |
| 29 |
TEST (void) |
| 30 |
{ |
| 31 |
UNION_TYPE (AVX512F_LEN, ) s1, s2, res1, res2, res3; |
| 32 |
MASK_TYPE mask = MASK_VALUE; |
| 33 |
float res_ref[SIZE]; |
| 34 |
int i, sign = 1; |
| 35 |
|
| 36 |
for (i = 0; i < SIZE; i++) |
| 37 |
{ |
| 38 |
s1.a[i] = 234.567 * i * sign; |
| 39 |
s2.a[i] = 100 * (i + 1); |
| 40 |
res2.a[i] = DEFAULT_VALUE; |
| 41 |
sign = -sign; |
| 42 |
} |
| 43 |
|
| 44 |
res1.x = INTRINSIC (_range_ps) (s1.x, s2.x, IMM); |
| 45 |
res2.x = INTRINSIC (_mask_range_ps) (res2.x, mask, s1.x, s2.x, IMM); |
| 46 |
res3.x = INTRINSIC (_maskz_range_ps) (mask, s1.x, s2.x, IMM); |
| 47 |
|
| 48 |
CALC (s1.a, s2.a, res_ref); |
| 49 |
|
| 50 |
if (UNION_CHECK (AVX512F_LEN, ) (res1, res_ref)) |
| 51 |
abort (); |
| 52 |
|
| 53 |
MASK_MERGE () (res_ref, mask, SIZE); |
| 54 |
if (UNION_CHECK (AVX512F_LEN, ) (res2, res_ref)) |
| 55 |
abort (); |
| 56 |
|
| 57 |
MASK_ZERO () (res_ref, mask, SIZE); |
| 58 |
if (UNION_CHECK (AVX512F_LEN, ) (res3, res_ref)) |
| 59 |
abort (); |
| 60 |
} |