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 #define MASK ((1 << SIZE) - 1)
12 #include <x86intrin.h>
13
14 static void
CALC(double * s,double * r,MASK_TYPE mask)15 CALC (double *s, double *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[k++] = s[i];
23 }
24 }
25
26 void
TEST(void)27 TEST (void)
28 {
29 UNION_TYPE (AVX512F_LEN, d) s, res1, res2;
30 double res3[SIZE];
31 MASK_TYPE compressed_mask, mask = MASK_VALUE;
32 double res_ref[SIZE];
33 int i, mask_bit_count, sign = 1;
34
35 for (i = 0; i < SIZE; i++)
36 {
37 s.a[i] = 12345 * (i + 200) * sign;
38 res1.a[i] = DEFAULT_VALUE;
39 res3[i] = DEFAULT_VALUE;
40 sign = -sign;
41 }
42
43 res1.x = INTRINSIC (_mask_compress_pd) (res1.x, mask, s.x);
44 res2.x = INTRINSIC (_maskz_compress_pd) (mask, s.x);
45 INTRINSIC (_mask_compressstoreu_pd) (res3, mask, s.x);
46
47 mask_bit_count = __popcntd (mask & MASK);
48 compressed_mask = (1 << mask_bit_count) - 1;
49 CALC (s.a, res_ref, mask);
50
51 MASK_MERGE (d) (res_ref, compressed_mask, SIZE);
52 if (UNION_CHECK (AVX512F_LEN, d) (res1, res_ref))
53 abort ();
54
55 MASK_ZERO (d) (res_ref, compressed_mask, SIZE);
56 if (UNION_CHECK (AVX512F_LEN, d) (res2, res_ref))
57 abort ();
58
59 MASK_MERGE (d) (res_ref, compressed_mask, SIZE);
60 if (checkVd (res3, res_ref, SIZE))
61 abort ();
62 }
63