diff mbox series

[10/nn,AArch64] Minor rtx costs tweak

Message ID 87she4afbp.fsf@linaro.org
State New
Headers show
Series [10/nn,AArch64] Minor rtx costs tweak | expand

Commit Message

Richard Sandiford Oct. 27, 2017, 1:30 p.m. UTC
aarch64_rtx_costs uses the number of registers in a mode as the basis
of SET costs.  This patch makes it get the number of registers from
aarch64_hard_regno_nregs rather than repeating the calcalation inline.
Handling SVE modes in aarch64_hard_regno_nregs is then enough to get
the correct SET cost as well.


2017-10-27  Richard Sandiford  <richard.sandiford@linaro.org>
	    Alan Hayward  <alan.hayward@arm.com>
	    David Sherwood  <david.sherwood@arm.com>

gcc/
	* config/aarch64/aarch64.c (aarch64_rtx_costs): Use
	aarch64_hard_regno_nregs to get the number of registers
	in a mode.

Comments

James Greenhalgh Oct. 31, 2017, 6:04 p.m. UTC | #1
On Fri, Oct 27, 2017 at 02:30:18PM +0100, Richard Sandiford wrote:
> aarch64_rtx_costs uses the number of registers in a mode as the basis

> of SET costs.  This patch makes it get the number of registers from

> aarch64_hard_regno_nregs rather than repeating the calcalation inline.

> Handling SVE modes in aarch64_hard_regno_nregs is then enough to get

> the correct SET cost as well.


OK.

Reviewed-By: James Greenhalgh  <james.greenhalgh@arm.com>


Thanks,
James

> 

> 

> 2017-10-27  Richard Sandiford  <richard.sandiford@linaro.org>

> 	    Alan Hayward  <alan.hayward@arm.com>

> 	    David Sherwood  <david.sherwood@arm.com>

> 

> gcc/

> 	* config/aarch64/aarch64.c (aarch64_rtx_costs): Use

> 	aarch64_hard_regno_nregs to get the number of registers

> 	in a mode.

>
diff mbox series

Patch

Index: gcc/config/aarch64/aarch64.c
===================================================================
--- gcc/config/aarch64/aarch64.c	2017-10-27 14:12:11.045026014 +0100
+++ gcc/config/aarch64/aarch64.c	2017-10-27 14:12:14.533257115 +0100
@@ -7200,18 +7200,16 @@  aarch64_rtx_costs (rtx x, machine_mode m
 	  /* The cost is one per vector-register copied.  */
 	  if (VECTOR_MODE_P (GET_MODE (op0)) && REG_P (op1))
 	    {
-	      int n_minus_1 = (GET_MODE_SIZE (GET_MODE (op0)) - 1)
-			      / GET_MODE_SIZE (V4SImode);
-	      *cost = COSTS_N_INSNS (n_minus_1 + 1);
+	      int nregs = aarch64_hard_regno_nregs (V0_REGNUM, GET_MODE (op0));
+	      *cost = COSTS_N_INSNS (nregs);
 	    }
 	  /* const0_rtx is in general free, but we will use an
 	     instruction to set a register to 0.  */
 	  else if (REG_P (op1) || op1 == const0_rtx)
 	    {
 	      /* The cost is 1 per register copied.  */
-	      int n_minus_1 = (GET_MODE_SIZE (GET_MODE (op0)) - 1)
-			      / UNITS_PER_WORD;
-	      *cost = COSTS_N_INSNS (n_minus_1 + 1);
+	      int nregs = aarch64_hard_regno_nregs (R0_REGNUM, GET_MODE (op0));
+	      *cost = COSTS_N_INSNS (nregs);
 	    }
           else
 	    /* Cost is just the cost of the RHS of the set.  */