public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/109038] New: Miss optimization to simplify bit_and + rotate to shift
@ 2023-03-06  9:55 crazylht at gmail dot com
  2023-03-06 17:46 ` [Bug middle-end/109038] " pinskia at gcc dot gnu.org
  2023-05-19 23:29 ` [Bug tree-optimization/109038] " pinskia at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: crazylht at gmail dot com @ 2023-03-06  9:55 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 109038
           Summary: Miss optimization to simplify bit_and + rotate to
                    shift
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: crazylht at gmail dot com
  Target Milestone: ---
            Target: x86_64-*-* i?86-*-*

unsigned
foo (unsigned int a)
{
  unsigned int b = a & 0x00FFFFFF;
  unsigned int c = ((b & 0x000000FF) << 8
                    | (b & 0x0000FF00) << 8
                    | (b & 0x00FF0000) << 8
                    | (b & 0xFF000000) >> 24);
  return c;
}

gcc generates

foo:
        mov     eax, edi
        and     eax, 16777215
        rol     eax, 8
        ret

But it can be optimized as below

foo:                                    # @foo
        mov     eax, edi
        shl     eax, 8
        ret

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

end of thread, other threads:[~2023-05-19 23:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-06  9:55 [Bug middle-end/109038] New: Miss optimization to simplify bit_and + rotate to shift crazylht at gmail dot com
2023-03-06 17:46 ` [Bug middle-end/109038] " pinskia at gcc dot gnu.org
2023-05-19 23:29 ` [Bug tree-optimization/109038] " pinskia 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).