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]

[m68k] Adjust costs for mul/div instructions on ColdFire cores


Adjust costs for mul/div instructions on ColdFire cores.

(based on uClinux patches for GCC 2.95.3 by Paul Dale <pauli@snapgear.com>
and ColdFire patches for GCC 3.2.3 by Peter Barada <patches for GCC 3.2.3).


2003-08-21  Bernardo Innocenti  <bernie@develer.com>
            Paul Dale  <pauli@snapgear.com>
            Peter Barada  <peter@baradas.org>

	* config/m68k/m68k.c (m68k_rtx_costs): Adjust mul/div costs for
	ColdFire cores.

diff -Nrup gcc-3.4-20030730.orig/gcc/config/m68k/m68k.c gcc-3.4-20030730/gcc/config/m68k/m68k.c
--- gcc-3.4-20030730.orig/gcc/config/m68k/m68k.c	2003-08-03 01:34:38.000000000 +0200
+++ gcc-3.4-20030730/gcc/config/m68k/m68k.c	2003-08-03 01:48:15.000000000 +0200
@@ -1801,9 +1801,10 @@ m68k_rtx_costs (x, code, outer_code, tot
        for add and the time for shift, taking away a little more because
        sometimes move insns are needed.  */
     /* div?.w is relatively cheaper on 68000 counted in COSTS_N_INSNS terms.  */
-#define MULL_COST (TARGET_68060 ? 2 : TARGET_68040 ? 5 : 13)
-#define MULW_COST (TARGET_68060 ? 2 : TARGET_68040 ? 3 : TARGET_68020 ? 8 : 5)
-#define DIVW_COST (TARGET_68020 ? 27 : 12)
+#define MULL_COST (TARGET_68060 ? 2 : TARGET_68040 ? 5 : TARGET_CFV3 ? 3 : TARGET_COLDFIRE ? 10 : 13)
+#define MULW_COST (TARGET_68060 ? 2 : TARGET_68040 ? 3 : TARGET_68020 ? 8 : \
+			TARGET_CFV3 ? 2 : 5)
+#define DIVW_COST (TARGET_68020 ? 27 : TARGET_CF_HWDIV ? 11 : 12)
 
     case PLUS:
       /* An lea costs about three times as much as a simple add.  */
@@ -1815,7 +1816,11 @@ m68k_rtx_costs (x, code, outer_code, tot
 	  && (INTVAL (XEXP (XEXP (x, 0), 1)) == 2
 	      || INTVAL (XEXP (XEXP (x, 0), 1)) == 4
 	      || INTVAL (XEXP (XEXP (x, 0), 1)) == 8))
-	*total = COSTS_N_INSNS (3);	 /* lea an@(dx:l:i),am */
+	{
+	    /* lea an@(dx:l:i),am */
+	    *total = COSTS_N_INSNS (TARGET_COLDFIRE ? 2 : 3);
+	    return true;
+	}
       return false;
 
     case ASHIFT:
@@ -1826,7 +1831,7 @@ m68k_rtx_costs (x, code, outer_code, tot
           *total = COSTS_N_INSNS(1);
 	  return true;
 	}
-      if (! TARGET_68020)
+      if (! TARGET_68020 && ! TARGET_COLDFIRE)
         {
 	  if (GET_CODE (XEXP (x, 1)) == CONST_INT)
 	    {
@@ -1851,7 +1856,7 @@ m68k_rtx_costs (x, code, outer_code, tot
 	  && !(INTVAL (XEXP (x, 1)) > 0
 	       && INTVAL (XEXP (x, 1)) <= 8))
 	{
-	  *total = COSTS_N_INSNS (3);	 /* lsr #i,dn */
+	  *total = COSTS_N_INSNS (TARGET_COLDFIRE ? 1 : 3);	 /* lsr #i,dn */
 	  return true;
 	}
       return false;
@@ -1873,6 +1878,8 @@ m68k_rtx_costs (x, code, outer_code, tot
     case UMOD:
       if (GET_MODE (x) == QImode || GET_MODE (x) == HImode)
         *total = COSTS_N_INSNS (DIVW_COST);	/* div.w */
+      else if (TARGET_CF_HWDIV)
+        *total = COSTS_N_INSNS(18);
       else
 	*total = COSTS_N_INSNS (43);		/* div.l */
       return true;


-- 
  // Bernardo Innocenti - Develer S.r.l., R&D dept.
\X/  http://www.develer.com/

Please don't send Word attachments - http://www.gnu.org/philosophy/no-word-attachments.html



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