public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Peter Bergner <bergner@linux.ibm.com>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Cc: "ian@airs.com" <ian@airs.com>,
	Segher Boessenkool <segher@kernel.crashing.org>,
	Richard Biener <richard.guenther@gmail.com>
Subject: [PATCH] lower-subreg: PR94123, SVN r273240, causes gcc.target/powerpc/pr87507.c to fail
Date: Fri, 27 Mar 2020 17:41:36 -0500	[thread overview]
Message-ID: <20ee8944-f0bf-cec1-e3d1-5dd5e9c6a4ef@linux.ibm.com> (raw)

The pr87507.c test case regressed due to Segher's commit that added
-fsplit-wide-types-early.  The issue is that the lower-subreg pass only
decomposes the TImode code in the example if there is a pseudo reg to pseudo
reg copy.  When the lower-subreg pass is called late (its old location),
then combine changes the generated code by adding a TImode pseudo reg to
pseudo reg copy and lower-subreg successfully decomposes it.

When we run lower-subreg before combine, that copy isn't there so we
do not decompose our TImode uses.  I'm not sure why we require a pseudo
to pseudo copy before we decompose things, but changing find_pseudo_copy
to allow pseudo and hard regs to be copied into a pseudo like below fixes
the issue.

Ian, do you remember why we don't just decompose all wide types and instead
require a pseudo to pseudo copy to exist?

This patch survived bootstrap and regtesting on powerpc64le-linux with
no regressions.

	* lower-subreg.c (find_pseudo_copy): Allow copies from hard registers
	too.

diff --git a/gcc/lower-subreg.c b/gcc/lower-subreg.c
index 4c8bc835f93..c6816a34489 100644
--- a/gcc/lower-subreg.c
+++ b/gcc/lower-subreg.c
@@ -419,7 +419,7 @@ find_pseudo_copy (rtx set)
 
   rd = REGNO (dest);
   rs = REGNO (src);
-  if (HARD_REGISTER_NUM_P (rd) || HARD_REGISTER_NUM_P (rs))
+  if (HARD_REGISTER_NUM_P (rd))
     return false;
 
   b = reg_copy_graph[rs];

Given we're late in stage4, the above patch (assuming it's ok) probably
shouldn't go in until stage1, since it is changing lower-subreg's behaviour
slightly.

A different (ie, safer) approach would be to just rerun lower-subreg at
its old location, regardless of whether we used -fsplit-wide-types-early.
This way, we are not changing lower-subreg's behaviour, just running it an
extra time (3 times instead of twice when using -fsplit-wide-types-early).
I don't think lower-subreg is too expensive to run an extra time and we'd
only do it when using -fsplit-wide-types-early.  The only downside (if any)
is that we don't decompose these TImode uses early like the patch above does,
so combine, etc. can't see what they will eventually become.  This does fix
the bug and also survives bootstrap and regtesting on powerpc64le-linux
with no regressions.

	* lower-subreg.c (pass_lower_subreg3::gate): Remove test for
	flag_split_wide_types_early.

diff --git a/gcc/lower-subreg.c b/gcc/lower-subreg.c
index 4c8bc835f93..807ad398b64 100644
--- a/gcc/lower-subreg.c
+++ b/gcc/lower-subreg.c
@@ -1844,8 +1844,7 @@ public:
   {}
 
   /* opt_pass methods: */
-  virtual bool gate (function *) { return flag_split_wide_types
-					  && !flag_split_wide_types_early; }
+  virtual bool gate (function *) { return flag_split_wide_types != 0; }
   virtual unsigned int execute (function *)
     {
       decompose_multiword_subregs (true);


Does anyone have any preferences on the patches above or comments?
If we go with the first patch for stage1, I'll add -fno-split-wide-types-early
to pr87507.c so it doesn't FAIL until the patch goes in.

Peter


             reply	other threads:[~2020-03-27 22:41 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-27 22:41 Peter Bergner [this message]
2020-03-27 23:26 ` Ian Lance Taylor
2020-03-28 19:22 ` Segher Boessenkool
2020-03-28 23:39   ` Peter Bergner
2020-04-02 21:56     ` Segher Boessenkool
2020-03-30  8:50 ` Richard Sandiford
2020-03-30 11:26   ` Segher Boessenkool
2020-03-30 16:23     ` Peter Bergner
2020-03-30 16:26       ` Peter Bergner
2020-03-30 16:39       ` Segher Boessenkool
2020-03-30 16:06   ` Segher Boessenkool
2020-04-01 17:48   ` Peter Bergner
2020-04-01 18:32     ` Richard Sandiford
2020-04-01 19:43       ` Peter Bergner

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=20ee8944-f0bf-cec1-e3d1-5dd5e9c6a4ef@linux.ibm.com \
    --to=bergner@linux.ibm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=ian@airs.com \
    --cc=richard.guenther@gmail.com \
    --cc=segher@kernel.crashing.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).