lra.c (lra): Clear lra_optional_reload_pseudos before every constraint pass.

2013-09-10  Vladimir Makarov  <vmakarov@redhat.com>

	* lra.c (lra): Clear lra_optional_reload_pseudos before every
	constraint pass.
	* lra-constraints.c (curr_insn_transform): Switch on optional
	reloads.  Check destination too to check move insn.
	(undo_optional_reloads): Add check that the original peudo did not
	changed its allocation and the optional reload was inherited on
	last inheritance pass.  Break loop after deciding to keep optional
	reload.
	(lra_undo_inheritance): Add check that inherited pseudo still in
	memory.

From-SVN: r202468
This commit is contained in:
Vladimir Makarov 2013-09-10 15:37:57 +00:00 committed by Vladimir Makarov
parent 14c3433049
commit b0681c9e51
3 changed files with 62 additions and 25 deletions

View File

@ -1,3 +1,16 @@
2013-09-10 Vladimir Makarov <vmakarov@redhat.com>
* lra.c (lra): Clear lra_optional_reload_pseudos before every
constraint pass.
* lra-constraints.c (curr_insn_transform): Switch on optional
reloads. Check destination too to check move insn.
(undo_optional_reloads): Add check that the original peudo did not
changed its allocation and the optional reload was inherited on
last inheritance pass. Break loop after deciding to keep optional
reload.
(lra_undo_inheritance): Add check that inherited pseudo still in
memory.
2013-09-10 James Greenhalgh <james.greenhalgh@arm.com> 2013-09-10 James Greenhalgh <james.greenhalgh@arm.com>
* config/aarch64/aarch64.md (generic_sched): New. * config/aarch64/aarch64.md (generic_sched): New.

View File

