1 /* { dg-do run } */
2 /* { dg-options "-O2 -mavx512bw" } */
3 /* { dg-require-effective-target avx512bw } */
4 
5 #define AVX512BW
6 #include "avx512f-helper.h"
7 
8 #define SIZE (AVX512F_LEN / 8)
9 #include "avx512f-mask-type.h"
10 
11 void
CALC(MASK_TYPE * r,char * s1,char * s2)12 CALC (MASK_TYPE *r, char *s1, char *s2)
13 {
14   int i;
15   *r = 0;
16   MASK_TYPE one = 1;
17 
18   for (i = 0; i < SIZE; i++)
19     if (s1[i] == s2[i])
20       *r = *r | (one << i);
21 }
22 
23 void
TEST(void)24 TEST (void)
25 {
26   int i;
27   UNION_TYPE (AVX512F_LEN, i_b) src1, src2;
28   MASK_TYPE res_ref, res1, res2;
29   MASK_TYPE mask = MASK_VALUE;
30   res1 = 0;
31   res2 = 0;
32 
33   for (i = 0; i < SIZE / 2; i++)
34     {
35       src1.a[i * 2] = i;
36       src1.a[i * 2 + 1] = i * i;
37       src2.a[i * 2] = 2 * i;
38       src2.a[i * 2 + 1] = i * i;
39     }
40 
41   res1 = INTRINSIC (_cmpeq_epi8_mask) (src1.x, src2.x);
42   res2 = INTRINSIC (_mask_cmpeq_epi8_mask) (mask, src1.x, src2.x);
43 
44   CALC (&res_ref, src1.a, src2.a);
45 
46   if (res_ref != res1)
47     abort ();
48 
49   res_ref &= mask;
50 
51   if (res_ref != res2)
52     abort ();
53 }
54