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 
12 void
13 CALC (float *e, UNION_TYPE (AVX512F_LEN,) s1, UNION_TYPE (AVX512F_LEN,) s2,
14       int imm)
15 {
16   e[0] = s1.a[(imm >> 0) & 0x3];
17   e[1] = s1.a[(imm >> 2) & 0x3];
18   e[2] = s2.a[(imm >> 4) & 0x3];
19   e[3] = s2.a[(imm >> 6) & 0x3];
20 #if AVX512F_LEN > 128
21   e[4] = s1.a[4 + ((imm >> 0) & 0x3)];
22   e[5] = s1.a[4 + ((imm >> 2) & 0x3)];
23   e[6] = s2.a[4 + ((imm >> 4) & 0x3)];
24   e[7] = s2.a[4 + ((imm >> 6) & 0x3)];
25 #if AVX512F_LEN > 256
26   e[8] = s1.a[8 + ((imm >> 0) & 0x3)];
27   e[9] = s1.a[8 + ((imm >> 2) & 0x3)];
28   e[10] = s2.a[8 + ((imm >> 4) & 0x3)];
29   e[11] = s2.a[8 + ((imm >> 6) & 0x3)];
30   e[12] = s1.a[12 + ((imm >> 0) & 0x3)];
31   e[13] = s1.a[12 + ((imm >> 2) & 0x3)];
32   e[14] = s2.a[12 + ((imm >> 4) & 0x3)];
33   e[15] = s2.a[12 + ((imm >> 6) & 0x3)];
34 #endif
35 #endif
36 }
37 
38 void
TEST(void)39 TEST (void)
40 {
41   UNION_TYPE (AVX512F_LEN,) u1, u2, u3, s1, s2;
42   float e[SIZE];
43   int i, sign;
44   MASK_TYPE mask = MASK_VALUE;
45 
46   sign = -1;
47   for (i = 0; i < SIZE; i++)
48     {
49       s1.a[i] = 1.5 + 34.67 * i * sign;
50       s2.a[i] = -22.17 * i * sign;
51       u1.a[i] = DEFAULT_VALUE;
52       u2.a[i] = DEFAULT_VALUE;
53       u3.a[i] = DEFAULT_VALUE;
54       sign = sign * -1;
55     }
56 
57 
58   u1.x = INTRINSIC (_shuffle_ps) (s1.x, s2.x, 203);
59   u2.x = INTRINSIC (_mask_shuffle_ps) (u2.x, mask, s1.x, s2.x, 203);
60   u3.x = INTRINSIC (_maskz_shuffle_ps) (mask, s1.x, s2.x, 203);
61 
62   CALC (e, s1, s2, 203);
63 
64   if (UNION_CHECK (AVX512F_LEN,) (u1, e))
65     abort ();
66 
67   MASK_MERGE ()(e, mask, SIZE);
68   if (UNION_CHECK (AVX512F_LEN,) (u2, e))
69     abort ();
70 
71   MASK_ZERO ()(e, mask, SIZE);
72   if (UNION_CHECK (AVX512F_LEN,) (u3, e))
73     abort ();
74 }
75