| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-options "-O2 -mavx512f" } */ |
| 3 |
/* { dg-require-effective-target avx512f } */ |
| 4 |
|
| 5 |
#define AVX512F |
| 6 |
|
| 7 |
#include "avx512f-helper.h" |
| 8 |
|
| 9 |
#define SIZE (AVX512F_LEN / 32) |
| 10 |
#include "avx512f-mask-type.h" |
| 11 |
#include "math.h" |
| 12 |
|
| 13 |
static void |
| 14 |
CALC (float *dst, float *src1, int *ind, float *src2) |
| 15 |
{ |
| 16 |
int i; |
| 17 |
|
| 18 |
for (i = 0; i < SIZE; i++) |
| 19 |
{ |
| 20 |
unsigned long long offset = ind[i] & (SIZE - 1); |
| 21 |
unsigned long long cond = ind[i] & SIZE; |
| 22 |
|
| 23 |
dst[i] = cond ? src2[offset] : src1[offset]; |
| 24 |
} |
| 25 |
} |
| 26 |
|
| 27 |
void |
| 28 |
TEST (void) |
| 29 |
{ |
| 30 |
int i, k; |
| 31 |
UNION_TYPE (AVX512F_LEN,) s1, s2, res; |
| 32 |
UNION_TYPE (AVX512F_LEN, i_d) ind; |
| 33 |
float res_ref[SIZE]; |
| 34 |
|
| 35 |
union |
| 36 |
{ |
| 37 |
float f; |
| 38 |
int i; |
| 39 |
} ind_copy[SIZE]; |
| 40 |
|
| 41 |
MASK_TYPE mask = MASK_VALUE; |
| 42 |
|
| 43 |
for (i = 0; i < SIZE; i++) |
| 44 |
{ |
| 45 |
/* Some of the integer indexes may be interpreted as floating point |
| 46 |
values in mask-merge mode, that's why we use IND_COPY. */ |
| 47 |
ind.a[i] = ind_copy[i].i = 17 * (i << 1); |
| 48 |
s1.a[i] = 42.5 * i + 1; |
| 49 |
s2.a[i] = 22.5 * i; |
| 50 |
|
| 51 |
res.a[i] = DEFAULT_VALUE; |
| 52 |
} |
| 53 |
|
| 54 |
CALC (res_ref, s1.a, ind.a, s2.a); |
| 55 |
|
| 56 |
res.x = INTRINSIC (_mask2_permutex2var_ps) (s1.x, ind.x, mask, s2.x); |
| 57 |
|
| 58 |
/* Standard MASK_MERGE cannot be used since VPERMI2PS in mask-merge mode |
| 59 |
merges vectors of two different types (_m512 and __m512i). */ |
| 60 |
for (k = 0; k < SIZE; k++) |
| 61 |
res_ref[k] = (mask & (1LL << k)) ? res_ref[k] : ind_copy[k].f; |
| 62 |
|
| 63 |
if (UNION_CHECK (AVX512F_LEN,) (res, res_ref)) |
| 64 |
abort (); |
| 65 |
} |