[patch] MIPS: Size optimization costs.

David Ung davidu@mips.com
Mon Nov 6 13:37:00 GMT 2006


This patch adds a new table for costs when optimizing for size.  The existing 
cost tables are good for speed, but not useful for size.

Bootstrapped on linux native and cross-compiled.
ok for mainline?

David.

	* config/mips/mips.c (mips_rtx_cost_optimize_size): New table of
	costs when optimizing for size.
	(override_options): Use mips_rtx_cost_optimize_size table for cost
	calculations.

Index: gcc/gcc/gcc/config/mips/mips.c
===================================================================
--- gcc.orig/gcc/gcc/config/mips/mips.c 2006-11-01 15:41:41.000000000 +0000
+++ gcc/gcc/gcc/config/mips/mips.c      2006-11-03 18:21:38.000000000 +0000
@@ -796,6 +796,21 @@
                        COSTS_N_INSNS (256), /* fp_div_sf */    \
                        COSTS_N_INSNS (256)  /* fp_div_df */

+static struct mips_rtx_cost_data const mips_rtx_cost_optimize_size =
+  {
+      COSTS_N_INSNS (1),            /* fp_add */
+      COSTS_N_INSNS (1),            /* fp_mult_sf */
+      COSTS_N_INSNS (1),            /* fp_mult_df */
+      COSTS_N_INSNS (1),            /* fp_div_sf */
+      COSTS_N_INSNS (1),            /* fp_div_df */
+      COSTS_N_INSNS (1),            /* int_mult_si */
+      COSTS_N_INSNS (1),            /* int_mult_di */
+      COSTS_N_INSNS (1),            /* int_div_si */
+      COSTS_N_INSNS (1),            /* int_div_di */
+                       2,           /* branch_cost */
+                       4            /* memory_latency */
+  };
+
  static struct mips_rtx_cost_data const mips_rtx_cost_data[PROCESSOR_MAX] =
    {
      { /* R3000 */
@@ -4749,7 +4764,10 @@
      mips_set_tune (mips_arch_info);

    /* Set cost structure for the processor.  */
-  mips_cost = &mips_rtx_cost_data[mips_tune];
+  if (optimize_size)
+    mips_cost = &mips_rtx_cost_optimize_size;
+  else
+    mips_cost = &mips_rtx_cost_data[mips_tune];

    if ((target_flags_explicit & MASK_64BIT) != 0)
      {



More information about the Gcc-patches mailing list