public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH, GCC] PR target/86487: fix the way 'uses_hard_regs_p' handles paradoxical subregs
@ 2019-01-07 14:42 Andre Vieira (lists)
  2019-01-07 22:50 ` Jeff Law
  0 siblings, 1 reply; 9+ messages in thread
From: Andre Vieira (lists) @ 2019-01-07 14:42 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 1803 bytes --]

Hi,

This patch fixes the way 'uses_hard_regs_p' handles paradoxical subregs. 
  The function is supposed to detect whether a register access of 'x' 
overlaps with 'set'.  For SUBREGs it should check whether any of the 
full multi-register overlaps with 'set'.  The former behavior used to 
grab the widest mode of the inner/outer registers of a SUBREG and the 
inner register, and check all registers from the inner-register onwards 
for the given width.  For normal SUBREGS this gives you the full 
register, for paradoxical SUBREGS however it may give you the wrong set 
of registers if the index is not the first of the multi-register set.

The original error reported in PR target/86487 can no longer be 
reproduced with the given test, this was due to an unrelated code-gen 
change, regardless I believe this should still be fixed as it is simply 
wrong behavior by uses_hard_regs_p which may be triggered by a different 
test-case or by future changes to the compiler.  Also it is useful to 
point out that this isn't actually a 'target' issue as this code could 
potentially hit any other target using paradoxical SUBREGS.  Should I 
change the Bugzilla ticket to reflect this is actually a target agnostic 
issue in RTL?

There is a gotcha here, I don't know what would happen if you hit the 
cases of get_hard_regno where it would return -1, quoting the comment 
above that function "If X is not a register or a subreg of a register, 
return -1." though I think if we are hitting this then things must have 
gone wrong before?

Bootstrapped on aarch64, arm and x86, no regressions.

Is this OK for trunk?


gcc/ChangeLog:
2019-01-07 Andre Vieira  <andre.simoesdiasvieira@arm.com>


         PR target/86487
         * lra-constraints.c(uses_hard_regs_p): Fix handling of 
paradoxical SUBREGS.

[-- Attachment #2: use_hard_regs_p.patch --]
[-- Type: text/x-patch, Size: 950 bytes --]

diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c
index c061093ed699620afe2dfda60d58066d6967523a..736b084acc552b75ff4d369b6584bc9ab422e21b 100644
--- a/gcc/lra-constraints.c
+++ b/gcc/lra-constraints.c
@@ -1761,11 +1761,21 @@ uses_hard_regs_p (rtx x, HARD_REG_SET set)
     return false;
   code = GET_CODE (x);
   mode = GET_MODE (x);
+
   if (code == SUBREG)
     {
+      /* For all SUBREGs we want to check whether the full multi-register
+	 overlaps the set.  For normal SUBREGs this means 'get_hard_regno' of
+	 the inner register, for paradoxical SUBREGs this means the
+	 'get_hard_regno' of the full SUBREG and for complete SUBREGs either is
+	 fine.  Use the wider mode for all cases.  */
+      rtx subreg = SUBREG_REG (x);
       mode = wider_subreg_mode (x);
-      x = SUBREG_REG (x);
-      code = GET_CODE (x);
+      if (mode == GET_MODE (subreg))
+	{
+	  x = subreg;
+	  code = GET_CODE (x);
+	}
     }
 
   if (REG_P (x))

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

end of thread, other threads:[~2019-02-19  4:27 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-07 14:42 [PATCH, GCC] PR target/86487: fix the way 'uses_hard_regs_p' handles paradoxical subregs Andre Vieira (lists)
2019-01-07 22:50 ` Jeff Law
2019-01-08 15:21   ` Andre Vieira (lists)
2019-01-11 22:54     ` Jeff Law
2019-02-01 14:31       ` Andre Vieira (lists)
2019-02-13 10:55         ` Andre Vieira (lists)
2019-02-13 16:46           ` Vladimir Makarov
2019-02-15 11:35             ` Andre Vieira (lists)
2019-02-19  4:27               ` Vladimir Makarov

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