OSDN Git Service

Add -mlzcnt.
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.target / i386 / lzcnt-6.c
1 /* { dg-do run { target { lzcnt && { ! ia32 } } } } */
2 /* { dg-options "-O2 -mlzcnt -fno-inline" } */
3
4 #include <x86intrin.h>
5
6 #include "lzcnt-check.h"
7
8 long long calc_lzcnt_u64 (long long src)
9 {
10   int i;
11   int res = 0;
12
13   while ((res < 64) && (((src >> (63 - res)) & 1) == 0))
14     ++res;
15
16   return res;
17 }
18
19 static void
20 lzcnt_test ()
21 {
22   unsigned i;
23   long long src = 0xce7ace0ce7ace0;
24   long long res, res_ref;
25
26   for (i=0; i<5; ++i) {
27     src = src >> i;
28
29     res_ref = calc_lzcnt_u64 (src);
30     res = __lzcnt64 (src);
31
32     if (res != res_ref)
33       abort();
34   }
35 }