blob: 7f7793f0efac1f0d793e6e99b84988e5cc5221c9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
/* { dg-do run } */
/* { dg-require-effective-target clzll } */
/* { dg-options "-O2 -fdump-tree-optimized" } */
#define PREC (__CHAR_BIT__ * __SIZEOF_LONG_LONG__)
int
__attribute__ ((noinline, noclone))
foo (unsigned long long b) {
int c = 0;
while (b) {
b >>= 1;
c++;
}
return c;
}
int main()
{
if (foo(0) != 0)
__builtin_abort ();
if (foo(5) != 3)
__builtin_abort ();
if (foo(1LL << (PREC - 1)) != PREC)
__builtin_abort ();
return 0;
}
/* { dg-final { scan-tree-dump-times "__builtin_clz|\\.CLZ" 1 "optimized" } } */
|