Daily bump.
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx512vbmi-vpmultishiftqb-2.c
blob0165d2ec7fd6caa400dc96a4e2f983f3a92425e9
1 /* { dg-do run } */
2 /* { dg-options "-O2 -mavx512vbmi" } */
3 /* { dg-require-effective-target avx512vbmi } */
5 #define AVX512VBMI
7 #include "avx512f-helper.h"
9 #define SIZE (AVX512F_LEN / 8)
10 #include "avx512f-mask-type.h"
12 void
13 CALC (char *r, char *s1, char *s2)
15 int i, j, k;
16 long long a, b, ctrl;
18 for (i = 0; i < SIZE / sizeof (long long); i++)
20 union
22 long long x;
23 char a[sizeof(long long)];
24 } src;
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++)
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++)
34 r[i * sizeof (long long) + j] |= ((src.x >> ((ctrl + k) % (sizeof (long long) * 8))) & 1) << k;
40 void
41 TEST (void)
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;
48 for (i = 0; i < SIZE; i++)
50 src1.a[i] = 15 + 3467 * i;
51 src2.a[i] = 9217 + i;
52 dst2.a[i] = DEFAULT_VALUE;
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);
60 if (UNION_CHECK (AVX512F_LEN, i_b) (dst1, dst_ref))
61 abort ();
63 MASK_MERGE (i_b) (dst_ref, mask, SIZE);
64 if (UNION_CHECK (AVX512F_LEN, i_b) (dst2, dst_ref))
65 abort ();
67 MASK_ZERO (i_b) (dst_ref, mask, SIZE);
68 if (UNION_CHECK (AVX512F_LEN, i_b) (dst3, dst_ref))
69 abort ();