diff options
author | rsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-08-18 12:37:53 +0000 |
---|---|---|
committer | rsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-08-18 12:37:53 +0000 |
commit | 20d892d1b5bad381d02001ab7beef9b34b2223e6 (patch) | |
tree | 32eb4ba0348b5f9ebbe8e13117af0c1d2e9f4d87 /gcc | |
parent | 7013e87c514a70ba6ea24d9d7e16165730752543 (diff) | |
download | gcc-20d892d1b5bad381d02001ab7beef9b34b2223e6.tar.gz |
gcc/
* doc/tm.texi.in (TARGET_RTX_COSTS): Add an opno paramter.
* doc/tm.texi: Regenerate.
* target.def (rtx_costs): Add an opno parameter.
* hooks.h (hook_bool_rtx_int_int_intp_bool_false): Replace with...
(hook_bool_rtx_int_int_int_intp_bool_false): ...this.
* hooks.c (hook_bool_rtx_int_int_intp_bool_false): Replace with...
(hook_bool_rtx_int_int_int_intp_bool_false): ...this.
* cse.c (COST_IN): Add an opno parameter.
(notreg_cost): Likewise. Update call to rtx_cost.
(COST, fold_rtx): Update accordingly.
* dojump.c (prefer_and_bit_test): Update call to rtx_cost.
* expmed.c (emit_store_flag): Likewise.
* optabs.c (avoid_expensive_constant): Add an opno parameter.
Update call to rtx_cost.
(expand_binop_directly, expand_binop): Likewise.
(expand_twoval_binop, prepare_cmp_insn): Likewise.
* rtl.h (rtx_cost, get_full_rtx_cost): Add opno parameters.
(set_src_cost, get_full_set_src_cost): Update accordingly.
* rtlanal.c (rtx_cost): Add an opno parameter. Update call
to target hook.
(get_full_rtx_cost): Add an opno paramter. Update calls to rtx_cost.
(default_adress_cost): Update calls to rtx_cost.
* config/arm/arm.c (arm_rtx_costs_1, arm_size_rtx_costs)
(arm_slowmul_rtx_costs): Adjust calls to rtx_cost.
(arm_rtx_costs): Add an opno parameter.
* config/alpha/alpha.c (alpha_rtx_costs): Add an opno parameter and
adjust any recursive rtx-cost calls.
* config/avr/avr.c (avr_operand_rtx_cost, avr_rtx_costs): Likewise.
* config/bfin/bfin.c (bfin_rtx_costs): Likewise.
* config/c6x/c6x.c (c6x_rtx_costs): Likewise.
* config/cris/cris.c (cris_rtx_costs): Likewise.
* config/frv/frv.c (frv_rtx_costs): Likewise.
* config/h8300/h8300.c (h8300_rtx_costs): Likewise.
* config/i386/i386.c (ix86_rtx_costs): Likewise.
* config/ia64/ia64.c (ia64_rtx_costs): Likewise.
* config/iq2000/iq2000.c (iq2000_rtx_costs): Likewise.
* config/lm32/lm32.c (lm32_rtx_costs): Likewise.
* config/m32c/m32c.c (m32c_rtx_costs): Likewise.
* config/m32r/m32r.c (m32r_rtx_costs): Likewise.
* config/m68k/m68k.c (m68k_rtx_costs): Likewise.
* config/mcore/mcore.c (mcore_rtx_costs): Likewise.
* config/mep/mep.c (mep_rtx_cost): Likewise.
* config/microblaze/microblaze.c (microblaze_rtx_costs): Likewise.
* config/mips/mips.c (mips_binary_cost): Update call to rtx_cost.
(mips_zero_extend_cost): Add an opno parameter.
* config/mmix/mmix.c (mmix_rtx_costs): Likewise.
* config/mn10300/mn10300.c (mn10300_address_cost): Update call
to rtx_cost.
(mn10300_rtx_costs): Add an opno parameter and adjust any recursive
rtx-cost calls.
* config/pa/pa.c (hppa_rtx_costs): Likewise.
* config/pdp11/pdp11.c (pdp11_rtx_costs): Likewise.
* config/picochip/picochip.c (picochip_rtx_costs): Likewise.
* config/rs6000/rs6000.c (rs6000_rtx_costs): Likewise.
(rs6000_debug_rtx_costs): Likewise.
* config/s390/s390.c (s390_rtx_costs): Likewise.
* config/score/score-protos.h (score_rtx_costs): Likewise.
* config/score/score.c (score_rtx_costs): Likewise.
* config/sh/sh.c (andcosts): Update call to rtx_cost.
(sh_rtx_costs): Add an opno parameter.
* config/sparc/sparc.c (sparc_rtx_costs): Likewise.
* config/spu/spu.c (spu_rtx_costs): Likewise.
* config/stormy16/stormy16.c (xstormy16_rtx_costs): Likewise.
* config/v850/v850.c (v850_rtx_costs): Likewise.
* config/vax/vax.c (vax_rtx_costs): Likewise.
* config/xtensa/xtensa.c (xtensa_rtx_costs): Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@177852 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
47 files changed, 403 insertions, 264 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index a0fdc127e91..27cc3887a33 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,75 @@ 2011-08-18 Richard Sandiford <richard.sandiford@linaro.org> + * doc/tm.texi.in (TARGET_RTX_COSTS): Add an opno paramter. + * doc/tm.texi: Regenerate. + * target.def (rtx_costs): Add an opno parameter. + * hooks.h (hook_bool_rtx_int_int_intp_bool_false): Replace with... + (hook_bool_rtx_int_int_int_intp_bool_false): ...this. + * hooks.c (hook_bool_rtx_int_int_intp_bool_false): Replace with... + (hook_bool_rtx_int_int_int_intp_bool_false): ...this. + * cse.c (COST_IN): Add an opno parameter. + (notreg_cost): Likewise. Update call to rtx_cost. + (COST, fold_rtx): Update accordingly. + * dojump.c (prefer_and_bit_test): Update call to rtx_cost. + * expmed.c (emit_store_flag): Likewise. + * optabs.c (avoid_expensive_constant): Add an opno parameter. + Update call to rtx_cost. + (expand_binop_directly, expand_binop): Likewise. + (expand_twoval_binop, prepare_cmp_insn): Likewise. + * rtl.h (rtx_cost, get_full_rtx_cost): Add opno parameters. + (set_src_cost, get_full_set_src_cost): Update accordingly. + * rtlanal.c (rtx_cost): Add an opno parameter. Update call + to target hook. + (get_full_rtx_cost): Add an opno paramter. Update calls to rtx_cost. + (default_adress_cost): Update calls to rtx_cost. + + * config/arm/arm.c (arm_rtx_costs_1, arm_size_rtx_costs) + (arm_slowmul_rtx_costs): Adjust calls to rtx_cost. + (arm_rtx_costs): Add an opno parameter. + * config/alpha/alpha.c (alpha_rtx_costs): Add an opno parameter and + adjust any recursive rtx-cost calls. + * config/avr/avr.c (avr_operand_rtx_cost, avr_rtx_costs): Likewise. + * config/bfin/bfin.c (bfin_rtx_costs): Likewise. + * config/c6x/c6x.c (c6x_rtx_costs): Likewise. + * config/cris/cris.c (cris_rtx_costs): Likewise. + * config/frv/frv.c (frv_rtx_costs): Likewise. + * config/h8300/h8300.c (h8300_rtx_costs): Likewise. + * config/i386/i386.c (ix86_rtx_costs): Likewise. + * config/ia64/ia64.c (ia64_rtx_costs): Likewise. + * config/iq2000/iq2000.c (iq2000_rtx_costs): Likewise. + * config/lm32/lm32.c (lm32_rtx_costs): Likewise. + * config/m32c/m32c.c (m32c_rtx_costs): Likewise. + * config/m32r/m32r.c (m32r_rtx_costs): Likewise. + * config/m68k/m68k.c (m68k_rtx_costs): Likewise. + * config/mcore/mcore.c (mcore_rtx_costs): Likewise. + * config/mep/mep.c (mep_rtx_cost): Likewise. + * config/microblaze/microblaze.c (microblaze_rtx_costs): Likewise. + * config/mips/mips.c (mips_binary_cost): Update call to rtx_cost. + (mips_zero_extend_cost): Add an opno parameter. + * config/mmix/mmix.c (mmix_rtx_costs): Likewise. + * config/mn10300/mn10300.c (mn10300_address_cost): Update call + to rtx_cost. + (mn10300_rtx_costs): Add an opno parameter and adjust any recursive + rtx-cost calls. + * config/pa/pa.c (hppa_rtx_costs): Likewise. + * config/pdp11/pdp11.c (pdp11_rtx_costs): Likewise. + * config/picochip/picochip.c (picochip_rtx_costs): Likewise. + * config/rs6000/rs6000.c (rs6000_rtx_costs): Likewise. + (rs6000_debug_rtx_costs): Likewise. + * config/s390/s390.c (s390_rtx_costs): Likewise. + * config/score/score-protos.h (score_rtx_costs): Likewise. + * config/score/score.c (score_rtx_costs): Likewise. + * config/sh/sh.c (andcosts): Update call to rtx_cost. + (sh_rtx_costs): Add an opno parameter. + * config/sparc/sparc.c (sparc_rtx_costs): Likewise. + * config/spu/spu.c (spu_rtx_costs): Likewise. + * config/stormy16/stormy16.c (xstormy16_rtx_costs): Likewise. + * config/v850/v850.c (v850_rtx_costs): Likewise. + * config/vax/vax.c (vax_rtx_costs): Likewise. + * config/xtensa/xtensa.c (xtensa_rtx_costs): Likewise. + +2011-08-18 Richard Sandiford <richard.sandiford@linaro.org> + * rtl.h (set_src_cost, get_full_set_src_cost): New functions. * auto-inc-dec.c (attempt_change): Use set_src_cost instead of rtx_cost. diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c index a8a96075ee7..e195df5c0d6 100644 --- a/gcc/config/alpha/alpha.c +++ b/gcc/config/alpha/alpha.c @@ -1154,7 +1154,7 @@ alpha_legitimize_reload_address (rtx x, scanned. In either case, *TOTAL contains the cost result. */ static bool -alpha_rtx_costs (rtx x, int code, int outer_code, int *total, +alpha_rtx_costs (rtx x, int code, int outer_code, int opno, int *total, bool speed) { enum machine_mode mode = GET_MODE (x); @@ -1222,9 +1222,9 @@ alpha_rtx_costs (rtx x, int code, int outer_code, int *total, && const48_operand (XEXP (XEXP (x, 0), 1), VOIDmode)) { *total = (rtx_cost (XEXP (XEXP (x, 0), 0), - (enum rtx_code) outer_code, speed) + (enum rtx_code) outer_code, opno, speed) + rtx_cost (XEXP (x, 1), - (enum rtx_code) outer_code, speed) + (enum rtx_code) outer_code, opno, speed) + COSTS_N_INSNS (1)); return true; } diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index fc2fd474b7c..b32e863909a 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -151,7 +151,7 @@ static bool arm_slowmul_rtx_costs (rtx, enum rtx_code, enum rtx_code, int *, boo static bool arm_fastmul_rtx_costs (rtx, enum rtx_code, enum rtx_code, int *, bool); static bool arm_xscale_rtx_costs (rtx, enum rtx_code, enum rtx_code, int *, bool); static bool arm_9e_rtx_costs (rtx, enum rtx_code, enum rtx_code, int *, bool); -static bool arm_rtx_costs (rtx, int, int, int *, bool); +static bool arm_rtx_costs (rtx, int, int, int, int *, bool); static int arm_address_cost (rtx, bool); static bool arm_memory_load_p (rtx); static bool arm_cirrus_insn_p (rtx); @@ -6881,7 +6881,7 @@ arm_rtx_costs_1 (rtx x, enum rtx_code outer, int* total, bool speed) if (GET_CODE (XEXP (x, 1)) == REG) *total = COSTS_N_INSNS (1); /* Need to subtract from 32 */ else if (GET_CODE (XEXP (x, 1)) != CONST_INT) - *total = rtx_cost (XEXP (x, 1), code, speed); + *total = rtx_cost (XEXP (x, 1), code, 1, speed); /* Fall through */ case ROTATERT: @@ -6893,7 +6893,7 @@ arm_rtx_costs_1 (rtx x, enum rtx_code outer, int* total, bool speed) /* Fall through */ case ASHIFT: case LSHIFTRT: case ASHIFTRT: - *total += rtx_cost (XEXP (x, 0), code, speed); + *total += rtx_cost (XEXP (x, 0), code, 0, speed); if (mode == DImode) { *total += COSTS_N_INSNS (3); @@ -6916,14 +6916,14 @@ arm_rtx_costs_1 (rtx x, enum rtx_code outer, int* total, bool speed) if (GET_CODE (XEXP (x, 0)) == CONST_INT && const_ok_for_arm (INTVAL (XEXP (x, 0)))) { - *total += rtx_cost (XEXP (x, 1), code, speed); + *total += rtx_cost (XEXP (x, 1), code, 1, speed); return true; } if (GET_CODE (XEXP (x, 1)) == CONST_INT && const_ok_for_arm (INTVAL (XEXP (x, 1)))) { - *total += rtx_cost (XEXP (x, 0), code, speed); + *total += rtx_cost (XEXP (x, 0), code, 0, speed); return true; } @@ -6940,14 +6940,14 @@ arm_rtx_costs_1 (rtx x, enum rtx_code outer, int* total, bool speed) if (GET_CODE (XEXP (x, 0)) == CONST_DOUBLE && arm_const_double_rtx (XEXP (x, 0))) { - *total += rtx_cost (XEXP (x, 1), code, speed); + *total += rtx_cost (XEXP (x, 1), code, 1, speed); return true; } if (GET_CODE (XEXP (x, 1)) == CONST_DOUBLE && arm_const_double_rtx (XEXP (x, 1))) { - *total += rtx_cost (XEXP (x, 0), code, speed); + *total += rtx_cost (XEXP (x, 0), code, 0, speed); return true; } @@ -6961,7 +6961,7 @@ arm_rtx_costs_1 (rtx x, enum rtx_code outer, int* total, bool speed) if (GET_CODE (XEXP (x, 0)) == CONST_INT && const_ok_for_arm (INTVAL (XEXP (x, 0)))) { - *total += rtx_cost (XEXP (x, 1), code, speed); + *total += rtx_cost (XEXP (x, 1), code, 1, speed); return true; } @@ -6970,8 +6970,8 @@ arm_rtx_costs_1 (rtx x, enum rtx_code outer, int* total, bool speed) || subcode == LSHIFTRT || subcode == ROTATE || subcode == ROTATERT) { - *total += rtx_cost (XEXP (x, 0), code, speed); - *total += rtx_cost (XEXP (XEXP (x, 1), 0), subcode, speed); + *total += rtx_cost (XEXP (x, 0), code, 0, speed); + *total += rtx_cost (XEXP (XEXP (x, 1), 0), subcode, 0, speed); return true; } @@ -6979,23 +6979,23 @@ arm_rtx_costs_1 (rtx x, enum rtx_code outer, int* total, bool speed) if (GET_CODE (XEXP (x, 0)) == MULT && power_of_two_operand (XEXP (XEXP (x, 0), 1), SImode)) { - *total += rtx_cost (XEXP (XEXP (x, 0), 0), code, speed); - *total += rtx_cost (XEXP (x, 1), code, speed); + *total += rtx_cost (XEXP (XEXP (x, 0), 0), code, 0, speed); + *total += rtx_cost (XEXP (x, 1), code, 1, speed); return true; } if (subcode == MULT && power_of_two_operand (XEXP (XEXP (x, 1), 1), SImode)) { - *total += rtx_cost (XEXP (x, 0), code, speed); - *total += rtx_cost (XEXP (XEXP (x, 1), 0), subcode, speed); + *total += rtx_cost (XEXP (x, 0), code, 0, speed); + *total += rtx_cost (XEXP (XEXP (x, 1), 0), subcode, 0, speed); return true; } if (GET_RTX_CLASS (GET_CODE (XEXP (x, 1))) == RTX_COMPARE || GET_RTX_CLASS (GET_CODE (XEXP (x, 1))) == RTX_COMM_COMPARE) { - *total = COSTS_N_INSNS (1) + rtx_cost (XEXP (x, 0), code, speed); + *total = COSTS_N_INSNS (1) + rtx_cost (XEXP (x, 0), code, 0, speed); if (GET_CODE (XEXP (XEXP (x, 1), 0)) == REG && REGNO (XEXP (XEXP (x, 1), 0)) != CC_REGNUM) *total += COSTS_N_INSNS (1); @@ -7012,8 +7012,8 @@ arm_rtx_costs_1 (rtx x, enum rtx_code outer, int* total, bool speed) { *total = COSTS_N_INSNS (1); *total += rtx_cost (XEXP (XEXP (x, 0), 0), GET_CODE (XEXP (x, 0)), - speed); - *total += rtx_cost (XEXP (x, 1), code, speed); + 0, speed); + *total += rtx_cost (XEXP (x, 1), code, 1, speed); return true; } @@ -7037,7 +7037,7 @@ arm_rtx_costs_1 (rtx x, enum rtx_code outer, int* total, bool speed) if (GET_CODE (XEXP (x, 1)) == CONST_DOUBLE && arm_const_double_rtx (XEXP (x, 1))) { - *total += rtx_cost (XEXP (x, 0), code, speed); + *total += rtx_cost (XEXP (x, 0), code, 0, speed); return true; } @@ -7051,7 +7051,7 @@ arm_rtx_costs_1 (rtx x, enum rtx_code outer, int* total, bool speed) if (GET_RTX_CLASS (GET_CODE (XEXP (x, 0))) == RTX_COMPARE || GET_RTX_CLASS (GET_CODE (XEXP (x, 0))) == RTX_COMM_COMPARE) { - *total = COSTS_N_INSNS (1) + rtx_cost (XEXP (x, 1), code, speed); + *total = COSTS_N_INSNS (1) + rtx_cost (XEXP (x, 1), code, 1, speed); if (GET_CODE (XEXP (XEXP (x, 0), 0)) == REG && REGNO (XEXP (XEXP (x, 0), 0)) != CC_REGNUM) *total += COSTS_N_INSNS (1); @@ -7078,7 +7078,7 @@ arm_rtx_costs_1 (rtx x, enum rtx_code outer, int* total, bool speed) if (GET_CODE (XEXP (x, 1)) == CONST_INT && const_ok_for_op (INTVAL (XEXP (x, 1)), code)) { - *total += rtx_cost (XEXP (x, 0), code, speed); + *total += rtx_cost (XEXP (x, 0), code, 0, speed); return true; } @@ -7089,7 +7089,7 @@ arm_rtx_costs_1 (rtx x, enum rtx_code outer, int* total, bool speed) if (GET_CODE (XEXP (x, 1)) == CONST_INT && const_ok_for_op (INTVAL (XEXP (x, 1)), code)) { - *total += rtx_cost (XEXP (x, 0), code, speed); + *total += rtx_cost (XEXP (x, 0), code, 0, speed); return true; } subcode = GET_CODE (XEXP (x, 0)); @@ -7097,16 +7097,16 @@ arm_rtx_costs_1 (rtx x, enum rtx_code outer, int* total, bool speed) || subcode == LSHIFTRT || subcode == ROTATE || subcode == ROTATERT) { - *total += rtx_cost (XEXP (x, 1), code, speed); - *total += rtx_cost (XEXP (XEXP (x, 0), 0), subcode, speed); + *total += rtx_cost (XEXP (x, 1), code, 1, speed); + *total += rtx_cost (XEXP (XEXP (x, 0), 0), subcode, 0, speed); return true; } if (subcode == MULT && power_of_two_operand (XEXP (XEXP (x, 0), 1), SImode)) { - *total += rtx_cost (XEXP (x, 1), code, speed); - *total += rtx_cost (XEXP (XEXP (x, 0), 0), subcode, speed); + *total += rtx_cost (XEXP (x, 1), code, 1, speed); + *total += rtx_cost (XEXP (XEXP (x, 0), 0), subcode, 0, speed); return true; } @@ -7132,7 +7132,7 @@ arm_rtx_costs_1 (rtx x, enum rtx_code outer, int* total, bool speed) && (GET_CODE (XEXP (XEXP (XEXP (x, 0), 0), 0)) == ZERO_EXTEND || GET_CODE (XEXP (XEXP (XEXP (x, 0), 0), 0)) == SIGN_EXTEND)) { - *total = rtx_cost (XEXP (XEXP (x, 0), 0), LSHIFTRT, speed); + *total = rtx_cost (XEXP (XEXP (x, 0), 0), LSHIFTRT, 0, speed); return true; } *total = COSTS_N_INSNS (2); /* Plus the cost of the MULT */ @@ -7164,11 +7164,11 @@ arm_rtx_costs_1 (rtx x, enum rtx_code outer, int* total, bool speed) || (subcode == MULT && power_of_two_operand (XEXP (XEXP (x, 0), 1), SImode))) { - *total += rtx_cost (XEXP (XEXP (x, 0), 0), subcode, speed); + *total += rtx_cost (XEXP (XEXP (x, 0), 0), subcode, 0, speed); /* Register shifts cost an extra cycle. */ if (GET_CODE (XEXP (XEXP (x, 0), 1)) != CONST_INT) *total += COSTS_N_INSNS (1) + rtx_cost (XEXP (XEXP (x, 0), 1), - subcode, speed); + subcode, 1, speed); return true; } } @@ -7189,14 +7189,14 @@ arm_rtx_costs_1 (rtx x, enum rtx_code outer, int* total, bool speed) && GET_CODE (XEXP (operand, 0)) == REG && REGNO (XEXP (operand, 0)) == CC_REGNUM)) *total += COSTS_N_INSNS (1); - *total += (rtx_cost (XEXP (x, 1), code, speed) - + rtx_cost (XEXP (x, 2), code, speed)); + *total += (rtx_cost (XEXP (x, 1), code, 1, speed) + + rtx_cost (XEXP (x, 2), code, 2, speed)); return true; case NE: if (mode == SImode && XEXP (x, 1) == const0_rtx) { - *total = COSTS_N_INSNS (2) + rtx_cost (XEXP (x, 0), code, speed); + *total = COSTS_N_INSNS (2) + rtx_cost (XEXP (x, 0), code, 0, speed); return true; } goto scc_insn; @@ -7205,7 +7205,7 @@ arm_rtx_costs_1 (rtx x, enum rtx_code outer, int* total, bool speed) if ((GET_CODE (XEXP (x, 0)) != REG || REGNO (XEXP (x, 0)) != CC_REGNUM) && mode == SImode && XEXP (x, 1) == const0_rtx) { - *total = COSTS_N_INSNS (2) + rtx_cost (XEXP (x, 0), code, speed); + *total = COSTS_N_INSNS (2) + rtx_cost (XEXP (x, 0), code, 0, speed); return true; } goto scc_insn; @@ -7214,7 +7214,7 @@ arm_rtx_costs_1 (rtx x, enum rtx_code outer, int* total, bool speed) if ((GET_CODE (XEXP (x, 0)) != REG || REGNO (XEXP (x, 0)) != CC_REGNUM) && mode == SImode && XEXP (x, 1) == const0_rtx) { - *total = COSTS_N_INSNS (1) + rtx_cost (XEXP (x, 0), code, speed); + *total = COSTS_N_INSNS (1) + rtx_cost (XEXP (x, 0), code, 0, speed); return true; } goto scc_insn; @@ -7255,7 +7255,7 @@ arm_rtx_costs_1 (rtx x, enum rtx_code outer, int* total, bool speed) if (GET_CODE (XEXP (x, 1)) == CONST_INT && const_ok_for_op (INTVAL (XEXP (x, 1)), code)) { - *total += rtx_cost (XEXP (x, 0), code, speed); + *total += rtx_cost (XEXP (x, 0), code, 0, speed); return true; } @@ -7264,16 +7264,16 @@ arm_rtx_costs_1 (rtx x, enum rtx_code outer, int* total, bool speed) || subcode == LSHIFTRT || subcode == ROTATE || subcode == ROTATERT) { - *total += rtx_cost (XEXP (x, 1), code, speed); - *total += rtx_cost (XEXP (XEXP (x, 0), 0), subcode, speed); + *total += rtx_cost (XEXP (x, 1), code, 1, speed); + *total += rtx_cost (XEXP (XEXP (x, 0), 0), subcode, 0, speed); return true; } if (subcode == MULT && power_of_two_operand (XEXP (XEXP (x, 0), 1), SImode)) { - *total += rtx_cost (XEXP (x, 1), code, speed); - *total += rtx_cost (XEXP (XEXP (x, 0), 0), subcode, speed); + *total += rtx_cost (XEXP (x, 1), code, 1, speed); + *total += rtx_cost (XEXP (XEXP (x, 0), 0), subcode, 0, speed); return true; } @@ -7283,10 +7283,10 @@ arm_rtx_costs_1 (rtx x, enum rtx_code outer, int* total, bool speed) case UMAX: case SMIN: case SMAX: - *total = COSTS_N_INSNS (2) + rtx_cost (XEXP (x, 0), code, speed); + *total = COSTS_N_INSNS (2) + rtx_cost (XEXP (x, 0), code, 0, speed); if (GET_CODE (XEXP (x, 1)) != CONST_INT || !const_ok_for_arm (INTVAL (XEXP (x, 1)))) - *total += rtx_cost (XEXP (x, 1), code, speed); + *total += rtx_cost (XEXP (x, 1), code, 1, speed); return true; case ABS: @@ -7363,7 +7363,7 @@ arm_rtx_costs_1 (rtx x, enum rtx_code outer, int* total, bool speed) case ZERO_EXTRACT: case SIGN_EXTRACT: - *total = COSTS_N_INSNS (1) + rtx_cost (XEXP (x, 0), code, speed); + *total = COSTS_N_INSNS (1) + rtx_cost (XEXP (x, 0), code, 0, speed); return true; case CONST_INT: @@ -7388,7 +7388,7 @@ arm_rtx_costs_1 (rtx x, enum rtx_code outer, int* total, bool speed) case LO_SUM: *total = COSTS_N_INSNS (1); - *total += rtx_cost (XEXP (x, 0), code, speed); + *total += rtx_cost (XEXP (x, 0), code, 0, speed); return true; case CONST_DOUBLE: @@ -7574,7 +7574,7 @@ arm_size_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, case ROTATE: if (mode == SImode && GET_CODE (XEXP (x, 1)) == REG) { - *total = COSTS_N_INSNS (2) + rtx_cost (XEXP (x, 0), code, false); + *total = COSTS_N_INSNS (2) + rtx_cost (XEXP (x, 0), code, 0, false); return true; } /* Fall through */ @@ -7584,15 +7584,15 @@ arm_size_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, case ASHIFTRT: if (mode == DImode && GET_CODE (XEXP (x, 1)) == CONST_INT) { - *total = COSTS_N_INSNS (3) + rtx_cost (XEXP (x, 0), code, false); + *total = COSTS_N_INSNS (3) + rtx_cost (XEXP (x, 0), code, 0, false); return true; } else if (mode == SImode) { - *total = COSTS_N_INSNS (1) + rtx_cost (XEXP (x, 0), code, false); + *total = COSTS_N_INSNS (1) + rtx_cost (XEXP (x, 0), code, 0, false); /* Slightly disparage register shifts, but not by much. */ if (GET_CODE (XEXP (x, 1)) != CONST_INT) - *total += 1 + rtx_cost (XEXP (x, 1), code, false); + *total += 1 + rtx_cost (XEXP (x, 1), code, 1, false); return true; } @@ -7644,8 +7644,8 @@ arm_size_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, && power_of_two_operand (XEXP (XEXP (x, 0), 1), SImode)) { *total = COSTS_N_INSNS (TARGET_THUMB2 ? 2 : 1); - *total += rtx_cost (XEXP (XEXP (x, 0), 0), code, false); - *total += rtx_cost (XEXP (x, 1), code, false); + *total += rtx_cost (XEXP (XEXP (x, 0), 0), code, 0, false); + *total += rtx_cost (XEXP (x, 1), code, 1, false); return true; } @@ -7757,8 +7757,8 @@ arm_size_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, /* RTX costs when optimizing for size. */ static bool -arm_rtx_costs (rtx x, int code, int outer_code, int *total, - bool speed) +arm_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, + int *total, bool speed) { if (!speed) return arm_size_rtx_costs (x, (enum rtx_code) code, @@ -7811,7 +7811,7 @@ arm_slowmul_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, } *total = COSTS_N_INSNS (cost); - *total += rtx_cost (XEXP (x, 0), code, speed); + *total += rtx_cost (XEXP (x, 0), code, 0, speed); return true; } diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c index 79cf0a5bffd..3980feb5f6f 100644 --- a/gcc/config/avr/avr.c +++ b/gcc/config/avr/avr.c @@ -89,8 +89,9 @@ static void avr_asm_out_ctor (rtx, int); static void avr_asm_out_dtor (rtx, int); static int avr_register_move_cost (enum machine_mode, reg_class_t, reg_class_t); static int avr_memory_move_cost (enum machine_mode, reg_class_t, bool); -static int avr_operand_rtx_cost (rtx, enum machine_mode, enum rtx_code, bool); -static bool avr_rtx_costs (rtx, int, int, int *, bool); +static int avr_operand_rtx_cost (rtx, enum machine_mode, enum rtx_code, + int, bool); +static bool avr_rtx_costs (rtx, int, int, int, int *, bool); static int avr_address_cost (rtx, bool); static bool avr_return_in_memory (const_tree, const_tree); static struct machine_function * avr_init_machine_status (void); @@ -1640,7 +1641,8 @@ final_prescan_insn (rtx insn, rtx *operand ATTRIBUTE_UNUSED, set_src_cost (SET_SRC (set), optimize_insn_for_speed_p ())); else fprintf (asm_out_file, "/* DEBUG: pattern-cost = %d. */\n", - rtx_cost (PATTERN (insn), INSN, optimize_insn_for_speed_p())); + rtx_cost (PATTERN (insn), INSN, 0, + optimize_insn_for_speed_p())); } } @@ -5302,7 +5304,7 @@ avr_memory_move_cost (enum machine_mode mode, reg_class_t rclass ATTRIBUTE_UNUSE static int avr_operand_rtx_cost (rtx x, enum machine_mode mode, enum rtx_code outer, - bool speed) + int opno, bool speed) { enum rtx_code code = GET_CODE (x); int total; @@ -5322,7 +5324,7 @@ avr_operand_rtx_cost (rtx x, enum machine_mode mode, enum rtx_code outer, } total = 0; - avr_rtx_costs (x, code, outer, &total, speed); + avr_rtx_costs (x, code, outer, opno, &total, speed); return total; } @@ -5332,8 +5334,8 @@ avr_operand_rtx_cost (rtx x, enum machine_mode mode, enum rtx_code outer, case, *TOTAL contains the cost result. */ static bool -avr_rtx_costs (rtx x, int codearg, int outer_code ATTRIBUTE_UNUSED, int *total, - bool speed) +avr_rtx_costs (rtx x, int codearg, int outer_code ATTRIBUTE_UNUSED, + int opno ATTRIBUTE_UNUSED, int *total, bool speed) { enum rtx_code code = (enum rtx_code) codearg; enum machine_mode mode = GET_MODE (x); @@ -5373,7 +5375,7 @@ avr_rtx_costs (rtx x, int codearg, int outer_code ATTRIBUTE_UNUSED, int *total, default: return false; } - *total += avr_operand_rtx_cost (XEXP (x, 0), mode, code, speed); + *total += avr_operand_rtx_cost (XEXP (x, 0), mode, code, 0, speed); return true; case ABS: @@ -5387,24 +5389,24 @@ avr_rtx_costs (rtx x, int codearg, int outer_code ATTRIBUTE_UNUSED, int *total, default: return false; } - *total += avr_operand_rtx_cost (XEXP (x, 0), mode, code, speed); + *total += avr_operand_rtx_cost (XEXP (x, 0), mode, code, 0, speed); return true; case NOT: *total = COSTS_N_INSNS (GET_MODE_SIZE (mode)); - *total += avr_operand_rtx_cost (XEXP (x, 0), mode, code, speed); + *total += avr_operand_rtx_cost (XEXP (x, 0), mode, code, 0, speed); return true; case ZERO_EXTEND: *total = COSTS_N_INSNS (GET_MODE_SIZE (mode) - GET_MODE_SIZE (GET_MODE (XEXP (x, 0)))); - *total += avr_operand_rtx_cost (XEXP (x, 0), mode, code, speed); + *total += avr_operand_rtx_cost (XEXP (x, 0), mode, code, 0, speed); return true; case SIGN_EXTEND: *total = COSTS_N_INSNS (GET_MODE_SIZE (mode) + 2 - GET_MODE_SIZE (GET_MODE (XEXP (x, 0)))); - *total += avr_operand_rtx_cost (XEXP (x, 0), mode, code, speed); + *total += avr_operand_rtx_cost (XEXP (x, 0), mode, code, 0, speed); return true; case PLUS: @@ -5413,14 +5415,15 @@ avr_rtx_costs (rtx x, int codearg, int outer_code ATTRIBUTE_UNUSED, int *total, case QImode: *total = COSTS_N_INSNS (1); if (GET_CODE (XEXP (x, 1)) != CONST_INT) - *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, speed); + *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, 1, speed); break; case HImode: if (GET_CODE (XEXP (x, 1)) != CONST_INT) { *total = COSTS_N_INSNS (2); - *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, speed); + *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, 1, + speed); } else if (INTVAL (XEXP (x, 1)) >= -63 && INTVAL (XEXP (x, 1)) <= 63) *total = COSTS_N_INSNS (1); @@ -5432,7 +5435,8 @@ avr_rtx_costs (rtx x, int codearg, int outer_code ATTRIBUTE_UNUSED, int *total, if (GET_CODE (XEXP (x, 1)) != CONST_INT) { *total = COSTS_N_INSNS (4); - *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, speed); + *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, 1, + speed); } else if (INTVAL (XEXP (x, 1)) >= -63 && INTVAL (XEXP (x, 1)) <= 63) *total = COSTS_N_INSNS (1); @@ -5443,22 +5447,22 @@ avr_rtx_costs (rtx x, int codearg, int outer_code ATTRIBUTE_UNUSED, int *total, default: return false; } - *total += avr_operand_rtx_cost (XEXP (x, 0), mode, code, speed); + *total += avr_operand_rtx_cost (XEXP (x, 0), mode, code, 0, speed); return true; case MINUS: case AND: case IOR: *total = COSTS_N_INSNS (GET_MODE_SIZE (mode)); - *total += avr_operand_rtx_cost (XEXP (x, 0), mode, code, speed); + *total += avr_operand_rtx_cost (XEXP (x, 0), mode, code, 0, speed); if (GET_CODE (XEXP (x, 1)) != CONST_INT) - *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, speed); + *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, 1, speed); return true; case XOR: *total = COSTS_N_INSNS (GET_MODE_SIZE (mode)); - *total += avr_operand_rtx_cost (XEXP (x, 0), mode, code, speed); - *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, speed); + *total += avr_operand_rtx_cost (XEXP (x, 0), mode, code, 0, speed); + *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, 1, speed); return true; case MULT: @@ -5548,8 +5552,8 @@ avr_rtx_costs (rtx x, int codearg, int outer_code ATTRIBUTE_UNUSED, int *total, default: return false; } - *total += avr_operand_rtx_cost (XEXP (x, 0), mode, code, speed); - *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, speed); + *total += avr_operand_rtx_cost (XEXP (x, 0), mode, code, 0, speed); + *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, 1, speed); return true; case DIV: @@ -5560,8 +5564,8 @@ avr_rtx_costs (rtx x, int codearg, int outer_code ATTRIBUTE_UNUSED, int *total, *total = COSTS_N_INSNS (AVR_HAVE_JMP_CALL ? 2 : 1); else return false; - *total += avr_operand_rtx_cost (XEXP (x, 0), mode, code, speed); - *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, speed); + *total += avr_operand_rtx_cost (XEXP (x, 0), mode, code, 0, speed); + *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, 1, speed); return true; case ROTATE: @@ -5596,7 +5600,7 @@ avr_rtx_costs (rtx x, int codearg, int outer_code ATTRIBUTE_UNUSED, int *total, default: return false; } - *total += avr_operand_rtx_cost (XEXP (x, 0), mode, code, speed); + *total += avr_operand_rtx_cost (XEXP (x, 0), mode, code, 0, speed); return true; case ASHIFT: @@ -5606,7 +5610,8 @@ avr_rtx_costs (rtx x, int codearg, int outer_code ATTRIBUTE_UNUSED, int *total, if (GET_CODE (XEXP (x, 1)) != CONST_INT) { *total = COSTS_N_INSNS (!speed ? 4 : 17); - *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, speed); + *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, 1, + speed); } else { @@ -5635,7 +5640,8 @@ avr_rtx_costs (rtx x, int codearg, int outer_code ATTRIBUTE_UNUSED, int *total, if (GET_CODE (XEXP (x, 1)) != CONST_INT) { *total = COSTS_N_INSNS (!speed ? 5 : 41); - *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, speed); + *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, 1, + speed); } else switch (INTVAL (XEXP (x, 1))) @@ -5672,7 +5678,8 @@ avr_rtx_costs (rtx x, int codearg, int outer_code ATTRIBUTE_UNUSED, int *total, break; default: *total = COSTS_N_INSNS (!speed ? 5 : 41); - *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, speed); + *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, 1, + speed); } break; @@ -5680,7 +5687,8 @@ avr_rtx_costs (rtx x, int codearg, int outer_code ATTRIBUTE_UNUSED, int *total, if (GET_CODE (XEXP (x, 1)) != CONST_INT) { *total = COSTS_N_INSNS (!speed ? 7 : 113); - *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, speed); + *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, 1, + speed); } else switch (INTVAL (XEXP (x, 1))) @@ -5704,14 +5712,15 @@ avr_rtx_costs (rtx x, int codearg, int outer_code ATTRIBUTE_UNUSED, int *total, break; default: *total = COSTS_N_INSNS (!speed ? 7 : 113); - *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, speed); + *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, 1, + speed); } break; default: return false; } - *total += avr_operand_rtx_cost (XEXP (x, 0), mode, code, speed); + *total += avr_operand_rtx_cost (XEXP (x, 0), mode, code, 0, speed); return true; case ASHIFTRT: @@ -5721,7 +5730,8 @@ avr_rtx_costs (rtx x, int codearg, int outer_code ATTRIBUTE_UNUSED, int *total, if (GET_CODE (XEXP (x, 1)) != CONST_INT) { *total = COSTS_N_INSNS (!speed ? 4 : 17); - *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, speed); + *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, 1, + speed); } else { @@ -5741,7 +5751,8 @@ avr_rtx_costs (rtx x, int codearg, int outer_code ATTRIBUTE_UNUSED, int *total, if (GET_CODE (XEXP (x, 1)) != CONST_INT) { *total = COSTS_N_INSNS (!speed ? 5 : 41); - *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, speed); + *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, 1, + speed); } else switch (INTVAL (XEXP (x, 1))) @@ -5777,7 +5788,8 @@ avr_rtx_costs (rtx x, int codearg, int outer_code ATTRIBUTE_UNUSED, int *total, break; default: *total = COSTS_N_INSNS (!speed ? 5 : 41); - *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, speed); + *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, 1, + speed); } break; @@ -5785,7 +5797,8 @@ avr_rtx_costs (rtx x, int codearg, int outer_code ATTRIBUTE_UNUSED, int *total, if (GET_CODE (XEXP (x, 1)) != CONST_INT) { *total = COSTS_N_INSNS (!speed ? 7 : 113); - *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, speed); + *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, 1, + speed); } else switch (INTVAL (XEXP (x, 1))) @@ -5809,14 +5822,15 @@ avr_rtx_costs (rtx x, int codearg, int outer_code ATTRIBUTE_UNUSED, int *total, break; default: *total = COSTS_N_INSNS (!speed ? 7 : 113); - *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, speed); + *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, 1, + speed); } break; default: return false; } - *total += avr_operand_rtx_cost (XEXP (x, 0), mode, code, speed); + *total += avr_operand_rtx_cost (XEXP (x, 0), mode, code, 0, speed); return true; case LSHIFTRT: @@ -5826,7 +5840,8 @@ avr_rtx_costs (rtx x, int codearg, int outer_code ATTRIBUTE_UNUSED, int *total, if (GET_CODE (XEXP (x, 1)) != CONST_INT) { *total = COSTS_N_INSNS (!speed ? 4 : 17); - *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, speed); + *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, 1, + speed); } else { @@ -5844,7 +5859,8 @@ avr_rtx_costs (rtx x, int codearg, int outer_code ATTRIBUTE_UNUSED, int *total, if (GET_CODE (XEXP (x, 1)) != CONST_INT) { *total = COSTS_N_INSNS (!speed ? 5 : 41); - *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, speed); + *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, 1, + speed); } else switch (INTVAL (XEXP (x, 1))) @@ -5883,7 +5899,8 @@ avr_rtx_costs (rtx x, int codearg, int outer_code ATTRIBUTE_UNUSED, int *total, break; default: *total = COSTS_N_INSNS (!speed ? 5 : 41); - *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, speed); + *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, 1, + speed); } break; @@ -5891,7 +5908,8 @@ avr_rtx_costs (rtx x, int codearg, int outer_code ATTRIBUTE_UNUSED, int *total, if (GET_CODE (XEXP (x, 1)) != CONST_INT) { *total = COSTS_N_INSNS (!speed ? 7 : 113); - *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, speed); + *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, 1, + speed); } else switch (INTVAL (XEXP (x, 1))) @@ -5915,14 +5933,15 @@ avr_rtx_costs (rtx x, int codearg, int outer_code ATTRIBUTE_UNUSED, int *total, break; default: *total = COSTS_N_INSNS (!speed ? 7 : 113); - *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, speed); + *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, 1, + speed); } break; default: return false; } - *total += avr_operand_rtx_cost (XEXP (x, 0), mode, code, speed); + *total += avr_operand_rtx_cost (XEXP (x, 0), mode, code, 0, speed); return true; case COMPARE: @@ -5931,13 +5950,13 @@ avr_rtx_costs (rtx x, int codearg, int outer_code ATTRIBUTE_UNUSED, int *total, case QImode: *total = COSTS_N_INSNS (1); if (GET_CODE (XEXP (x, 1)) != CONST_INT) - *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, speed); + *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, 1, speed); break; case HImode: *total = COSTS_N_INSNS (2); if (GET_CODE (XEXP (x, 1)) != CONST_INT) - *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, speed); + *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, 1, speed); else if (INTVAL (XEXP (x, 1)) != 0) *total += COSTS_N_INSNS (1); break; @@ -5945,7 +5964,7 @@ avr_rtx_costs (rtx x, int codearg, int outer_code ATTRIBUTE_UNUSED, int *total, case SImode: *total = COSTS_N_INSNS (4); if (GET_CODE (XEXP (x, 1)) != CONST_INT) - *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, speed); + *total += avr_operand_rtx_cost (XEXP (x, 1), mode, code, 1, speed); else if (INTVAL (XEXP (x, 1)) != 0) *total += COSTS_N_INSNS (3); break; @@ -5953,7 +5972,7 @@ avr_rtx_costs (rtx x, int codearg, int outer_code ATTRIBUTE_UNUSED, int *total, default: return false; } - *total += avr_operand_rtx_cost (XEXP (x, 0), mode, code, speed); + *total += avr_operand_rtx_cost (XEXP (x, 0), mode, code, 0, speed); return true; case TRUNCATE: diff --git a/gcc/config/bfin/bfin.c b/gcc/config/bfin/bfin.c index 8cd315d9e76..8a0d5a0a807 100644 --- a/gcc/config/bfin/bfin.c +++ b/gcc/config/bfin/bfin.c @@ -2779,7 +2779,8 @@ bfin_legitimate_constant_p (enum machine_mode mode ATTRIBUTE_UNUSED, rtx x) } static bool -bfin_rtx_costs (rtx x, int code_i, int outer_code_i, int *total, bool speed) +bfin_rtx_costs (rtx x, int code_i, int outer_code_i, int opno, int *total, + bool speed) { enum rtx_code code = (enum rtx_code) code_i; enum rtx_code outer_code = (enum rtx_code) outer_code_i; @@ -2829,8 +2830,8 @@ bfin_rtx_costs (rtx x, int code_i, int outer_code_i, int *total, bool speed) if (val == 2 || val == 4) { *total = cost2; - *total += rtx_cost (XEXP (op0, 0), outer_code, speed); - *total += rtx_cost (op1, outer_code, speed); + *total += rtx_cost (XEXP (op0, 0), outer_code, opno, speed); + *total += rtx_cost (op1, outer_code, opno, speed); return true; } } @@ -2849,10 +2850,10 @@ bfin_rtx_costs (rtx x, int code_i, int outer_code_i, int *total, bool speed) *total = 6 * cost2; if (GET_CODE (op1) != CONST_INT || !satisfies_constraint_Ks7 (op1)) - *total += rtx_cost (op1, PLUS, speed); + *total += rtx_cost (op1, PLUS, 1, speed); if (GET_CODE (op0) != REG && (GET_CODE (op0) != SUBREG || GET_CODE (SUBREG_REG (op0)) != REG)) - *total += rtx_cost (op0, PLUS, speed); + *total += rtx_cost (op0, PLUS, 0, speed); } return true; @@ -2875,7 +2876,7 @@ bfin_rtx_costs (rtx x, int code_i, int outer_code_i, int *total, bool speed) op1 = XEXP (x, 1); if (GET_CODE (op0) != REG && (GET_CODE (op0) != SUBREG || GET_CODE (SUBREG_REG (op0)) != REG)) - *total += rtx_cost (op0, code, speed); + *total += rtx_cost (op0, code, 0, speed); return true; @@ -2900,7 +2901,7 @@ bfin_rtx_costs (rtx x, int code_i, int outer_code_i, int *total, bool speed) if (GET_CODE (op0) != REG && (GET_CODE (op0) != SUBREG || GET_CODE (SUBREG_REG (op0)) != REG)) - *total += rtx_cost (op0, code, speed); + *total += rtx_cost (op0, code, 0, speed); if (GET_MODE (x) == DImode) { @@ -2914,12 +2915,12 @@ bfin_rtx_costs (rtx x, int code_i, int outer_code_i, int *total, bool speed) if (code == AND) { if (! rhs_andsi3_operand (XEXP (x, 1), SImode)) - *total += rtx_cost (XEXP (x, 1), code, speed); + *total += rtx_cost (XEXP (x, 1), code, 1, speed); } else { if (! regorlog2_operand (XEXP (x, 1), SImode)) - *total += rtx_cost (XEXP (x, 1), code, speed); + *total += rtx_cost (XEXP (x, 1), code, 1, speed); } return true; @@ -2959,10 +2960,10 @@ bfin_rtx_costs (rtx x, int code_i, int outer_code_i, int *total, bool speed) if (GET_CODE (op0) != REG && (GET_CODE (op0) != SUBREG || GET_CODE (SUBREG_REG (op0)) != REG)) - *total += rtx_cost (op0, MULT, speed); + *total += rtx_cost (op0, MULT, 0, speed); if (GET_CODE (op1) != REG && (GET_CODE (op1) != SUBREG || GET_CODE (SUBREG_REG (op1)) != REG)) - *total += rtx_cost (op1, MULT, speed); + *total += rtx_cost (op1, MULT, 1, speed); } return true; diff --git a/gcc/config/c6x/c6x.c b/gcc/config/c6x/c6x.c index deb2f5395dd..e77ed70fd35 100644 --- a/gcc/config/c6x/c6x.c +++ b/gcc/config/c6x/c6x.c @@ -4772,7 +4772,8 @@ shift_p (rtx x, enum rtx_code code, int amount) scanned. In either case, *TOTAL contains the cost result. */ static bool -c6x_rtx_costs (rtx x, int code, int outer_code, int *total, bool speed) +c6x_rtx_costs (rtx x, int code, int outer_code, int opno, int *total, + bool speed) { int cost2 = COSTS_N_INSNS (1); rtx op0, op1; @@ -4826,8 +4827,8 @@ c6x_rtx_costs (rtx x, int code, int outer_code, int *total, bool speed) *total = COSTS_N_INSNS (2); else *total = COSTS_N_INSNS (12); - *total += rtx_cost (XEXP (op0, 0), code0, speed); - *total += rtx_cost (XEXP (op1, 0), code1, speed); + *total += rtx_cost (XEXP (op0, 0), code0, 0, speed); + *total += rtx_cost (XEXP (op1, 0), code1, 0, speed); return true; } } @@ -4855,8 +4856,8 @@ c6x_rtx_costs (rtx x, int code, int outer_code, int *total, bool speed) || INTVAL (XEXP (op0, 1)) == 4 || (code == PLUS && INTVAL (XEXP (op0, 1)) == 8))) { - *total += rtx_cost (XEXP (op0, 0), ASHIFT, speed); - *total += rtx_cost (op1, (enum rtx_code)code, speed); + *total += rtx_cost (XEXP (op0, 0), ASHIFT, 0, speed); + *total += rtx_cost (op1, (enum rtx_code) code, 1, speed); return true; } return false; @@ -4926,10 +4927,10 @@ c6x_rtx_costs (rtx x, int code, int outer_code, int *total, bool speed) if (GET_CODE (op0) != REG && (GET_CODE (op0) != SUBREG || GET_CODE (SUBREG_REG (op0)) != REG)) - *total += rtx_cost (op0, MULT, speed); + *total += rtx_cost (op0, MULT, 0, speed); if (op1 && GET_CODE (op1) != REG && (GET_CODE (op1) != SUBREG || GET_CODE (SUBREG_REG (op1)) != REG)) - *total += rtx_cost (op1, MULT, speed); + *total += rtx_cost (op1, MULT, 1, speed); return true; case UDIV: @@ -4947,7 +4948,8 @@ c6x_rtx_costs (rtx x, int code, int outer_code, int *total, bool speed) && XEXP (op0, 1) == const0_rtx && rtx_equal_p (XEXP (x, 1), XEXP (op0, 0))) { - *total = rtx_cost (XEXP (x, 1), (enum rtx_code)outer_code, speed); + *total = rtx_cost (XEXP (x, 1), (enum rtx_code) outer_code, + opno, speed); return false; } return false; diff --git a/gcc/config/cris/cris.c b/gcc/config/cris/cris.c index 0c318268440..24cfa5a2d53 100644 --- a/gcc/config/cris/cris.c +++ b/gcc/config/cris/cris.c @@ -123,7 +123,7 @@ static void cris_init_libfuncs (void); static int cris_register_move_cost (enum machine_mode, reg_class_t, reg_class_t); static int cris_memory_move_cost (enum machine_mode, reg_class_t, bool); -static bool cris_rtx_costs (rtx, int, int, int *, bool); +static bool cris_rtx_costs (rtx, int, int, int, int *, bool); static int cris_address_cost (rtx, bool); static bool cris_pass_by_reference (cumulative_args_t, enum machine_mode, const_tree, bool); @@ -1777,7 +1777,7 @@ cris_expand_return (bool on_stack) scanned. In either case, *TOTAL contains the cost result. */ static bool -cris_rtx_costs (rtx x, int code, int outer_code, int *total, +cris_rtx_costs (rtx x, int code, int outer_code, int opno, int *total, bool speed) { switch (code) @@ -1871,7 +1871,8 @@ cris_rtx_costs (rtx x, int code, int outer_code, int *total, && !CRIS_CONST_OK_FOR_LETTER_P (INTVAL (XEXP (x, 1)), 'I')) { *total - = (rtx_cost (XEXP (x, 0), (enum rtx_code) outer_code, speed) + 2 + = (rtx_cost (XEXP (x, 0), (enum rtx_code) outer_code, + opno, speed) + 2 + 2 * GET_MODE_NUNITS (GET_MODE (XEXP (x, 0)))); return true; } @@ -1883,7 +1884,7 @@ cris_rtx_costs (rtx x, int code, int outer_code, int *total, /* fall through */ case ZERO_EXTEND: case SIGN_EXTEND: - *total = rtx_cost (XEXP (x, 0), (enum rtx_code) outer_code, speed); + *total = rtx_cost (XEXP (x, 0), (enum rtx_code) outer_code, opno, speed); return true; default: diff --git a/gcc/config/frv/frv.c b/gcc/config/frv/frv.c index 01ed8e769e7..7d8b47bb1dd 100644 --- a/gcc/config/frv/frv.c +++ b/gcc/config/frv/frv.c @@ -364,7 +364,8 @@ static void frv_setup_incoming_varargs (cumulative_args_t, tree, int *, int); static rtx frv_expand_builtin_saveregs (void); static void frv_expand_builtin_va_start (tree, rtx); -static bool frv_rtx_costs (rtx, int, int, int*, bool); +static bool frv_rtx_costs (rtx, int, int, int, int*, + bool); static int frv_register_move_cost (enum machine_mode, reg_class_t, reg_class_t); static int frv_memory_move_cost (enum machine_mode, @@ -9496,6 +9497,7 @@ static bool frv_rtx_costs (rtx x, int code ATTRIBUTE_UNUSED, int outer_code ATTRIBUTE_UNUSED, + int opno ATTRIBUTE_UNUSED, int *total, bool speed ATTRIBUTE_UNUSED) { diff --git a/gcc/config/h8300/h8300.c b/gcc/config/h8300/h8300.c index a929a28663a..c5603934372 100644 --- a/gcc/config/h8300/h8300.c +++ b/gcc/config/h8300/h8300.c @@ -1174,7 +1174,8 @@ h8300_shift_costs (rtx x) /* Worker function for TARGET_RTX_COSTS. */ static bool -h8300_rtx_costs (rtx x, int code, int outer_code, int *total, bool speed) +h8300_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, + int *total, bool speed) { if (TARGET_H8300SX && outer_code == MEM) { diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index fe6ccbeb59c..3356cfd748c 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -28825,7 +28825,8 @@ ix86_modes_tieable_p (enum machine_mode mode1, enum machine_mode mode2) scanned. In either case, *TOTAL contains the cost result. */ static bool -ix86_rtx_costs (rtx x, int code, int outer_code_i, int *total, bool speed) +ix86_rtx_costs (rtx x, int code, int outer_code_i, int opno, int *total, + bool speed) { enum rtx_code outer_code = (enum rtx_code) outer_code_i; enum machine_mode mode = GET_MODE (x); @@ -28949,18 +28950,18 @@ ix86_rtx_costs (rtx x, int code, int outer_code_i, int *total, bool speed) /* ??? SSE scalar/vector cost should be used here. */ /* ??? Bald assumption that fma has the same cost as fmul. */ *total = cost->fmul; - *total += rtx_cost (XEXP (x, 1), FMA, speed); + *total += rtx_cost (XEXP (x, 1), FMA, 1, speed); /* Negate in op0 or op2 is free: FMS, FNMA, FNMS. */ sub = XEXP (x, 0); if (GET_CODE (sub) == NEG) sub = XEXP (sub, 0); - *total += rtx_cost (sub, FMA, speed); + *total += rtx_cost (sub, FMA, 0, speed); sub = XEXP (x, 2); if (GET_CODE (sub) == NEG) sub = XEXP (sub, 0); - *total += rtx_cost (sub, FMA, speed); + *total += rtx_cost (sub, FMA, 2, speed); return true; } @@ -29022,7 +29023,8 @@ ix86_rtx_costs (rtx x, int code, int outer_code_i, int *total, bool speed) *total = (cost->mult_init[MODE_INDEX (mode)] + nbits * cost->mult_bit - + rtx_cost (op0, outer_code, speed) + rtx_cost (op1, outer_code, speed)); + + rtx_cost (op0, outer_code, opno, speed) + + rtx_cost (op1, outer_code, opno, speed)); return true; } @@ -29056,10 +29058,11 @@ ix86_rtx_costs (rtx x, int code, int outer_code_i, int *total, bool speed) if (val == 2 || val == 4 || val == 8) { *total = cost->lea; - *total += rtx_cost (XEXP (XEXP (x, 0), 1), outer_code, speed); + *total += rtx_cost (XEXP (XEXP (x, 0), 1), + outer_code, opno, speed); *total += rtx_cost (XEXP (XEXP (XEXP (x, 0), 0), 0), - outer_code, speed); - *total += rtx_cost (XEXP (x, 1), outer_code, speed); + outer_code, opno, speed); + *total += rtx_cost (XEXP (x, 1), outer_code, opno, speed); return true; } } @@ -29070,17 +29073,20 @@ ix86_rtx_costs (rtx x, int code, int outer_code_i, int *total, bool speed) if (val == 2 || val == 4 || val == 8) { *total = cost->lea; - *total += rtx_cost (XEXP (XEXP (x, 0), 0), outer_code, speed); - *total += rtx_cost (XEXP (x, 1), outer_code, speed); + *total += rtx_cost (XEXP (XEXP (x, 0), 0), + outer_code, opno, speed); + *total += rtx_cost (XEXP (x, 1), outer_code, opno, speed); return true; } } else if (GET_CODE (XEXP (x, 0)) == PLUS) { *total = cost->lea; - *total += rtx_cost (XEXP (XEXP (x, 0), 0), outer_code, speed); - *total += rtx_cost (XEXP (XEXP (x, 0), 1), outer_code, speed); - *total += rtx_cost (XEXP (x, 1), outer_code, speed); + *total += rtx_cost (XEXP (XEXP (x, 0), 0), + outer_code, opno, speed); + *total += rtx_cost (XEXP (XEXP (x, 0), 1), + outer_code, opno, speed); + *total += rtx_cost (XEXP (x, 1), outer_code, opno, speed); return true; } } @@ -29112,9 +29118,9 @@ ix86_rtx_costs (rtx x, int code, int outer_code_i, int *total, bool speed) if (!TARGET_64BIT && mode == DImode) { *total = (cost->add * 2 - + (rtx_cost (XEXP (x, 0), outer_code, speed) + + (rtx_cost (XEXP (x, 0), outer_code, opno, speed) << (GET_MODE (XEXP (x, 0)) != DImode)) - + (rtx_cost (XEXP (x, 1), outer_code, speed) + + (rtx_cost (XEXP (x, 1), outer_code, opno, speed) << (GET_MODE (XEXP (x, 1)) != DImode))); return true; } @@ -29156,8 +29162,8 @@ ix86_rtx_costs (rtx x, int code, int outer_code_i, int *total, bool speed) /* This kind of construct is implemented using test[bwl]. Treat it as if we had an AND. */ *total = (cost->add - + rtx_cost (XEXP (XEXP (x, 0), 0), outer_code, speed) - + rtx_cost (const1_rtx, outer_code, speed)); + + rtx_cost (XEXP (XEXP (x, 0), 0), outer_code, opno, speed) + + rtx_cost (const1_rtx, outer_code, opno, speed)); return true; } return false; diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c index fa3b93fa6cc..f4fbf08396d 100644 --- a/gcc/config/ia64/ia64.c +++ b/gcc/config/ia64/ia64.c @@ -217,7 +217,7 @@ static int ia64_register_move_cost (enum machine_mode, reg_class_t, reg_class_t); static int ia64_memory_move_cost (enum machine_mode mode, reg_class_t, bool); -static bool ia64_rtx_costs (rtx, int, int, int *, bool); +static bool ia64_rtx_costs (rtx, int, int, int, int *, bool); static int ia64_unspec_may_trap_p (const_rtx, unsigned); static void fix_range (const char *); static struct machine_function * ia64_init_machine_status (void); @@ -5244,8 +5244,8 @@ ia64_print_operand (FILE * file, rtx x, int code) /* ??? This is incomplete. */ static bool -ia64_rtx_costs (rtx x, int code, int outer_code, int *total, - bool speed ATTRIBUTE_UNUSED) +ia64_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, + int *total, bool speed ATTRIBUTE_UNUSED) { switch (code) { diff --git a/gcc/config/iq2000/iq2000.c b/gcc/config/iq2000/iq2000.c index 916acf28408..7d8630e6bbb 100644 --- a/gcc/config/iq2000/iq2000.c +++ b/gcc/config/iq2000/iq2000.c @@ -151,7 +151,7 @@ static bool iq2000_return_in_memory (const_tree, const_tree); static void iq2000_setup_incoming_varargs (cumulative_args_t, enum machine_mode, tree, int *, int); -static bool iq2000_rtx_costs (rtx, int, int, int *, bool); +static bool iq2000_rtx_costs (rtx, int, int, int, int *, bool); static int iq2000_address_cost (rtx, bool); static section *iq2000_select_section (tree, int, unsigned HOST_WIDE_INT); static rtx iq2000_legitimize_address (rtx, rtx, enum machine_mode); @@ -3285,7 +3285,8 @@ iq2000_legitimize_address (rtx xinsn, rtx old_x ATTRIBUTE_UNUSED, static bool -iq2000_rtx_costs (rtx x, int code, int outer_code ATTRIBUTE_UNUSED, int * total, +iq2000_rtx_costs (rtx x, int code, int outer_code ATTRIBUTE_UNUSED, + int opno ATTRIBUTE_UNUSED, int * total, bool speed ATTRIBUTE_UNUSED) { enum machine_mode mode = GET_MODE (x); diff --git a/gcc/config/lm32/lm32.c b/gcc/config/lm32/lm32.c index e9800e7f55e..0d0ee5f9a9e 100644 --- a/gcc/config/lm32/lm32.c +++ b/gcc/config/lm32/lm32.c @@ -68,8 +68,8 @@ static bool lm32_in_small_data_p (const_tree); static void lm32_setup_incoming_varargs (cumulative_args_t cum, enum machine_mode mode, tree type, int *pretend_size, int no_rtl); -static bool lm32_rtx_costs (rtx x, int code, int outer_code, int *total, - bool speed); +static bool lm32_rtx_costs (rtx x, int code, int outer_code, int opno, + int *total, bool speed); static bool lm32_can_eliminate (const int, const int); static bool lm32_legitimate_address_p (enum machine_mode mode, rtx x, bool strict); @@ -928,7 +928,8 @@ nonpic_symbol_mentioned_p (rtx x) scanned. In either case, *TOTAL contains the cost result. */ static bool -lm32_rtx_costs (rtx x, int code, int outer_code, int *total, bool speed) +lm32_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, + int *total, bool speed) { enum machine_mode mode = GET_MODE (x); bool small_mode; diff --git a/gcc/config/m32c/m32c.c b/gcc/config/m32c/m32c.c index a967e217135..39d8ede0dee 100644 --- a/gcc/config/m32c/m32c.c +++ b/gcc/config/m32c/m32c.c @@ -2429,8 +2429,8 @@ m32c_memory_move_cost (enum machine_mode mode ATTRIBUTE_UNUSED, #undef TARGET_RTX_COSTS #define TARGET_RTX_COSTS m32c_rtx_costs static bool -m32c_rtx_costs (rtx x, int code, int outer_code, int *total, - bool speed ATTRIBUTE_UNUSED) +m32c_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, + int *total, bool speed ATTRIBUTE_UNUSED) { switch (code) { diff --git a/gcc/config/m32r/m32r.c b/gcc/config/m32r/m32r.c index 577345e9c98..97636703602 100644 --- a/gcc/config/m32r/m32r.c +++ b/gcc/config/m32r/m32r.c @@ -84,7 +84,7 @@ static bool m32r_function_value_regno_p (const unsigned int); static void m32r_setup_incoming_varargs (cumulative_args_t, enum machine_mode, tree, int *, int); static void init_idents (void); -static bool m32r_rtx_costs (rtx, int, int, int *, bool speed); +static bool m32r_rtx_costs (rtx, int, int, int, int *, bool speed); static int m32r_memory_move_cost (enum machine_mode, reg_class_t, bool); static bool m32r_pass_by_reference (cumulative_args_t, enum machine_mode, const_tree, bool); @@ -1356,7 +1356,8 @@ m32r_memory_move_cost (enum machine_mode mode, } static bool -m32r_rtx_costs (rtx x, int code, int outer_code ATTRIBUTE_UNUSED, int *total, +m32r_rtx_costs (rtx x, int code, int outer_code ATTRIBUTE_UNUSED, + int opno ATTRIBUTE_UNUSED, int *total, bool speed ATTRIBUTE_UNUSED) { switch (code) diff --git a/gcc/config/m68k/m68k.c b/gcc/config/m68k/m68k.c index 8b57d6cd740..71df1410394 100644 --- a/gcc/config/m68k/m68k.c +++ b/gcc/config/m68k/m68k.c @@ -150,7 +150,7 @@ static bool m68k_save_reg (unsigned int regno, bool interrupt_handler); static bool m68k_ok_for_sibcall_p (tree, tree); static bool m68k_tls_symbol_p (rtx); static rtx m68k_legitimize_address (rtx, rtx, enum machine_mode); -static bool m68k_rtx_costs (rtx, int, int, int *, bool); +static bool m68k_rtx_costs (rtx, int, int, int, int *, bool); #if M68K_HONOR_TARGET_STRICT_ALIGNMENT static bool m68k_return_in_memory (const_tree, const_tree); #endif @@ -2765,8 +2765,8 @@ const_int_cost (HOST_WIDE_INT i) } static bool -m68k_rtx_costs (rtx x, int code, int outer_code, int *total, - bool speed ATTRIBUTE_UNUSED) +m68k_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, + int *total, bool speed ATTRIBUTE_UNUSED) { switch (code) { diff --git a/gcc/config/mcore/mcore.c b/gcc/config/mcore/mcore.c index 8a822bd185c..82ae0cfe68b 100644 --- a/gcc/config/mcore/mcore.c +++ b/gcc/config/mcore/mcore.c @@ -121,7 +121,8 @@ static const char *mcore_strip_name_encoding (const char *); static int mcore_const_costs (rtx, RTX_CODE); static int mcore_and_cost (rtx); static int mcore_ior_cost (rtx); -static bool mcore_rtx_costs (rtx, int, int, int *, bool); +static bool mcore_rtx_costs (rtx, int, int, int, + int *, bool); static void mcore_external_libcall (rtx); static bool mcore_return_in_memory (const_tree, const_tree); static int mcore_arg_partial_bytes (cumulative_args_t, @@ -508,8 +509,8 @@ mcore_ior_cost (rtx x) } static bool -mcore_rtx_costs (rtx x, int code, int outer_code, int * total, - bool speed ATTRIBUTE_UNUSED) +mcore_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, + int * total, bool speed ATTRIBUTE_UNUSED) { switch (code) { diff --git a/gcc/config/mep/mep.c b/gcc/config/mep/mep.c index c18e7b7f04c..39d9cf95d30 100644 --- a/gcc/config/mep/mep.c +++ b/gcc/config/mep/mep.c @@ -211,7 +211,7 @@ static void mep_move_ready_insn (rtx *, int, rtx); static int mep_sched_reorder (FILE *, int, rtx *, int *, int); static rtx mep_make_bundle (rtx, rtx); static void mep_bundle_insns (rtx); -static bool mep_rtx_cost (rtx, int, int, int *, bool); +static bool mep_rtx_cost (rtx, int, int, int, int *, bool); static int mep_address_cost (rtx, bool); static void mep_setup_incoming_varargs (cumulative_args_t, enum machine_mode, tree, int *, int); @@ -7261,7 +7261,9 @@ mep_expand_binary_intrinsic (int ATTRIBUTE_UNUSED immediate, } static bool -mep_rtx_cost (rtx x, int code, int outer_code ATTRIBUTE_UNUSED, int *total, bool ATTRIBUTE_UNUSED speed_t) +mep_rtx_cost (rtx x, int code, int outer_code ATTRIBUTE_UNUSED, + int opno ATTRIBUTE_UNUSED, int *total, + bool ATTRIBUTE_UNUSED speed_t) { switch (code) { diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c index 288b86fc10f..97d91ca10f1 100644 --- a/gcc/config/microblaze/microblaze.c +++ b/gcc/config/microblaze/microblaze.c @@ -861,7 +861,8 @@ microblaze_expand_block_move (rtx dest, rtx src, rtx length, rtx align_rtx) } static bool -microblaze_rtx_costs (rtx x, int code, int outer_code ATTRIBUTE_UNUSED, int *total, +microblaze_rtx_costs (rtx x, int code, int outer_code ATTRIBUTE_UNUSED, + int opno ATTRIBUTE_UNUSED, int *total, bool speed ATTRIBUTE_UNUSED) { enum machine_mode mode = GET_MODE (x); diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c index 88988b66ca2..1c9b86697af 100644 --- a/gcc/config/mips/mips.c +++ b/gcc/config/mips/mips.c @@ -3334,7 +3334,7 @@ mips_binary_cost (rtx x, int single_cost, int double_cost, bool speed) cost = single_cost; return (cost + set_src_cost (XEXP (x, 0), speed) - + rtx_cost (XEXP (x, 1), GET_CODE (x), speed)); + + rtx_cost (XEXP (x, 1), GET_CODE (x), 1, speed)); } /* Return the cost of floating-point multiplications of mode MODE. */ @@ -3404,7 +3404,8 @@ mips_zero_extend_cost (enum machine_mode mode, rtx op) /* Implement TARGET_RTX_COSTS. */ static bool -mips_rtx_costs (rtx x, int code, int outer_code, int *total, bool speed) +mips_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, + int *total, bool speed) { enum machine_mode mode = GET_MODE (x); bool float_mode_p = FLOAT_MODE_P (mode); diff --git a/gcc/config/mmix/mmix.c b/gcc/config/mmix/mmix.c index 29826b5c1b9..c87d09e0e2f 100644 --- a/gcc/config/mmix/mmix.c +++ b/gcc/config/mmix/mmix.c @@ -140,7 +140,7 @@ static void mmix_setup_incoming_varargs (cumulative_args_t, enum machine_mode, tree, int *, int); static void mmix_file_start (void); static void mmix_file_end (void); -static bool mmix_rtx_costs (rtx, int, int, int *, bool); +static bool mmix_rtx_costs (rtx, int, int, int, int *, bool); static int mmix_register_move_cost (enum machine_mode, reg_class_t, reg_class_t); static rtx mmix_struct_value_rtx (tree, int); @@ -1229,6 +1229,7 @@ static bool mmix_rtx_costs (rtx x ATTRIBUTE_UNUSED, int code ATTRIBUTE_UNUSED, int outer_code ATTRIBUTE_UNUSED, + int opno ATTRIBUTE_UNUSED, int *total ATTRIBUTE_UNUSED, bool speed ATTRIBUTE_UNUSED) { diff --git a/gcc/config/mn10300/mn10300.c b/gcc/config/mn10300/mn10300.c index 24a07d87d55..eca88713349 100644 --- a/gcc/config/mn10300/mn10300.c +++ b/gcc/config/mn10300/mn10300.c @@ -2182,7 +2182,7 @@ mn10300_address_cost (rtx x, bool speed) return speed ? 2 : 6; default: - return rtx_cost (x, MEM, speed); + return rtx_cost (x, MEM, 0, speed); } } @@ -2296,7 +2296,8 @@ mn10300_memory_move_cost (enum machine_mode mode ATTRIBUTE_UNUSED, to represent cycles. Size-relative costs are in bytes. */ static bool -mn10300_rtx_costs (rtx x, int code, int outer_code, int *ptotal, bool speed) +mn10300_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, + int *ptotal, bool speed) { /* This value is used for SYMBOL_REF etc where we want to pretend we have a full 32-bit constant. */ @@ -2387,7 +2388,7 @@ mn10300_rtx_costs (rtx x, int code, int outer_code, int *ptotal, bool speed) i = INTVAL (XEXP (x, 1)); if (i == 1 || i == 4) { - total = 1 + rtx_cost (XEXP (x, 0), PLUS, speed); + total = 1 + rtx_cost (XEXP (x, 0), PLUS, 0, speed); goto alldone; } } diff --git a/gcc/config/pa/pa.c b/gcc/config/pa/pa.c index b208215d36e..db404cd3c2e 100644 --- a/gcc/config/pa/pa.c +++ b/gcc/config/pa/pa.c @@ -92,7 +92,7 @@ static void fix_range (const char *); static int hppa_register_move_cost (enum machine_mode mode, reg_class_t, reg_class_t); static int hppa_address_cost (rtx, bool); -static bool hppa_rtx_costs (rtx, int, int, int *, bool); +static bool hppa_rtx_costs (rtx, int, int, int, int *, bool); static inline rtx force_mode (enum machine_mode, rtx); static void pa_reorg (void); static void pa_combine_instructions (void); @@ -1411,8 +1411,8 @@ hppa_address_cost (rtx X, scanned. In either case, *TOTAL contains the cost result. */ static bool -hppa_rtx_costs (rtx x, int code, int outer_code, int *total, - bool speed ATTRIBUTE_UNUSED) +hppa_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, + int *total, bool speed ATTRIBUTE_UNUSED) { switch (code) { diff --git a/gcc/config/pdp11/pdp11.c b/gcc/config/pdp11/pdp11.c index 63e99865dd6..42e3af078db 100644 --- a/gcc/config/pdp11/pdp11.c +++ b/gcc/config/pdp11/pdp11.c @@ -141,7 +141,7 @@ decode_pdp11_d (const struct real_format *fmt ATTRIBUTE_UNUSED, static const char *singlemove_string (rtx *); static bool pdp11_assemble_integer (rtx, unsigned int, int); -static bool pdp11_rtx_costs (rtx, int, int, int *, bool); +static bool pdp11_rtx_costs (rtx, int, int, int, int *, bool); static bool pdp11_return_in_memory (const_tree, const_tree); static rtx pdp11_function_value (const_tree, const_tree, bool); static rtx pdp11_libcall_value (enum machine_mode, const_rtx); @@ -888,7 +888,8 @@ pdp11_register_move_cost (enum machine_mode mode ATTRIBUTE_UNUSED, } static bool -pdp11_rtx_costs (rtx x, int code, int outer_code ATTRIBUTE_UNUSED, int *total, +pdp11_rtx_costs (rtx x, int code, int outer_code ATTRIBUTE_UNUSED, + int opno ATTRIBUTE_UNUSED, int *total, bool speed ATTRIBUTE_UNUSED) { switch (code) diff --git a/gcc/config/picochip/picochip.c b/gcc/config/picochip/picochip.c index c3a7046763a..b878a1f1777 100644 --- a/gcc/config/picochip/picochip.c +++ b/gcc/config/picochip/picochip.c @@ -101,7 +101,8 @@ int picochip_sched_reorder (FILE * file, int verbose, rtx * ready, void picochip_init_builtins (void); rtx picochip_expand_builtin (tree, rtx, rtx, enum machine_mode, int); -bool picochip_rtx_costs (rtx x, int code, int outer_code, int* total, bool speed); +bool picochip_rtx_costs (rtx x, int code, int outer_code, int opno, + int* total, bool speed); bool picochip_return_in_memory(const_tree type, const_tree fntype ATTRIBUTE_UNUSED); bool picochip_legitimate_address_p (enum machine_mode, rtx, bool); @@ -3741,7 +3742,8 @@ gen_SImode_mem(rtx opnd1,rtx opnd2) } bool -picochip_rtx_costs (rtx x, int code, int outer_code ATTRIBUTE_UNUSED, int* total, bool speed) +picochip_rtx_costs (rtx x, int code, int outer_code ATTRIBUTE_UNUSED, + int opno ATTRIBUTE_UNUSED, int* total, bool speed) { int localTotal = 0; diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index a1141f1416d..a94a4f6c40b 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -948,8 +948,8 @@ static int rs6000_variable_issue (FILE *, int, rtx, int); static int rs6000_register_move_cost (enum machine_mode, reg_class_t, reg_class_t); static int rs6000_memory_move_cost (enum machine_mode, reg_class_t, bool); -static bool rs6000_rtx_costs (rtx, int, int, int *, bool); -static bool rs6000_debug_rtx_costs (rtx, int, int, int *, bool); +static bool rs6000_rtx_costs (rtx, int, int, int, int *, bool); +static bool rs6000_debug_rtx_costs (rtx, int, int, int, int *, bool); static int rs6000_debug_address_cost (rtx, bool); static int rs6000_adjust_cost (rtx, rtx, rtx, int); static int rs6000_debug_adjust_cost (rtx, rtx, rtx, int); @@ -25730,8 +25730,8 @@ rs6000_xcoff_file_end (void) scanned. In either case, *TOTAL contains the cost result. */ static bool -rs6000_rtx_costs (rtx x, int code, int outer_code, int *total, - bool speed) +rs6000_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, + int *total, bool speed) { enum machine_mode mode = GET_MODE (x); @@ -26074,17 +26074,18 @@ rs6000_rtx_costs (rtx x, int code, int outer_code, int *total, /* Debug form of r6000_rtx_costs that is selected if -mdebug=cost. */ static bool -rs6000_debug_rtx_costs (rtx x, int code, int outer_code, int *total, +rs6000_debug_rtx_costs (rtx x, int code, int outer_code, int opno, int *total, bool speed) { - bool ret = rs6000_rtx_costs (x, code, outer_code, total, speed); + bool ret = rs6000_rtx_costs (x, code, outer_code, opno, total, speed); fprintf (stderr, "\nrs6000_rtx_costs, return = %s, code = %s, outer_code = %s, " - "total = %d, speed = %s, x:\n", + "opno = %d, total = %d, speed = %s, x:\n", ret ? "complete" : "scan inner", GET_RTX_NAME (code), GET_RTX_NAME (outer_code), + opno, *total, speed ? "true" : "false"); diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c index c8f9a1ed5b7..22f05f9fd21 100644 --- a/gcc/config/s390/s390.c +++ b/gcc/config/s390/s390.c @@ -2374,8 +2374,8 @@ s390_memory_move_cost (enum machine_mode mode ATTRIBUTE_UNUSED, of the superexpression of x. */ static bool -s390_rtx_costs (rtx x, int code, int outer_code, int *total, - bool speed ATTRIBUTE_UNUSED) +s390_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, + int *total, bool speed ATTRIBUTE_UNUSED) { switch (code) { @@ -2480,9 +2480,9 @@ s390_rtx_costs (rtx x, int code, int outer_code, int *total, /* Negate in the third argument is free: FMSUB. */ if (GET_CODE (XEXP (x, 2)) == NEG) { - *total += (rtx_cost (XEXP (x, 0), FMA, speed) - + rtx_cost (XEXP (x, 1), FMA, speed) - + rtx_cost (XEXP (XEXP (x, 2), 0), FMA, speed)); + *total += (rtx_cost (XEXP (x, 0), FMA, 0, speed) + + rtx_cost (XEXP (x, 1), FMA, 1, speed) + + rtx_cost (XEXP (XEXP (x, 2), 0), FMA, 2, speed)); return true; } return false; diff --git a/gcc/config/score/score-protos.h b/gcc/config/score/score-protos.h index 3a96eabd176..dc56fc7e5dd 100644 --- a/gcc/config/score/score-protos.h +++ b/gcc/config/score/score-protos.h @@ -73,7 +73,8 @@ extern const char * score_select (rtx *ops, const char *inst_pre, bool commu, extern const char * score_output_casesi (rtx *operands); extern const char * score_rpush (rtx *ops); extern const char * score_rpop (rtx *ops); -extern bool score_rtx_costs (rtx x, int code, int outer_code, int *total, bool speed); +extern bool score_rtx_costs (rtx x, int code, int outer_code, int opno, + int *total, bool speed); #ifdef RTX_CODE extern enum machine_mode score_select_cc_mode (enum rtx_code op, rtx x, rtx y); diff --git a/gcc/config/score/score.c b/gcc/config/score/score.c index 6325dd9b7a5..c789f22f1bb 100644 --- a/gcc/config/score/score.c +++ b/gcc/config/score/score.c @@ -1074,7 +1074,8 @@ score_address_insns (rtx x, enum machine_mode mode) /* Implement TARGET_RTX_COSTS macro. */ bool -score_rtx_costs (rtx x, int code, int outer_code, int *total, bool speed ATTRIBUTE_UNUSED) +score_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, + int *total, bool speed ATTRIBUTE_UNUSED) { enum machine_mode mode = GET_MODE (x); diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c index 1b81e259476..93477ff8b05 100644 --- a/gcc/config/sh/sh.c +++ b/gcc/config/sh/sh.c @@ -247,7 +247,7 @@ static int addsubcosts (rtx); static int multcosts (rtx); static bool unspec_caller_rtx_p (rtx); static bool sh_cannot_copy_insn_p (rtx); -static bool sh_rtx_costs (rtx, int, int, int *, bool); +static bool sh_rtx_costs (rtx, int, int, int, int *, bool); static int sh_address_cost (rtx, bool); static int sh_pr_n_sets (void); static rtx sh_allocate_initial_value (rtx); @@ -2849,7 +2849,7 @@ andcosts (rtx x) || satisfies_constraint_J16 (XEXP (x, 1))) return 1; else - return 1 + rtx_cost (XEXP (x, 1), AND, !optimize_size); + return 1 + rtx_cost (XEXP (x, 1), AND, 1, !optimize_size); } /* These constants are single cycle extu.[bw] instructions. */ @@ -2949,8 +2949,8 @@ multcosts (rtx x ATTRIBUTE_UNUSED) scanned. In either case, *TOTAL contains the cost result. */ static bool -sh_rtx_costs (rtx x, int code, int outer_code, int *total, - bool speed ATTRIBUTE_UNUSED) +sh_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, + int *total, bool speed ATTRIBUTE_UNUSED) { switch (code) { diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c index d4c64d01d26..de9a7eb6929 100644 --- a/gcc/config/sparc/sparc.c +++ b/gcc/config/sparc/sparc.c @@ -428,7 +428,7 @@ static const char *get_some_local_dynamic_name (void); static int get_some_local_dynamic_name_1 (rtx *, void *); static int sparc_register_move_cost (enum machine_mode, reg_class_t, reg_class_t); -static bool sparc_rtx_costs (rtx, int, int, int *, bool); +static bool sparc_rtx_costs (rtx, int, int, int, int *, bool); static rtx sparc_function_value (const_tree, const_tree, bool); static rtx sparc_libcall_value (enum machine_mode, const_rtx); static bool sparc_function_value_regno_p (const unsigned int); @@ -9414,8 +9414,8 @@ sparc_fold_builtin (tree fndecl, int n_args ATTRIBUTE_UNUSED, ??? the latencies and then CSE will just use that. */ static bool -sparc_rtx_costs (rtx x, int code, int outer_code, int *total, - bool speed ATTRIBUTE_UNUSED) +sparc_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, + int *total, bool speed ATTRIBUTE_UNUSED) { enum machine_mode mode = GET_MODE (x); bool float_mode_p = FLOAT_MODE_P (mode); diff --git a/gcc/config/spu/spu.c b/gcc/config/spu/spu.c index b8e3fb35da3..952aea50444 100644 --- a/gcc/config/spu/spu.c +++ b/gcc/config/spu/spu.c @@ -203,7 +203,7 @@ static int mem_is_padded_component_ref (rtx x); static int reg_aligned_for_addr (rtx x); static bool spu_assemble_integer (rtx x, unsigned int size, int aligned_p); static void spu_asm_globalize_label (FILE * file, const char *name); -static bool spu_rtx_costs (rtx x, int code, int outer_code, +static bool spu_rtx_costs (rtx x, int code, int outer_code, int opno, int *total, bool speed); static bool spu_function_ok_for_sibcall (tree decl, tree exp); static void spu_init_libfuncs (void); @@ -5482,7 +5482,8 @@ spu_asm_globalize_label (FILE * file, const char *name) } static bool -spu_rtx_costs (rtx x, int code, int outer_code ATTRIBUTE_UNUSED, int *total, +spu_rtx_costs (rtx x, int code, int outer_code ATTRIBUTE_UNUSED, + int opno ATTRIBUTE_UNUSED, int *total, bool speed ATTRIBUTE_UNUSED) { enum machine_mode mode = GET_MODE (x); diff --git a/gcc/config/stormy16/stormy16.c b/gcc/config/stormy16/stormy16.c index 910dc2e302f..99acee6f69b 100644 --- a/gcc/config/stormy16/stormy16.c +++ b/gcc/config/stormy16/stormy16.c @@ -57,7 +57,7 @@ static void xstormy16_asm_output_mi_thunk (FILE *, tree, HOST_WIDE_INT, static void xstormy16_init_builtins (void); static rtx xstormy16_expand_builtin (tree, rtx, rtx, enum machine_mode, int); -static bool xstormy16_rtx_costs (rtx, int, int, int *, bool); +static bool xstormy16_rtx_costs (rtx, int, int, int, int *, bool); static int xstormy16_address_cost (rtx, bool); static bool xstormy16_return_in_memory (const_tree, const_tree); @@ -69,7 +69,8 @@ static GTY(()) section *bss100_section; static bool xstormy16_rtx_costs (rtx x, int code, int outer_code ATTRIBUTE_UNUSED, - int *total, bool speed ATTRIBUTE_UNUSED) + int opno ATTRIBUTE_UNUSED, int *total, + bool speed ATTRIBUTE_UNUSED) { switch (code) { diff --git a/gcc/config/v850/v850.c b/gcc/config/v850/v850.c index 5074ebe417f..5c43607347e 100644 --- a/gcc/config/v850/v850.c +++ b/gcc/config/v850/v850.c @@ -310,6 +310,7 @@ static bool v850_rtx_costs (rtx x, int codearg, int outer_code ATTRIBUTE_UNUSED, + int opno ATTRIBUTE_UNUSED, int * total, bool speed) { enum rtx_code code = (enum rtx_code) codearg; diff --git a/gcc/config/vax/vax.c b/gcc/config/vax/vax.c index 13a45158f94..4e704b6f714 100644 --- a/gcc/config/vax/vax.c +++ b/gcc/config/vax/vax.c @@ -54,7 +54,7 @@ static void vax_output_mi_thunk (FILE *, tree, HOST_WIDE_INT, HOST_WIDE_INT, tree); static int vax_address_cost_1 (rtx); static int vax_address_cost (rtx, bool); -static bool vax_rtx_costs (rtx, int, int, int *, bool); +static bool vax_rtx_costs (rtx, int, int, int, int *, bool); static rtx vax_function_arg (cumulative_args_t, enum machine_mode, const_tree, bool); static void vax_function_arg_advance (cumulative_args_t, enum machine_mode, @@ -745,8 +745,8 @@ vax_address_cost (rtx x, bool speed ATTRIBUTE_UNUSED) costs on a per cpu basis. */ static bool -vax_rtx_costs (rtx x, int code, int outer_code, int *total, - bool speed ATTRIBUTE_UNUSED) +vax_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, + int *total, bool speed ATTRIBUTE_UNUSED) { enum machine_mode mode = GET_MODE (x); int i = 0; /* may be modified in switch */ diff --git a/gcc/config/xtensa/xtensa.c b/gcc/config/xtensa/xtensa.c index 5ba468131e0..7f42e48dd53 100644 --- a/gcc/config/xtensa/xtensa.c +++ b/gcc/config/xtensa/xtensa.c @@ -136,7 +136,7 @@ static unsigned int xtensa_multibss_section_type_flags (tree, const char *, int) ATTRIBUTE_UNUSED; static section *xtensa_select_rtx_section (enum machine_mode, rtx, unsigned HOST_WIDE_INT); -static bool xtensa_rtx_costs (rtx, int, int, int *, bool); +static bool xtensa_rtx_costs (rtx, int, int, int, int *, bool); static int xtensa_register_move_cost (enum machine_mode, reg_class_t, reg_class_t); static int xtensa_memory_move_cost (enum machine_mode, reg_class_t, bool); @@ -3342,8 +3342,8 @@ xtensa_memory_move_cost (enum machine_mode mode ATTRIBUTE_UNUSED, scanned. In either case, *TOTAL contains the cost result. */ static bool -xtensa_rtx_costs (rtx x, int code, int outer_code, int *total, - bool speed ATTRIBUTE_UNUSED) +xtensa_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, + int *total, bool speed ATTRIBUTE_UNUSED) { switch (code) { diff --git a/gcc/cse.c b/gcc/cse.c index 54edf7ee942..ae676851632 100644 --- a/gcc/cse.c +++ b/gcc/cse.c @@ -475,8 +475,8 @@ struct table_elt || (HARD_REGISTER_NUM_P (N) \ && FIXED_REGNO_P (N) && REGNO_REG_CLASS (N) != NO_REGS)) -#define COST(X) (REG_P (X) ? 0 : notreg_cost (X, SET)) -#define COST_IN(X,OUTER) (REG_P (X) ? 0 : notreg_cost (X, OUTER)) +#define COST(X) (REG_P (X) ? 0 : notreg_cost (X, SET, 1)) +#define COST_IN(X, OUTER, OPNO) (REG_P (X) ? 0 : notreg_cost (X, OUTER, OPNO)) /* Get the number of times this register has been updated in this basic block. */ @@ -552,7 +552,7 @@ static bitmap cse_ebb_live_in, cse_ebb_live_out; static sbitmap cse_visited_basic_blocks; static bool fixed_base_plus_p (rtx x); -static int notreg_cost (rtx, enum rtx_code); +static int notreg_cost (rtx, enum rtx_code, int); static int approx_reg_cost_1 (rtx *, void *); static int approx_reg_cost (rtx); static int preferable (int, int, int, int); @@ -752,7 +752,7 @@ preferable (int cost_a, int regcost_a, int cost_b, int regcost_b) from COST macro to keep it simple. */ static int -notreg_cost (rtx x, enum rtx_code outer) +notreg_cost (rtx x, enum rtx_code outer, int opno) { return ((GET_CODE (x) == SUBREG && REG_P (SUBREG_REG (x)) @@ -764,7 +764,7 @@ notreg_cost (rtx x, enum rtx_code outer) && TRULY_NOOP_TRUNCATION_MODES_P (GET_MODE (x), GET_MODE (SUBREG_REG (x)))) ? 0 - : rtx_cost (x, outer, optimize_this_for_speed_p) * 2); + : rtx_cost (x, outer, opno, optimize_this_for_speed_p) * 2); } @@ -3296,7 +3296,7 @@ fold_rtx (rtx x, rtx insn) argument. */ if (const_arg != 0 && const_arg != folded_arg - && COST_IN (const_arg, code) <= COST_IN (folded_arg, code) + && COST_IN (const_arg, code, i) <= COST_IN (folded_arg, code, i) /* It's not safe to substitute the operand of a conversion operator with a constant, as the conversion's identity diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi index d383ecaa6b2..832aefef4f1 100644 --- a/gcc/doc/tm.texi +++ b/gcc/doc/tm.texi @@ -6415,14 +6415,19 @@ Define this macro if a non-short-circuit operation produced by @code{BRANCH_COST} is greater than or equal to the value 2. @end defmac -@deftypefn {Target Hook} bool TARGET_RTX_COSTS (rtx @var{x}, int @var{code}, int @var{outer_code}, int *@var{total}, bool @var{speed}) +@deftypefn {Target Hook} bool TARGET_RTX_COSTS (rtx @var{x}, int @var{code}, int @var{outer_code}, int @var{opno}, int *@var{total}, bool @var{speed}) This target hook describes the relative costs of RTL expressions. The cost may depend on the precise form of the expression, which is -available for examination in @var{x}, and the rtx code of the expression -in which it is contained, found in @var{outer_code}. @var{code} is the -expression code---redundant, since it can be obtained with -@code{GET_CODE (@var{x})}. +available for examination in @var{x}, and the fact that @var{x} appears +as operand @var{opno} of an expression with rtx code @var{outer_code}. +That is, the hook can assume that there is some rtx @var{y} such +that @samp{GET_CODE (@var{y}) == @var{outer_code}} and such that +either (a) @samp{XEXP (@var{y}, @var{opno}) == @var{x}} or +(b) @samp{XVEC (@var{y}, @var{opno})} contains @var{x}. + +@var{code} is @var{x}'s expression code---redundant, since it can be +obtained with @code{GET_CODE (@var{x})}. In implementing this hook, you can use the construct @code{COSTS_N_INSNS (@var{n})} to specify a cost equal to @var{n} fast diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in index 9d10844d787..c53cbe82b66 100644 --- a/gcc/doc/tm.texi.in +++ b/gcc/doc/tm.texi.in @@ -6357,10 +6357,15 @@ Define this macro if a non-short-circuit operation produced by This target hook describes the relative costs of RTL expressions. The cost may depend on the precise form of the expression, which is -available for examination in @var{x}, and the rtx code of the expression -in which it is contained, found in @var{outer_code}. @var{code} is the -expression code---redundant, since it can be obtained with -@code{GET_CODE (@var{x})}. +available for examination in @var{x}, and the fact that @var{x} appears +as operand @var{opno} of an expression with rtx code @var{outer_code}. +That is, the hook can assume that there is some rtx @var{y} such +that @samp{GET_CODE (@var{y}) == @var{outer_code}} and such that +either (a) @samp{XEXP (@var{y}, @var{opno}) == @var{x}} or +(b) @samp{XVEC (@var{y}, @var{opno})} contains @var{x}. + +@var{code} is @var{x}'s expression code---redundant, since it can be +obtained with @code{GET_CODE (@var{x})}. In implementing this hook, you can use the construct @code{COSTS_N_INSNS (@var{n})} to specify a cost equal to @var{n} fast diff --git a/gcc/dojump.c b/gcc/dojump.c index 7606c15330d..093d3ef2d6d 100644 --- a/gcc/dojump.c +++ b/gcc/dojump.c @@ -144,6 +144,8 @@ static GTY(()) rtx shift_test; static bool prefer_and_bit_test (enum machine_mode mode, int bitnum) { + bool speed_p; + if (and_test == 0) { /* Set up rtxes for the two variations. Use NULL as a placeholder @@ -168,8 +170,9 @@ prefer_and_bit_test (enum machine_mode mode, int bitnum) mode); XEXP (XEXP (shift_test, 0), 1) = GEN_INT (bitnum); - return (rtx_cost (and_test, IF_THEN_ELSE, optimize_insn_for_speed_p ()) - <= rtx_cost (shift_test, IF_THEN_ELSE, optimize_insn_for_speed_p ())); + speed_p = optimize_insn_for_speed_p (); + return (rtx_cost (and_test, IF_THEN_ELSE, 0, speed_p) + <= rtx_cost (shift_test, IF_THEN_ELSE, 0, speed_p)); } /* Subroutine of do_jump, dealing with exploded comparisons of the type diff --git a/gcc/expmed.c b/gcc/expmed.c index f75ea7acd61..0047cd09076 100644 --- a/gcc/expmed.c +++ b/gcc/expmed.c @@ -5431,7 +5431,7 @@ emit_store_flag (rtx target, enum rtx_code code, rtx op0, rtx op1, /* For the reverse comparison, use either an addition or a XOR. */ if (want_add - && rtx_cost (GEN_INT (normalizep), PLUS, + && rtx_cost (GEN_INT (normalizep), PLUS, 1, optimize_insn_for_speed_p ()) == 0) { tem = emit_store_flag_1 (subtarget, rcode, op0, op1, mode, 0, @@ -5442,7 +5442,7 @@ emit_store_flag (rtx target, enum rtx_code code, rtx op0, rtx op1, target, 0, OPTAB_WIDEN); } else if (!want_add - && rtx_cost (trueval, XOR, + && rtx_cost (trueval, XOR, 1, optimize_insn_for_speed_p ()) == 0) { tem = emit_store_flag_1 (subtarget, rcode, op0, op1, mode, 0, @@ -5535,7 +5535,7 @@ emit_store_flag (rtx target, enum rtx_code code, rtx op0, rtx op1, /* Again, for the reverse comparison, use either an addition or a XOR. */ if (want_add - && rtx_cost (GEN_INT (normalizep), PLUS, + && rtx_cost (GEN_INT (normalizep), PLUS, 1, optimize_insn_for_speed_p ()) == 0) { tem = emit_store_flag_1 (subtarget, rcode, op0, op1, mode, 0, @@ -5545,7 +5545,7 @@ emit_store_flag (rtx target, enum rtx_code code, rtx op0, rtx op1, GEN_INT (normalizep), target, 0, OPTAB_WIDEN); } else if (!want_add - && rtx_cost (trueval, XOR, + && rtx_cost (trueval, XOR, 1, optimize_insn_for_speed_p ()) == 0) { tem = emit_store_flag_1 (subtarget, rcode, op0, op1, mode, 0, diff --git a/gcc/hooks.c b/gcc/hooks.c index 9dfde822a5f..90251834e4e 100644 --- a/gcc/hooks.c +++ b/gcc/hooks.c @@ -267,11 +267,12 @@ hook_bool_uintp_uintp_false (unsigned int *a ATTRIBUTE_UNUSED, } bool -hook_bool_rtx_int_int_intp_bool_false (rtx a ATTRIBUTE_UNUSED, - int b ATTRIBUTE_UNUSED, - int c ATTRIBUTE_UNUSED, - int *d ATTRIBUTE_UNUSED, - bool speed_p ATTRIBUTE_UNUSED) +hook_bool_rtx_int_int_int_intp_bool_false (rtx a ATTRIBUTE_UNUSED, + int b ATTRIBUTE_UNUSED, + int c ATTRIBUTE_UNUSED, + int d ATTRIBUTE_UNUSED, + int *e ATTRIBUTE_UNUSED, + bool speed_p ATTRIBUTE_UNUSED) { return false; } diff --git a/gcc/hooks.h b/gcc/hooks.h index a1b011203d5..156d708ac01 100644 --- a/gcc/hooks.h +++ b/gcc/hooks.h @@ -53,7 +53,8 @@ extern bool hook_bool_const_tree_hwi_hwi_const_tree_true (const_tree, extern bool hook_bool_rtx_false (rtx); extern bool hook_bool_rtx_int_false (rtx, int); extern bool hook_bool_uintp_uintp_false (unsigned int *, unsigned int *); -extern bool hook_bool_rtx_int_int_intp_bool_false (rtx, int, int, int *, bool); +extern bool hook_bool_rtx_int_int_int_intp_bool_false (rtx, int, int, int, + int *, bool); extern bool hook_bool_tree_tree_false (tree, tree); extern bool hook_bool_tree_tree_true (tree, tree); extern bool hook_bool_tree_bool_false (tree, bool); diff --git a/gcc/optabs.c b/gcc/optabs.c index 195853401e5..8f1114ec2d9 100644 --- a/gcc/optabs.c +++ b/gcc/optabs.c @@ -1204,21 +1204,21 @@ commutative_optab_p (optab binoptab) || binoptab == umul_highpart_optab); } -/* X is to be used in mode MODE as an operand to BINOPTAB. If we're +/* X is to be used in mode MODE as operand OPN to BINOPTAB. If we're optimizing, and if the operand is a constant that costs more than 1 instruction, force the constant into a register and return that register. Return X otherwise. UNSIGNEDP says whether X is unsigned. */ static rtx avoid_expensive_constant (enum machine_mode mode, optab binoptab, - rtx x, bool unsignedp) + int opn, rtx x, bool unsignedp) { bool speed = optimize_insn_for_speed_p (); if (mode != VOIDmode && optimize && CONSTANT_P (x) - && rtx_cost (x, binoptab->code, speed) > set_src_cost (x, speed)) + && rtx_cost (x, binoptab->code, opn, speed) > set_src_cost (x, speed)) { if (CONST_INT_P (x)) { @@ -1265,9 +1265,9 @@ expand_binop_directly (enum machine_mode mode, optab binoptab, } /* If we are optimizing, force expensive constants into a register. */ - xop0 = avoid_expensive_constant (xmode0, binoptab, xop0, unsignedp); + xop0 = avoid_expensive_constant (xmode0, binoptab, 0, xop0, unsignedp); if (!shift_optab_p (binoptab)) - xop1 = avoid_expensive_constant (xmode1, binoptab, xop1, unsignedp); + xop1 = avoid_expensive_constant (xmode1, binoptab, 1, xop1, unsignedp); /* In case the insn wants input operands in modes different from those of the actual operands, convert the operands. It would @@ -1479,10 +1479,10 @@ expand_binop (enum machine_mode mode, optab binoptab, rtx op0, rtx op1, && mclass == MODE_INT) { no_extend = 1; - xop0 = avoid_expensive_constant (mode, binoptab, + xop0 = avoid_expensive_constant (mode, binoptab, 0, xop0, unsignedp); if (binoptab != ashl_optab) - xop1 = avoid_expensive_constant (mode, binoptab, + xop1 = avoid_expensive_constant (mode, binoptab, 1, xop1, unsignedp); } @@ -2216,8 +2216,8 @@ expand_twoval_binop (optab binoptab, rtx op0, rtx op1, rtx targ0, rtx targ1, rtx xop0 = op0, xop1 = op1; /* If we are optimizing, force expensive constants into a register. */ - xop0 = avoid_expensive_constant (mode0, binoptab, xop0, unsignedp); - xop1 = avoid_expensive_constant (mode1, binoptab, xop1, unsignedp); + xop0 = avoid_expensive_constant (mode0, binoptab, 0, xop0, unsignedp); + xop1 = avoid_expensive_constant (mode1, binoptab, 1, xop1, unsignedp); create_fixed_operand (&ops[0], targ0); create_convert_operand_from (&ops[1], op0, mode, unsignedp); @@ -3790,12 +3790,12 @@ prepare_cmp_insn (rtx x, rtx y, enum rtx_code comparison, rtx size, /* If we are optimizing, force expensive constants into a register. */ if (CONSTANT_P (x) && optimize - && (rtx_cost (x, COMPARE, optimize_insn_for_speed_p ()) + && (rtx_cost (x, COMPARE, 0, optimize_insn_for_speed_p ()) > COSTS_N_INSNS (1))) x = force_reg (mode, x); if (CONSTANT_P (y) && optimize - && (rtx_cost (y, COMPARE, optimize_insn_for_speed_p ()) + && (rtx_cost (y, COMPARE, 1, optimize_insn_for_speed_p ()) > COSTS_N_INSNS (1))) y = force_reg (mode, y); diff --git a/gcc/rtl.h b/gcc/rtl.h index 4f126865dea..5323dcc1b4e 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -1196,9 +1196,10 @@ costs_add_n_insns (struct full_rtx_costs *c, int n) } extern void init_rtlanal (void); -extern int rtx_cost (rtx, enum rtx_code, bool); +extern int rtx_cost (rtx, enum rtx_code, int, bool); extern int address_cost (rtx, enum machine_mode, addr_space_t, bool); -extern void get_full_rtx_cost (rtx, enum rtx_code, struct full_rtx_costs *); +extern void get_full_rtx_cost (rtx, enum rtx_code, int, + struct full_rtx_costs *); extern unsigned int subreg_lsb (const_rtx); extern unsigned int subreg_lsb_1 (enum machine_mode, enum machine_mode, unsigned int); @@ -1224,7 +1225,7 @@ extern int low_bitmask_len (enum machine_mode, unsigned HOST_WIDE_INT); static inline int set_rtx_cost (rtx x, bool speed_p) { - return rtx_cost (x, INSN, speed_p); + return rtx_cost (x, INSN, 4, speed_p); } /* Like set_rtx_cost, but return both the speed and size costs in C. */ @@ -1232,7 +1233,7 @@ set_rtx_cost (rtx x, bool speed_p) static inline void get_full_set_rtx_cost (rtx x, struct full_rtx_costs *c) { - get_full_rtx_cost (x, INSN, c); + get_full_rtx_cost (x, INSN, 4, c); } /* Return the cost of moving X into a register, relative to the cost @@ -1242,7 +1243,7 @@ get_full_set_rtx_cost (rtx x, struct full_rtx_costs *c) static inline int set_src_cost (rtx x, bool speed_p) { - return rtx_cost (x, SET, speed_p); + return rtx_cost (x, SET, 1, speed_p); } /* Like set_src_cost, but return both the speed and size costs in C. */ @@ -1250,7 +1251,7 @@ set_src_cost (rtx x, bool speed_p) static inline void get_full_set_src_cost (rtx x, struct full_rtx_costs *c) { - get_full_rtx_cost (x, SET, c); + get_full_rtx_cost (x, SET, 1, c); } #endif diff --git a/gcc/rtlanal.c b/gcc/rtlanal.c index 348371d2ddb..7fa3ca6f315 100644 --- a/gcc/rtlanal.c +++ b/gcc/rtlanal.c @@ -3674,11 +3674,12 @@ label_is_jump_target_p (const_rtx label, const_rtx jump_insn) Another is in rtl generation, to pick the cheapest way to multiply. Other uses like the latter are expected in the future. - SPEED parameter specify whether costs optimized for speed or size should + X appears as operand OPNO in an expression with code OUTER_CODE. + SPEED specifies whether costs optimized for speed or size should be returned. */ int -rtx_cost (rtx x, enum rtx_code outer_code ATTRIBUTE_UNUSED, bool speed) +rtx_cost (rtx x, enum rtx_code outer_code, int opno, bool speed) { int i, j; enum rtx_code code; @@ -3726,7 +3727,7 @@ rtx_cost (rtx x, enum rtx_code outer_code ATTRIBUTE_UNUSED, bool speed) break; default: - if (targetm.rtx_costs (x, code, outer_code, &total, speed)) + if (targetm.rtx_costs (x, code, outer_code, opno, &total, speed)) return total; break; } @@ -3737,22 +3738,23 @@ rtx_cost (rtx x, enum rtx_code outer_code ATTRIBUTE_UNUSED, bool speed) fmt = GET_RTX_FORMAT (code); for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--) if (fmt[i] == 'e') - total += rtx_cost (XEXP (x, i), code, speed); + total += rtx_cost (XEXP (x, i), code, i, speed); else if (fmt[i] == 'E') for (j = 0; j < XVECLEN (x, i); j++) - total += rtx_cost (XVECEXP (x, i, j), code, speed); + total += rtx_cost (XVECEXP (x, i, j), code, i, speed); return total; } /* Fill in the structure C with information about both speed and size rtx - costs for X, with outer code OUTER. */ + costs for X, which is operand OPNO in an expression with code OUTER. */ void -get_full_rtx_cost (rtx x, enum rtx_code outer, struct full_rtx_costs *c) +get_full_rtx_cost (rtx x, enum rtx_code outer, int opno, + struct full_rtx_costs *c) { - c->speed = rtx_cost (x, outer, true); - c->size = rtx_cost (x, outer, false); + c->speed = rtx_cost (x, outer, opno, true); + c->size = rtx_cost (x, outer, opno, false); } @@ -3780,7 +3782,7 @@ address_cost (rtx x, enum machine_mode mode, addr_space_t as, bool speed) int default_address_cost (rtx x, bool speed) { - return rtx_cost (x, MEM, speed); + return rtx_cost (x, MEM, 0, speed); } diff --git a/gcc/target.def b/gcc/target.def index 9ff97e690e9..479e1a111fc 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -1645,8 +1645,8 @@ DEFHOOKPOD DEFHOOK (rtx_costs, "", - bool, (rtx x, int code, int outer_code, int *total, bool speed), - hook_bool_rtx_int_int_intp_bool_false) + bool, (rtx x, int code, int outer_code, int opno, int *total, bool speed), + hook_bool_rtx_int_int_int_intp_bool_false) /* Compute the cost of X, used as an address. Never called with invalid addresses. */ |