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
12 static void
CALC(char * r,long long * s,int mem)13 CALC (char *r, long long *s, int mem)
14 {
15 int i;
16 /* Don't zero out upper half if destination is memory. */
17 int len = mem ? SIZE : 16;
18 for (i = 0; i < len; i++)
19 {
20 r[i] = (i < SIZE) ? (char) s[i] : 0;
21 }
22 }
23
24 void
TEST(void)25 TEST (void)
26 {
27 int i, sign;
28 UNION_TYPE (128, i_b) res1, res2, res3;
29 char res4[16];
30 UNION_TYPE (AVX512F_LEN, i_q) src;
31 MASK_TYPE mask = MASK_VALUE;
32 char res_ref[16];
33 char res_ref2[16];
34
35 sign = -1;
36 for (i = 0; i < SIZE; i++)
37 {
38 src.a[i] = 1 + 34 * i * sign;
39 sign = sign * -1;
40 res2.a[i] = DEFAULT_VALUE;
41 res4[i] = DEFAULT_VALUE;
42 }
43
44 for (i = SIZE; i < 16; i++)
45 {
46 /* To check that memory is not touched. */
47 res4[i] = DEFAULT_VALUE * 2;
48 res_ref2[i] = DEFAULT_VALUE * 2;
49 }
50
51 res1.x = INTRINSIC (_cvtepi64_epi8) (src.x);
52 res2.x = INTRINSIC (_mask_cvtepi64_epi8) (res2.x, mask, src.x);
53 res3.x = INTRINSIC (_maskz_cvtepi64_epi8) (mask, src.x);
54
55 CALC (res_ref, src.a, 0);
56
57 if (UNION_CHECK (128, i_b) (res1, res_ref))
58 abort ();
59
60 MASK_MERGE (i_b) (res_ref, mask, SIZE);
61 if (UNION_CHECK (128, i_b) (res2, res_ref))
62 abort ();
63
64 MASK_ZERO (i_b) (res_ref, mask, SIZE);
65 if (UNION_CHECK (128, i_b) (res3, res_ref))
66 abort ();
67
68
69 INTRINSIC (_mask_cvtepi64_storeu_epi8) (res4, mask, src.x);
70
71 CALC (res_ref2, src.a, 1);
72 MASK_MERGE (i_b) (res_ref2, mask, SIZE);
73
74 if (checkVc (res4, res_ref2, 16))
75 abort ();
76 }
77