libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / clz-int.c
blob96646f8e19cd5b2342acb88949b3ef6e3e2abd5a
1 /* { dg-do run } */
2 /* { dg-require-effective-target clzl } */
3 /* { dg-options "-O2 -fno-tree-ch -fdump-tree-optimized" } */
5 #define PREC (__CHAR_BIT__ * __SIZEOF_INT__)
7 int
8 __attribute__ ((noinline, noclone))
9 foo (unsigned int b) {
10 int c = 0;
12 if (b == 0)
13 return PREC;
15 while (!(b & (1 << (PREC - 1)))) {
16 b <<= 1;
17 c++;
20 return c;
23 int main()
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;
34 /* { dg-final { scan-tree-dump-times "__builtin_clz|\\.CLZ" 1 "optimized" } } */