Initial support for AVX-512{VL,BW,DQ}
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx512bw-vpermt2w-2.c
blob58d75f4b8ec9a9e55610fcdff2d82dd2cfe72565
1 /* { dg-do run } */
2 /* { dg-options "-O2 -mavx512bw -DAVX512BW" } */
3 /* { dg-require-effective-target avx512bw } */
5 #include "avx512f-helper.h"
7 #define SIZE (AVX512F_LEN / 16)
8 #include "math.h"
9 #include "values.h"
10 #include "avx512f-mask-type.h"
12 #define NUM 32
14 void
15 CALC (short *dst, short *src1, short *ind, short *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
29 TEST (void)
31 int i, j;
32 UNION_TYPE (AVX512F_LEN, i_w) s1, s2, res1, res2, res3, ind;
33 short res_ref[SIZE];
35 MASK_TYPE mask = MASK_VALUE;
37 for (i = 0; i < NUM; i++)
39 for (j = 0; j < SIZE; j++)
41 ind.a[j] = i * (j << 1);
42 s1.a[j] = DEFAULT_VALUE;
43 s2.a[j] = 1.5 * i * 2 * j;
45 res1.a[j] = DEFAULT_VALUE;
46 res2.a[j] = DEFAULT_VALUE;
47 res3.a[j] = DEFAULT_VALUE;
50 CALC (res_ref, s1.a, ind.a, s2.a);
52 res1.x = INTRINSIC (_permutex2var_epi16) (s1.x, ind.x, s2.x);
53 res2.x =
54 INTRINSIC (_mask_permutex2var_epi16) (s1.x, mask, ind.x, s2.x);
55 res3.x =
56 INTRINSIC (_maskz_permutex2var_epi16) (mask, s1.x, ind.x,
57 s2.x);
59 if (UNION_CHECK (AVX512F_LEN, i_w) (res1, res_ref))
60 abort ();
62 MASK_MERGE (i_w) (res_ref, mask, SIZE);
63 if (UNION_CHECK (AVX512F_LEN, i_w) (res2, res_ref))
64 abort ();
66 MASK_ZERO (i_w) (res_ref, mask, SIZE);
67 if (UNION_CHECK (AVX512F_LEN, i_w) (res3, res_ref))
68 abort ();