[new-ra] constraint modifiers bugfix, spilling dead webs

Denis Chertykov denisc@overta.ru
Thu Dec 18 19:06:00 GMT 2003


Michael Matz <matz@suse.de> writes:

> Hi Denis,
> 
> On Sun, 14 Dec 2003, Denis Chertykov wrote:
> 
> >  - wrong handling of '#' constraint modifier;
> 
> Of course this now means, that you might end up with more reloads later.
> I think this change will make the code worse.

Yes. The code will be worse but it will be correct.
Without this fix allocator can permit incorrect regclass and you will
have a true reloads after allocation. (I just repeat you)

Why you think that reloads after incorrect allocation will be better
then pre-reloads or spilling made by allocator ?

I think that significantly better to have a correct insns and remove
reload at all.

> >  - wrong handling of '*' constraint modifier;
> 
> The documentation of '*' says that only the next letter (not the whole
> rest of alternative) is ignored for register preferences.

You rigth.
The corrected patch at end of file.

I have founded this strange things (wrong '#' and '*') because I have
started experiments with 'regclass' for choosing class
preferrences for webs. (I remember that you don't like 'regclass'.)
I want to prepare statistic results and send it to you.
The statistic will show how many webs have a wrong regclass choosed by
pre-reload and why this happened.

Denis.



2003-12-14  Denis Chertykov  <denisc@overta.ru>

	* ra.c (all_allocatable_regs): New variable. All registers
	which can be used by allocator.
	(init_ra): Calculate all_allocatable_regs.
	* ra.h: Declare all_allocatable_regs.

	* ra-build.c (web_class): Use all_allocatable_regs instead of
	contents of GENERAL_REGS because all_allocatable_regs may be
	wider.

	* ra-colorize.c (colorize_one_web): Disable usage of "dead"
	webs for spilling.

	* pre-reload.c (scan_alternative): Ignore all constraint in an
	alternative marked by '*' modifier because current pre-reload
	work as regclass. This must increase colorability.
	Ignore rest of alternative marked by '#' modifier.

Index: pre-reload.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/pre-reload.c,v
retrieving revision 1.1.2.22
diff -c -3 -p -r1.1.2.22 pre-reload.c
*** pre-reload.c	27 Oct 2003 20:00:57 -0000	1.1.2.22
--- pre-reload.c	18 Dec 2003 18:17:08 -0000
*************** scan_alternative (this_alt, constraints,
*** 2368,2374 ****
  	    break;
  		
  	  case '*':
! 	    reject += 4;
  	    break;
  
  	  case '%':
--- 2368,2379 ----
  	    break;
  		
  	  case '*':
! 	    /* Ignore next constraint because it's reloading.
! 	       It's not a regclass.  */
! 	    c = *++p;
! 	    len = 0;
! 	    if (c && c != ',')
! 	      len = CONSTRAINT_LEN (c, p);
  	    break;
  
  	  case '%':
*************** scan_alternative (this_alt, constraints,
*** 2389,2401 ****
  	  case '#':
  	    /* Ignore rest of this alternative as far as
  	       reloading is concerned.  */
! 	    if (match_seen)
! 	      {
! 		do
! 		  p++;
! 		while (*p && *p != ',');
! 		len = 0;
! 	      }
  	    break;
  
  	  case '0':  case '1':  case '2':  case '3':  case '4':
--- 2394,2403 ----
  	  case '#':
  	    /* Ignore rest of this alternative as far as
  	       reloading is concerned.  */
! 	    do
! 	      p++;
! 	    while (*p && *p != ',');
! 	    len = 0;
  	    break;
  
  	  case '0':  case '1':  case '2':  case '3':  case '4':
Index: ra-build.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ra-build.c,v
retrieving revision 1.1.2.26
diff -c -3 -p -r1.1.2.26 ra-build.c
*** ra-build.c	6 Nov 2003 17:07:02 -0000	1.1.2.26
--- ra-build.c	18 Dec 2003 18:18:21 -0000
*************** web_class (web)
*** 3973,3979 ****
  		c = class;
  		/* FIXME denisc@overta.ru
  		   I have disabled the `web_class_spill_ref'.  */
! 		class = GENERAL_REGS;
  		break;
  	      }
  	    if (!blocks)
--- 3973,3980 ----
  		c = class;
  		/* FIXME denisc@overta.ru
  		   I have disabled the `web_class_spill_ref'.  */
! 		class = NO_REGS;
! 		n = 2;
  		break;
  	      }
  	    if (!blocks)
*************** web_class (web)
*** 3996,4005 ****
    else
      {
        /* XXX Ugly hack to suppress repeated spilling tries for such webs.  */
!       if (!class_ok_for_mode (class, PSEUDO_REGNO_MODE (web->regno)))
! 	class = GENERAL_REGS;
!       web->regclass = class;
!       COPY_HARD_REG_SET (web->usable_regs, usable_regs[class]);
      }
  
    if (already_insn)
--- 3997,4012 ----
    else
      {
        /* XXX Ugly hack to suppress repeated spilling tries for such webs.  */
!       if (class_ok_for_mode (class, PSEUDO_REGNO_MODE (web->regno)))
! 	{
! 	  web->regclass = class;
! 	  COPY_HARD_REG_SET (web->usable_regs, usable_regs[class]);
! 	}
!       else
! 	{
! 	  class = GENERAL_REGS;
! 	  COPY_HARD_REG_SET (web->usable_regs, all_allocatable_regs);
! 	}
      }
  
    if (already_insn)
Index: ra.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ra.c,v
retrieving revision 1.1.2.76
diff -c -3 -p -r1.1.2.76 ra.c
*** ra.c	29 Oct 2003 13:59:24 -0000	1.1.2.76
--- ra.c	18 Dec 2003 18:19:33 -0000
*************** HARD_REG_SET usable_regs[N_REG_CLASSES];
*** 153,158 ****
--- 153,159 ----
  unsigned int num_free_regs[N_REG_CLASSES];
  HARD_REG_SET hardregs_for_mode[NUM_MACHINE_MODES];
  HARD_REG_SET invalid_mode_change_regs;
+ HARD_REG_SET all_allocatable_regs;
  unsigned char byte2bitcount[256];
  
  /* Used to detect spill instructions inserted by me.  */
*************** init_ra (void)
*** 609,614 ****
--- 610,616 ----
        size = hard_regs_count (rs);
        num_free_regs[i] = size;
        COPY_HARD_REG_SET (usable_regs[i], rs);
+       IOR_HARD_REG_SET (all_allocatable_regs, rs);
      }
  
    /* Setup hardregs_for_mode[].
Index: ra-colorize.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ra-colorize.c,v
retrieving revision 1.1.2.19
diff -c -3 -p -r1.1.2.19 ra-colorize.c
*** ra-colorize.c	10 Nov 2003 12:27:41 -0000	1.1.2.19
--- ra-colorize.c	18 Dec 2003 18:20:32 -0000
*************** colorize_one_web (struct web *web, int h
*** 1549,1555 ****
  		     becoming recolored higher up in the recursion stack.
  		     This would screw up the roll back of the neighbors
  		     of _that_ web, when some got a color in between.  */
