Commit d797b115 by Claudiu Zissulescu Committed by Claudiu Zissulescu

[ARC] Update RTX costs.

Update RTX costs to reflect better the ARC architecture.

gcc/
xxxx-xx-xx  Claudiu Zissulescu  <claziss@synopsys.com>

	* config/arc/arc.c (arc_rtx_costs): Update costs.

/gcc/testsuite
xxxx-xx-xx  Claudiu Zissulescu  <claziss@synopsys.com>

	* gcc.target/arc/jumptables.c: Update test.

From-SVN: r272113
parent 03301dcc
2019-06-10 Claudiu Zissulescu <claziss@synopsys.com> 2019-06-10 Claudiu Zissulescu <claziss@synopsys.com>
* config/arc/arc.c (arc_rtx_costs): Update costs.
2019-06-10 Claudiu Zissulescu <claziss@synopsys.com>
* config/arc/arc-protos.h (arc_check_ior_const): Declare. * config/arc/arc-protos.h (arc_check_ior_const): Declare.
(arc_split_ior): Likewise. (arc_split_ior): Likewise.
(arc_check_mov_const): Likewise. (arc_check_mov_const): Likewise.
......
...@@ -5560,41 +5560,39 @@ arc_rtx_costs (rtx x, machine_mode mode, int outer_code, ...@@ -5560,41 +5560,39 @@ arc_rtx_costs (rtx x, machine_mode mode, int outer_code,
case CONST_INT: case CONST_INT:
{ {
bool nolimm = false; /* Can we do without long immediate? */ bool nolimm = false; /* Can we do without long immediate? */
bool fast = false; /* Is the result available immediately? */
bool condexec = false; /* Does this allow conditiobnal execution? */
bool compact = false; /* Is a 16 bit opcode available? */
/* CONDEXEC also implies that we can have an unconditional
3-address operation. */
nolimm = compact = condexec = false; nolimm = false;
if (UNSIGNED_INT6 (INTVAL (x))) if (UNSIGNED_INT6 (INTVAL (x)))
nolimm = condexec = compact = true; nolimm = true;
else else
{ {
if (SMALL_INT (INTVAL (x)))
nolimm = fast = true;
switch (outer_code) switch (outer_code)
{ {
case AND: /* bclr, bmsk, ext[bw] */ case AND: /* bclr, bmsk, ext[bw] */
if (satisfies_constraint_Ccp (x) /* bclr */ if (satisfies_constraint_Ccp (x) /* bclr */
|| satisfies_constraint_C1p (x) /* bmsk */) || satisfies_constraint_C1p (x) /* bmsk */)
nolimm = fast = condexec = compact = true; nolimm = true;
break; break;
case IOR: /* bset */ case IOR: /* bset */
if (satisfies_constraint_C0p (x)) /* bset */ if (satisfies_constraint_C0p (x)) /* bset */
nolimm = fast = condexec = compact = true; nolimm = true;
break; break;
case XOR: case XOR:
if (satisfies_constraint_C0p (x)) /* bxor */ if (satisfies_constraint_C0p (x)) /* bxor */
nolimm = fast = condexec = true; nolimm = true;
break; break;
case SET:
if (UNSIGNED_INT8 (INTVAL (x)))
nolimm = true;
if (satisfies_constraint_Chi (x))
nolimm = true;
if (satisfies_constraint_Clo (x))
nolimm = true;
default: default:
break; break;
} }
} }
/* FIXME: Add target options to attach a small cost if if (nolimm && !speed)
condexec / compact is not true. */
if (nolimm)
{ {
*total = 0; *total = 0;
return true; return true;
...@@ -5607,7 +5605,7 @@ arc_rtx_costs (rtx x, machine_mode mode, int outer_code, ...@@ -5607,7 +5605,7 @@ arc_rtx_costs (rtx x, machine_mode mode, int outer_code,
case CONST: case CONST:
case LABEL_REF: case LABEL_REF:
case SYMBOL_REF: case SYMBOL_REF:
*total = COSTS_N_INSNS (1); *total = speed ? COSTS_N_INSNS (1) : COSTS_N_INSNS (4);
return true; return true;
case CONST_DOUBLE: case CONST_DOUBLE:
...@@ -5633,16 +5631,10 @@ arc_rtx_costs (rtx x, machine_mode mode, int outer_code, ...@@ -5633,16 +5631,10 @@ arc_rtx_costs (rtx x, machine_mode mode, int outer_code,
case LSHIFTRT: case LSHIFTRT:
if (TARGET_BARREL_SHIFTER) if (TARGET_BARREL_SHIFTER)
{ {
/* If we want to shift a constant, we need a LIMM. */
/* ??? when the optimizers want to know if a constant should be
hoisted, they ask for the cost of the constant. OUTER_CODE is
insufficient context for shifts since we don't know which operand
we are looking at. */
if (CONSTANT_P (XEXP (x, 0))) if (CONSTANT_P (XEXP (x, 0)))
{ {
*total += (COSTS_N_INSNS (2) *total += rtx_cost (XEXP (x, 1), mode, (enum rtx_code) code,
+ rtx_cost (XEXP (x, 1), mode, (enum rtx_code) code, 0, speed);
0, speed));
return true; return true;
} }
*total = COSTS_N_INSNS (1); *total = COSTS_N_INSNS (1);
...@@ -5662,7 +5654,13 @@ arc_rtx_costs (rtx x, machine_mode mode, int outer_code, ...@@ -5662,7 +5654,13 @@ arc_rtx_costs (rtx x, machine_mode mode, int outer_code,
case DIV: case DIV:
case UDIV: case UDIV:
if (speed) if (GET_MODE_CLASS (mode) == MODE_FLOAT
&& (TARGET_FP_SP_SQRT || TARGET_FP_DP_SQRT))
*total = COSTS_N_INSNS(1);
else if (GET_MODE_CLASS (mode) == MODE_INT
&& TARGET_DIVREM)
*total = COSTS_N_INSNS(1);
else if (speed)
*total = COSTS_N_INSNS(30); *total = COSTS_N_INSNS(30);
else else
*total = COSTS_N_INSNS(1); *total = COSTS_N_INSNS(1);
...@@ -5675,19 +5673,28 @@ arc_rtx_costs (rtx x, machine_mode mode, int outer_code, ...@@ -5675,19 +5673,28 @@ arc_rtx_costs (rtx x, machine_mode mode, int outer_code,
*total= arc_multcost; *total= arc_multcost;
/* We do not want synth_mult sequences when optimizing /* We do not want synth_mult sequences when optimizing
for size. */ for size. */
else if (TARGET_MUL64_SET || TARGET_ARC700_MPY) else if (TARGET_ANY_MPY)
*total = COSTS_N_INSNS (1); *total = COSTS_N_INSNS (1);
else else
*total = COSTS_N_INSNS (2); *total = COSTS_N_INSNS (2);
return false; return false;
case PLUS: case PLUS:
if (outer_code == MEM && CONST_INT_P (XEXP (x, 1))
&& RTX_OK_FOR_OFFSET_P (mode, XEXP (x, 1)))
{
*total = 0;
return true;
}
if ((GET_CODE (XEXP (x, 0)) == ASHIFT if ((GET_CODE (XEXP (x, 0)) == ASHIFT
&& _1_2_3_operand (XEXP (XEXP (x, 0), 1), VOIDmode)) && _1_2_3_operand (XEXP (XEXP (x, 0), 1), VOIDmode))
|| (GET_CODE (XEXP (x, 0)) == MULT || (GET_CODE (XEXP (x, 0)) == MULT
&& _2_4_8_operand (XEXP (XEXP (x, 0), 1), VOIDmode))) && _2_4_8_operand (XEXP (XEXP (x, 0), 1), VOIDmode)))
{ {
*total += (rtx_cost (XEXP (x, 1), mode, PLUS, 0, speed) if (CONSTANT_P (XEXP (x, 1)) && !speed)
+ rtx_cost (XEXP (XEXP (x, 0), 0), mode, PLUS, 1, speed)); *total += COSTS_N_INSNS (4);
*total += rtx_cost (XEXP (XEXP (x, 0), 0), mode, PLUS, 1, speed);
return true; return true;
} }
return false; return false;
...@@ -5697,11 +5704,13 @@ arc_rtx_costs (rtx x, machine_mode mode, int outer_code, ...@@ -5697,11 +5704,13 @@ arc_rtx_costs (rtx x, machine_mode mode, int outer_code,
|| (GET_CODE (XEXP (x, 1)) == MULT || (GET_CODE (XEXP (x, 1)) == MULT
&& _2_4_8_operand (XEXP (XEXP (x, 1), 1), VOIDmode))) && _2_4_8_operand (XEXP (XEXP (x, 1), 1), VOIDmode)))
{ {
*total += (rtx_cost (XEXP (x, 0), mode, PLUS, 0, speed) if (CONSTANT_P (XEXP (x, 0)) && !speed)
+ rtx_cost (XEXP (XEXP (x, 1), 0), mode, PLUS, 1, speed)); *total += COSTS_N_INSNS (4);
*total += rtx_cost (XEXP (XEXP (x, 1), 0), mode, PLUS, 1, speed);
return true; return true;
} }
return false; return false;
case COMPARE: case COMPARE:
{ {
rtx op0 = XEXP (x, 0); rtx op0 = XEXP (x, 0);
......
2019-06-10 Claudiu Zissulescu <claziss@synopsys.com> 2019-06-10 Claudiu Zissulescu <claziss@synopsys.com>
* gcc.target/arc/jumptables.c: Update test.
2019-06-10 Claudiu Zissulescu <claziss@synopsys.com>
* gcc.target/arc/and-cnst-size.c: New test. * gcc.target/arc/and-cnst-size.c: New test.
* gcc.target/arc/mov-cnst-size.c: Likewise. * gcc.target/arc/mov-cnst-size.c: Likewise.
* gcc.target/arc/or-cnst-size.c: Likewise. * gcc.target/arc/or-cnst-size.c: Likewise.
......
...@@ -31,4 +31,4 @@ int switchCase(int value, int b) ...@@ -31,4 +31,4 @@ int switchCase(int value, int b)
} }
/* { dg-final { scan-assembler-times "bih" 1 } } */ /* { dg-final { scan-assembler-times "bih" 1 } } */
/* { dg-final { scan-assembler-times "b_s" 8 } } */ /* { dg-final { scan-assembler-times "b_s" 6 } } */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment