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]

Move Sparc RTX_COSTS implementation



I was about to make RTX_COSTS more accurate on Sparc,
but then I remembered I promised Mark that I'd move
these huge sparc.h marcos out into sparc.c :-)

Done and regression tested on the mainline as follows.

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

	* config/sparc/sparc-protos.h (sparc_rtx_costs): New.
	* config/sparc/sparc.c (sparc_rtx_costs): New function
	implementing RTX_COSTS and CONST_COSTS.
	* config/sparc/sparc.h (CONST_COSTS): Delete.
	(RTX_COSTS_CASES): Define.
	(RTX_COSTS): Expand RTX_COSTS_CASES and use sparc_rtx_costs to do
	the work.

--- ./config/sparc/sparc.h.~1~	Fri May  3 20:53:36 2002
+++ ./config/sparc/sparc.h	Fri May  3 22:19:28 2002
@@ -2645,33 +2645,6 @@ do {                                    
    of the libgcc2 functions is used.  */
 #define FLOAT_LIB_COMPARE_RETURNS_BOOL(MODE, COMPARISON) ((MODE) == TFmode)
 
-/* Compute the cost of computing a constant rtl expression RTX
-   whose rtx-code is CODE.  The body of this macro is a portion
-   of a switch statement.  If the code is computed here,
-   return it with a return statement.  Otherwise, break from the switch.  */
-
-#define CONST_COSTS(RTX,CODE,OUTER_CODE) \
-  case CONST_INT:						\
-    if (INTVAL (RTX) < 0x1000 && INTVAL (RTX) >= -0x1000)	\
-      return 0;							\
-  case HIGH:							\
-    return 2;							\
-  case CONST:							\
-  case LABEL_REF:						\
-  case SYMBOL_REF:						\
-    return 4;							\
-  case CONST_DOUBLE:						\
-    if (GET_MODE (RTX) == DImode)				\
-      if ((XINT (RTX, 3) == 0					\
-	   && (unsigned) XINT (RTX, 2) < 0x1000)		\
-	  || (XINT (RTX, 3) == -1				\
-	      && XINT (RTX, 2) < 0				\
-	      && XINT (RTX, 2) >= -0x1000))			\
-	return 0;						\
-    return 8;
-
-#define ADDRESS_COST(RTX)  1
-
 /* Compute extra cost of moving data between one register class
    and another.  */
 #define GENERAL_OR_I64(C) ((C) == GENERAL_REGS || (C) == I64_REGS)
@@ -2699,37 +2672,22 @@ do {                                    
          : (sparc_cpu == PROCESSOR_ULTRASPARC3 \
             ? 9 : 3))
 
-/* Provide the costs of a rtl expression.  This is in the body of a
-   switch on CODE.  The purpose for the cost of MULT is to encourage
-   `synth_mult' to find a synthetic multiply when reasonable.
+/* The cases that RTX_COSTS handles.  */
 
-   If we need more than 12 insns to do a multiply, then go out-of-line,
-   since the call overhead will be < 10% of the cost of the multiply.  */
+#define RTX_COSTS_CASES	\
+case MULT: case DIV: case UDIV: case MOD: case UMOD: \
+case FLOAT: case FIX: \
+case CONST_INT: case HIGH: case CONST: \
+case LABEL_REF: case SYMBOL_REF: case CONST_DOUBLE:
+
+/* Provide the costs of a rtl expression.  This is in the body of a
+   switch on CODE.  */
 
 #define RTX_COSTS(X,CODE,OUTER_CODE)			\
-  case MULT:						\
-    if (sparc_cpu == PROCESSOR_ULTRASPARC)		\
-      return (GET_MODE (X) == DImode ?			\
-              COSTS_N_INSNS (34) : COSTS_N_INSNS (19));	\
-    if (sparc_cpu == PROCESSOR_ULTRASPARC3)		\
-      return COSTS_N_INSNS (6);				\
-    return TARGET_HARD_MUL ? COSTS_N_INSNS (5) : COSTS_N_INSNS (25); \
-  case DIV:						\
-  case UDIV:						\
-  case MOD:						\
-  case UMOD:						\
-    if (sparc_cpu == PROCESSOR_ULTRASPARC)		\
-      return (GET_MODE (X) == DImode ?			\
-              COSTS_N_INSNS (68) : COSTS_N_INSNS (37));	\
-    if (sparc_cpu == PROCESSOR_ULTRASPARC3)		\
-      return (GET_MODE (X) == DImode ?			\
-              COSTS_N_INSNS (71) : COSTS_N_INSNS (40));	\
-    return COSTS_N_INSNS (25);				\
-  /* Make FLOAT and FIX more expensive than CONST_DOUBLE,\
-     so that cse will favor the latter.  */		\
-  case FLOAT:						\
-  case FIX:						\
-    return 19;
+  RTX_COSTS_CASES					\
+    return sparc_rtx_costs(X,CODE,OUTER_CODE);
+
+#define ADDRESS_COST(RTX)  1
 
 #define PREFETCH_BLOCK \
 	((sparc_cpu == PROCESSOR_ULTRASPARC \
--- ./config/sparc/sparc-protos.h.~1~	Fri May  3 15:52:16 2002
+++ ./config/sparc/sparc-protos.h	Fri May  3 22:20:06 2002
@@ -121,6 +121,7 @@ extern char *sparc_v8plus_shift PARAMS (
 extern int sparc_check_64 PARAMS ((rtx, rtx));
 extern rtx gen_df_reg PARAMS ((rtx, int));
 extern int sparc_extra_constraint_check PARAMS ((rtx, int, int));
+extern int sparc_rtx_costs PARAMS ((rtx, enum rtx_code, enum rtx_code));
 #endif /* RTX_CODE */
 
 #endif /* __SPARC_PROTOS_H__ */
--- ./config/sparc/sparc.c.~1~	Fri May  3 20:40:50 2002
+++ ./config/sparc/sparc.c	Fri May  3 22:27:55 2002
@@ -8085,3 +8085,68 @@ sparc_extra_constraint_check (op, c, str
 
   return reload_ok_mem;
 }
+
+int
+sparc_rtx_costs (x, code, outer_code)
+     rtx x;
+     enum rtx_code code, outer_code;
+{
+  switch (code)
+    {
+    case MULT:
+      if (sparc_cpu == PROCESSOR_ULTRASPARC)
+	return (GET_MODE (x) == DImode ?
+		COSTS_N_INSNS (34) : COSTS_N_INSNS (19));
+
+      if (sparc_cpu == PROCESSOR_ULTRASPARC3)
+	return COSTS_N_INSNS (6);
+
+      return (TARGET_HARD_MUL
+	      ? COSTS_N_INSNS (5)
+	      : COSTS_N_INSNS (25));
+
+    case DIV:
+    case UDIV:
+    case MOD:
+    case UMOD:
+      if (sparc_cpu == PROCESSOR_ULTRASPARC)
+	return (GET_MODE (x) == DImode ?
+		COSTS_N_INSNS (68) : COSTS_N_INSNS (37));
+      if (sparc_cpu == PROCESSOR_ULTRASPARC3)
+	return (GET_MODE (x) == DImode ?
+		COSTS_N_INSNS (71) : COSTS_N_INSNS (40));
+      return COSTS_N_INSNS (25);
+
+      /* Make FLOAT and FIX more expensive than CONST_DOUBLE,
+	 so that cse will favor the latter.  */
+    case FLOAT:
+    case FIX:
+      return 19;
+
+    case CONST_INT:
+      if (INTVAL (x) < 0x1000 && INTVAL (x) >= -0x1000)
+	return 0;
+
+    /* fallthru */
+    case HIGH:
+      return 2;
+
+    case CONST:
+    case LABEL_REF:
+    case SYMBOL_REF:
+      return 4;
+
+    case CONST_DOUBLE:
+      if (GET_MODE (x) == DImode)
+	if ((XINT (x, 3) == 0
+	     && (unsigned) XINT (x, 2) < 0x1000)
+	    || (XINT (x, 3) == -1
+		&& XINT (x, 2) < 0
+		&& XINT (x, 2) >= -0x1000))
+	  return 0;
+      return 8;
+
+    default:
+      abort();
+    };
+}


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