This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
rtlopt merge part 6 - tiny 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: Fri, 7 Feb 2003 02:24:56 +0100
- Subject: rtlopt merge part 6 - tiny regrename improvement
Hi,
tiny patch I noticed sitting on the rtlopt branch. Regrename deals
quite poorly in the case the replacement failed - the ticks are not
modified and next time it often chose the same register as was used by
the insn updating failed for.
This is common for eax on i386 at least.
It makes measurable improvement for i386, but it is tiny as well :)
Fri Feb 7 02:20:25 CET 2003 Jan Hubicka <jh@suse.cz>
* regrename.c (regrename_optimize): Deal better with situation when
replacement failed.
*** regrename.c Mon Dec 16 19:19:50 2002
--- /aux/hubicka/rtlopt/gcc/gcc/regrename.c Thu Feb 6 12:30:31 2003
*************** 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]);
*************** do_replace (chain, reg)
*** 377,385 ****
--- 379,390 ----
while (chain)
{
unsigned int regno = ORIGINAL_REGNO (*chain->loc);
+ struct reg_attrs * attr = REG_ATTRS (*chain->loc);
+
*chain->loc = gen_raw_REG (GET_MODE (*chain->loc), reg);
if (regno >= FIRST_PSEUDO_REGISTER)
ORIGINAL_REGNO (*chain->loc) = regno;
+ REG_ATTRS (*chain->loc) = attr;
chain = chain->next_use;
}
}
*************** find_oldest_value_reg (class, reg, vd)
*** 1393,1398 ****
--- 1398,1404 ----
regno)))
{
ORIGINAL_REGNO (new) = ORIGINAL_REGNO (reg);
+ REG_ATTRS (new) = REG_ATTRS (reg);
return new;
}
}
*************** copyprop_hardreg_forward_1 (bb, vd)
*** 1686,1691 ****
--- 1692,1698 ----
if (validate_change (insn, &SET_SRC (set), new, 0))
{
ORIGINAL_REGNO (new) = ORIGINAL_REGNO (src);
+ REG_ATTRS (new) = REG_ATTRS (src);
if (rtl_dump_file)
fprintf (rtl_dump_file,
"insn %u: replaced reg %u with %u\n",