public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/101200] Unneeded AND after shift
Date: Thu, 24 Jun 2021 20:50:46 +0000	[thread overview]
Message-ID: <bug-101200-4-a1CgILuS5H@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-101200-4@http.gcc.gnu.org/bugzilla/>

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-06-24
             Target|                            |x86_64-linux-gnu

--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
For aarch64 we get:
        adrp    x1, .LANCHOR0
        add     x0, x1, :lo12:.LANCHOR0
        add     x0, x0, 8
        ldrb    w1, [x1, #:lo12:.LANCHOR0]
        and     x2, x1, 15
        ubfx    x1, x1, 4, 4
        ldr     w2, [x0, x2, lsl 2]
        str     w2, [x0, x1, lsl 2]
        ret

Note the shift and and is combined into one instruction (ubfx) but really only
a shift instruction is needed.
Here we have:
Trying 21 -> 22:
   21: r112:SI=r92:SI 0>>0x4
      REG_DEAD r92:SI
   22: r113:DI=sign_extend(r112:SI)
      REG_DEAD r112:SI
Successfully matched this instruction:
(set (reg:DI 113)
    (zero_extract:DI (subreg:DI (reg:SI 92 [ d.0_1 ]) 0)
        (const_int 4 [0x4])
        (const_int 4 [0x4])))

The multiple modes issue is part of the problem.  If I was redesigning the
backends, I would only allow DI mode (and SI mode for i386) and always have the
zero extends on loads.

  parent reply	other threads:[~2021-06-24 20:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-24 20:19 [Bug tree-optimization/101200] New: " steinar+gcc at gunderson dot no
2021-06-24 20:37 ` [Bug rtl-optimization/101200] " pinskia at gcc dot gnu.org
2021-06-24 20:45 ` pinskia at gcc dot gnu.org
2021-06-24 20:50 ` pinskia at gcc dot gnu.org [this message]
2021-06-25  9:34 ` [Bug target/101200] " jakub at gcc dot gnu.org
2021-06-25  9:38 ` jakub at gcc dot gnu.org
2021-06-25 10:38 ` steinar+gcc at gunderson dot no
2021-06-29 17:40 ` law at gcc dot gnu.org

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-101200-4-a1CgILuS5H@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).