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]
Other format: [Raw text]

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


Hi Michael.

I have found a few bugs inside pre-reload.c and ra-colorize.c they
are:
 - wrong handling of '#' constraint modifier;
 - wrong handling of '*' constraint modifier;
 - spilling dead webs by colorize_one_web.

Bootstrapped with c, c++, java, f77.


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: 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	14 Dec 2003 07:44:32 -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	14 Dec 2003 07:46:50 -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	14 Dec 2003 07:48:33 -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	14 Dec 2003 07:49:53 -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];
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	14 Dec 2003 07:50:40 -0000
*************** scan_alternative (this_alt, constraints,
*** 2368,2374 ****
  	    break;
  		
  	  case '*':
! 	    reject += 4;
  	    break;
  
  	  case '%':
--- 2368,2379 ----
  	    break;
  		
  	  case '*':
! 	    /* Ignore rest of this alternative because it's reloading.
! 	       It's not a regclass.  */
! 	    do
! 	      p++;
! 	    while (*p && *p != ',');
! 	    len = 0;
  	    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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]