1 /* { dg-do run } */
2 /* { dg-options "-O2 -mavx512f -mgfni -mavx512bw" } */
3 /* { dg-require-effective-target avx512f } */
4 /* { dg-require-effective-target gfni } */
5
6 #define AVX512F
7
8 #define GFNI
9 #include "avx512f-helper.h"
10
11 #define SIZE (AVX512F_LEN / 8)
12
13 #include "avx512f-mask-type.h"
14 #include <x86intrin.h>
15
16 static void
CALC(unsigned char * r,unsigned char * s1,unsigned char * s2,unsigned char imm)17 CALC (unsigned char *r, unsigned char *s1, unsigned char *s2, unsigned char imm)
18 {
19 for (int a = 0; a < SIZE/8; a++)
20 {
21 for (int val = 0; val < 8; val++)
22 {
23 unsigned char result = 0;
24 for (int bit = 0; bit < 8; bit++)
25 {
26 unsigned char temp = s1[a*8 + val] & s2[a*8 + bit];
27 unsigned char parity = __popcntd(temp);
28 if (parity % 2)
29 result |= (1 << (8 - bit - 1));
30 }
31 r[a*8 + val] = result ^ imm;
32 }
33 }
34 }
35
36 void
TEST(void)37 TEST (void)
38 {
39 int i;
40 UNION_TYPE (AVX512F_LEN, i_b) res1, res2, res3, src1, src2;
41 MASK_TYPE mask = MASK_VALUE;
42 char res_ref[SIZE];
43 unsigned char imm = 0;
44
45 for (i = 0; i < SIZE; i++)
46 {
47 src1.a[i] = 1 + i;
48 src2.a[i] = 1;
49 }
50
51 for (i = 0; i < SIZE; i++)
52 {
53 res1.a[i] = DEFAULT_VALUE;
54 res2.a[i] = DEFAULT_VALUE;
55 res3.a[i] = DEFAULT_VALUE;
56 }
57
58 CALC (res_ref, src1.a, src2.a, imm);
59
60 res1.x = INTRINSIC (_gf2p8affine_epi64_epi8) (src1.x, src2.x, imm);
61 res2.x = INTRINSIC (_mask_gf2p8affine_epi64_epi8) (res2.x, mask, src1.x, src2.x, imm);
62 res3.x = INTRINSIC (_maskz_gf2p8affine_epi64_epi8) (mask, src1.x, src2.x, imm);
63 if (UNION_CHECK (AVX512F_LEN, i_b) (res1, res_ref))
64 abort ();
65
66 MASK_MERGE (i_b) (res_ref, mask, SIZE);
67 if (UNION_CHECK (AVX512F_LEN, i_b) (res2, res_ref))
68 abort ();
69
70 MASK_ZERO (i_b) (res_ref, mask, SIZE);
71 if (UNION_CHECK (AVX512F_LEN, i_b) (res3, res_ref))
72 abort ();
73
74 }
75