* g++.dg/other/i386-2.C (dg-options): Add -mavx512pf.
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx512cd-vplzcntq-2.c
blobf0cc40304c9ded54c255b4b544948338f6575244
1 /* { dg-do run } */
2 /* { dg-options "-O2 -mavx512cd" } */
3 /* { dg-require-effective-target avx512cd } */
5 #define HAVE_512
6 #define AVX512CD
8 #include "avx512f-helper.h"
10 #define SIZE (AVX512F_LEN / 64)
11 #include "avx512f-mask-type.h"
12 #include <strings.h>
14 static void
15 CALC (long long *s, long long *r)
17 int i, res;
19 for (i = 0; i < SIZE; i++)
21 res = 0;
22 while ((res < 64) && (((s[i] >> (63 - res)) & 1) == 0))
23 ++res;
24 r[i] = res;
28 static void
29 TEST (void)
31 UNION_TYPE (AVX512F_LEN, i_q) s, res1, res2, res3;
32 long long res_ref[SIZE];
33 MASK_TYPE mask = MASK_VALUE;
34 int i;
36 for (i = 0; i < SIZE; i++)
38 s.a[i] = 12345678 * (i % 5);
39 res1.a[i] = DEFAULT_VALUE;
40 res2.a[i] = DEFAULT_VALUE;
41 res3.a[i] = DEFAULT_VALUE;
44 res1.x = INTRINSIC (_lzcnt_epi64) (s.x);
45 res2.x = INTRINSIC (_mask_lzcnt_epi64) (res2.x, mask, s.x);
46 res3.x = INTRINSIC (_maskz_lzcnt_epi64) (mask, s.x);
48 CALC (s.a, res_ref);
50 if (UNION_CHECK (AVX512F_LEN, i_q) (res1, res_ref))
51 abort ();
53 MASK_MERGE (i_q) (res_ref, mask, SIZE);
54 if (UNION_CHECK (AVX512F_LEN, i_q) (res2, res_ref))
55 abort ();
57 MASK_ZERO (i_q) (res_ref, mask, SIZE);
58 if (UNION_CHECK (AVX512F_LEN, i_q) (res3, res_ref))
59 abort ();