This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [RFC] potential fix for PR middle-end/7151
From: Richard Henderson <rth@redhat.com>
Date: Tue, 1 Oct 2002 14:59:54 -0700
On Tue, Oct 01, 2002 at 02:34:05PM -0700, David S. Miller wrote:
> Can we see GET_CODE (SUBREG_REG (x)) == MEM when generating
> reloads? Upon further reading, it appears not.
Dunno if its historic or not, but find_reloads has code
to handle REG or MEM subregs, so I think we should as well
in push_reloads.
So a true_regnum() based fix seems like the best.
How does this look?
2002-10-01 David S. Miller <davem@redhat.com>
Jan Hubicka <jh@suse.cz>
* reload1.c (gen_reload:SECONDARY_MEMORY_NEEDED): Handle SUBREG.
* reload.c (push_reload:SECONDARY_MEMORY_NEEDED): Likewise.
--- reload.c.~1~ Wed Sep 25 14:12:29 2002
+++ reload.c Tue Oct 1 15:00:57 2002
@@ -1283,12 +1283,17 @@ push_reload (in, out, inloc, outloc, cla
So add an additional reload. */
#ifdef SECONDARY_MEMORY_NEEDED
- /* If a memory location is needed for the copy, make one. */
- if (in != 0 && GET_CODE (in) == REG
- && REGNO (in) < FIRST_PSEUDO_REGISTER
- && SECONDARY_MEMORY_NEEDED (REGNO_REG_CLASS (REGNO (in)),
- class, inmode))
- get_secondary_mem (in, inmode, opnum, type);
+ {
+ int regnum;
+
+ /* If a memory location is needed for the copy, make one. */
+ if (in != 0
+ && ((regnum = true_regnum (in)) >= 0)
+ && regnum < FIRST_PSEUDO_REGISTER
+ && SECONDARY_MEMORY_NEEDED (REGNO_REG_CLASS (regnum),
+ class, inmode))
+ get_secondary_mem (in, inmode, opnum, type);
+ }
#endif
i = n_reloads;
@@ -1314,11 +1319,16 @@ push_reload (in, out, inloc, outloc, cla
n_reloads++;
#ifdef SECONDARY_MEMORY_NEEDED
- if (out != 0 && GET_CODE (out) == REG
- && REGNO (out) < FIRST_PSEUDO_REGISTER
- && SECONDARY_MEMORY_NEEDED (class, REGNO_REG_CLASS (REGNO (out)),
- outmode))
- get_secondary_mem (out, outmode, opnum, type);
+ {
+ int regnum;
+
+ if (out != 0
+ && ((regnum = true_regnum (out)) >= 0)
+ && regnum < FIRST_PSEUDO_REGISTER
+ && SECONDARY_MEMORY_NEEDED (class, REGNO_REG_CLASS (regnum),
+ outmode))
+ get_secondary_mem (out, outmode, opnum, type);
+ }
#endif
}
else
--- reload1.c.~1~ Tue May 21 16:42:54 2002
+++ reload1.c Mon Sep 30 18:24:28 2002
@@ -7354,6 +7354,9 @@ gen_reload (out, in, opnum, type)
{
rtx last = get_last_insn ();
rtx tem;
+#ifdef SECONDARY_MEMORY_NEEDED
+ int in_regnum, out_regnum;
+#endif
/* If IN is a paradoxical SUBREG, remove it and try to put the
opposite SUBREG on OUT. Likewise for a paradoxical SUBREG on OUT. */
@@ -7516,20 +7519,22 @@ gen_reload (out, in, opnum, type)
#ifdef SECONDARY_MEMORY_NEEDED
/* If we need a memory location to do the move, do it that way. */
- else if (GET_CODE (in) == REG && REGNO (in) < FIRST_PSEUDO_REGISTER
- && GET_CODE (out) == REG && REGNO (out) < FIRST_PSEUDO_REGISTER
- && SECONDARY_MEMORY_NEEDED (REGNO_REG_CLASS (REGNO (in)),
- REGNO_REG_CLASS (REGNO (out)),
+ else if ((in_regnum = true_regnum (in)) >= 0
+ && in_regnum < FIRST_PSEUDO_REGISTER
+ && (out_regnum = true_regnum (out)) >= 0
+ && out_regnum < FIRST_PSEUDO_REGISTER
+ && SECONDARY_MEMORY_NEEDED (REGNO_REG_CLASS (in_regnum),
+ REGNO_REG_CLASS (out_regnum),
GET_MODE (out)))
{
/* Get the memory to use and rewrite both registers to its mode. */
rtx loc = get_secondary_mem (in, GET_MODE (out), opnum, type);
if (GET_MODE (loc) != GET_MODE (out))
- out = gen_rtx_REG (GET_MODE (loc), REGNO (out));
+ out = gen_rtx_REG (GET_MODE (loc), out_regnum);
if (GET_MODE (loc) != GET_MODE (in))
- in = gen_rtx_REG (GET_MODE (loc), REGNO (in));
+ in = gen_rtx_REG (GET_MODE (loc), in_regnum);
gen_reload (loc, in, opnum, type);
gen_reload (out, loc, opnum, type);