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
12static void
13CALC (int *s1, unsigned char imm, int *r)
14{
15  int i, j, offset;
16
17  for (j = 0; j < SIZE / 4; j++)
18    {
19      offset = j * 4;
20      for (i = 0; i < 4; i++)
21	r[i + offset] =
22	  s1[((imm & (0x3 << (2 * i))) >> (2 * i)) + offset];
23    }
24}
25
26void
27TEST (void)
28{
29  UNION_TYPE (AVX512F_LEN, i_d) s1, res1, res2, res3;
30  int res_ref[SIZE];
31  int j, sign = 1;
32  MASK_TYPE mask = MASK_VALUE;
33
34  for (j = 0; j < SIZE; j++)
35    {
36      s1.a[j] = j * sign;
37      res1.a[j] = DEFAULT_VALUE;
38      res2.a[j] = DEFAULT_VALUE;
39      res3.a[j] = DEFAULT_VALUE;
40      sign = -sign;
41    }
42
43  res1.x = INTRINSIC (_shuffle_epi32) (s1.x, 0xec);
44  res2.x = INTRINSIC (_mask_shuffle_epi32) (res2.x, mask, s1.x, 0xec);
45  res3.x = INTRINSIC (_maskz_shuffle_epi32) (mask, s1.x, 0xec);
46
47  CALC (s1.a, 0xec, res_ref);
48
49  if (UNION_CHECK (AVX512F_LEN, i_d) (res1, res_ref))
50    abort ();
51
52  MASK_MERGE (i_d) (res_ref, mask, SIZE);
53  if (UNION_CHECK (AVX512F_LEN, i_d) (res2, res_ref))
54    abort ();
55
56  MASK_ZERO (i_d) (res_ref, mask, SIZE);
57  if (UNION_CHECK (AVX512F_LEN, i_d) (res3, res_ref))
58    abort ();
59}
60