gcc/testsuite/gcc.target/aarch64/pr62262.c
raw| 1 | /* { dg-do compile } */ |
| 2 | /* { dg-options "-O2 -fprofile-use -Wno-missing-profile" } */ |
| 3 | |
| 4 | static inline int CLZ(int mask) { |
| 5 | return mask ? __builtin_clz(mask) : 32; |
| 6 | } |
| 7 | |
| 8 | int foo(int value) |
| 9 | { |
| 10 | if (value == 0) |
| 11 | return 0; |
| 12 | |
| 13 | int bias = CLZ(value); |
| 14 | value >>= bias; |
| 15 | int zeros = CLZ(value << 1); |
| 16 | value <<= zeros; |
| 17 | |
| 18 | int packed = (unsigned)(value << 9) >> 9; |
| 19 | return packed; |
| 20 | } |