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/71775] Redundant move instruction for sign extension
Date: Sat, 07 Aug 2021 04:53:55 +0000	[thread overview]
Message-ID: <bug-71775-4-Qyz5Y6KraP@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-71775-4@http.gcc.gnu.org/bugzilla/>

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
           Severity|normal                      |enhancement
          Component|target                      |rtl-optimization
           Keywords|                            |missed-optimization
   Last reconfirmed|                            |2021-08-07

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed:
Trying 11 -> 13:
   11: {r87:DI=ctz(r86:DI);clobber flags:CC;}
      REG_UNUSED flags:CC
   13: r88:DI=sign_extend(r87:DI#0)
      REG_DEAD r87:DI
Failed to match this instruction:
(set (reg:DI 88 [ _1 ])
    (sign_extend:DI (subreg:SI (ctz:DI (reg/v:DI 86 [ x ])) 0)))


Part of the problem is ctz has an unkown value at 0 but we know x is non-zero
(well kinda, at the gimple level we do).

We do the right thing on aarch64 because we know the value at 0.
Trying 11 -> 13:
   11: r97:DI=ctz(r96:DI)
   13: r98:DI=sign_extend(r97:DI#0)
      REG_DEAD r97:DI
Successfully matched this instruction:
(set (reg:DI 98 [ _1 ])
    (ctz:DI (reg/v:DI 96 [ x ])))
allowing combination of insns 11 and 13
original costs 8 + 4 = 12
replacement cost 8
deferring deletion of insn with uid = 11.
modifying insn i3    13: r98:DI=ctz(r96:DI)
deferring rescan insn with uid = 13.

So this requires us to bring the range down from gimple to RTL.

Here is the range:
  # RANGE [1, 18446744073709551615]
  # x_12 = PHI <x_10(3), x_6(D)(2)>

       reply	other threads:[~2021-08-07  4:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-71775-4@http.gcc.gnu.org/bugzilla/>
2021-08-07  4:53 ` pinskia at gcc dot gnu.org [this message]
2022-08-03  7:58 ` cvs-commit 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-71775-4-Qyz5Y6KraP@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).