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