https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97759
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Looking at the referenced benchmark, options that would result in popcnt* instruction aren't there though and in the assembly it calls __popcountdi2. So, I guess we want at least: 1) for POPCOUNT (x) == 1 use x && (x & (x - 1)) == 0 if optab_handler (popcount_optab, mode) == CODE_FOR_nothing (a fuzzy case are the double-word cases where we'd end up with popcount (x >> wordbits) + popcount ((word) x) == 1 vs. double-word x && (x & (x - 1)) = 0) 2) the case Richi wrote about, optimize POPCOUNT (x) <= 1 or POPCOUNT (x) == 1 || x == 0 to (x & (x - 1)) == 0 always