[Bug middle-end/106727] Missed fold / canonicalization for checking if a number is a power of 2

pinskia at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Mar 4 22:58:23 GMT 2024


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106727

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #1)
> Confirmed.  Expanding __builtin_popcount (n) <= 1 as (n & (n - 1)) == 0
> might be already done.  The canonicalization could be applied if .POPCOUNT
> is available.

No, it is not already done, expanding `__builtin_popcount (n) == 1` is done
(and including if n is known not to include 0 which is exapnded as `n & (n - 1)
== 0`)


More information about the Gcc-bugs mailing list