Commit 7bd8c53f by Richard Sandiford Committed by Richard Sandiford

reload1.c (reload_regs_reach_end_p): Replace with...

gcc/
	* reload1.c (reload_regs_reach_end_p): Replace with...
	(reload_reg_rtx_reaches_end_p): ...this function.
	(new_spill_reg_store): Update commentary.
	(emit_input_reload_insns): Don't clear new_spill_reg_store here.
	(emit_output_reload_insns): Check reload_reg_rtx_reaches_end_p
	before setting new_spill_reg_store.
	(emit_reload_insns): Use a separate loop to clear new_spill_reg_store.
	Use reload_reg_rtx_reaches_end_p instead of reload_regs_reach_end_p.
	Also use reload_reg_rtx_reaches_end_p when reading new_spill_reg_store
	for non-spill reload registers.

From-SVN: r183908
parent f4f62939
2012-02-05 Richard Sandiford <rdsandiford@googlemail.com>
* reload1.c (reload_regs_reach_end_p): Replace with...
(reload_reg_rtx_reaches_end_p): ...this function.
(new_spill_reg_store): Update commentary.
(emit_input_reload_insns): Don't clear new_spill_reg_store here.
(emit_output_reload_insns): Check reload_reg_rtx_reaches_end_p
before setting new_spill_reg_store.
(emit_reload_insns): Use a separate loop to clear new_spill_reg_store.
Use reload_reg_rtx_reaches_end_p instead of reload_regs_reach_end_p.
Also use reload_reg_rtx_reaches_end_p when reading new_spill_reg_store
for non-spill reload registers.
2012-02-05 Ira Rosen <irar@il.ibm.com> 2012-02-05 Ira Rosen <irar@il.ibm.com>
PR tree-optimization/52091 PR tree-optimization/52091
......
...@@ -5505,15 +5505,15 @@ reload_reg_reaches_end_p (unsigned int regno, int reloadnum) ...@@ -5505,15 +5505,15 @@ reload_reg_reaches_end_p (unsigned int regno, int reloadnum)
} }
/* Like reload_reg_reaches_end_p, but check that the condition holds for /* Like reload_reg_reaches_end_p, but check that the condition holds for
every register in the range [REGNO, REGNO + NREGS). */ every register in REG. */
static bool static bool
reload_regs_reach_end_p (unsigned int regno, int nregs, int reloadnum) reload_reg_rtx_reaches_end_p (rtx reg, int reloadnum)
{ {
int i; unsigned int i;
for (i = 0; i < nregs; i++) for (i = REGNO (reg); i < END_REGNO (reg); i++)
if (!reload_reg_reaches_end_p (regno + i, reloadnum)) if (!reload_reg_reaches_end_p (i, reloadnum))
return false; return false;
return true; return true;
} }
...@@ -7058,7 +7058,9 @@ static rtx operand_reload_insns = 0; ...@@ -7058,7 +7058,9 @@ static rtx operand_reload_insns = 0;
static rtx other_operand_reload_insns = 0; static rtx other_operand_reload_insns = 0;
static rtx other_output_reload_insns[MAX_RECOG_OPERANDS]; static rtx other_output_reload_insns[MAX_RECOG_OPERANDS];
/* Values to be put in spill_reg_store are put here first. */ /* Values to be put in spill_reg_store are put here first. Instructions
must only be placed here if the associated reload register reaches
the end of the instruction's reload sequence. */
static rtx new_spill_reg_store[FIRST_PSEUDO_REGISTER]; static rtx new_spill_reg_store[FIRST_PSEUDO_REGISTER];
static HARD_REG_SET reg_reloaded_died; static HARD_REG_SET reg_reloaded_died;
...@@ -7219,9 +7221,7 @@ emit_input_reload_insns (struct insn_chain *chain, struct reload *rl, ...@@ -7219,9 +7221,7 @@ emit_input_reload_insns (struct insn_chain *chain, struct reload *rl,
/* Prevent normal processing of this reload. */ /* Prevent normal processing of this reload. */
special = 1; special = 1;
/* Output a special code sequence for this case, and forget about /* Output a special code sequence for this case. */
spill reg information. */
new_spill_reg_store[REGNO (reloadreg)] = NULL;
inc_for_reload (reloadreg, oldequiv, rl->out, rl->inc); inc_for_reload (reloadreg, oldequiv, rl->out, rl->inc);
} }
...@@ -7742,14 +7742,14 @@ emit_output_reload_insns (struct insn_chain *chain, struct reload *rl, ...@@ -7742,14 +7742,14 @@ emit_output_reload_insns (struct insn_chain *chain, struct reload *rl,
rld[s].out_reg = rl->out_reg; rld[s].out_reg = rl->out_reg;
set = single_set (next); set = single_set (next);
if (set && SET_SRC (set) == s_reg if (set && SET_SRC (set) == s_reg
&& ! new_spill_reg_store[REGNO (s_reg)]) && reload_reg_rtx_reaches_end_p (s_reg, s))
{ {
SET_HARD_REG_BIT (reg_is_output_reload, SET_HARD_REG_BIT (reg_is_output_reload,
REGNO (s_reg)); REGNO (s_reg));
new_spill_reg_store[REGNO (s_reg)] = next; new_spill_reg_store[REGNO (s_reg)] = next;
} }
} }
else else if (reload_reg_rtx_reaches_end_p (rl_reg_rtx, j))
new_spill_reg_store[REGNO (rl_reg_rtx)] = p; new_spill_reg_store[REGNO (rl_reg_rtx)] = p;
} }
} }
...@@ -8009,6 +8009,15 @@ emit_reload_insns (struct insn_chain *chain) ...@@ -8009,6 +8009,15 @@ emit_reload_insns (struct insn_chain *chain)
debug_reload_to_stream (dump_file); debug_reload_to_stream (dump_file);
} }
for (j = 0; j < n_reloads; j++)
if (rld[j].reg_rtx && HARD_REGISTER_P (rld[j].reg_rtx))
{
unsigned int i;
for (i = REGNO (rld[j].reg_rtx); i < END_REGNO (rld[j].reg_rtx); i++)
new_spill_reg_store[i] = 0;
}
/* Now output the instructions to copy the data into and out of the /* Now output the instructions to copy the data into and out of the
reload registers. Do these in the order that the reloads were reported, reload registers. Do these in the order that the reloads were reported,
since reloads of base and index registers precede reloads of operands since reloads of base and index registers precede reloads of operands
...@@ -8016,14 +8025,6 @@ emit_reload_insns (struct insn_chain *chain) ...@@ -8016,14 +8025,6 @@ emit_reload_insns (struct insn_chain *chain)
for (j = 0; j < n_reloads; j++) for (j = 0; j < n_reloads; j++)
{ {
if (rld[j].reg_rtx && HARD_REGISTER_P (rld[j].reg_rtx))
{
unsigned int i;
for (i = REGNO (rld[j].reg_rtx); i < END_REGNO (rld[j].reg_rtx); i++)
new_spill_reg_store[i] = 0;
}
do_input_reload (chain, rld + j, j); do_input_reload (chain, rld + j, j);
do_output_reload (chain, rld + j, j); do_output_reload (chain, rld + j, j);
} }
...@@ -8149,15 +8150,13 @@ emit_reload_insns (struct insn_chain *chain) ...@@ -8149,15 +8150,13 @@ emit_reload_insns (struct insn_chain *chain)
&& GET_CODE (rld[r].out) != PRE_MODIFY)))) && GET_CODE (rld[r].out) != PRE_MODIFY))))
{ {
rtx reg; rtx reg;
enum machine_mode mode;
int regno, nregs;
reg = reload_reg_rtx_for_output[r]; reg = reload_reg_rtx_for_output[r];
mode = GET_MODE (reg); if (reload_reg_rtx_reaches_end_p (reg, r))
regno = REGNO (reg);
nregs = hard_regno_nregs[regno][mode];
if (reload_regs_reach_end_p (regno, nregs, r))
{ {
enum machine_mode mode = GET_MODE (reg);
int regno = REGNO (reg);
int nregs = hard_regno_nregs[regno][mode];
rtx out = (REG_P (rld[r].out) rtx out = (REG_P (rld[r].out)
? rld[r].out ? rld[r].out
: rld[r].out_reg : rld[r].out_reg
...@@ -8221,20 +8220,21 @@ emit_reload_insns (struct insn_chain *chain) ...@@ -8221,20 +8220,21 @@ emit_reload_insns (struct insn_chain *chain)
&& !reg_set_p (reload_reg_rtx_for_input[r], PATTERN (insn))) && !reg_set_p (reload_reg_rtx_for_input[r], PATTERN (insn)))
{ {
rtx reg; rtx reg;
enum machine_mode mode;
int regno, nregs;
reg = reload_reg_rtx_for_input[r]; reg = reload_reg_rtx_for_input[r];
mode = GET_MODE (reg); if (reload_reg_rtx_reaches_end_p (reg, r))
regno = REGNO (reg);
nregs = hard_regno_nregs[regno][mode];
if (reload_regs_reach_end_p (regno, nregs, r))
{ {
enum machine_mode mode;
int regno;
int nregs;
int in_regno; int in_regno;
int in_nregs; int in_nregs;
rtx in; rtx in;
bool piecemeal; bool piecemeal;
mode = GET_MODE (reg);
regno = REGNO (reg);
nregs = hard_regno_nregs[regno][mode];
if (REG_P (rld[r].in) if (REG_P (rld[r].in)
&& REGNO (rld[r].in) >= FIRST_PSEUDO_REGISTER) && REGNO (rld[r].in) >= FIRST_PSEUDO_REGISTER)
in = rld[r].in; in = rld[r].in;
...@@ -8336,10 +8336,17 @@ emit_reload_insns (struct insn_chain *chain) ...@@ -8336,10 +8336,17 @@ emit_reload_insns (struct insn_chain *chain)
delete_output_reload. */ delete_output_reload. */
src_reg = reload_reg_rtx_for_output[r]; src_reg = reload_reg_rtx_for_output[r];
/* If this is an optional reload, try to find the source reg if (src_reg)
from an input reload. */
if (! src_reg)
{ {
if (reload_reg_rtx_reaches_end_p (src_reg, r))
store_insn = new_spill_reg_store[REGNO (src_reg)];
else
src_reg = NULL_RTX;
}
else
{
/* If this is an optional reload, try to find the
source reg from an input reload. */
rtx set = single_set (insn); rtx set = single_set (insn);
if (set && SET_DEST (set) == rld[r].out) if (set && SET_DEST (set) == rld[r].out)
{ {
...@@ -8357,8 +8364,6 @@ emit_reload_insns (struct insn_chain *chain) ...@@ -8357,8 +8364,6 @@ emit_reload_insns (struct insn_chain *chain)
} }
} }
} }
else
store_insn = new_spill_reg_store[REGNO (src_reg)];
if (src_reg && REG_P (src_reg) if (src_reg && REG_P (src_reg)
&& REGNO (src_reg) < FIRST_PSEUDO_REGISTER) && REGNO (src_reg) < FIRST_PSEUDO_REGISTER)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment