* gcc.target/i386/avx512bw-vpermi2w-2.c: Fix includes to use actual
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx512bw-vpermi2w-2.c
blobb1aa81dc9a7bd4eaca0358132006030fc6c8b64a
1 /* { dg-do run } */
2 /* { dg-options "-O2 -mavx512bw" } */
3 /* { dg-require-effective-target avx512bw } */
5 #define AVX512BW
6 #include "avx512f-helper.h"
8 #define SIZE (AVX512F_LEN / 16)
9 #include <math.h>
10 #include <limits.h>
11 #include <float.h>
12 #include "avx512f-mask-type.h"
14 #define NUM 32
16 void
17 CALC (short *dst, short *src1, short *ind, short *src2)
19 int i;
21 for (i = 0; i < SIZE; i++)
23 unsigned long long offset = ind[i] & (SIZE - 1);
24 unsigned long long cond = ind[i] & SIZE;
26 dst[i] = cond ? src2[offset] : src1[offset];
30 void
31 TEST (void)
33 int i, j;
34 UNION_TYPE (AVX512F_LEN, i_w) s1, s2, res, ind;
35 short res_ref[SIZE];
37 MASK_TYPE mask = MASK_VALUE;
39 for (i = 0; i < NUM; i++)
41 for (j = 0; j < SIZE; j++)
43 ind.a[j] = DEFAULT_VALUE;
44 s1.a[j] = i * 2 * j + 1;
45 s2.a[j] = i * 2 * j;
47 res.a[j] = DEFAULT_VALUE;
50 CALC (res_ref, s1.a, ind.a, s2.a);
52 res.x =
53 INTRINSIC (_mask2_permutex2var_epi16) (s1.x, ind.x, mask,
54 s2.x);
56 MASK_MERGE (i_w) (res_ref, mask, SIZE);
57 if (UNION_CHECK (AVX512F_LEN, i_w) (res, res_ref))
58 abort ();