This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
move register renaming before sched2
- To: gcc-patches at gcc dot gnu dot org
- Subject: move register renaming before sched2
- From: Stan Cox <scox at cygnus dot com>
- Date: Wed, 10 May 2000 18:48:56 -0700 (PDT)
This patch moves register renaming before sched2. It also improves the
REG_DEAD handling in insns containing renamed registers.
2000-05-10 Stan Cox <scox@cygnus.com>
* regrename.c (replace_reg_in_block): Improve REG_DEAD handling.
* timevar.def (TV_RENAME_REGISTERS): Move before TV_SCHED2.
* toplev.c (rest_of_compilation): Call regrename_optimize before sched2.
Index: timevar.def
===================================================================
RCS file: /cvs/gcc/egcs/gcc/timevar.def,v
retrieving revision 1.2
diff -c -2 -p -r1.2 timevar.def
*** timevar.def 2000/04/30 11:01:53 1.2
--- timevar.def 2000/05/11 01:13:31
*************** DEFTIMEVAR (TV_FLOW2 , "
*** 61,68 ****
DEFTIMEVAR (TV_IFCVT2 , "if-conversion 2")
DEFTIMEVAR (TV_PEEPHOLE2 , "peephole 2")
! DEFTIMEVAR (TV_SCHED2 , "schedulding 2")
DEFTIMEVAR (TV_DBR_SCHED , "delay branch sched")
DEFTIMEVAR (TV_REORDER_BLOCKS , "reorder blocks")
- DEFTIMEVAR (TV_RENAME_REGISTERS , "rename registers")
DEFTIMEVAR (TV_SHORTEN_BRANCH , "shorten branches")
DEFTIMEVAR (TV_REG_STACK , "reg stack")
--- 61,68 ----
DEFTIMEVAR (TV_IFCVT2 , "if-conversion 2")
DEFTIMEVAR (TV_PEEPHOLE2 , "peephole 2")
! DEFTIMEVAR (TV_RENAME_REGISTERS , "rename registers")
! DEFTIMEVAR (TV_SCHED2 , "scheduling 2")
DEFTIMEVAR (TV_DBR_SCHED , "delay branch sched")
DEFTIMEVAR (TV_REORDER_BLOCKS , "reorder blocks")
DEFTIMEVAR (TV_SHORTEN_BRANCH , "shorten branches")
DEFTIMEVAR (TV_REG_STACK , "reg stack")
Index: toplev.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/toplev.c,v
retrieving revision 1.333
diff -c -2 -p -r1.333 toplev.c
*** toplev.c 2000/05/09 19:55:48 1.333
--- toplev.c 2000/05/11 01:13:35
*************** enum dump_file_index
*** 273,279 ****
DFI_ce2,
DFI_peephole2,
DFI_sched2,
DFI_bbro,
- DFI_rnreg,
DFI_jump2,
DFI_mach,
--- 273,279 ----
DFI_ce2,
DFI_peephole2,
+ DFI_rnreg,
DFI_sched2,
DFI_bbro,
DFI_jump2,
DFI_mach,
*************** struct dump_file_info dump_file[DFI_MAX]
*** 315,321 ****
{ "ce2", 'E', 1, 0, 0 },
{ "peephole2", 'z', 1, 0, 0 },
{ "sched2", 'R', 1, 0, 0 },
{ "bbro", 'B', 1, 0, 0 },
- { "rnreg", 'n', 1, 0, 0 },
{ "jump2", 'J', 1, 0, 0 },
{ "mach", 'M', 1, 0, 0 },
--- 315,321 ----
{ "ce2", 'E', 1, 0, 0 },
{ "peephole2", 'z', 1, 0, 0 },
+ { "rnreg", 'n', 1, 0, 0 },
{ "sched2", 'R', 1, 0, 0 },
{ "bbro", 'B', 1, 0, 0 },
{ "jump2", 'J', 1, 0, 0 },
{ "mach", 'M', 1, 0, 0 },
*************** rest_of_compilation (decl)
*** 3358,3362 ****
life_analysis (insns, rtl_dump_file, PROP_FINAL);
! /* This is kind of heruistics. We need to run combine_stack_adjustments
even for machines with possibly nonzero RETURN_POPS_ARGS
and ACCUMULATE_OUTGOING_ARGS. We expect that only ports having
--- 3358,3362 ----
life_analysis (insns, rtl_dump_file, PROP_FINAL);
! /* This is kind of a heuristic. We need to run combine_stack_adjustments
even for machines with possibly nonzero RETURN_POPS_ARGS
and ACCUMULATE_OUTGOING_ARGS. We expect that only ports having
*************** rest_of_compilation (decl)
*** 3400,3403 ****
--- 3400,3414 ----
#endif
+ if (optimize > 0 && flag_rename_registers)
+ {
+ timevar_push (TV_RENAME_REGISTERS);
+ open_dump_file (DFI_rnreg, decl);
+
+ regrename_optimize ();
+
+ close_dump_file (DFI_rnreg, print_rtl_with_bb, insns);
+ timevar_pop (TV_RENAME_REGISTERS);
+ }
+
#ifdef INSN_SCHEDULING
if (optimize > 0 && flag_schedule_insns_after_reload)
*************** rest_of_compilation (decl)
*** 3433,3447 ****
close_dump_file (DFI_bbro, print_rtl_with_bb, insns);
timevar_pop (TV_REORDER_BLOCKS);
- }
-
- if (optimize > 0 && flag_rename_registers)
- {
- timevar_push (TV_RENAME_REGISTERS);
- open_dump_file (DFI_rnreg, decl);
-
- regrename_optimize ();
-
- close_dump_file (DFI_rnreg, print_rtl_with_bb, insns);
- timevar_pop (TV_RENAME_REGISTERS);
}
--- 3444,3447 ----
Index: regrename.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/regrename.c,v
retrieving revision 1.5
diff -c -2 -p -r1.5 regrename.c
*** regrename.c 2000/04/10 11:23:17 1.5
--- regrename.c 2000/05/11 01:13:31
*************** replace_reg_in_block (du, uid_ruid, def,
*** 527,532 ****
--- 527,535 ----
{
int du_idx, status = 1;
+ int last_replaced_insn;
unsigned int r = REGNO (reg_def);
rtx death_note;
+ rtx reg_notes;
+ rtx reg_use;
rtx new_reg = gen_rtx_REG (GET_MODE (reg_def), avail_reg);
*************** replace_reg_in_block (du, uid_ruid, def,
*** 537,561 ****
return status;
! death_note = find_reg_note (VARRAY_RTX (*uid_ruid, def), REG_DEAD, reg_def);
! if (!death_note)
! death_note = find_reg_note (VARRAY_RTX (*uid_ruid, def), REG_UNUSED,
! reg_def);
if (death_note)
! rr_replace_reg (death_note, reg_def, new_reg, 0,
! VARRAY_RTX (*uid_ruid, def), &status);
for (du_idx = def + 1; du_idx < du->high_bound; du_idx++)
{
- rtx reg_use;
- rtx new_reg;
-
if (GET_RTX_CLASS (GET_CODE (VARRAY_RTX (*uid_ruid, du_idx))) != 'i')
continue;
reg_use = regno_use_in (r, PATTERN (VARRAY_RTX (*uid_ruid, du_idx)));
if (reg_use && TEST_BIT (du->uses[r], du_idx))
{
new_reg = gen_rtx_REG (GET_MODE (reg_use), avail_reg);
rr_replace_reg (PATTERN (VARRAY_RTX (*uid_ruid, du_idx)), reg_use,
new_reg, SOURCE, VARRAY_RTX (*uid_ruid, du_idx),
--- 540,578 ----
return status;
! death_note = 0;
! /* This typically happens if a constraint check failed and the register
! changes are being reversed. */
! for (reg_notes = REG_NOTES (VARRAY_RTX (*uid_ruid, def));
! reg_notes; reg_notes = XEXP (reg_notes, 1))
! {
! if (REG_NOTE_KIND (reg_notes) == REG_DEAD
! && REGNO (XEXP (reg_notes, 0)) == avail_reg)
! death_note = reg_notes;
! }
if (death_note)
! remove_note (VARRAY_RTX (*uid_ruid, def), death_note);
!
! /* The old destination is now dead if it is also a source. */
! if (regno_use_in (r, PATTERN (VARRAY_RTX (*uid_ruid, def))))
! REG_NOTES (VARRAY_RTX (*uid_ruid, def))
! = gen_rtx_EXPR_LIST (REG_DEAD, reg_def,
! REG_NOTES (VARRAY_RTX (*uid_ruid,
! def)));
+ last_replaced_insn = 0;
+
+ /* Now replace in the uses. */
for (du_idx = def + 1; du_idx < du->high_bound; du_idx++)
{
if (GET_RTX_CLASS (GET_CODE (VARRAY_RTX (*uid_ruid, du_idx))) != 'i')
continue;
reg_use = regno_use_in (r, PATTERN (VARRAY_RTX (*uid_ruid, du_idx)));
+
if (reg_use && TEST_BIT (du->uses[r], du_idx))
{
new_reg = gen_rtx_REG (GET_MODE (reg_use), avail_reg);
+
rr_replace_reg (PATTERN (VARRAY_RTX (*uid_ruid, du_idx)), reg_use,
new_reg, SOURCE, VARRAY_RTX (*uid_ruid, du_idx),
*************** replace_reg_in_block (du, uid_ruid, def,
*** 563,573 ****
death_note = find_reg_note (VARRAY_RTX (*uid_ruid, du_idx),
REG_DEAD, reg_use);
- if (!death_note)
- death_note = find_reg_note (VARRAY_RTX (*uid_ruid, du_idx),
- REG_UNUSED, reg_use);
if (death_note)
! rr_replace_reg (death_note, reg_use, new_reg, 0,
! VARRAY_RTX (*uid_ruid, def), &status);
SET_BIT (du->uses[avail_reg], du_idx);
RESET_BIT (du->uses[r], du_idx);
--- 580,601 ----
death_note = find_reg_note (VARRAY_RTX (*uid_ruid, du_idx),
REG_DEAD, reg_use);
if (death_note)
! {
! REG_NOTES (VARRAY_RTX (*uid_ruid, du_idx))
! = gen_rtx_EXPR_LIST (REG_DEAD, new_reg,
! REG_NOTES (VARRAY_RTX (*uid_ruid,
! du_idx)));
! remove_note (VARRAY_RTX (*uid_ruid, du_idx),
! find_reg_note (VARRAY_RTX (*uid_ruid, du_idx),
! REG_DEAD, reg_use));
! }
! }
+ /* This insn may contain shared rtl replaced in the previous iteration.
+ Treat this equivalent to the rr_replace_reg case. */
+ if (TEST_BIT (du->uses[r], du_idx))
+ {
+ last_replaced_insn = du_idx;
+
SET_BIT (du->uses[avail_reg], du_idx);
RESET_BIT (du->uses[r], du_idx);
*************** replace_reg_in_block (du, uid_ruid, def,
*** 580,583 ****
--- 608,632 ----
}
+ /* Add REG_DEAD note for replaced register at last use. */
+
+ if (last_replaced_insn)
+ {
+ new_reg = regno_use_in (avail_reg,
+ PATTERN (VARRAY_RTX (*uid_ruid,
+ last_replaced_insn)));
+ if (new_reg
+ && ! find_reg_note (VARRAY_RTX (*uid_ruid, last_replaced_insn),
+ REG_DEAD, new_reg))
+ {
+ REG_NOTES (VARRAY_RTX (*uid_ruid, last_replaced_insn))
+ = gen_rtx_EXPR_LIST (REG_DEAD, new_reg,
+ REG_NOTES (VARRAY_RTX (*uid_ruid,
+ last_replaced_insn)));
+ remove_note (VARRAY_RTX (*uid_ruid, last_replaced_insn),
+ find_reg_note (VARRAY_RTX (*uid_ruid, last_replaced_insn),
+ REG_DEAD, reg_use));
+ }
+ }
+
return status;
}
*************** rr_replace_reg (x, reg_use, reg_sub, rep
*** 612,616 ****
return reg_sub;
else
! return gen_rtx_REG (GET_MODE (x), REGNO (reg_use));
}
--- 661,665 ----
return reg_sub;
else
! return gen_rtx_REG (GET_MODE (x), REGNO (reg_sub));
}