]>
Commit | Line | Data |
---|---|---|
4798080d AC |
1 | /* { dg-do run } */ |
2 | /* { dg-require-effective-target ctzll } */ | |
3 | /* { dg-options "-O2 -fno-tree-ch -fdump-tree-optimized" } */ | |
4 | ||
5 | #define PREC (__CHAR_BIT__ * __SIZEOF_LONG_LONG__) | |
6 | ||
7 | int | |
8 | __attribute__ ((noinline, noclone)) | |
9 | foo (unsigned long long b) { | |
10 | int c = 0; | |
11 | ||
12 | if (b == 0) | |
13 | return PREC; | |
14 | ||
15 | while (!(b & 1)) { | |
16 | b >>= 1; | |
17 | c++; | |
18 | } | |
19 | ||
20 | return c; | |
21 | } | |
22 | ||
23 | int main() | |
24 | { | |
25 | if (foo(0) != PREC) | |
26 | __builtin_abort (); | |
27 | if (foo(1LL << (PREC - 1)) != PREC - 1) | |
28 | __builtin_abort (); | |
29 | if (foo(96) != 5) | |
30 | __builtin_abort (); | |
31 | if (foo(35) != 0) | |
32 | __builtin_abort (); | |
33 | return 0; | |
34 | } | |
35 | ||
36 | /* { dg-final { scan-tree-dump-times "__builtin_ctz|\\.CTZ" 1 "optimized" } } */ |