This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

minor regrename improvements


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 register even
if our replacement has failed.

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.

BTW are these any plans to update debug information in the reg-rename pass
so it can be enabled by default for -O2?

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/egcs/gcc/regrename.c,v
retrieving revision 1.22
diff -c -3 -p -r1.22 regrename.c
*** regrename.c	2001/05/19 05:59:52	1.22
--- regrename.c	2001/06/25 12:24:22
*************** regrename_optimize ()
*** 233,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;
  	  HARD_REG_SET this_unavailable;
  	  int reg = REGNO (*this->loc), treg;
  	  int nregs = HARD_REGNO_NREGS (reg, GET_MODE (*this->loc));
  	  int i;
  
--- 233,244 ----
        CLEAR_HARD_REG_SET (regs_seen);
        while (all_chains)
  	{
  	  int n_uses;
  	  struct du_chain *this = all_chains;
  	  struct du_chain *tmp, *last;
  	  HARD_REG_SET this_unavailable;
  	  int reg = REGNO (*this->loc), treg;
+ 	  int new_reg, best_new_reg = reg;
  	  int nregs = HARD_REGNO_NREGS (reg, GET_MODE (*this->loc));
  	  int i;
  
*************** regrename_optimize ()
*** 318,325 ****
  		  break;
  	      if (! tmp)
  		{
! 		  if (best_new_reg == -1
! 		      || tick[best_new_reg] > tick[new_reg])
  		    best_new_reg = new_reg;
  		}
  	    }
--- 318,324 ----
  		  break;
  	      if (! tmp)
  		{
! 		  if (tick[best_new_reg] > tick[new_reg])
  		    best_new_reg = new_reg;
  		}
  	    }
*************** regrename_optimize ()
*** 332,346 ****
  		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]);
--- 331,346 ----
  		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]);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]