https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116616
--- Comment #5 from Filip Kastl <pheeck at gcc dot gnu.org> --- The patch I pushed to trunk should fix this issue. I will wait a bit and then close this PR. Btw, as a follow-up to this, one could modify some RTL pass to pattern match (var ^ (var - 1)) > (var - 1) to some sort of popcount instruction (I think the RTL pass for this is combine but I don't have any experience with RTL). This way we would get the fast popcount instruction but wouldn't run into problems such as this PR. I intend to look into that.