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.