public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/94787] New: Failure to detect single bit popcount pattern
@ 2020-04-27  8:35 gabravier at gmail dot com
  2020-04-27  8:56 ` [Bug tree-optimization/94787] " gabravier at gmail dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: gabravier at gmail dot com @ 2020-04-27  8:35 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 94787
           Summary: Failure to detect single bit popcount pattern
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gabravier at gmail dot com
  Target Milestone: ---

bool f(unsigned v)
{
    return v && !(v & (v - 1));
}

Depending on the supported architecture, we may want to optimize this to
`__builtin_popcount(v) == 1;` (when a fast hardware instruction is available).
For example, on x86, this should make programs faster when `popcnt` is
available. LLVM already does this.

Comparison with x86 `-mpopcnt` here : https://godbolt.org/z/M6f28d

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-03-04 16:42 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-27  8:35 [Bug tree-optimization/94787] New: Failure to detect single bit popcount pattern 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
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

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).