1 /* { dg-do run } */
2 /* { dg-options "-O2 -mavx512vbmi" } */
3 /* { dg-require-effective-target avx512vbmi } */
4
5 #define AVX512VBMI
6
7 #include "avx512f-helper.h"
8
9 #define SIZE (AVX512F_LEN / 8)
10 #include "avx512f-mask-type.h"
11
12 void
CALC(char * r,char * s1,char * s2)13 CALC (char *r, char *s1, char *s2)
14 {
15 int i, j, k;
16 long long a, b, ctrl;
17
18 for (i = 0; i < SIZE / sizeof (long long); i++)
19 {
20 union
21 {
22 long long x;
23 char a[sizeof(long long)];
24 } src;
25
26 for (j = 0; j < sizeof (long long); j++)
27 src.a[j] = s2[i * sizeof (long long) + j];
28 for (j = 0; j < sizeof (long long); j++)
29 {
30 ctrl = s1[i * sizeof (long long) + j] & ((1 << sizeof (long long)) - 1);
31 r[i * sizeof (long long) + j] = 0;
32 for (k = 0; k < 8; k++)
33 {
34 r[i * sizeof (long long) + j] |= ((src.x >> ((ctrl + k) % (sizeof (long long) * 8))) & 1) << k;
35 }
36 }
37 }
38 }
39
40 void
TEST(void)41 TEST (void)
42 {
43 UNION_TYPE (AVX512F_LEN, i_b) src1, src2, dst1, dst2, dst3;
44 char dst_ref[SIZE];
45 int i;
46 MASK_TYPE mask = MASK_VALUE;
47
48 for (i = 0; i < SIZE; i++)
49 {
50 src1.a[i] = 15 + 3467 * i;
51 src2.a[i] = 9217 + i;
52 dst2.a[i] = DEFAULT_VALUE;
53 }
54
55 CALC (dst_ref, src1.a, src2.a);
56 dst1.x = INTRINSIC (_multishift_epi64_epi8) (src1.x, src2.x);
57 dst2.x = INTRINSIC (_mask_multishift_epi64_epi8) (dst2.x, mask, src1.x, src2.x);
58 dst3.x = INTRINSIC (_maskz_multishift_epi64_epi8) (mask, src1.x, src2.x);
59
60 if (UNION_CHECK (AVX512F_LEN, i_b) (dst1, dst_ref))
61 abort ();
62
63 MASK_MERGE (i_b) (dst_ref, mask, SIZE);
64 if (UNION_CHECK (AVX512F_LEN, i_b) (dst2, dst_ref))
65 abort ();
66
67 MASK_ZERO (i_b) (dst_ref, mask, SIZE);
68 if (UNION_CHECK (AVX512F_LEN, i_b) (dst3, dst_ref))
69 abort ();
70 }
71