https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115857
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Keywords| |missed-optimization
Ever confirmed|0 |1
Component|c |tree-optimization
Last reconfirmed| |2024-07-10
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
We handle
int popcount64c (uint64_t x)
{
x -= (x >> 1) & 0x5555555555555555ULL;
x = (x & 0x3333333333333333ULL) + ((x >> 2) & 0x3333333333333333ULL);
x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0fULL;
return (x * 0x0101010101010101ULL) >> 56;
}
int popcount32c (uint32_t x)
{
x -= (x >> 1) & 0x55555555;
x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
x = (x + (x >> 4)) & 0x0f0f0f0f;
return (x * 0x01010101) >> 24;
}
at the moment. This is detected by a pattern in match.pd. Doing a similar
variant for your version should be possible.