public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/99887] New: Failure to optimize log2 pattern to clz
@ 2021-04-03  0:04 gabravier at gmail dot com
  2021-04-06  7:52 ` [Bug tree-optimization/99887] " rguenth at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: gabravier at gmail dot com @ 2021-04-03  0:04 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 99887
           Summary: Failure to optimize log2 pattern to clz
           Product: gcc
           Version: 11.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: ---

static inline unsigned int_log2_rec(unsigned x)
{
  return x == 0 ? 0 : int_log2_rec(x >> 1) + 1;
}

unsigned int_log2(unsigned x)
{
  return x == 0 ? 0 : int_log2_rec(x) - 1;
}

This can be optimized to `return x == 0 ? x : 31 - __builtin_clz(x);`. This
transformation is done by LLVM, but not by GCC.

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

* [Bug tree-optimization/99887] Failure to optimize log2 pattern to clz
  2021-04-03  0:04 [Bug tree-optimization/99887] New: Failure to optimize log2 pattern to clz gabravier at gmail dot com
@ 2021-04-06  7:52 ` rguenth at gcc dot gnu.org
  2021-04-06  7:59 ` jakub at gcc dot gnu.org
  2021-08-03 23:20 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-04-06  7:52 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-04-06
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.  We're not having CLZ pattern detection (niter analysis can do
popcount only)

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

* [Bug tree-optimization/99887] Failure to optimize log2 pattern to clz
  2021-04-03  0:04 [Bug tree-optimization/99887] New: Failure to optimize log2 pattern to clz gabravier at gmail dot com
  2021-04-06  7:52 ` [Bug tree-optimization/99887] " rguenth at gcc dot gnu.org
@ 2021-04-06  7:59 ` jakub at gcc dot gnu.org
  2021-08-03 23:20 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-04-06  7:59 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Related to PR94793

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

* [Bug tree-optimization/99887] Failure to optimize log2 pattern to clz
  2021-04-03  0:04 [Bug tree-optimization/99887] New: Failure to optimize log2 pattern to clz gabravier at gmail dot com
  2021-04-06  7:52 ` [Bug tree-optimization/99887] " rguenth at gcc dot gnu.org
  2021-04-06  7:59 ` jakub at gcc dot gnu.org
@ 2021-08-03 23:20 ` pinskia at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-03 23:20 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This is the same as PR 94793 really.

*** This bug has been marked as a duplicate of bug 94793 ***

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

end of thread, other threads:[~2021-08-03 23:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-03  0:04 [Bug tree-optimization/99887] New: Failure to optimize log2 pattern to clz gabravier at gmail dot com
2021-04-06  7:52 ` [Bug tree-optimization/99887] " rguenth at gcc dot gnu.org
2021-04-06  7:59 ` jakub at gcc dot gnu.org
2021-08-03 23:20 ` 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).