! 		  || bitmap_bit_p (webs_in_recoloring, aw->id))
  		continue;
  	      else
  		{
--- 1549,1557 ----
  		     becoming recolored higher up in the recursion stack.
  		     This would screw up the roll back of the neighbors
  		     of _that_ web, when some got a color in between.  */
! 		  || bitmap_bit_p (webs_in_recoloring, aw->id)
! 		  /* We can't spill dead webs.  */
! 		  || find_web_for_subweb (w)->num_uses == 0)
  		continue;
  	      else
  		{
Index: ra.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ra.h,v
retrieving revision 1.1.2.13
diff -c -3 -p -r1.1.2.13 ra.h
*** ra.h	27 Oct 2003 20:00:57 -0000	1.1.2.13
--- ra.h	18 Dec 2003 18:21:05 -0000
*************** extern unsigned int num_free_regs[N_REG_
*** 519,524 ****
--- 519,526 ----
  extern HARD_REG_SET hardregs_for_mode[NUM_MACHINE_MODES];
  /* The set of hardregs, for which _any_ mode change is invalid.  */
  extern HARD_REG_SET invalid_mode_change_regs;
+ /* Regset of all registers which can be used for allocation.  */
+ extern HARD_REG_SET all_allocatable_regs;
  /* For 0 <= I <= 255, the number of bits set in I.  Used to calculate
     the number of set bits in a HARD_REG_SET.  */
  extern unsigned char byte2bitcount[256];



More information about the Gcc-patches mailing list