1 /* { dg-do run } */
2 /* { dg-options "-O2 -mavx512cd" } */
3 /* { dg-require-effective-target avx512cd } */
4 
5 #define HAVE_512
6 #define AVX512CD
7 
8 #include "avx512f-helper.h"
9 
10 #define SIZE (AVX512F_LEN / 32)
11 #include "avx512f-mask-type.h"
12 
13 static void
CALC(int * s,int * r)14 CALC (int *s, int *r)
15 {
16   int i, j;
17 
18   for (i = 0; i < SIZE; i++)
19     {
20       r[i] = 0;
21       for (j = 0; j < i; j++)
22 	{
23 	  r[i] |= s[j] == s[i] ? 1 << j : 0;
24 	}
25     }
26 }
27 
28 void
TEST(void)29 TEST (void)
30 {
31   UNION_TYPE (AVX512F_LEN, i_d) s, res1, res2, res3;
32   int res_ref[SIZE];
33   MASK_TYPE mask = MASK_VALUE;
34   int i;
35 
36   for (i = 0; i < SIZE; i++)
37     {
38       s.a[i] = 1234 * (i % 5);
39       res1.a[i] = DEFAULT_VALUE;
40       res2.a[i] = DEFAULT_VALUE;
41       res3.a[i] = DEFAULT_VALUE;
42     }
43 
44   res1.x = INTRINSIC (_conflict_epi32) (s.x);
45   res2.x = INTRINSIC (_mask_conflict_epi32) (res2.x, mask, s.x);
46   res3.x = INTRINSIC (_maskz_conflict_epi32) (mask, s.x);
47 
48   CALC (s.a, res_ref);
49 
50   if (UNION_CHECK (AVX512F_LEN, i_d) (res1, res_ref))
51     abort ();
52 
53   MASK_MERGE (i_d) (res_ref, mask, SIZE);
54   if (UNION_CHECK (AVX512F_LEN, i_d) (res2, res_ref))
55     abort ();
56 
57   MASK_ZERO (i_d) (res_ref, mask, SIZE);
58   if (UNION_CHECK (AVX512F_LEN, i_d) (res3, res_ref))
59     abort ();
60 }
61