This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
updated patch: minor regrename improvement
- From: Jan Hubicka <jh at suse dot cz>
- To: gcc-patches at gcc dot gnu dot org, rth at cygnus dot com
- Date: Wed, 1 Jan 2003 18:33:29 +0100
- Subject: updated patch: minor regrename improvement
Hi,
On the simple testcase:
float a,b,c,d;
test()
{
a=b;
c=d;
}
regrename pass renames both uses from eax to edx, as tick counter
is initialized to 0 and the tick for first use is not taken into account.
Similary I think we should take into account the use of original
register when our replacement has failed so we won't reuse it early.
Last modification is that I've made code to choose old register to be
best choice at the begginig. This avoid uneeded renaming and improves
code, as the old register wasn't taken into account previously at all.
Honza
Mon Jun 25 14:24:32 CEST 2001 Jan Hubicka <jh@suse.cz>
* regrename.c (regrename_optimize): Initialize best_reg to reg;
increment tick first; set tick even if replacement failed.
Index: regrename.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/regrename.c,v
retrieving revision 1.59.2.4
diff -c -3 -p -r1.59.2.4 regrename.c
*** regrename.c 8 Dec 2002 14:36:33 -0000 1.59.2.4
--- regrename.c 1 Jan 2003 17:18:49 -0000
*************** regrename_optimize ()
*** 238,244 ****
CLEAR_HARD_REG_SET (regs_seen);
while (all_chains)
{
! int new_reg, best_new_reg = -1;
int n_uses;
struct du_chain *this = all_chains;
struct du_chain *tmp, *last;
--- 238,244 ----
CLEAR_HARD_REG_SET (regs_seen);
while (all_chains)
{
! int new_reg, best_new_reg;
int n_uses;
struct du_chain *this = all_chains;
struct du_chain *tmp, *last;
*************** regrename_optimize ()
*** 248,253 ****
--- 248,255 ----
all_chains = this->next_chain;
+ best_new_reg = reg;
+
#if 0 /* This just disables optimization opportunities. */
/* Only rename once we've seen the reg more than once. */
if (! TEST_HARD_REG_BIT (regs_seen, reg))
*************** regrename_optimize ()
*** 328,335 ****
break;
if (! tmp)
{
! if (best_new_reg == -1
! || tick[best_new_reg] > tick[new_reg])
best_new_reg = new_reg;
}
}
--- 330,336 ----
break;
if (! tmp)
{
! if (tick[best_new_reg] > tick[new_reg])
best_new_reg = new_reg;
}
}
*************** regrename_optimize ()
*** 342,356 ****
fprintf (rtl_dump_file, " crosses a call");
}
! if (best_new_reg == -1)
{
if (rtl_dump_file)
! fprintf (rtl_dump_file, "; no available registers\n");
continue;
}
do_replace (this, best_new_reg);
! tick[best_new_reg] = this_tick++;
if (rtl_dump_file)
fprintf (rtl_dump_file, ", renamed as %s\n", reg_names[best_new_reg]);
--- 343,358 ----
fprintf (rtl_dump_file, " crosses a call");
}
! if (best_new_reg == reg)
{
+ tick[reg] = ++this_tick;
if (rtl_dump_file)
! fprintf (rtl_dump_file, "; no available better choice\n");
continue;
}
do_replace (this, best_new_reg);
! tick[best_new_reg] = ++this_tick;
if (rtl_dump_file)
fprintf (rtl_dump_file, ", renamed as %s\n", reg_names[best_new_reg]);