public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "wilco at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/94787] Failure to detect single bit popcount pattern
Date: Wed, 29 Apr 2020 12:52:30 +0000 [thread overview]
Message-ID: <bug-94787-4-C3TFHz9yVP@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-94787-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94787
Wilco <wilco at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |wilco at gcc dot gnu.org
--- Comment #3 from Wilco <wilco at gcc dot gnu.org> ---
(In reply to Gabriel Ravier from comment #1)
> Inversely, I'd also suggest doing the opposite. That is, if there is no
> hardware popcount instruction, `__builtin_popcount(v) == 1` should be
> optimized to `v && !(v & (v - 1))`
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.
So I suggest not to have LLVM emit popcount for this is there a popcount
instruction since that is non-optimal for pretty much every target.
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90693
next prev parent reply other threads:[~2020-04-29 12:52 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-27 8:35 [Bug tree-optimization/94787] New: " gabravier at gmail dot com
2020-04-27 8:56 ` [Bug tree-optimization/94787] " gabravier at gmail dot com
2020-04-27 10:28 ` rguenth at gcc dot gnu.org
2020-04-29 12:52 ` wilco at gcc dot gnu.org [this message]
2021-12-12 13:24 ` [Bug middle-end/94787] " pinskia at gcc dot gnu.org
2023-11-15 19:27 ` tavianator at gmail dot com
2024-03-04 7:45 ` pinskia at gcc dot gnu.org
2024-03-04 16:38 ` pinskia at gcc dot gnu.org
2024-03-04 16:42 ` pinskia at gcc dot gnu.org
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-94787-4-C3TFHz9yVP@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).