| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O2 -fdump-tree-optimized" } */ |
| 3 |
|
| 4 |
int foo(unsigned int x) |
| 5 |
{ |
| 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 |
| 13 |
} |
| 14 |
|
| 15 |
int bar(unsigned long x) |
| 16 |
{ |
| 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 |
| 24 |
} |
| 25 |
|
| 26 |
int baz(unsigned long long x) |
| 27 |
{ |
| 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 |
| 35 |
} |
| 36 |
|
| 37 |
/* { dg-final { scan-tree-dump-not "bswap" "optimized" } } */ |