https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114224
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jakub at gcc dot gnu.org --- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> --- This is a matter of rtl costs. .POPCOUNT expansion in expand_POPCOUNT expands the sequence both ways and asks the backend what is cheaper: /* If .POPCOUNT call has 2 arguments, match_single_bit_test marked it because the result is only used in an equality comparison against 1. Use rtx costs in that case to determine if .POPCOUNT (arg) == 1 or (arg ^ (arg - 1)) > arg - 1 is cheaper. If .POPCOUNT second argument is 0, we additionally know that arg is non-zero, so use arg & (arg - 1) == 0 instead. */