[Bug middle-end/94787] Failure to detect single bit popcount pattern

tavianator at gmail dot com gcc-bugzilla@gcc.gnu.org
Wed Nov 15 19:27:07 GMT 2023


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

Tavian Barnes <tavianator at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |tavianator at gmail dot com

--- Comment #4 from Tavian Barnes <tavianator at gmail dot com> ---
(In reply to Wilco from comment #3)
> I actually posted a patch for this and popcount(x) > 1 given the reverse
> transformation is faster on all targets - even if they have popcount
> instruction (since they are typically more expensive). This is true on x86
> as well, (x-1) <u (x & -x) is never slower than using popcount.

There's also these:

(x-1) <u (x ^ (x-1))

-x >u (x ^ -x)


More information about the Gcc-bugs mailing list