PR middle-end/85602 - -Wsizeof-pointer-memaccess for strncat with size of source
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx512bitalg-vpshufbitqmb-1.c
blob668064aa4e19a75eebe55c99def5796d0b303d78
1 /* { dg-do run } */
2 /* { dg-options "-O2 -mavx512bitalg -mavx512f -mavx512bw" } */
3 /* { dg-require-effective-target avx512bitalg } */
5 #define AVX512BITALG
6 #define SIZE (AVX512F_LEN / 8)
8 #include "avx512f-helper.h"
9 #include "avx512f-mask-type.h"
11 #define TYPE unsigned long long
13 unsigned char
14 CALC (TYPE a, TYPE b)
16 unsigned char res = 0;
17 for (int i = 0; i < 8; i++)
19 unsigned char m = (b >> (64 - ((i+1)*8))) & 0x3F;
20 unsigned char bit = (a >> m) & 1;
21 res |= (bit << (8 - i - 1));
24 return res;
27 void
28 TEST (void)
30 UNION_TYPE (AVX512F_LEN, i_q) src1, src2;
31 MASK_TYPE mask = MASK_VALUE;
32 TYPE res1, res2;
33 TYPE res_ref = 0;
35 src1.x = INTRINSIC (_set1_epi8) (0x13);
36 src2.x = INTRINSIC (_set1_epi8) (0x17);
38 src1.a[0] = 0xff;
39 src2.a[0] = 0xff;
41 for (int i = 0; i < SIZE/8; i++)
43 unsigned long long bit = CALC (src1.a[i], src2.a[i]);
44 res_ref |= ((unsigned long long)(CALC (src1.a[i], src2.a[i])) << (i*8));
47 res1 = INTRINSIC (_bitshuffle_epi64_mask) (src1.x, src2.x);
48 res2 = INTRINSIC (_mask_bitshuffle_epi64_mask) (mask, src1.x, src2.x);
50 if (res1 != res_ref)
51 abort();
53 for (int i = 0; i < SIZE; i++)
55 if (!((mask >> i) & 1))
56 res_ref &= ~((unsigned long long)1 <<i);
58 if (res2 != res_ref)
59 abort();