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 #include "string.h"
12
13 static void
CALC(double * e,UNION_TYPE (AVX512F_LEN,d)s1,UNION_TYPE (AVX512F_LEN,d)s2,int imm)14 CALC (double *e, UNION_TYPE (AVX512F_LEN, d) s1,
15 UNION_TYPE (AVX512F_LEN, d) s2, int imm)
16 {
17 int i, offset, selector;
18 double *source;
19 for (i = 0; i < SIZE / 2; i++)
20 {
21
22 #if AVX512F_LEN == 512
23 selector = (imm >> i * 2) & 0x3;
24 #else
25 selector = (imm >> i) & 0x1;
26 #endif
27
28 offset = i * 2;
29 source = i * 2 * 64 < AVX512F_LEN / 2 ? s1.a : s2.a;
30 memcpy (e + offset, source + selector * 2, 16);
31 }
32 }
33
34 void
TEST(void)35 TEST (void)
36 {
37 UNION_TYPE (AVX512F_LEN, d) u1, u2, u3, s1, s2;
38 MASK_TYPE mask = MASK_VALUE;
39 double e[SIZE];
40 int i;
41 #if AVX512F_LEN == 512
42 int imm = 203;
43 #else
44 int imm = 1;
45 #endif
46
47 for (i = 0; i < SIZE; i++)
48 {
49 s1.a[i] = 1.2 / (i + 0.378);
50 s2.a[i] = 91.02 / (i + 4.3578);
51 u1.a[i] = DEFAULT_VALUE;
52 u2.a[i] = DEFAULT_VALUE;
53 u3.a[i] = DEFAULT_VALUE;
54 }
55
56 u1.x = INTRINSIC (_shuffle_f64x2) (s1.x, s2.x, imm);
57 u2.x = INTRINSIC (_mask_shuffle_f64x2) (u2.x, mask, s1.x, s2.x, imm);
58 u3.x = INTRINSIC (_maskz_shuffle_f64x2) (mask, s1.x, s2.x, imm);
59
60 CALC (e, s1, s2, imm);
61
62 if (UNION_CHECK (AVX512F_LEN, d) (u1, e))
63 abort ();
64
65 MASK_MERGE (d) (e, mask, SIZE);
66 if (UNION_CHECK (AVX512F_LEN, d) (u2, e))
67 abort ();
68
69 MASK_ZERO (d) (e, mask, SIZE);
70 if (UNION_CHECK (AVX512F_LEN, d) (u3, e))
71 abort ();
72 }
73