public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/99520] New: Failure to detect bswap pattern
@ 2021-03-10 15:54 ktkachov at gcc dot gnu.org
  2021-03-10 16:03 ` [Bug middle-end/99520] " jakub at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: ktkachov at gcc dot gnu.org @ 2021-03-10 15:54 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 99520
           Summary: Failure to detect bswap pattern
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ktkachov at gcc dot gnu.org
  Target Milestone: ---

#include <stdint.h>

 uint32_t endian_fix32( uint32_t x ){
    return (x<<24) + ((x<<8)&0xff0000) + ((x>>8)&0xff00) + (x>>24);

}

For aarch64 clang manages to optimise it to:
endian_fix32(unsigned int):                      // @endian_fix32(unsigned int)
        rev     w0, w0
        ret

GCC doesn't:
endian_fix32(unsigned int):
        lsl     w1, w0, 8
        lsr     w2, w0, 8
        and     w2, w2, 65280
        lsr     w3, w0, 24
        and     w1, w1, 16711680
        add     w0, w3, w0, lsl 24
        orr     w1, w1, w2
        add     w0, w1, w0
        ret

Is there something missing in the bswap pass?

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

end of thread, other threads:[~2021-11-25 20:28 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-10 15:54 [Bug middle-end/99520] New: Failure to detect bswap pattern ktkachov at gcc dot gnu.org
2021-03-10 16:03 ` [Bug middle-end/99520] " jakub at gcc dot gnu.org
2021-03-10 16:13 ` jakub at gcc dot gnu.org
2021-03-10 16:17 ` jakub at gcc dot gnu.org
2021-03-10 16:19 ` ktkachov at gcc dot gnu.org
2021-03-10 16:28 ` jakub at gcc dot gnu.org
2021-03-10 17:43 ` ktkachov at gcc dot gnu.org
2021-03-11  8:10 ` [Bug tree-optimization/99520] " rguenth at gcc dot gnu.org
2021-11-21 14:46 ` pinskia at gcc dot gnu.org
2021-11-25 20:28 ` roger at nextmovesoftware dot com

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).