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 / 16)
12 #include "avx512f-mask-type.h"
13 
14 static void
CALC(short * s,short * r,MASK_TYPE mask)15 CALC (short *s, short *r, MASK_TYPE mask)
16 {
17   int i, k;
18 
19   for (i = 0, k = 0; i < SIZE; i++)
20     {
21       if (mask & (1 << i))
22 	r[i] = s[k++];
23     }
24 }
25 
26 void
TEST(void)27 TEST (void)
28 {
29   UNION_TYPE (AVX512F_LEN, i_w) s1, res1, res2, res3, res4;
30   MASK_TYPE mask = MASK_VALUE;
31   short s2[SIZE];
32   short res_ref1[SIZE];
33   short 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       res3.a[i] = DEFAULT_VALUE;
42       sign = -sign;
43     }
44 
45   res1.x = INTRINSIC (_mask_expand_epi16) (res1.x, mask, s1.x);
46   res2.x = INTRINSIC (_maskz_expand_epi16) (mask, s1.x);
47   res3.x = INTRINSIC (_mask_expandloadu_epi16) (res3.x, mask, s2);
48   res4.x = INTRINSIC (_maskz_expandloadu_epi16) (mask, s2);
49 
50   CALC (s1.a, res_ref1, mask);
51   CALC (s2, res_ref2, mask);
52 
53   MASK_MERGE (i_w) (res_ref1, mask, SIZE);
54   if (UNION_CHECK (AVX512F_LEN, i_w) (res1, res_ref1))
55     abort ();
56 
57   MASK_ZERO (i_w) (res_ref1, mask, SIZE);
58   if (UNION_CHECK (AVX512F_LEN, i_w) (res2, res_ref1))
59     abort ();
60 
61   MASK_MERGE (i_w) (res_ref2, mask, SIZE);
62   if (UNION_CHECK (AVX512F_LEN, i_w) (res3, res_ref2))
63     abort ();
64 
65   MASK_ZERO (i_w) (res_ref2, mask, SIZE);
66   if (UNION_CHECK (AVX512F_LEN, i_w) (res4, res_ref2))
67     abort ();
68 }
69