libcpp, c, middle-end: Optimize initializers using #embed in C
[official-gcc.git] / gcc / testsuite / gcc.dg / fold-popcount-6.c
blob7e67c6e6ab2c9abb50270abd8f775aeacde09411
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fdump-tree-optimized" } */
4 int foo(unsigned int x)
6 #if __SIZEOF_INT__ == 4
7 return __builtin_popcount (__builtin_bswap32(x));
8 #elif __SIZEOF_INT__ == 2
9 return __builtin_popcount (__builtin_bswap16(x));
10 #else
11 return x;
12 #endif
15 int bar(unsigned long x)
17 #if __SIZEOF_LONG__ == 8
18 return __builtin_popcountl (__builtin_bswap64(x));
19 #elif __SIZEOF_LONG__ == 4
20 return __builtin_popcountl (__builtin_bswap32(x));
21 #else
22 return x;
23 #endif
26 int baz(unsigned long long x)
28 #if __SIZEOF_LONG_LONG__ == 8
29 return __builtin_popcountll (__builtin_bswap64(x));
30 #elif __SIZEOF_LONG_LONG__ == 4
31 return __builtin_popcountll (__builtin_bswap32(x));
32 #else
33 return x;
34 #endif
37 /* { dg-final { scan-tree-dump-not "bswap" "optimized" } } */