[Bug c/126734] New: Continuing regression in quality of generated x86 machine code for a simple bit rotation

contact at ivanchev dot net via Gcc-bugs <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126734

            Bug ID: 126734
           Summary: Continuing regression in quality of generated x86
                    machine code for a simple bit rotation
           Product: gcc
           Version: 16.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: contact at ivanchev dot net
  Target Milestone: ---

I have the following bit-rotation sample in a set of tools for stress-testing
compilers:

#include <stdint.h>

uint32_t func(uint32_t a) {
    uint64_t b = ((uint64_t) a << 32) | a;
    return (uint32_t) (b >> 16);
}

The quality of the generated machine code with "-O2 -m32" has been dropping
continuously since GCC 12.5 as is evident here:

https://godbolt.org/z/cajcb5Gz4

GCC 16.2 generates useless push / pop sequence and the trunk is straight up
suspicious whereas clang correctly identifies the pattern and emits a ROR
instruction.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.