public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/95532] New: Failure to optimize __builtin_ctz & 0x1F to __builtin_ctz on x86 with BMI
@ 2020-06-04 12:41 gabravier at gmail dot com
  2020-06-04 15:54 ` [Bug target/95532] " jakub at gcc dot gnu.org
  2020-06-04 15:57 ` gabravier at gmail dot com
  0 siblings, 2 replies; 3+ messages in thread
From: gabravier at gmail dot com @ 2020-06-04 12:41 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 95532
           Summary: Failure to optimize __builtin_ctz & 0x1F to
                    __builtin_ctz on x86 with BMI
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gabravier at gmail dot com
  Target Milestone: ---

int f(int x)
{
  return __builtin_ctz(x) & 0x1F;
}

With -mbmi, this can be optimized to `__builtin_ctz(x)` (directly using `tzcnt`
without an `and` afterwards). This transformation is done by LLVM, but not by
GCC.

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

* [Bug target/95532] Failure to optimize __builtin_ctz & 0x1F to __builtin_ctz on x86 with BMI
  2020-06-04 12:41 [Bug target/95532] New: Failure to optimize __builtin_ctz & 0x1F to __builtin_ctz on x86 with BMI gabravier at gmail dot com
@ 2020-06-04 15:54 ` jakub at gcc dot gnu.org
  2020-06-04 15:57 ` gabravier at gmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-06-04 15:54 UTC (permalink / raw)
  To: gcc-bugs

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

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

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

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Didn't you file the same for clz already?
The thing isthat at GIMPLE opts we include 32 in the range of possibly returned
values because it is a very common result for the 0 case and at RTL opts time
even know it will return 32 for 0, but the fact that it came up from a built
that was documented to have UB with zero value is lost there.

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

* [Bug target/95532] Failure to optimize __builtin_ctz & 0x1F to __builtin_ctz on x86 with BMI
  2020-06-04 12:41 [Bug target/95532] New: Failure to optimize __builtin_ctz & 0x1F to __builtin_ctz on x86 with BMI gabravier at gmail dot com
  2020-06-04 15:54 ` [Bug target/95532] " jakub at gcc dot gnu.org
@ 2020-06-04 15:57 ` gabravier at gmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: gabravier at gmail dot com @ 2020-06-04 15:57 UTC (permalink / raw)
  To: gcc-bugs

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

Gabriel Ravier <gabravier at gmail dot com> changed:

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

--- Comment #2 from Gabriel Ravier <gabravier at gmail dot com> ---
Oops, now I remember doing that. smh my head, marking as duplicate of
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94801

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

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

end of thread, other threads:[~2020-06-04 15:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-04 12:41 [Bug target/95532] New: Failure to optimize __builtin_ctz & 0x1F to __builtin_ctz on x86 with BMI gabravier at gmail dot com
2020-06-04 15:54 ` [Bug target/95532] " jakub at gcc dot gnu.org
2020-06-04 15:57 ` gabravier at gmail dot com

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