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]

Re: [PATCH] Clean up mips_rtx_costs to use speed rather than optimize_size


Adam Nemet <anemet@caviumnetworks.com> writes:
> Honza's patch <http://gcc.gnu.org/ml/gcc-patches/2008-08/msg02376.html> to
> change TARGET_RTX_COSTS to use a speed parameter was pretty incomplete for
> MIPS.  This patch fills in the missing pieces.

Good catch.  OK with a couple of minor changes:

> Index: gcc/config/mips/mips.c
> ===================================================================
> --- gcc.orig/config/mips/mips.c	2009-10-18 14:00:10.000000000 -0700
> +++ gcc/config/mips/mips.c	2009-10-19 13:04:08.000000000 -0700
> @@ -3390,7 +3390,7 @@ mips_immediate_operand_p (int code, HOST
>     and that the sequence of a double-word operation has cost DOUBLE_COST.  */
>  
>  static int
> -mips_binary_cost (rtx x, int single_cost, int double_cost)
> +mips_binary_cost (rtx x, int single_cost, int double_cost, bool speed)

Document the new parameter.  Something as simple as
"SPEED is as for mips_rtx_costs" would be fine.

> @@ -3527,7 +3526,7 @@ mips_rtx_costs (rtx x, int code, int out
>  	     operand needs to be forced into a register, we will often be
>  	     able to hoist the constant load out of the loop, so the load
>  	     should not contribute to the cost.  */
> -	  if (!optimize_size
> +	  if (speed
>  	      || mips_immediate_operand_p (outer_code, INTVAL (x)))

Let's join the lines now that we can.

> @@ -3626,7 +3625,8 @@ mips_rtx_costs (rtx x, int code, int out
>      case IOR:
>      case XOR:
>        /* Double-word operations use two single-word operations.  */
> -      *total = mips_binary_cost (x, COSTS_N_INSNS (1), COSTS_N_INSNS (2));
> +      *total =
> +	mips_binary_cost (x, COSTS_N_INSNS (1), COSTS_N_INSNS (2), speed);
>        return true;
>  
>      case ASHIFT:

Strictly speaking, the second line should start with "=", a bit like
"&&" in multi-line conditionals.  I prefer breaking the lines in the
parameters instead, a bit like we do for longer lines below.  I.e.:

      *total = mips_binary_cost (x, COSTS_N_INSNS (1),
                                 COSTS_N_INSNS (2), speed);

Same for later hunks.

No need to retest for that.

Richard


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