| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O2 -fdump-rtl-expand-details" } */ |
| 3 |
/* { dg-final { check-function-bodies "**" "" } } */ |
| 4 |
/* PR middle-end/116508 */ |
| 5 |
|
| 6 |
#pragma GCC target "+nocssc" |
| 7 |
|
| 8 |
/* |
| 9 |
** h16: |
| 10 |
** sub w([0-9]+), w0, #1 |
| 11 |
** eor w([0-9]+), w0, w\1 |
| 12 |
** and w([0-9]+), w\1, 65535 |
| 13 |
** cmp w\3, w\2, uxth |
| 14 |
** cset w0, cc |
| 15 |
** ret |
| 16 |
*/ |
| 17 |
|
| 18 |
/* when expanding popcount == 1, should use |
| 19 |
`(arg ^ (arg - 1)) > arg - 1` as that has a lower latency |
| 20 |
than doing the popcount then comparing against 1. |
| 21 |
The popcount/addv can be costly. */ |
| 22 |
unsigned h16 (const unsigned short a) { |
| 23 |
return __builtin_popcountg (a) == 1; |
| 24 |
} |
| 25 |
|
| 26 |
/* unsigned char should also do the same trick */ |
| 27 |
/* Currently xfailed since the cost does not take into account the |
| 28 |
moving between gprs and vector regs correctly. */ |
| 29 |
/* |
| 30 |
** h8: { xfail *-*-* } |
| 31 |
** sub w([0-9]+), w0, #1 |
| 32 |
** eor w([0-9]+), w0, w\1 |
| 33 |
** and w([0-9]+), w\1, 255 |
| 34 |
** cmp w\3, w\2, uxtb |
| 35 |
** cset w0, cc |
| 36 |
** ret |
| 37 |
*/ |
| 38 |
|
| 39 |
|
| 40 |
unsigned h8 (const unsigned char a) { |
| 41 |
return __builtin_popcountg (a) == 1; |
| 42 |
} |
| 43 |
|
| 44 |
/* There should be printing out the costs for h8 and h16's popcount == 1 */ |
| 45 |
/* { dg-final { scan-rtl-dump-times "popcount == 1:" 2 "expand"} } */ |