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]

[RFA] fix PR/26778 by reapplying a reverted patch


PR/26778 is about a bad choice of registers made by regclass, which uses a SSE register to "spill" a value even though the move will need to go through memory.

The PR is fixed by Dale Johannesen's patch that allows regclass to suggest storing a pseudo directly in memory. A part of the PR/19653 fix, it caused two latent bugs to surface. One was a rs6000 issue with TOCs which was fixed by David Edelsohn.

The other was PR27117 (the sh issue where the back-end lies to reload). Joern approved a sh-only patch to fix it, so Dale's patch could go in again. It is attached and it was bootstrapped i686-pc-linux-gnu for all languages except Ada. In addition, Richard Guenther bootstrapped & tested the patch with no regressions on ia64, ppc, x86_64, s390, everywhere including Ada but not Java (it was broken at the time I asked).

I don't know if I can self-approve a reversion of a reversion. Anyway the patch caused some bugs to appear in the past, and though I think they're all fixed, this alone would be a reason to ask for approval. Ok for mainline?

Paolo
2005-08-08  Paolo Bonzini  <bonzini@gnu.org>
            Dale Johannesen  <dalej@apple.com>

	PR target/26778
	* regclass.c (struct reg_pref): Update documentation.
	(regclass): Set prefclass to NO_REGS if memory is the best option.
	(record_reg_classes): Cope with a prefclass set to NO_REGS.

Index: regclass.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/regclass.c,v
retrieving revision 1.206
diff -u -b -r1.206 regclass.c
--- regclass.c	25 Jun 2005 02:00:52 -0000	1.206
+++ regclass.c	27 Jul 2005 06:04:40 -0000
@@ -838,7 +838,8 @@
 /* Structure used to record preferences of given pseudo.  */
 struct reg_pref
 {
-  /* (enum reg_class) prefclass is the preferred class.  */
+  /* (enum reg_class) prefclass is the preferred class.  May be
+     NO_REGS if no class is better than memory.  */
   char prefclass;
 
   /* altclass is a register class that we should use for allocating
@@ -1321,6 +1322,10 @@
 		best = reg_class_subunion[(int) best][class];
 	    }
 
+	  /* If no register class is better than memory, use memory. */
+	  if (p->mem_cost < best_cost)
+	    best = NO_REGS;
+
 	  /* Record the alternate register class; i.e., a class for which
 	     every register in it is better than using memory.  If adding a
 	     class would make a smaller class (i.e., no union of just those
@@ -1528,7 +1533,7 @@
 		     to what we would add if this register were not in the
 		     appropriate class.  */
 
-		  if (reg_pref)
+		  if (reg_pref && reg_pref[REGNO (op)].prefclass != NO_REGS)
 		    alt_cost
 		      += (may_move_in_cost[mode]
 			  [(unsigned char) reg_pref[REGNO (op)].prefclass]
@@ -1754,7 +1759,7 @@
 		     to what we would add if this register were not in the
 		     appropriate class.  */
 
-		  if (reg_pref)
+		  if (reg_pref && reg_pref[REGNO (op)].prefclass != NO_REGS)
 		    alt_cost
 		      += (may_move_in_cost[mode]
 			  [(unsigned char) reg_pref[REGNO (op)].prefclass]
@@ -1840,7 +1845,8 @@
 	  int class;
 	  unsigned int nr;
 
-	  if (regno >= FIRST_PSEUDO_REGISTER && reg_pref != 0)
+	  if (regno >= FIRST_PSEUDO_REGISTER && reg_pref != 0
+	      && reg_pref[regno].prefclass != NO_REGS)
 	    {
 	      enum reg_class pref = reg_pref[regno].prefclass;
 

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