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 / 64)
10 #include "avx512f-mask-type.h"
11 
12 #define N 0x7c
13 
14 static void
CALC(double * s1,double * r)15 CALC (double *s1, double *r)
16 {
17   int i;
18 
19   for (i = 0; i < SIZE; i++)
20     {
21       int index = (N >> ((i % 4) * 2)) & 3;
22       int base = i / 4;
23       r[i] = s1[4 * base + index];
24     }
25 }
26 
27 void
TEST(void)28 TEST (void)
29 {
30   UNION_TYPE (AVX512F_LEN, d) src1, res1, res2, res3;
31   MASK_TYPE mask = MASK_VALUE;
32   double res_ref[SIZE];
33   int i, sign = 1;
34 
35   for (i = 0; i < SIZE; i++)
36     {
37       src1.a[i] = i * i * sign;
38       res2.a[i] = DEFAULT_VALUE;
39       sign = -sign;
40     }
41 
42   res1.x = INTRINSIC (_permutex_pd) (src1.x, N);
43   res2.x = INTRINSIC (_mask_permutex_pd) (res2.x, mask, src1.x, N);
44   res3.x = INTRINSIC (_maskz_permutex_pd) (mask, src1.x, N);
45 
46   CALC (src1.a, res_ref);
47 
48   if (UNION_CHECK (AVX512F_LEN, d) (res1, res_ref))
49     abort ();
50 
51   MASK_MERGE (d) (res_ref, mask, SIZE);
52   if (UNION_CHECK (AVX512F_LEN, d) (res2, res_ref))
53     abort ();
54 
55   MASK_ZERO (d) (res_ref, mask, SIZE);
56   if (UNION_CHECK (AVX512F_LEN, d) (res3, res_ref))
57     abort ();
58 }
59