aboutsummaryrefslogtreecommitdiff
path: root/gcc/reload.c
diff options
context:
space:
mode:
authorRichard Kenner <kenner@gcc.gnu.org>1994-05-17 15:51:48 -0400
committerRichard Kenner <kenner@gcc.gnu.org>1994-05-17 15:51:48 -0400
commit9d926da5630b8a633a1d25d604f3fb6c9e0271f7 (patch)
tree131f1a968a221c3f3c402905c548821db1f52d53 /gcc/reload.c
parenta533969946ef38da61a5264d06faba0aedfed216 (diff)
downloadgcc-9d926da5630b8a633a1d25d604f3fb6c9e0271f7.zip
gcc-9d926da5630b8a633a1d25d604f3fb6c9e0271f7.tar.gz
gcc-9d926da5630b8a633a1d25d604f3fb6c9e0271f7.tar.bz2
(find_reloads): Properly account for cost when constant is forced to
memory to ensure same alternative chosen later. From-SVN: r7319
Diffstat (limited to 'gcc/reload.c')
-rw-r--r--gcc/reload.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/gcc/reload.c b/gcc/reload.c
index cd4d754..afa1072 100644
--- a/gcc/reload.c
+++ b/gcc/reload.c
@@ -2530,6 +2530,9 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
regardless of what the constraint says. */
int force_reload = 0;
int offmemok = 0;
+ /* Nonzero if a constant forced into memory would be OK for this
+ operand. */
+ int constmemok = 0;
int earlyclobber = 0;
/* If the operand is a SUBREG, extract
@@ -2718,6 +2721,7 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
win = 1;
if (CONSTANT_P (operand))
badop = 0;
+ constmemok = 1;
break;
case '<':
@@ -2784,6 +2788,7 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
win = 1;
if (CONSTANT_P (operand) || GET_CODE (operand) == MEM)
badop = 0;
+ constmemok = 1;
offmemok = 1;
break;
@@ -2917,6 +2922,8 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
this_alternative_win[i] = 1;
else
{
+ int const_to_mem = 0;
+
this_alternative_offmemok[i] = offmemok;
losers++;
if (badop)
@@ -2949,9 +2956,12 @@ find_reloads (insn, replace, ind_levels, live_known, reload_reg_p)
&& (PREFERRED_RELOAD_CLASS (operand,
(enum reg_class) this_alternative[i])
== NO_REGS)
- && this_alternative[i] != (int) NO_REGS
&& operand_mode[i] != VOIDmode)
- losers++;
+ {
+ const_to_mem = 1;
+ if (this_alternative[i] != (int) NO_REGS)
+ losers++;
+ }
/* If we can't reload this value at all, reject this
alternative. Note that we could also lose due to
@@ -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.
If we are reloading a SCRATCH, we won't be generating any
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
&& REGNO (operand) >= FIRST_PSEUDO_REGISTER)
- && GET_CODE (operand) != SCRATCH)
+ && GET_CODE (operand) != SCRATCH
+ && ! (const_to_mem && constmemok))
reject++;
}