1 /* { dg-do run } */
2 /* { dg-options "-O2 -fno-tree-ch -fdump-tree-optimized" } */
3
4 /* This test case is based on gcc.dg/tree-ssa/clz-char.c. */
5
6 #define PREC (sizeof(short) * 8)
7
8 int
9 __attribute__ ((noinline, noclone))
10 foo (unsigned short b) {
11 int c = 0;
12
13 if (b == 0)
14 return PREC;
15
16 while (!(b & (1 << (PREC - 1)))) {
17 b <<= 1;
18 c++;
19 }
20
21 return c;
22 }
23
24 int main()
25 {
26 if (foo(0) != PREC)
27 __builtin_abort ();
28 if (foo(1 << (PREC - 1)) != 0)
29 __builtin_abort ();
30 if (foo(35) != PREC - 6)
31 __builtin_abort ();
32 return 0;
33 }
34
35 /* { dg-final { scan-tree-dump-times "__builtin_clz|\\.CLZ" 1 "optimized" } } */