From: Claudiu Zissulescu Date: Mon, 10 Jun 2019 08:25:37 +0000 (+0200) Subject: [ARC] Update RTX costs. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d797b11519bf0f555ea30472441395013c1411f0;p=gcc.git [ARC] Update RTX costs. Update RTX costs to reflect better the ARC architecture. gcc/ xxxx-xx-xx Claudiu Zissulescu * config/arc/arc.c (arc_rtx_costs): Update costs. /gcc/testsuite xxxx-xx-xx Claudiu Zissulescu * gcc.target/arc/jumptables.c: Update test. From-SVN: r272113 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a69a656e25f..d8fbb00c3bf 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2019-06-10 Claudiu Zissulescu + + * config/arc/arc.c (arc_rtx_costs): Update costs. + 2019-06-10 Claudiu Zissulescu * config/arc/arc-protos.h (arc_check_ior_const): Declare. diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c index 04ca554d907..2a530dea88c 100644 --- a/gcc/config/arc/arc.c +++ b/gcc/config/arc/arc.c @@ -5560,41 +5560,39 @@ arc_rtx_costs (rtx x, machine_mode mode, int outer_code, case CONST_INT: { 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))) - nolimm = condexec = compact = true; + nolimm = true; else { - if (SMALL_INT (INTVAL (x))) - nolimm = fast = true; switch (outer_code) { case AND: /* bclr, bmsk, ext[bw] */ if (satisfies_constraint_Ccp (x) /* bclr */ || satisfies_constraint_C1p (x) /* bmsk */) - nolimm = fast = condexec = compact = true; + nolimm = true; break; case IOR: /* bset */ if (satisfies_constraint_C0p (x)) /* bset */ - nolimm = fast = condexec = compact = true; + nolimm = true; break; case XOR: if (satisfies_constraint_C0p (x)) /* bxor */ - nolimm = fast = condexec = true; + nolimm = true; 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: break; } } - /* FIXME: Add target options to attach a small cost if - condexec / compact is not true. */ - if (nolimm) + if (nolimm && !speed) { *total = 0; return true; @@ -5607,7 +5605,7 @@ arc_rtx_costs (rtx x, machine_mode mode, int outer_code, case CONST: case LABEL_REF: case SYMBOL_REF: - *total = COSTS_N_INSNS (1); + *total = speed ? COSTS_N_INSNS (1) : COSTS_N_INSNS (4); return true; case CONST_DOUBLE: @@ -5633,16 +5631,10 @@ arc_rtx_costs (rtx x, machine_mode mode, int outer_code, case LSHIFTRT: 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))) { - *total += (COSTS_N_INSNS (2) - + rtx_cost (XEXP (x, 1), mode, (enum rtx_code) code, - 0, speed)); + *total += rtx_cost (XEXP (x, 1), mode, (enum rtx_code) code, + 0, speed); return true; } *total = COSTS_N_INSNS (1); @@ -5662,7 +5654,13 @@ arc_rtx_costs (rtx x, machine_mode mode, int outer_code, case DIV: 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); else *total = COSTS_N_INSNS(1); @@ -5675,19 +5673,28 @@ arc_rtx_costs (rtx x, machine_mode mode, int outer_code, *total= arc_multcost; /* We do not want synth_mult sequences when optimizing for size. */ - else if (TARGET_MUL64_SET || TARGET_ARC700_MPY) + else if (TARGET_ANY_MPY) *total = COSTS_N_INSNS (1); else *total = COSTS_N_INSNS (2); return false; + 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 && _1_2_3_operand (XEXP (XEXP (x, 0), 1), VOIDmode)) || (GET_CODE (XEXP (x, 0)) == MULT && _2_4_8_operand (XEXP (XEXP (x, 0), 1), VOIDmode))) { - *total += (rtx_cost (XEXP (x, 1), mode, PLUS, 0, speed) - + rtx_cost (XEXP (XEXP (x, 0), 0), mode, PLUS, 1, speed)); + if (CONSTANT_P (XEXP (x, 1)) && !speed) + *total += COSTS_N_INSNS (4); + *total += rtx_cost (XEXP (XEXP (x, 0), 0), mode, PLUS, 1, speed); return true; } return false; @@ -5697,11 +5704,13 @@ arc_rtx_costs (rtx x, machine_mode mode, int outer_code, || (GET_CODE (XEXP (x, 1)) == MULT && _2_4_8_operand (XEXP (XEXP (x, 1), 1), VOIDmode))) { - *total += (rtx_cost (XEXP (x, 0), mode, PLUS, 0, speed) - + rtx_cost (XEXP (XEXP (x, 1), 0), mode, PLUS, 1, speed)); + if (CONSTANT_P (XEXP (x, 0)) && !speed) + *total += COSTS_N_INSNS (4); + *total += rtx_cost (XEXP (XEXP (x, 1), 0), mode, PLUS, 1, speed); return true; } return false; + case COMPARE: { rtx op0 = XEXP (x, 0); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3f4606d4552..e6671e3c861 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2019-06-10 Claudiu Zissulescu + + * gcc.target/arc/jumptables.c: Update test. + 2019-06-10 Claudiu Zissulescu * gcc.target/arc/and-cnst-size.c: New test. diff --git a/gcc/testsuite/gcc.target/arc/jumptable.c b/gcc/testsuite/gcc.target/arc/jumptable.c index fbc58e33149..ffbcf93e164 100644 --- a/gcc/testsuite/gcc.target/arc/jumptable.c +++ b/gcc/testsuite/gcc.target/arc/jumptable.c @@ -31,4 +31,4 @@ int switchCase(int value, int b) } /* { dg-final { scan-assembler-times "bih" 1 } } */ -/* { dg-final { scan-assembler-times "b_s" 8 } } */ +/* { dg-final { scan-assembler-times "b_s" 6 } } */