Commit 9d926da5 by Richard Kenner

(find_reloads): Properly account for cost when constant is forced to

memory to ensure same alternative chosen later.

From-SVN: r7319
parent a5339699
...@@ -2530,6 +2530,9 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p) ...@@ -2530,6 +2530,9 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
regardless of what the constraint says. */ regardless of what the constraint says. */
int force_reload = 0; int force_reload = 0;
int offmemok = 0; int offmemok = 0;
/* Nonzero if a constant forced into memory would be OK for this
operand. */
int constmemok = 0;
int earlyclobber = 0; int earlyclobber = 0;
/* If the operand is a SUBREG, extract /* If the operand is a SUBREG, extract
...@@ -2718,6 +2721,7 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p) ...@@ -2718,6 +2721,7 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
win = 1; win = 1;
if (CONSTANT_P (operand)) if (CONSTANT_P (operand))
badop = 0; badop = 0;
constmemok = 1;
break; break;
case '<': case '<':
...@@ -2784,6 +2788,7 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p) ...@@ -2784,6 +2788,7 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
win = 1; win = 1;
if (CONSTANT_P (operand) || GET_CODE (operand) == MEM) if (CONSTANT_P (operand) || GET_CODE (operand) == MEM)
badop = 0; badop = 0;
constmemok = 1;
offmemok = 1; offmemok = 1;
break; break;
...@@ -2917,6 +2922,8 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p) ...@@ -2917,6 +2922,8 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
this_alternative_win[i] = 1; this_alternative_win[i] = 1;
else else
{ {
int const_to_mem = 0;
this_alternative_offmemok[i] = offmemok; this_alternative_offmemok[i] = offmemok;
losers++; losers++;
if (badop) if (badop)
...@@ -2949,9 +2956,12 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p) ...@@ -2949,9 +2956,12 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
&& (PREFERRED_RELOAD_CLASS (operand, && (PREFERRED_RELOAD_CLASS (operand,
(enum reg_class) this_alternative[i]) (enum reg_class) this_alternative[i])
== NO_REGS) == NO_REGS)
&& this_alternative[i] != (int) NO_REGS
&& operand_mode[i] != VOIDmode) && operand_mode[i] != VOIDmode)
{
const_to_mem = 1;
if (this_alternative[i] != (int) NO_REGS)
losers++; losers++;
}
/* If we can't reload this value at all, reject this /* If we can't reload this value at all, reject this
alternative. Note that we could also lose due to alternative. Note that we could also lose due to
...@@ -2968,10 +2978,14 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p) ...@@ -2968,10 +2978,14 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
since such reloads may be able to be eliminated later. since such reloads may be able to be eliminated later.
If we are reloading a SCRATCH, we won't be generating any If we are reloading a SCRATCH, we won't be generating any
insns, just using a register, so it is also preferred. insns, just using a register, so it is also preferred.
So bump REJECT in other cases. */ So bump REJECT in other cases. Don't do this in the
case where we are forcing a constant into memory and
it will then win since we don't want to have a different
alternative match then. */
if (! (GET_CODE (operand) == REG if (! (GET_CODE (operand) == REG
&& REGNO (operand) >= FIRST_PSEUDO_REGISTER) && REGNO (operand) >= FIRST_PSEUDO_REGISTER)
&& GET_CODE (operand) != SCRATCH) && GET_CODE (operand) != SCRATCH
&& ! (const_to_mem && constmemok))
reject++; reject++;
} }
......
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