@ -3309,15 +3309,19 @@ curr_insn_transform (void)
reg, we might improve the code through inheritance. If reg, we might improve the code through inheritance. If
it does not get a hard register we coalesce memory/memory it does not get a hard register we coalesce memory/memory
moves later. Ignore move insns to avoid cycling. */ moves later. Ignore move insns to avoid cycling. */
if (0 && ! lra_simple_p if (! lra_simple_p
&& lra_undo_inheritance_iter < LRA_MAX_INHERITANCE_PASSES && lra_undo_inheritance_iter < LRA_MAX_INHERITANCE_PASSES
&& goal_alt[i] != NO_REGS && REG_P (op) && goal_alt[i] != NO_REGS && REG_P (op)
&& (regno = REGNO (op)) >= FIRST_PSEUDO_REGISTER && (regno = REGNO (op)) >= FIRST_PSEUDO_REGISTER
&& ! lra_former_scratch_p (regno)
&& reg_renumber[regno] < 0 && reg_renumber[regno] < 0
&& (curr_insn_set == NULL_RTX && (curr_insn_set == NULL_RTX
|| !(REG_P (SET_SRC (curr_insn_set)) || !((REG_P (SET_SRC (curr_insn_set))
|| MEM_P (SET_SRC (curr_insn_set)) || MEM_P (SET_SRC (curr_insn_set))
|| GET_CODE (SET_SRC (curr_insn_set)) == SUBREG))) || GET_CODE (SET_SRC (curr_insn_set)) == SUBREG)
&& (REG_P (SET_DEST (curr_insn_set))
|| MEM_P (SET_DEST (curr_insn_set))
|| GET_CODE (SET_DEST (curr_insn_set)) == SUBREG))))
optional_p = true; optional_p = true;
else else
continue; continue;
@ -5441,7 +5445,7 @@ remove_inheritance_pseudos (bitmap remove_pseudos)
static bool static bool
undo_optional_reloads (void) undo_optional_reloads (void)
{ {
bool change_p; bool change_p, keep_p;
unsigned int regno, uid; unsigned int regno, uid;
bitmap_iterator bi, bi2; bitmap_iterator bi, bi2;
rtx insn, set, src, dest; rtx insn, set, src, dest;
@ -5451,26 +5455,42 @@ undo_optional_reloads (void)
bitmap_copy (&removed_optional_reload_pseudos, &lra_optional_reload_pseudos); bitmap_copy (&removed_optional_reload_pseudos, &lra_optional_reload_pseudos);
EXECUTE_IF_SET_IN_BITMAP (&lra_optional_reload_pseudos, 0, regno, bi) EXECUTE_IF_SET_IN_BITMAP (&lra_optional_reload_pseudos, 0, regno, bi)
if (reg_renumber[regno] >= 0) if (reg_renumber[regno] >= 0)
EXECUTE_IF_SET_IN_BITMAP (&lra_reg_info[regno].insn_bitmap, 0, uid, bi2) {
{ keep_p = false;
insn = lra_insn_recog_data[uid]->insn; if (reg_renumber[lra_reg_info[regno].restore_regno] >= 0)
if ((set = single_set (insn)) == NULL_RTX) /* If the original pseudo changed its allocation, just
continue; removing the optional pseudo is dangerous as the original
src = SET_SRC (set); pseudo will have longer live range. */
dest = SET_DEST (set); keep_p = true;
if (! REG_P (src) || ! REG_P (dest)) else
continue; EXECUTE_IF_SET_IN_BITMAP (&lra_reg_info[regno].insn_bitmap, 0, uid, bi2)
if ((REGNO (src) == regno
&& lra_reg_info[regno].restore_regno != (int) REGNO (dest))
|| (REGNO (dest) == regno
&& lra_reg_info[regno].restore_regno != (int) REGNO (src)))
{ {
/* Optional reload was inherited. Keep it. */ insn = lra_insn_recog_data[uid]->insn;
bitmap_clear_bit (&removed_optional_reload_pseudos, regno); if ((set = single_set (insn)) == NULL_RTX)
if (lra_dump_file != NULL) continue;
fprintf (lra_dump_file, "Keep optional reload reg %d\n", regno); src = SET_SRC (set);
dest = SET_DEST (set);
if (! REG_P (src) || ! REG_P (dest))
continue;
if (REGNO (dest) == regno
/* Ignore insn for optional reloads itself. */
&& lra_reg_info[regno].restore_regno != (int) REGNO (src)
/* Check only inheritance on last inheritance pass. */
&& (int) REGNO (src) >= new_regno_start
/* Check that the optional reload was inherited. */
&& bitmap_bit_p (&lra_inheritance_pseudos, REGNO (src)))
{
keep_p = true;
break;
}
} }
} if (keep_p)
{
bitmap_clear_bit (&removed_optional_reload_pseudos, regno);
if (lra_dump_file != NULL)
fprintf (lra_dump_file, "Keep optional reload reg %d\n", regno);
}
}
change_p = ! bitmap_empty_p (&removed_optional_reload_pseudos); change_p = ! bitmap_empty_p (&removed_optional_reload_pseudos);
bitmap_initialize (&insn_bitmap, &reg_obstack); bitmap_initialize (&insn_bitmap, &reg_obstack);
EXECUTE_IF_SET_IN_BITMAP (&removed_optional_reload_pseudos, 0, regno, bi) EXECUTE_IF_SET_IN_BITMAP (&removed_optional_reload_pseudos, 0, regno, bi)
@ -5552,7 +5572,11 @@ lra_undo_inheritance (void)
if (lra_reg_info[regno].restore_regno >= 0) if (lra_reg_info[regno].restore_regno >= 0)
{ {
n_all_inherit++; n_all_inherit++;
if (reg_renumber[regno] < 0) if (reg_renumber[regno] < 0
/* If the original pseudo changed its allocation, just
removing inheritance is dangerous as for changing
allocation we used shorter live-ranges. */
&& reg_renumber[lra_reg_info[regno].restore_regno] < 0)
bitmap_set_bit (&remove_pseudos, regno); bitmap_set_bit (&remove_pseudos, regno);
else else
n_inherit++; n_inherit++;

View File

@ -2315,6 +2315,7 @@ lra (FILE *f)
{ {
for (;;) for (;;)
{ {
bitmap_clear (&lra_optional_reload_pseudos);
/* We should try to assign hard registers to scratches even /* We should try to assign hard registers to scratches even
if there were no RTL transformations in if there were no RTL transformations in
lra_constraints. */ lra_constraints. */
@ -2365,7 +2366,6 @@ lra (FILE *f)
if (! live_p) if (! live_p)
lra_clear_live_ranges (); lra_clear_live_ranges ();
} }
bitmap_clear (&lra_optional_reload_pseudos);
} }
bitmap_clear (&lra_subreg_reload_pseudos); bitmap_clear (&lra_subreg_reload_pseudos);
bitmap_clear (&lra_inheritance_pseudos); bitmap_clear (&lra_inheritance_pseudos);