public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Ulrich Weigand <uweigand@de.ibm.com>
Cc: gcc-patches@gcc.gnu.org, bernds@codesourcery.com
Subject: Re: PATCH [10/n]: Prepare x32: PR rtl-optimization/49114: Reload failed to handle (set reg:X (plus:X (subreg:X (reg:Y) 0) (const
Date: Mon, 27 Jun 2011 23:36:00 -0000	[thread overview]
Message-ID: <BANLkTincKpRYsX_BkCmGDHU+aQ-sYKrahg@mail.gmail.com> (raw)
In-Reply-To: <BANLkTikM-fe=TH0rrAGb9WyHzcP6VAykYQ@mail.gmail.com>

On Mon, Jun 27, 2011 at 3:25 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Mon, Jun 27, 2011 at 3:19 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Mon, Jun 27, 2011 at 3:08 PM, Ulrich Weigand <uweigand@de.ibm.com> wrote:
>>> H.J. Lu wrote:
>>>
>>>> reload generates:
>>>>
>>>> (insn 914 912 0 (set (reg:SI 0 ax)
>>>>         (plus:SI (subreg:SI (reg/v/f:DI 182 [ b ]) 0)
>>>>             (const_int 8 [0x8]))) 248 {*lea_1_x32}
>>>>      (nil))
>>>>
>>>> from
>>>>
>>>> insn = emit_insn_if_valid_for_reload (gen_rtx_SET (VOIDmode, out, in));
>>>
>>> Interesting.  The pseudo should have been replaced by the
>>> hard register (reg:DI 1) during the preceding call to
>>>      op0 = find_replacement (&XEXP (in, 0));
>>> (since reload 0 should have pushed a replacement record.)
>>>
>>> Interestingly enough, in the final output that replacement *is*
>>> performed in the REG_EQUIV note:
>>>
>>> (insn 1023 1022 1024 34 (set (reg:SI 1 dx)
>>>        (plus:SI (reg:SI 1 dx)
>>>            (const_int 8 [0x8]))) spooles.c:291 248 {*lea_1_x32}
>>>     (expr_list:REG_EQUIV (plus:SI (subreg:SI (reg:DI 1 dx) 0)
>>>            (const_int 8 [0x8]))
>>>        (nil)))
>>>
>>> which is why I hadn't expected this to be a problem here.
>>>
>>> Can you try to find out why the find_replacement doesn't work
>>> with your test case?
>>>
>>
>> I will investigate.  Could (reg:SI 1 dx) vs  (subreg:SI (reg:DI 1 dx) 0)
>> a problem?
>>
>
> find_replacement never checks subreg:
>
> Breakpoint 3, find_replacement (loc=0x7ffff068ab00)
>    at /export/gnu/import/git/gcc-x32/gcc/reload.c:6411
> 6411          if (reloadreg && r->where == loc)
> (reg:DI 0 ax)
> (reg/v/f:DI 182 [ b ])
> (gdb) call debug_rtx (*loc)
> (subreg:SI (reg/v/f:DI 182 [ b ]) 0)
> (gdb)
>

This seems to work.  Does it make any senses?

Thanks.


-- 
H.J.
---
diff --git a/gcc/reload.c b/gcc/reload.c
index 3ad46b9..bdc47d3 100644
--- a/gcc/reload.c
+++ b/gcc/reload.c
@@ -6415,6 +6415,26 @@ find_replacement (rtx *loc)

 	  return reloadreg;
 	}
+      else if (reloadreg
+	       && REG_P (reloadreg)
+	       && !r->subreg_loc
+	       && GET_CODE (*loc) == SUBREG
+	       && r->where == &SUBREG_REG (*loc))
+	{
+	  int offset;
+
+	  if (r->mode != VOIDmode && GET_MODE (reloadreg) != r->mode)
+	    reloadreg = gen_rtx_REG (r->mode, REGNO (reloadreg));
+
+	  offset = (GET_MODE_SIZE (GET_MODE (reloadreg))
+		    - GET_MODE_SIZE (GET_MODE (*loc)));
+
+	  if (! BYTES_BIG_ENDIAN)
+	    offset = (offset / UNITS_PER_WORD) * UNITS_PER_WORD;
+	  else if (! WORDS_BIG_ENDIAN)
+	    offset %= UNITS_PER_WORD;
+	  return gen_rtx_SUBREG (GET_MODE (*loc), reloadreg, offset);
+	}
       else if (reloadreg && r->subreg_loc == loc)
 	{
 	  /* RELOADREG must be either a REG or a SUBREG.

  reply	other threads:[~2011-06-27 22:53 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-25 19:02 PATCH [10/n]: Prepare x32: PR rtl-optimization/49114: Reload failed to handle (set reg:X (plus:X (subreg:X (reg:Y) 0) (const_int))) H.J. Lu
2011-06-27 15:01 ` PATCH [10/n]: Prepare x32: PR rtl-optimization/49114: Reload failed to handle (set reg:X (plus:X (subreg:X (reg:Y) 0) (const_int Ulrich Weigand
2011-06-27 18:32   ` H.J. Lu
2011-06-27 18:51     ` PATCH [10/n]: Prepare x32: PR rtl-optimization/49114: Reload failed to handle (set reg:X (plus:X (subreg:X (reg:Y) 0) (const Ulrich Weigand
2011-06-27 18:56       ` H.J. Lu
2011-06-27 19:21         ` Ulrich Weigand
2011-06-27 21:20           ` H.J. Lu
2011-06-27 22:19             ` H.J. Lu
2011-06-27 22:26             ` Ulrich Weigand
2011-06-27 22:45               ` H.J. Lu
2011-06-27 22:53                 ` H.J. Lu
2011-06-27 23:36                   ` H.J. Lu [this message]
2011-06-28 15:05                     ` Ulrich Weigand
2011-06-28 15:08                       ` H.J. Lu
2011-06-28 15:19                         ` H.J. Lu
2011-06-28 15:45                           ` Ulrich Weigand
2011-06-28 16:18                             ` H.J. Lu
2011-06-28 22:16                               ` H.J. Lu
2011-06-29 13:00                                 ` Ulrich Weigand
2011-06-29 17:24                                   ` [commit] Fix -Werror build break (Re: PATCH [10/n]: Prepare x32: PR rtl-optimization/49114) Ulrich Weigand
2011-06-28 14:21                   ` PATCH [10/n]: Prepare x32: PR rtl-optimization/49114: Reload failed to handle (set reg:X (plus:X (subreg:X (reg:Y) 0) (const H.J. Lu

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=BANLkTincKpRYsX_BkCmGDHU+aQ-sYKrahg@mail.gmail.com \
    --to=hjl.tools@gmail.com \
    --cc=bernds@codesourcery.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=uweigand@de.ibm.com \
    /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).