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]

Re: new-regalloc vs alpha


On Thu, Feb 01, 2001 at 12:47:31PM -0500, Daniel Berlin wrote:
> This (the above insn) happens because we try to follow the register
> allocation order, which says to try the float regs first, and since they
> seem okay to us, we do.

I'd have thought this was a second-order consequence of
not paying enough attention to the register move costs.
We see that GENERAL_REGS has a cost of 0, and FLOAT_REGS
has a cost of 6, but put the thing in FLOAT_REGS anyway.

I bet you'll find that the following helps a lot: try
find_reg_given_constraints on the preferred register class alone,
and if that fails, try the alternate register class alone.

> Maybe I should just ignore the allocation order, since all it seems to do
> is cause us problems?

You don'y want to do that entirely.  For instance, on Alpha the
incoming return address is in r26.  It is a Good Thing if we can
avoid killing that in leaf functions.  We should prefer to use
r27 and r28 before r26.  I don't think you can get this sort of
information anywhere else.


r~


[ Patch generated with -b, as I removed a set of braces.  ]

Index: new-regalloc.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/new-regalloc.c,v
retrieving revision 1.1.2.8
diff -c -p -d -b -r1.1.2.8 new-regalloc.c
*** new-regalloc.c	2001/02/01 17:14:22	1.1.2.8
--- new-regalloc.c	2001/02/01 21:13:38
*************** assign_regs()
*** 1322,1342 ****
    
    while (VARRAY_ACTIVE_SIZE(selectStack) != 0)
      {
-       /* Eliminate colors of neighbors */
        unsigned int currReg = VARRAY_TOP_UINT(selectStack);
!       enum reg_class pref_class, alt_class;
!       HARD_REG_SET okColors;
!       HARD_REG_SET avoid;
        
        VARRAY_POP(selectStack);
- 
-       pref_class = reg_preferred_class (currReg);
-       alt_class = reg_alternate_class (currReg);
-       COPY_HARD_REG_SET (okColors, reg_class_contents[pref_class]);
-       IOR_HARD_REG_SET (okColors, reg_class_contents[alt_class]);
-       AND_COMPL_HARD_REG_SET (okColors, fixed_reg_set);
-       
        
        EXECUTE_IF_SET_IN_SBITMAP (regInfo[currReg]->adjList, 0, entry,
          {
  	  unsigned int w = get_alias(entry);
--- 1322,1335 ----
  
    while (VARRAY_ACTIVE_SIZE(selectStack) != 0)
      {
        unsigned int currReg = VARRAY_TOP_UINT(selectStack);
!       enum reg_class pref;
!       HARD_REG_SET okColors, badColors, avoid;
  
        VARRAY_POP(selectStack);
  
+       /* Eliminate colors of neighbors.  Also exclude all fixed registers.  */
+       COPY_HARD_REG_SET (badColors, fixed_reg_set);
        EXECUTE_IF_SET_IN_SBITMAP (regInfo[currReg]->adjList, 0, entry,
          {
  	  unsigned int w = get_alias(entry);
*************** assign_regs()
*** 1347,1358 ****
  		{
  		  /* If one is a superset of the other, this should already
  		     handle it, because we'll still clear the right bits.  */
! 		  CLEAR_HARD_REG_BIT (okColors, index);
! 		  AND_COMPL_HARD_REG_SET (okColors, excluded[w]);
  		}
  	    }
  	});
!       /* Biased coloring, not finished yet by a long shot */
        if (biased_coloring)
  	{
  	  unsigned int best_color;
--- 1340,1352 ----
  		{
  		  /* If one is a superset of the other, this should already
  		     handle it, because we'll still clear the right bits.  */
! 		  SET_HARD_REG_BIT (badColors, index);
! 		  IOR_HARD_REG_SET (badColors, excluded[w]);
  		}
  	    }
  	});
! 
!       /* Biased coloring, not finished yet by a long shot.  */
        if (biased_coloring)
  	{
  	  unsigned int best_color;
*************** assign_regs()
*** 1377,1383 ****
  		else if (! TEST_BIT (spilledNodes, partner))
  		  {
  		    unsigned int m;
! 		    EXECUTE_IF_SET_IN_SBITMAP (regInfo[partner]->adjList, 0, m, 
  		    {
  		      unsigned int neighbor = get_alias(m);
  		      unsigned int color = colors[neighbor];
--- 1371,1378 ----
  		  else if (! TEST_BIT (spilledNodes, partner))
  		    {
  		      unsigned int m;
! 		      EXECUTE_IF_SET_IN_SBITMAP (regInfo[partner]->adjList,
! 						 0, m,
  		        {
  			  unsigned int neighbor = get_alias(m);
  			  unsigned int color = colors[neighbor];
*************** assign_regs()
*** 1388,1398 ****
  	      }
  	  });	    
  	}
-       /* Non-biased coloring stuff */
-       {
  	
  	firstOKBit = find_reg_given_constraints (okColors, currReg);
  	
  	if (firstOKBit == -1)
  	  {
  	    /* Couldn't find a color to set -- guess we have to spill.  */
--- 1383,1406 ----
  		}
  	    });
  	}
  
+       /* Non-biased coloring stuff.  */
+ 
+       /* First try the preferred register class.  */
+       pref = reg_preferred_class (currReg);
+       COPY_HARD_REG_SET (okColors, reg_class_contents[pref]);
+       AND_COMPL_HARD_REG_SET (okColors, badColors);
        firstOKBit = find_reg_given_constraints (okColors, currReg);
  
+       /* If that fails, try the alternate register class, if any.  */
+       if (firstOKBit == -1
+ 	  && (pref = reg_alternate_class (currReg)) != NO_REGS)
+ 	{
+ 	  COPY_HARD_REG_SET (okColors, reg_class_contents[pref]);
+ 	  AND_COMPL_HARD_REG_SET (okColors, badColors);
+ 	  firstOKBit = find_reg_given_constraints (okColors, currReg);
+ 	}
+ 
        if (firstOKBit == -1)
  	{
  	  /* Couldn't find a color to set -- guess we have to spill.  */
*************** assign_regs()
*** 1421,1427 ****
  		       currReg, colors[currReg]);
  	  }
        }
-     }
    
    /* Now take care of coalesced variables.  */
    EXECUTE_IF_SET_IN_SBITMAP (coalescedNodes, 0, entry,
--- 1429,1434 ----

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