Patchwork [rs6000] Tidy up dumping of register/memory move cost

login
register
mail settings
Submitter Pat Haugen
Date May 25, 2011, 7:02 p.m.
Message ID <4DDD523F.1030108@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/97400/
State New
Headers show

Comments

Pat Haugen - May 25, 2011, 7:02 p.m.
The following fixes a problem when dumping register costs, where the incorrect 
'from' value was being written out because the code modified the incoming 
parameter value. It also changes things so that register/memory costs are only 
dumped on the outermost call, eliminating intermediate output when a cost 
calculation requires going through memory or GPRs.

Bootstrap/regtest on powerpc64-linux with no new regressions. Ok for trunk?

-Pat


2011-05-25  Pat Haugen <pthaugen@us.ibm.com>

	* config/rs6000/rs6000.c (rs6000_register_move_cost): Preserve from
	parameter value for dump. Dump cost on outermost call only.
	(rs6000_memory_move_cost): Dump cost on outermost call only.
David Edelsohn - May 31, 2011, 7:18 p.m.
On Wed, May 25, 2011 at 3:02 PM, Pat Haugen <pthaugen@linux.vnet.ibm.com> wrote:
> The following fixes a problem when dumping register costs, where the
> incorrect 'from' value was being written out because the code modified the
> incoming parameter value. It also changes things so that register/memory
> costs are only dumped on the outermost call, eliminating intermediate output
> when a cost calculation requires going through memory or GPRs.
>
> Bootstrap/regtest on powerpc64-linux with no new regressions. Ok for trunk?
>
> -Pat
>
>
> 2011-05-25  Pat Haugen <pthaugen@us.ibm.com>
>
>        * config/rs6000/rs6000.c (rs6000_register_move_cost): Preserve from
>        parameter value for dump. Dump cost on outermost call only.
>        (rs6000_memory_move_cost): Dump cost on outermost call only.

Okay.

Thanks, David

Patch

Index: gcc/config/rs6000/rs6000.c
===================================================================
--- gcc/config/rs6000/rs6000.c	(revision 174138)
+++ gcc/config/rs6000/rs6000.c	(working copy)
@@ -189,6 +189,8 @@  enum reg_class rs6000_regno_regclass[FIR
 /* Reload functions based on the type and the vector unit.  */
 static enum insn_code rs6000_vector_reload[NUM_MACHINE_MODES][2];
 
+static int dbg_cost_ctrl;
+
 /* Built in types.  */
 tree rs6000_builtin_types[RS6000_BTI_MAX];
 tree rs6000_builtin_decls[RS6000_BUILTIN_COUNT];
@@ -26428,26 +26430,31 @@  rs6000_register_move_cost (enum machine_
 {
   int ret;
 
+  if (TARGET_DEBUG_COST)
+    dbg_cost_ctrl++;
+
   /*  Moves from/to GENERAL_REGS.  */
   if (reg_classes_intersect_p (to, GENERAL_REGS)
       || reg_classes_intersect_p (from, GENERAL_REGS))
     {
+      reg_class_t rclass = from;
+
       if (! reg_classes_intersect_p (to, GENERAL_REGS))
-	from = to;
+	rclass = to;
 
-      if (from == FLOAT_REGS || from == ALTIVEC_REGS || from == VSX_REGS)
-	ret = (rs6000_memory_move_cost (mode, from, false)
+      if (rclass == FLOAT_REGS || rclass == ALTIVEC_REGS || rclass == VSX_REGS)
+	ret = (rs6000_memory_move_cost (mode, rclass, false)
 	       + rs6000_memory_move_cost (mode, GENERAL_REGS, false));
 
       /* It's more expensive to move CR_REGS than CR0_REGS because of the
 	 shift.  */
-      else if (from == CR_REGS)
+      else if (rclass == CR_REGS)
 	ret = 4;
 
       /* Power6 has slower LR/CTR moves so make them more expensive than
 	 memory in order to bias spills to memory .*/
       else if (rs6000_cpu == PROCESSOR_POWER6
-	       && reg_classes_intersect_p (from, LINK_OR_CTR_REGS))
+	       && reg_classes_intersect_p (rclass, LINK_OR_CTR_REGS))
         ret = 6 * hard_regno_nregs[0][mode];
 
       else
@@ -26471,10 +26478,14 @@  rs6000_register_move_cost (enum machine_
 	   + rs6000_register_move_cost (mode, from, GENERAL_REGS));
 
   if (TARGET_DEBUG_COST)
-    fprintf (stderr,
-	     "rs6000_register_move_cost:, ret=%d, mode=%s, from=%s, to=%s\n",
-	     ret, GET_MODE_NAME (mode), reg_class_names[from],
-	     reg_class_names[to]);
+    {
+      if (dbg_cost_ctrl == 1)
+	fprintf (stderr,
+		 "rs6000_register_move_cost:, ret=%d, mode=%s, from=%s, to=%s\n",
+		 ret, GET_MODE_NAME (mode), reg_class_names[from],
+		 reg_class_names[to]);
+      dbg_cost_ctrl--;
+    }
 
   return ret;
 }
@@ -26488,6 +26499,9 @@  rs6000_memory_move_cost (enum machine_mo
 {
   int ret;
 
+  if (TARGET_DEBUG_COST)
+    dbg_cost_ctrl++;
+
   if (reg_classes_intersect_p (rclass, GENERAL_REGS))
     ret = 4 * hard_regno_nregs[0][mode];
   else if (reg_classes_intersect_p (rclass, FLOAT_REGS))
@@ -26498,9 +26512,13 @@  rs6000_memory_move_cost (enum machine_mo
     ret = 4 + rs6000_register_move_cost (mode, rclass, GENERAL_REGS);
 
   if (TARGET_DEBUG_COST)
-    fprintf (stderr,
-	     "rs6000_memory_move_cost: ret=%d, mode=%s, rclass=%s, in=%d\n",
-	     ret, GET_MODE_NAME (mode), reg_class_names[rclass], in);
+    {
+      if (dbg_cost_ctrl == 1)
+	fprintf (stderr,
+		 "rs6000_memory_move_cost: ret=%d, mode=%s, rclass=%s, in=%d\n",
+		 ret, GET_MODE_NAME (mode), reg_class_names[rclass], in);
+      dbg_cost_ctrl--;
+    }
 
   return ret;
 }