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]

Fix approx_reg_cost



Here is the patch I originally was trying to regression test
for the mainline before I got stuck on the Sparc regressions
existing before my change :-)

Anyways, as mentioned on the gcc list earlier this week
approx_reg_cost is implemented with regsets which makes it
much more heavy than it needs to be, fix by just doing all
the counter bumping work in the for_each_rtx callback.

Mainline only.

2002-05-23  David S. Miller  <davem@redhat.com>

	* cse.c (approx_reg_cost_1, approx_reg_cost): Recode to not use
	regsets.

--- cse.c.~1~	Tue May 21 00:44:03 2002
+++ cse.c	Thu May 23 01:06:10 2002
@@ -720,10 +720,25 @@ approx_reg_cost_1 (xp, data)
      void *data;
 {
   rtx x = *xp;
-  regset set = (regset) data;
+  int *cost_p = data;
 
   if (x && GET_CODE (x) == REG)
-    SET_REGNO_REG_SET (set, REGNO (x));
+    {
+      unsigned int regno = REGNO (x);
+
+      if (! CHEAP_REGNO (regno))
+	{
+	  if (regno < FIRST_PSEUDO_REGISTER)
+	    {
+	      if (SMALL_REGISTER_CLASSES)
+		return 1;
+	      *cost_p += 2;
+	    }
+	  else
+	    *cost_p += 1;
+	}
+    }
+
   return 0;
 }
 
@@ -736,28 +751,12 @@ static int
 approx_reg_cost (x)
      rtx x;
 {
-  regset_head set;
-  int i;
   int cost = 0;
-  int hardregs = 0;
-
-  INIT_REG_SET (&set);
-  for_each_rtx (&x, approx_reg_cost_1, (void *) &set);
 
-  EXECUTE_IF_SET_IN_REG_SET
-    (&set, 0, i,
-     {
-       if (! CHEAP_REGNO (i))
-	 {
-	   if (i < FIRST_PSEUDO_REGISTER)
-	     hardregs++;
-
-	   cost += i < FIRST_PSEUDO_REGISTER ? 2 : 1;
-	 }
-     });
+  if (for_each_rtx (&x, approx_reg_cost_1, (void *) &cost))
+    return MAX_COST;
 
-  CLEAR_REG_SET (&set);
-  return hardregs && SMALL_REGISTER_CLASSES ? MAX_COST : cost;
+  return cost;
 }
 
 /* Return a negative value if an rtx A, whose costs are given by COST_A


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