public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/98957] New: [x86] Odd code generation for 8-bit left shift
@ 2021-02-03 17:42 gabravier at gmail dot com
  2021-02-04  7:52 ` [Bug target/98957] [11 Regression] " rguenth at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: gabravier at gmail dot com @ 2021-02-03 17:42 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 98957
           Summary: [x86] Odd code generation for 8-bit left shift
           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: ---

bool f(uint8_t m)
{
    return m >> 7;
}

With -O3, LLVM outputs this:

f(unsigned char):
  mov eax, edi
  shr al, 7
  ret

With -march=[some-amd-machine-type], GCC outputs this:

f(unsigned char):
  mov eax, edi
  shr ax, 7
  and eax, 1
  ret

Otherwise, it outputs the same thing as LLVM. I took a long look at
x86-tune.def to see if there was anything related to this triggered by either
from m_AMD_MULTIPLE or m_ZNVER, but couldn't find anything. Also, even if this
is normal (8-bit shr is bad and 16-bit shr is better?? Since when ?? I've
searched for a while and found nothing about this), GCC 10 outputs this:

f(unsigned char):
  movzx eax, dil
  shr ax, 7
  ret

making this look at the very least like a regression to me.

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

end of thread, other threads:[~2021-02-05  9:46 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-03 17:42 [Bug target/98957] New: [x86] Odd code generation for 8-bit left shift gabravier at gmail dot com
2021-02-04  7:52 ` [Bug target/98957] [11 Regression] " rguenth at gcc dot gnu.org
2021-02-04  9:13 ` jakub at gcc dot gnu.org
2021-02-04  9:19 ` jakub at gcc dot gnu.org
2021-02-04  9:43 ` jakub at gcc dot gnu.org
2021-02-04 10:07 ` jakub at gcc dot gnu.org
2021-02-04 11:34 ` [Bug target/98957] [11 Regression] [x86] Odd code generation for 8-bit right shift jakub at gcc dot gnu.org
2021-02-05  9:40 ` cvs-commit at gcc dot gnu.org
2021-02-05  9:46 ` jakub 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).