[Bug libstdc++/97759] Could std::has_single_bit be faster?

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Nov 9 08:16:39 GMT 2020


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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |crazylht at gmail dot com
             Target|                            |x86_64-*-* i?86-*-*

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
I think using popcount () in the standard library is reasonable and instead
GCC should eventually optimize popcount () == 1 during RTL expansion.  An
alternative would be to add an explicit __builtin_is_pow2 ().  Note
matching popcount (x) == 1 || x == 0 for the simple arithmetic trick would
be always good IMHO.


More information about the Gcc-bugs mailing list