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] Rename/export combine_insn_cost as insn_rtx_cost


On Sat, 10 Jul 2004, Roger Sayle wrote:
> 2004-07-10  Roger Sayle  <roger@eyesopen.com>
>
> 	* rtlanal.c (insn_rtx_cost): New function, moved and renamed from
> 	combine.c's combine_insn_cost.

> Index: rtlanal.c
> ===================================================================
> RCS file: /cvs/gcc/gcc/gcc/rtlanal.c,v
> retrieving revision 1.194
> diff -c -3 -p -r1.194 rtlanal.c
> *** rtlanal.c	9 Jul 2004 03:29:35 -0000	1.194
> --- rtlanal.c	10 Jul 2004 23:54:21 -0000
> *************** num_sign_bit_copies1 (rtx x, enum machin
> *** 4785,4787 ****
> --- 4785,4823 ----
>     return nonzero & ((HOST_WIDE_INT) 1 << (bitwidth - 1))
>   	 ? 1 : bitwidth - floor_log2 (nonzero) - 1;
>   }
> +
> + /* Calculate the rtx_cost of a single instruction.  A return value of
> +    zero indicates an instruction pattern without a known cost.  */
> +
> + int
> + insn_rtx_cost (rtx pat)
> + {
> +   int i, cost;
> +   rtx set;
> +
> +   /* Extract the single set rtx from the instruction pattern.
> +      We can't use single_set since we only have the pattern.  */
> +   if (GET_CODE (pat) == SET)
> +     set = pat;
> +   else if (GET_CODE (pat) == PARALLEL)
> +     {
> +       set = NULL_RTX;
> +       for (i = 0; i < XVECLEN (pat, 0); i++)
> + 	{
> + 	  rtx x = XVECEXP (pat, 0, i);
> + 	  if (GET_CODE (x) == SET)
> + 	    {
> + 	      if (set)
> + 		return 0;
> + 	      set = x;
> + 	    }
> + 	}
> +       if (!set)
> + 	return 0;
> +     }
> +   else
> +     return 0;
> +
> +   cost = rtx_cost (SET_SRC (set), SET);
> +   return cost > 0 ? cost : COSTS_N_INSNS (1);
> + }

I suggest that in the PARALLEL, you instead of 0 (signalling
failure) pick the set with the largest cost.  After all, they
*are* run in parallel.  (I care because CRIS has lots of
parallel (non-single-)setters, and will most likely gain a
higher percentage if/when migrating from being a cc0 port.
I haven't revisited its RTX_COSTS yet, FWIW.)

Any performance test needed for such a change?

brgds, H-P


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