1 /* { dg-do run } */
2 /* { dg-options "-O2 -mavx512bw" } */
3 /* { dg-require-effective-target avx512bw } */
4
5 #define AVX512BW
6 #include "avx512f-helper.h"
7
8 #define SIZE (AVX512F_LEN / 16)
9 #define SIZE_HALF (AVX512F_LEN_HALF / 8)
10 #include "avx512f-mask-type.h"
11
12 void
CALC(char * r,short * s)13 CALC (char *r, short *s)
14 {
15 int i;
16 for (i = 0; i < SIZE_HALF; i++)
17 {
18 r[i] = (i < SIZE) ? (char) s[i] : 0;
19 }
20 }
21
22 void
TEST(void)23 TEST (void)
24 {
25 int i, sign;
26 UNION_TYPE (AVX512F_LEN_HALF, i_b) res1, res2, res3;
27 char res4[SIZE];
28 UNION_TYPE (AVX512F_LEN, i_w) src;
29 MASK_TYPE mask = MASK_VALUE;
30 char res_ref[32];
31 char res_ref2[SIZE];
32
33 sign = -1;
34 for (i = 0; i < SIZE; i++)
35 {
36 src.a[i] = 1 + 34 * i * sign;
37 sign = sign * -1;
38 res2.a[i] = DEFAULT_VALUE;
39 res4[i] = DEFAULT_VALUE;
40 }
41
42 res1.x = INTRINSIC (_cvtepi16_epi8) (src.x);
43 res2.x = INTRINSIC (_mask_cvtepi16_epi8) (res2.x, mask, src.x);
44 res3.x = INTRINSIC (_maskz_cvtepi16_epi8) (mask, src.x);
45
46 CALC (res_ref, src.a);
47
48 if (UNION_CHECK (AVX512F_LEN_HALF, i_b) (res1, res_ref))
49 abort ();
50
51 MASK_MERGE (i_b) (res_ref, mask, SIZE);
52 if (UNION_CHECK (AVX512F_LEN_HALF, i_b) (res2, res_ref))
53 abort ();
54
55 MASK_ZERO (i_b) (res_ref, mask, SIZE);
56 if (UNION_CHECK (AVX512F_LEN_HALF, i_b) (res3, res_ref))
57 abort ();
58
59 INTRINSIC (_mask_cvtepi16_storeu_epi8) (res4, mask, src.x);
60 CALC (res_ref2, src.a);
61
62 MASK_MERGE (i_b) (res_ref2, mask, SIZE);
63 if (checkVc (res4, res_ref2, SIZE))
64 abort ();
65 }
66