public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/94860] New: Failure to recognize bzhi pattern
@ 2020-04-29 20:09 gabravier at gmail dot com
  2020-04-29 20:48 ` [Bug rtl-optimization/94860] " jakub at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: gabravier at gmail dot com @ 2020-04-29 20:09 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 94860
           Summary: Failure to recognize bzhi pattern
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gabravier at gmail dot com
  Target Milestone: ---

uint32_t bzhi32(uint32_t x, uint32_t y)
{
  return ((x << (32 - y)) >> (32 - y));
}

LLVM with -O3 -mbmi2 optimizes this to : 

bzhi32(unsigned int, unsigned int): # @bzhi32(unsigned int, unsigned int)
  bzhi eax, edi, esi
  ret

GCC outputs this :

bzhi32(unsigned int, unsigned int):
  mov eax, 32
  sub eax, esi
  shlx edi, edi, eax
  shrx eax, edi, eax
  ret

It should be optimized down to bzhi.

This optimization can be applied to :
- x86-64 (with bzhi)
- i686 (with bzhi)
- AMDGCN (with v_bfe_u32)

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

end of thread, other threads:[~2020-04-30  6:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-29 20:09 [Bug rtl-optimization/94860] New: Failure to recognize bzhi pattern gabravier at gmail dot com
2020-04-29 20:48 ` [Bug rtl-optimization/94860] " jakub at gcc dot gnu.org
2020-04-29 21:05 ` [Bug target/94860] " pinskia at gcc dot gnu.org
2020-04-30  6:52 ` rguenth 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).