public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] lower-subreg: PR94123, SVN r273240, causes gcc.target/powerpc/pr87507.c to fail
@ 2020-03-27 22:41 Peter Bergner
  2020-03-27 23:26 ` Ian Lance Taylor
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Peter Bergner @ 2020-03-27 22:41 UTC (permalink / raw)
  To: GCC Patches; +Cc: ian, Segher Boessenkool, Richard Biener

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


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2020-04-02 21:56 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-27 22:41 [PATCH] lower-subreg: PR94123, SVN r273240, causes gcc.target/powerpc/pr87507.c to fail Peter Bergner
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

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).