2016-12-21 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / lzcnt-6.c
blobf0bf5dab04420fedb926eb0792a576c40e3a989b
1 /* { dg-do run { target { lzcnt && { ! ia32 } } } } */
2 /* { dg-options "-O2 -mlzcnt -fno-inline" } */
4 #include <x86intrin.h>
6 #include "lzcnt-check.h"
8 long long calc_lzcnt_u64 (long long src)
10 int i;
11 int res = 0;
13 while ((res < 64) && (((src >> (63 - res)) & 1) == 0))
14 ++res;
16 return res;
19 static void
20 lzcnt_test ()
22 unsigned i;
23 long long src = 0xce7ace0ce7ace0;
24 long long res, res_ref;
26 for (i=0; i<5; ++i) {
27 src = src >> i;
29 res_ref = calc_lzcnt_u64 (src);
30 res = __lzcnt64 (src);
32 if (res != res_ref)
33 abort();