public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ktkachov at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/99520] New: Failure to detect bswap pattern
Date: Wed, 10 Mar 2021 15:54:27 +0000	[thread overview]
Message-ID: <bug-99520-4@http.gcc.gnu.org/bugzilla/> (raw)

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?

             reply	other threads:[~2021-03-10 15:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-10 15:54 ktkachov at gcc dot gnu.org [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-99520-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).