public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "segher at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/95737] PPC: Unnecessary extsw after negative less than
Date: Sun, 21 Jun 2020 16:30:41 +0000	[thread overview]
Message-ID: <bug-95737-4-KvAOYJpmGm@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-95737-4@http.gcc.gnu.org/bugzilla/>

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

Segher Boessenkool <segher at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |segher at gcc dot gnu.org
                 CC|                            |segher at gcc dot gnu.org
             Target|powerpc-*-*-*               |powerpc64*-*-*
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2020-06-21

--- Comment #5 from Segher Boessenkool <segher at gcc dot gnu.org> ---
In gimple this already is

negativeLessThan (long long unsigned int a, long long unsigned int b)
{
  _Bool _1;
  int _2;
  int _3;
  long long unsigned int _6;

  _1 = a_4(D) < b_5(D);
  _2 = (int) _1;
  _3 = -_2;
  _6 = (long long unsigned int) _3;
  return _6;
}

Then, it is expanded as a sign_extend:DI of a subreg:SI, and nowhere
does it see this isn't necessary (it isn't because that SI cannot be
negative).

The RTL code isn't optimised very well before combine, and that does

Trying 11 -> 12:
   11: {r128:SI=ca:SI-0x1;clobber ca:SI;}
      REG_UNUSED ca:SI
   12: r123:DI=sign_extend(r128:SI)
      REG_DEAD r128:SI
Failed to match this instruction:
(set (reg:DI 123)
    (sign_extend:DI (plus:SI (reg:SI 98 ca [+4 ])
            (const_int -1 [0xffffffffffffffff]))))

(note everything is made SImode in insn 11 before, it absorbed the
subreg).  Combine cannot keep track of known zero bits of hard regs
well, so it fails to see that XER[CA] is only ever 0 or 1 here (it
always is, but it doesn't know that either).

I'll try to add an extra pattern for this extend, that will do the
trick I think.

  parent reply	other threads:[~2020-06-21 16:30 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-18  8:10 [Bug target/95737] New: " jens.seifert at de dot ibm.com
2020-06-19 16:40 ` [Bug target/95737] " wschmidt at gcc dot gnu.org
2020-06-19 16:42 ` wschmidt at gcc dot gnu.org
2020-06-19 17:43 ` jens.seifert at de dot ibm.com
2020-06-21 15:35 ` wschmidt at linux dot ibm.com
2020-06-21 16:30 ` segher at gcc dot gnu.org [this message]
2022-01-06  5:39 ` guihaoc at gcc dot gnu.org
2022-01-13 12:19 ` segher at gcc dot gnu.org
2022-01-13 16:34 ` segher at gcc dot gnu.org
2022-01-14  9:16 ` guihaoc at gcc dot gnu.org
2022-05-18  5:24 ` cvs-commit at gcc dot gnu.org
2022-07-29  2:52 ` guihaoc 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-95737-4-KvAOYJpmGm@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).