Debian Codegraph @

gcc/testsuite/gcc.dg/tree-ssa/clz-int.c

raw
1 /* { dg-do run } */
2 /* { dg-require-effective-target clzl } */
3 /* { dg-options "-O2 -fno-tree-ch -fdump-tree-optimized" } */
4
5 #define PREC (__CHAR_BIT__ * __SIZEOF_INT__)
6
7 int
8 __attribute__ ((noinline, noclone))
9 foo (unsigned int b) {
10 int c = 0;
11
12 if (b == 0)
13 return PREC;
14
15 while (!(b & (1 << (PREC - 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(1 << (PREC - 1)) != 0)
28 __builtin_abort ();
29 if (foo(35) != PREC - 6)
30 __builtin_abort ();
31 return 0;
32 }
33
34 /* { dg-final { scan-tree-dump-times "__builtin_clz|\\.CLZ" 1 "optimized" } } */