1 /* { dg-do run } */
2 /* { dg-options "-O2 -mavx512f -mavx512vbmi2 -mavx512bw" } */
3 /* { dg-require-effective-target avx512f } */
4 /* { dg-require-effective-target avx512vbmi2 } */
5
6 #define AVX512F
7
8 #define AVX512VBMI2
9 #include "avx512f-helper.h"
10
11 #define SIZE (AVX512F_LEN / 32)
12 #include "avx512f-mask-type.h"
13
14 static void
15 CALC (int *s, int *r, MASK_TYPE mask)
16 {
17 int i, k;
18
19 for (i = 0, k = 0; i < SIZE; i++)
20 {
21 if (mask & ((long long)1 << i))
22 r[i] = s[k++];
23 }
24 }
25
26 void
27 TEST (void)
28 {
29 UNION_TYPE (AVX512F_LEN, i_d) s1, res1, res2, res3, res4, res5, res6, res7, res8;
30 MASK_TYPE mask = (1 << SIZE - 1) - 1;
31 int s2[SIZE];
32 int res_ref1[SIZE];
33 int res_ref2[SIZE];
34 int i, sign = 1;
35
36 for (i = 0; i < SIZE; i++)
37 {
38 s1.a[i] = 12345 * (i + 200) * sign;
39 s2[i] = 67890 * (i + 300) * sign;
40 res1.a[i] = DEFAULT_VALUE;
41 res5.a[i] = DEFAULT_VALUE;
42 sign = -sign;
43 }
44
45 res2.x = INTRINSIC (_mask_expand_epi32) (res1.x, MASK_ALL_ONES, s1.x);
46 res3.x = INTRINSIC (_mask_expand_epi32) (res1.x, 0, s1.x);
47 res4.x = INTRINSIC (_mask_expand_epi32) (res1.x, mask, s1.x);
48 res6.x = INTRINSIC (_mask_expandloadu_epi32) (res5.x, MASK_ALL_ONES, s2);
49 res7.x = INTRINSIC (_mask_expandloadu_epi32) (res5.x, 0, s2);
50 res8.x = INTRINSIC (_mask_expandloadu_epi32) (res5.x, mask, s2);
51
52 CALC (s1.a, res_ref1, mask);
53 CALC (s2, res_ref2, mask);
54
55 if (UNION_CHECK (AVX512F_LEN, i_d) (res2, s1.a))
56 abort ();
57
58 if (UNION_CHECK (AVX512F_LEN, i_d) (res3, res1.a))
59 abort ();
60
61 MASK_MERGE (i_d) (res_ref1, mask, SIZE);
62 if (UNION_CHECK (AVX512F_LEN, i_d) (res4, res_ref1))
63 abort ();
64
65 if (UNION_CHECK (AVX512F_LEN, i_d) (res6, s2))
66 abort ();
67
68 if (UNION_CHECK (AVX512F_LEN, i_d) (res7, res5.a))
69 abort ();
70
71 MASK_MERGE (i_d) (res_ref2, mask, SIZE);
72 if (UNION_CHECK (AVX512F_LEN, i_d) (res8, res_ref2))
73 abort ();
74 }