Commit cb1cca12 by Vladimir Makarov Committed by Vladimir Makarov

lra-constraints.c (emit_spill_move): Remove assert.

2013-08-08  Vladimir Makarov  <vmakarov@redhat.com>

	* lra-constraints.c (emit_spill_move): Remove assert.
	(process_alt_operands): Add more debugging
	output.  Increase reject for spilling into memory.  Decrease
	reject for reloading scratch.
	(split_reg): Use HARD_REGNO_CALLER_SAVE_MODE.

From-SVN: r201611
parent a3719e31
2013-08-08 Vladimir Makarov <vmakarov@redhat.com>
* lra-constraints.c (emit_spill_move): Remove assert.
(process_alt_operands): Add more debugging
output. Increase reject for spilling into memory. Decrease
reject for reloading scratch.
(split_reg): Use HARD_REGNO_CALLER_SAVE_MODE.
2013-08-08 Steve Ellcey <sellcey@mips.com> 2013-08-08 Steve Ellcey <sellcey@mips.com>
* config/mips/mti-linux.h (SYSROOT_SUFFIX_SPEC): Add nan2008. * config/mips/mti-linux.h (SYSROOT_SUFFIX_SPEC): Add nan2008.
......
...@@ -859,8 +859,9 @@ emit_spill_move (bool to_p, rtx mem_pseudo, rtx val) ...@@ -859,8 +859,9 @@ emit_spill_move (bool to_p, rtx mem_pseudo, rtx val)
{ {
if (GET_MODE (mem_pseudo) != GET_MODE (val)) if (GET_MODE (mem_pseudo) != GET_MODE (val))
{ {
lra_assert (GET_MODE_SIZE (GET_MODE (mem_pseudo)) /* Usually size of mem_pseudo is greater than val size but in
>= GET_MODE_SIZE (GET_MODE (val))); rare cases it can be less as it can be defined by target
dependent macro HARD_REGNO_CALLER_SAVE_MODE. */
if (! MEM_P (val)) if (! MEM_P (val))
{ {
val = gen_rtx_SUBREG (GET_MODE (mem_pseudo), val = gen_rtx_SUBREG (GET_MODE (mem_pseudo),
...@@ -1423,8 +1424,14 @@ process_alt_operands (int only_alternative) ...@@ -1423,8 +1424,14 @@ process_alt_operands (int only_alternative)
overall = losers = reject = reload_nregs = reload_sum = 0; overall = losers = reject = reload_nregs = reload_sum = 0;
for (nop = 0; nop < n_operands; nop++) for (nop = 0; nop < n_operands; nop++)
reject += (curr_static_id {
->operand_alternative[nalt * n_operands + nop].reject); int inc = (curr_static_id
->operand_alternative[nalt * n_operands + nop].reject);
if (lra_dump_file != NULL && inc != 0)
fprintf (lra_dump_file,
" Staticly defined alt reject+=%d\n", inc);
reject += inc;
}
early_clobbered_regs_num = 0; early_clobbered_regs_num = 0;
for (nop = 0; nop < n_operands; nop++) for (nop = 0; nop < n_operands; nop++)
...@@ -1598,7 +1605,14 @@ process_alt_operands (int only_alternative) ...@@ -1598,7 +1605,14 @@ process_alt_operands (int only_alternative)
|| (find_regno_note (curr_insn, REG_DEAD, || (find_regno_note (curr_insn, REG_DEAD,
REGNO (operand_reg[nop])) REGNO (operand_reg[nop]))
== NULL_RTX)) == NULL_RTX))
reject += 2; {
if (lra_dump_file != NULL)
fprintf
(lra_dump_file,
" %d Matching alt: reject+=2\n",
nop);
reject += 2;
}
} }
/* If we have to reload this operand and some /* If we have to reload this operand and some
previous operand also had to match the same previous operand also had to match the same
...@@ -1854,16 +1868,35 @@ process_alt_operands (int only_alternative) ...@@ -1854,16 +1868,35 @@ process_alt_operands (int only_alternative)
{ {
if (in_hard_reg_set_p (this_costly_alternative_set, if (in_hard_reg_set_p (this_costly_alternative_set,
mode, hard_regno[nop])) mode, hard_regno[nop]))
reject++; {
if (lra_dump_file != NULL)
fprintf (lra_dump_file,
" %d Costly set: reject++\n",
nop);
reject++;
}
} }
else else
{ {
/* Prefer won reg to spilled pseudo under other equal /* Prefer won reg to spilled pseudo under other equal
conditions. */ conditions. */
if (lra_dump_file != NULL)
fprintf
(lra_dump_file,
" %d Non pseudo reload: reject++\n",
nop);
reject++; reject++;
if (in_class_p (operand_reg[nop], if (in_class_p (operand_reg[nop],
this_costly_alternative, NULL)) this_costly_alternative, NULL))
reject++; {
if (lra_dump_file != NULL)
fprintf
(lra_dump_file,
" %d Non pseudo costly reload:"
" reject++\n",
nop);
reject++;
}
} }
/* We simulate the behaviour of old reload here. /* We simulate the behaviour of old reload here.
Although scratches need hard registers and it Although scratches need hard registers and it
...@@ -1872,7 +1905,13 @@ process_alt_operands (int only_alternative) ...@@ -1872,7 +1905,13 @@ process_alt_operands (int only_alternative)
might cost something but probably less than old might cost something but probably less than old
reload pass believes. */ reload pass believes. */
if (lra_former_scratch_p (REGNO (operand_reg[nop]))) if (lra_former_scratch_p (REGNO (operand_reg[nop])))
reject += LRA_LOSER_COST_FACTOR; {
if (lra_dump_file != NULL)
fprintf (lra_dump_file,
" %d Scratch win: reject+=3\n",
nop);
reject += 3;
}
} }
} }
else if (did_match) else if (did_match)
...@@ -1914,7 +1953,12 @@ process_alt_operands (int only_alternative) ...@@ -1914,7 +1953,12 @@ process_alt_operands (int only_alternative)
this_alternative_offmemok = offmemok; this_alternative_offmemok = offmemok;
if (this_costly_alternative != NO_REGS) if (this_costly_alternative != NO_REGS)
reject++; {
if (lra_dump_file != NULL)
fprintf (lra_dump_file,
" %d Costly loser: reject++\n", nop);
reject++;
}
/* If the operand is dying, has a matching constraint, /* If the operand is dying, has a matching constraint,
and satisfies constraints of the matched operand and satisfies constraints of the matched operand
which failed to satisfy the own constraints, we do which failed to satisfy the own constraints, we do
...@@ -1996,7 +2040,13 @@ process_alt_operands (int only_alternative) ...@@ -1996,7 +2040,13 @@ process_alt_operands (int only_alternative)
|| (curr_static_id->operand[nop].type == OP_OUT || (curr_static_id->operand[nop].type == OP_OUT
&& (targetm.preferred_output_reload_class && (targetm.preferred_output_reload_class
(op, this_alternative) == NO_REGS)))) (op, this_alternative) == NO_REGS))))
reject += LRA_MAX_REJECT; {
if (lra_dump_file != NULL)
fprintf (lra_dump_file,
" %d Non-prefered reload: reject+=%d\n",
nop, LRA_MAX_REJECT);
reject += LRA_MAX_REJECT;
}
if (! (MEM_P (op) && offmemok) if (! (MEM_P (op) && offmemok)
&& ! (const_to_mem && constmemok)) && ! (const_to_mem && constmemok))
...@@ -2009,22 +2059,43 @@ process_alt_operands (int only_alternative) ...@@ -2009,22 +2059,43 @@ process_alt_operands (int only_alternative)
we don't want to have a different alternative we don't want to have a different alternative
match then. */ match then. */
if (! (REG_P (op) && REGNO (op) >= FIRST_PSEUDO_REGISTER)) if (! (REG_P (op) && REGNO (op) >= FIRST_PSEUDO_REGISTER))
reject += 2; {
if (lra_dump_file != NULL)
fprintf
(lra_dump_file,
" %d Non-pseudo reload: reject+=2\n",
nop);
reject += 2;
}
if (! no_regs_p) if (! no_regs_p)
reload_nregs reload_nregs
+= ira_reg_class_max_nregs[this_alternative][mode]; += ira_reg_class_max_nregs[this_alternative][mode];
if (SMALL_REGISTER_CLASS_P (this_alternative)) if (SMALL_REGISTER_CLASS_P (this_alternative))
reject += LRA_LOSER_COST_FACTOR / 2; {
if (lra_dump_file != NULL)
fprintf
(lra_dump_file,
" %d Small class reload: reject+=%d\n",
nop, LRA_LOSER_COST_FACTOR / 2);
reject += LRA_LOSER_COST_FACTOR / 2;
}
} }
/* We are trying to spill pseudo into memory. It is /* We are trying to spill pseudo into memory. It is
usually more costly than moving to a hard register usually more costly than moving to a hard register
although it might takes the same number of although it might takes the same number of
reloads. */ reloads. */
if (no_regs_p && REG_P (op)) if (no_regs_p && REG_P (op) && hard_regno[nop] >= 0)
reject += 2; {
if (lra_dump_file != NULL)
fprintf
(lra_dump_file,
" %d Spill pseudo in memory: reject+=3\n",
nop);
reject += 3;
}
#ifdef SECONDARY_MEMORY_NEEDED #ifdef SECONDARY_MEMORY_NEEDED
/* If reload requires moving value through secondary /* If reload requires moving value through secondary
...@@ -2043,12 +2114,23 @@ process_alt_operands (int only_alternative) ...@@ -2043,12 +2114,23 @@ process_alt_operands (int only_alternative)
reloads can be removed, so penalize output reloads can be removed, so penalize output
reloads. */ reloads. */
if (!REG_P (op) || curr_static_id->operand[nop].type != OP_IN) if (!REG_P (op) || curr_static_id->operand[nop].type != OP_IN)
reject++; {
if (lra_dump_file != NULL)
fprintf
(lra_dump_file,
" %d Non input pseudo reload: reject++\n",
nop);
reject++;
}
} }
if (early_clobber_p) if (early_clobber_p)
reject++; {
if (lra_dump_file != NULL)
fprintf (lra_dump_file,
" %d Early clobber: reject++\n", nop);
reject++;
}
/* ??? We check early clobbers after processing all operands /* ??? We check early clobbers after processing all operands
(see loop below) and there we update the costs more. (see loop below) and there we update the costs more.
Should we update the cost (may be approximately) here Should we update the cost (may be approximately) here
...@@ -2059,7 +2141,7 @@ process_alt_operands (int only_alternative) ...@@ -2059,7 +2141,7 @@ process_alt_operands (int only_alternative)
{ {
if (lra_dump_file != NULL) if (lra_dump_file != NULL)
fprintf (lra_dump_file, fprintf (lra_dump_file,
" alt=%d,overall=%d,losers=%d -- reject\n", " alt=%d,overall=%d,losers=%d -- refuse\n",
nalt, overall, losers); nalt, overall, losers);
goto fail; goto fail;
} }
...@@ -2102,10 +2184,12 @@ process_alt_operands (int only_alternative) ...@@ -2102,10 +2184,12 @@ process_alt_operands (int only_alternative)
insn we can transform it into an add still by insn we can transform it into an add still by
using this alternative. */ using this alternative. */
&& GET_CODE (no_subreg_reg_operand[1]) != PLUS))) && GET_CODE (no_subreg_reg_operand[1]) != PLUS)))
/* We have a move insn and a new reload insn will be similar {
to the current insn. We should avoid such situation as it /* We have a move insn and a new reload insn will be similar
results in LRA cycling. */ to the current insn. We should avoid such situation as it
overall += LRA_MAX_REJECT; results in LRA cycling. */
overall += LRA_MAX_REJECT;
}
ok_p = true; ok_p = true;
curr_alt_dont_inherit_ops_num = 0; curr_alt_dont_inherit_ops_num = 0;
for (nop = 0; nop < early_clobbered_regs_num; nop++) for (nop = 0; nop < early_clobbered_regs_num; nop++)
...@@ -2159,6 +2243,11 @@ process_alt_operands (int only_alternative) ...@@ -2159,6 +2243,11 @@ process_alt_operands (int only_alternative)
losers++; losers++;
/* Early clobber was already reflected in REJECT. */ /* Early clobber was already reflected in REJECT. */
lra_assert (reject > 0); lra_assert (reject > 0);
if (lra_dump_file != NULL)
fprintf
(lra_dump_file,
" %d Conflict early clobber reload: reject--\n",
i);
reject--; reject--;
overall += LRA_LOSER_COST_FACTOR - 1; overall += LRA_LOSER_COST_FACTOR - 1;
} }
...@@ -2186,6 +2275,12 @@ process_alt_operands (int only_alternative) ...@@ -2186,6 +2275,12 @@ process_alt_operands (int only_alternative)
losers++; losers++;
/* Early clobber was already reflected in REJECT. */ /* Early clobber was already reflected in REJECT. */
lra_assert (reject > 0); lra_assert (reject > 0);
if (lra_dump_file != NULL)
fprintf
(lra_dump_file,
" %d Matched conflict early clobber reloads:"
"reject--\n",
i);
reject--; reject--;
overall += LRA_LOSER_COST_FACTOR - 1; overall += LRA_LOSER_COST_FACTOR - 1;
} }
...@@ -4386,15 +4481,12 @@ split_reg (bool before_p, int original_regno, rtx insn, rtx next_usage_insns) ...@@ -4386,15 +4481,12 @@ split_reg (bool before_p, int original_regno, rtx insn, rtx next_usage_insns)
" ((((((((((((((((((((((((((((((((((((((((((((((((\n"); " ((((((((((((((((((((((((((((((((((((((((((((((((\n");
if (call_save_p) if (call_save_p)
{ {
enum machine_mode sec_mode; enum machine_mode mode = GET_MODE (original_reg);
#ifdef SECONDARY_MEMORY_NEEDED_MODE mode = HARD_REGNO_CALLER_SAVE_MODE (hard_regno,
sec_mode = SECONDARY_MEMORY_NEEDED_MODE (GET_MODE (original_reg)); hard_regno_nregs[hard_regno][mode],
#else mode);
sec_mode = GET_MODE (original_reg); new_reg = lra_create_new_reg (mode, NULL_RTX, NO_REGS, "save");
#endif
new_reg = lra_create_new_reg (sec_mode, NULL_RTX,
NO_REGS, "save");
} }
else else
{ {
......
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