diff options
author | Alan Modra <amodra@gmail.com> | 2015-07-08 12:32:27 +0930 |
---|---|---|
committer | Alan Modra <amodra@gcc.gnu.org> | 2015-07-08 12:32:27 +0930 |
commit | e548c9df071ecdb6f333601191a9396f2c17d1a7 (patch) | |
tree | 53f49dedf673ef5042d1e6f2ea443c7106b2c8ce /gcc/config | |
parent | c7131fb2b58ab692af97125b7432393ffb426d53 (diff) | |
download | gcc-e548c9df071ecdb6f333601191a9396f2c17d1a7.tar.gz |
target.def (rtx_costs): Remove "code" param, add "mode".
* target.def (rtx_costs): Remove "code" param, add "mode".
* rtl.h (rtx_cost, get_full_rtx_cost): Update prototype.
(set_src_cost, get_full_set_src_cost): Likewise. Move later in file.
(set_rtx_cost, get_full_set_rtx_cost): Move later in file.
* rtlanal.c (rtx_cost): Add "mode" parameter. Update targetm.rtx_costs
call. Track mode when given in rtx.
(get_full_rtx_cost): Add "mode" parameter. Update rtx_cost calls.
(default_address_cost): Pass Pmode to rtx_cost.
(insn_rtx_cost): Pass dest mode of set to set_src_cost.
* cprop.c (try_replace_reg): Ensure set_rtx_cost is not called
with NULL set.
* cse.c (COST, COST_IN): Add MODE param. Update all uses.
(notreg_cost): Add mode param. Use it.
* gcse.c (want_to_gcse_p): Delete forward declaration. Add
mode param and pass to set_src_cost. Update all calls.
(hash_scan_set): Formatting.
* hooks.c (hook_bool_rtx_int_int_int_intp_bool_false): Delete.
(hook_bool_rtx_mode_int_int_intp_bool_false): New function.
* hooks.h: Ditto.
* expmed.c (init_expmed_one_conv, init_expmed_one_mode,
init_expmed, expand_mult, mult_by_coeff_cost, expand_smod_pow2,
emit_store_flag): Update set_src_cost and rtx_cost calls.
* auto-inc-dec.c (attempt_change): Likewise.
* calls.c (precompute_register_parameters): Likewise.
* combine.c (expand_compound_operation, make_extraction,
force_to_mode, distribute_and_simplify_rtx): Likewise.
* dojump.c (prefer_and_bit_test): Likewise.
* dse.c (find_shift_sequence): Likewise.
* expr.c (compress_float_constant): Likewise.
* fwprop.c (should_replace_address, try_fwprop_subst): Likewise.
* ifcvt.c (noce_try_sign_mask): Likewise.
* loop-doloop.c (doloop_optimize): Likewise.
* loop-invariant.c (create_new_invariant): Likewise.
* lower-subreg.c (shift_cost, compute_costs): Likewise.
* optabs.c (avoid_expensive_constant, prepare_cmp_insn,
lshift_cheap_p): Likewise.
* postreload.c (reload_cse_simplify_set, reload_cse_simplify_operands,
try_replace_in_use, reload_cse_move2add): Likewise.
* reload1.c (calculate_elim_costs_all_insns, note_reg_elim_costly):
Likewise.
* simplify-rtx.c (simplify_binary_operation_1): Likewise.
* tree-ssa-loop-ivopts.c (computation_cost): Likewise.
* tree-ssa-reassoc.c (optimize_range_tests_to_bit_test): Likewise.
* tree-switch-conversion.c (emit_case_bit_tests): Likewise.
* config/aarch64/aarch64.c (aarch64_rtx_costs): Delete "code" param,
add "mode" param. Use "mode: in place of GET_MODE (x). Pass mode
to rtx_cost calls.
* config/alpha/alpha.c (alpha_rtx_costs): Likewise.
* config/arc/arc.c (arc_rtx_costs): Likewise.
* config/arm/arm.c (arm_rtx_costs): Likewise.
* config/avr/avr.c (avr_rtx_costs, avr_rtx_costs_1): 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/epiphany/epiphany.c (epiphany_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_rtx_costs): Likewise.
* config/mmix/mmix.c (mmix_rtx_costs): Likewise.
* config/mn10300/mn10300.c (mn10300_rtx_costs): Likewise.
* config/msp430/msp430.c (msp430_rtx_costs): Likewise.
* config/nds32/nds32-cost.c (nds32_rtx_costs_impl): Likewise.
* config/nds32/nds32-protos.h (nds32_rtx_costs_impl): Likewise.
* config/nds32/nds32.c (nds32_rtx_costs): Likewise.
* config/nios2/nios2.c (nios2_rtx_costs): Likewise.
* config/pa/pa.c (hppa_rtx_costs): Likewise.
* config/pdp11/pdp11.c (pdp11_rtx_costs): Likewise.
* config/rl78/rl78.c (rl78_rtx_costs): Likewise.
* config/rs6000/rs6000.c (rs6000_rtx_costs): Likewise.
* config/s390/s390.c (s390_rtx_costs): Likewise.
* config/sh/sh.c (sh_rtx_costs): Likewise.
* 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/tilegx/tilegx.c (tilegx_rtx_costs): Likewise.
* config/tilepro/tilepro.c (tilepro_rtx_costs): Likewise.
* config/v850/v850.c (v850_rtx_costs): Likewise.
* config/vax/vax.c (vax_rtx_costs): Likewise.
* config/visium/visium.c (visium_rtx_costs): Likewise.
* config/xtensa/xtensa.c (xtensa_rtx_costs): Likewise.
* config/aarch64/aarch64.c (aarch64_rtx_mult_cost): Change type of
"code" param, and pass as outer_code to first rtx_cost call. Pass
mode to rtx_cost calls.
(aarch64_address_cost, aarch64_if_then_else_costs): Update rtx_cost
calls.
(aarch64_rtx_costs_wrapper): Update.
* config/arm/arm.c (arm_rtx_costs_1, arm_size_rtx_costs,
arm_unspec_cost, arm_new_rtx_costs, arm_slowmul_rtx_costs): Update
rtx_cost calls.
* config/avr/avr.c (avr_final_prescan_insn): Update set_src_cost
and rtx_cost calls.
(avr_operand_rtx_cost): Similarly.
(avr_rtx_costs_1): Correct mode passed to avr_operand_rtx_cost
for subexpressions of ZERO_EXTEND, SIGN_EXTEND and COMPARE.
* config/mips/mips.c (mips_stack_address_p): Comment typo.
(mips_binary_cost): Update rtx_cost and set_src_cost calls.
(mips_rtx_costs): Use GET_MODE (x) to detect const_int.
* config/mn10300/mn10300.c (mn10300_address_cost): Pass Pmode to
rtx_cost.
(mn10300_rtx_costs): Correct mode passed to mn10300_address_cost.
* config/rs6000/rs6000.c (rs6000_debug_rtx_costs): Update.
* config/sh/sh.c (and_xor_ior_costs): Update rtx_cost call.
* doc/tm.texi: Regenerate.
From-SVN: r225532
Diffstat (limited to 'gcc/config')
44 files changed, 647 insertions, 551 deletions
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index f7a9f3ebbad..cb00ad379a3 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -5326,7 +5326,7 @@ aarch64_shift_p (enum rtx_code code) operands where needed. */ static int -aarch64_rtx_mult_cost (rtx x, int code, int outer, bool speed) +aarch64_rtx_mult_cost (rtx x, enum rtx_code code, int outer, bool speed) { rtx op0, op1; const struct cpu_cost_table *extra_cost @@ -5377,7 +5377,7 @@ aarch64_rtx_mult_cost (rtx x, int code, int outer, bool speed) if (is_extend) op0 = aarch64_strip_extend (op0); - cost += rtx_cost (op0, GET_CODE (op0), 0, speed); + cost += rtx_cost (op0, VOIDmode, code, 0, speed); return cost; } @@ -5397,8 +5397,8 @@ aarch64_rtx_mult_cost (rtx x, int code, int outer, bool speed) || (GET_CODE (op0) == SIGN_EXTEND && GET_CODE (op1) == SIGN_EXTEND)) { - cost += rtx_cost (XEXP (op0, 0), MULT, 0, speed) - + rtx_cost (XEXP (op1, 0), MULT, 1, speed); + cost += rtx_cost (XEXP (op0, 0), VOIDmode, MULT, 0, speed); + cost += rtx_cost (XEXP (op1, 0), VOIDmode, MULT, 1, speed); if (speed) { @@ -5415,8 +5415,8 @@ aarch64_rtx_mult_cost (rtx x, int code, int outer, bool speed) /* This is either an integer multiply or a MADD. In both cases we want to recurse and cost the operands. */ - cost += rtx_cost (op0, MULT, 0, speed) - + rtx_cost (op1, MULT, 1, speed); + cost += rtx_cost (op0, mode, MULT, 0, speed); + cost += rtx_cost (op1, mode, MULT, 1, speed); if (speed) { @@ -5449,8 +5449,8 @@ aarch64_rtx_mult_cost (rtx x, int code, int outer, bool speed) cost += extra_cost->fp[mode == DFmode].mult; } - cost += rtx_cost (op0, MULT, 0, speed) - + rtx_cost (op1, MULT, 1, speed); + cost += rtx_cost (op0, mode, MULT, 0, speed); + cost += rtx_cost (op1, mode, MULT, 1, speed); return cost; } } @@ -5474,7 +5474,7 @@ aarch64_address_cost (rtx x, /* This is a CONST or SYMBOL ref which will be split in a different way depending on the code model in use. Cost it through the generic infrastructure. */ - int cost_symbol_ref = rtx_cost (x, MEM, 1, speed); + int cost_symbol_ref = rtx_cost (x, Pmode, MEM, 1, speed); /* Divide through by the cost of one instruction to bring it to the same units as the address costs. */ cost_symbol_ref /= COSTS_N_INSNS (1); @@ -5697,11 +5697,11 @@ aarch64_if_then_else_costs (rtx op0, rtx op1, rtx op2, int *cost, bool speed) /* TBZ/TBNZ/CBZ/CBNZ. */ if (GET_CODE (inner) == ZERO_EXTRACT) /* TBZ/TBNZ. */ - *cost += rtx_cost (XEXP (inner, 0), ZERO_EXTRACT, - 0, speed); - else - /* CBZ/CBNZ. */ - *cost += rtx_cost (inner, cmpcode, 0, speed); + *cost += rtx_cost (XEXP (inner, 0), VOIDmode, + ZERO_EXTRACT, 0, speed); + else + /* CBZ/CBNZ. */ + *cost += rtx_cost (inner, VOIDmode, cmpcode, 0, speed); return true; } @@ -5725,8 +5725,8 @@ aarch64_if_then_else_costs (rtx op0, rtx op1, rtx op2, int *cost, bool speed) || (GET_CODE (op1) == PLUS && XEXP (op1, 1) == const1_rtx)) op1 = XEXP (op1, 0); - *cost += rtx_cost (op1, IF_THEN_ELSE, 1, speed); - *cost += rtx_cost (op2, IF_THEN_ELSE, 2, speed); + *cost += rtx_cost (op1, VOIDmode, IF_THEN_ELSE, 1, speed); + *cost += rtx_cost (op2, VOIDmode, IF_THEN_ELSE, 2, speed); return true; } @@ -5737,13 +5737,13 @@ aarch64_if_then_else_costs (rtx op0, rtx op1, rtx op2, int *cost, bool speed) /* Calculate the cost of calculating X, storing it in *COST. Result is true if the total cost of the operation has now been calculated. */ static bool -aarch64_rtx_costs (rtx x, int code, int outer ATTRIBUTE_UNUSED, +aarch64_rtx_costs (rtx x, machine_mode mode, int outer ATTRIBUTE_UNUSED, int param ATTRIBUTE_UNUSED, int *cost, bool speed) { rtx op0, op1, op2; const struct cpu_cost_table *extra_cost = aarch64_tune_params.insn_extra_cost; - machine_mode mode = GET_MODE (x); + int code = GET_CODE (x); /* By default, assume that everything has equivalent cost to the cheapest instruction. Any additional costs are applied as a delta @@ -5778,12 +5778,12 @@ aarch64_rtx_costs (rtx x, int code, int outer ATTRIBUTE_UNUSED, 0, speed)); } - *cost += rtx_cost (op1, SET, 1, speed); + *cost += rtx_cost (op1, mode, SET, 1, speed); return true; case SUBREG: if (! REG_P (SUBREG_REG (op0))) - *cost += rtx_cost (SUBREG_REG (op0), SET, 0, speed); + *cost += rtx_cost (SUBREG_REG (op0), VOIDmode, SET, 0, speed); /* Fall through. */ case REG: @@ -5805,7 +5805,7 @@ aarch64_rtx_costs (rtx x, int code, int outer ATTRIBUTE_UNUSED, } else /* Cost is just the cost of the RHS of the set. */ - *cost += rtx_cost (op1, SET, 1, speed); + *cost += rtx_cost (op1, mode, SET, 1, speed); return true; case ZERO_EXTRACT: @@ -5831,7 +5831,7 @@ aarch64_rtx_costs (rtx x, int code, int outer ATTRIBUTE_UNUSED, /* BFM. */ if (speed) *cost += extra_cost->alu.bfi; - *cost += rtx_cost (op1, (enum rtx_code) code, 1, speed); + *cost += rtx_cost (op1, VOIDmode, (enum rtx_code) code, 1, speed); } return true; @@ -5929,23 +5929,23 @@ aarch64_rtx_costs (rtx x, int code, int outer ATTRIBUTE_UNUSED, return false; } - if (GET_MODE_CLASS (GET_MODE (x)) == MODE_INT) - { + if (GET_MODE_CLASS (mode) == MODE_INT) + { if (GET_RTX_CLASS (GET_CODE (op0)) == RTX_COMPARE || GET_RTX_CLASS (GET_CODE (op0)) == RTX_COMM_COMPARE) { /* CSETM. */ - *cost += rtx_cost (XEXP (op0, 0), NEG, 0, speed); + *cost += rtx_cost (XEXP (op0, 0), VOIDmode, NEG, 0, speed); return true; } /* Cost this as SUB wzr, X. */ - op0 = CONST0_RTX (GET_MODE (x)); + op0 = CONST0_RTX (mode); op1 = XEXP (x, 0); goto cost_minus; } - if (GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT) + if (GET_MODE_CLASS (mode) == MODE_FLOAT) { /* Support (neg(fma...)) as a single instruction only if sign of zeros is unimportant. This matches the decision @@ -5953,7 +5953,7 @@ aarch64_rtx_costs (rtx x, int code, int outer ATTRIBUTE_UNUSED, if (GET_CODE (op0) == FMA && !HONOR_SIGNED_ZEROS (GET_MODE (op0))) { /* FNMADD. */ - *cost = rtx_cost (op0, NEG, 0, speed); + *cost = rtx_cost (op0, mode, NEG, 0, speed); return true; } if (speed) @@ -5984,6 +5984,7 @@ aarch64_rtx_costs (rtx x, int code, int outer ATTRIBUTE_UNUSED, && GET_CODE (op0) == AND) { x = op0; + mode = GET_MODE (op0); goto cost_logic; } @@ -5993,9 +5994,10 @@ aarch64_rtx_costs (rtx x, int code, int outer ATTRIBUTE_UNUSED, needs encoding in the cost tables. */ /* CC_ZESWPmode supports zero extend for free. */ - if (GET_MODE (x) == CC_ZESWPmode && GET_CODE (op0) == ZERO_EXTEND) + if (mode == CC_ZESWPmode && GET_CODE (op0) == ZERO_EXTEND) op0 = XEXP (op0, 0); + mode = GET_MODE (op0); /* ANDS. */ if (GET_CODE (op0) == AND) { @@ -6023,8 +6025,8 @@ aarch64_rtx_costs (rtx x, int code, int outer ATTRIBUTE_UNUSED, if (speed) *cost += extra_cost->alu.arith; - *cost += rtx_cost (op0, COMPARE, 0, speed); - *cost += rtx_cost (XEXP (op1, 0), NEG, 1, speed); + *cost += rtx_cost (op0, mode, COMPARE, 0, speed); + *cost += rtx_cost (XEXP (op1, 0), mode, NEG, 1, speed); return true; } @@ -6051,7 +6053,7 @@ aarch64_rtx_costs (rtx x, int code, int outer ATTRIBUTE_UNUSED, if (CONST_DOUBLE_P (op1) && aarch64_float_const_zero_rtx_p (op1)) { - *cost += rtx_cost (op0, COMPARE, 0, speed); + *cost += rtx_cost (op0, VOIDmode, COMPARE, 0, speed); /* FCMP supports constant 0.0 for no extra cost. */ return true; } @@ -6080,7 +6082,7 @@ aarch64_rtx_costs (rtx x, int code, int outer ATTRIBUTE_UNUSED, op1 = XEXP (x, 1); cost_minus: - *cost += rtx_cost (op0, MINUS, 0, speed); + *cost += rtx_cost (op0, mode, MINUS, 0, speed); /* Detect valid immediates. */ if ((GET_MODE_CLASS (mode) == MODE_INT @@ -6101,9 +6103,8 @@ cost_minus: if (speed) *cost += extra_cost->alu.extend_arith; - *cost += rtx_cost (XEXP (XEXP (op1, 0), 0), - (enum rtx_code) GET_CODE (op1), - 0, speed); + *cost += rtx_cost (XEXP (XEXP (op1, 0), 0), VOIDmode, + (enum rtx_code) GET_CODE (op1), 0, speed); return true; } @@ -6120,7 +6121,7 @@ cost_minus: return true; } - *cost += rtx_cost (new_op1, MINUS, 1, speed); + *cost += rtx_cost (new_op1, VOIDmode, MINUS, 1, speed); if (speed) { @@ -6155,8 +6156,8 @@ cost_plus: || GET_RTX_CLASS (GET_CODE (op0)) == RTX_COMM_COMPARE) { /* CSINC. */ - *cost += rtx_cost (XEXP (op0, 0), PLUS, 0, speed); - *cost += rtx_cost (op1, PLUS, 1, speed); + *cost += rtx_cost (XEXP (op0, 0), mode, PLUS, 0, speed); + *cost += rtx_cost (op1, mode, PLUS, 1, speed); return true; } @@ -6164,7 +6165,7 @@ cost_plus: && CONST_INT_P (op1) && aarch64_uimm12_shift (INTVAL (op1))) { - *cost += rtx_cost (op0, PLUS, 0, speed); + *cost += rtx_cost (op0, mode, PLUS, 0, speed); if (speed) /* ADD (immediate). */ @@ -6172,7 +6173,7 @@ cost_plus: return true; } - *cost += rtx_cost (op1, PLUS, 1, speed); + *cost += rtx_cost (op1, mode, PLUS, 1, speed); /* Look for ADD (extended register). */ if (aarch64_rtx_arith_op_extract_p (op0, mode)) @@ -6180,9 +6181,8 @@ cost_plus: if (speed) *cost += extra_cost->alu.extend_arith; - *cost += rtx_cost (XEXP (XEXP (op0, 0), 0), - (enum rtx_code) GET_CODE (op0), - 0, speed); + *cost += rtx_cost (XEXP (XEXP (op0, 0), 0), VOIDmode, + (enum rtx_code) GET_CODE (op0), 0, speed); return true; } @@ -6198,7 +6198,7 @@ cost_plus: return true; } - *cost += rtx_cost (new_op0, PLUS, 0, speed); + *cost += rtx_cost (new_op0, VOIDmode, PLUS, 0, speed); if (speed) { @@ -6250,8 +6250,8 @@ cost_plus: if (aarch64_extr_rtx_p (x, &op0, &op1)) { - *cost += rtx_cost (op0, IOR, 0, speed) - + rtx_cost (op1, IOR, 1, speed); + *cost += rtx_cost (op0, mode, IOR, 0, speed); + *cost += rtx_cost (op1, mode, IOR, 1, speed); if (speed) *cost += extra_cost->alu.shift; @@ -6279,20 +6279,20 @@ cost_plus: INTVAL (op1)) != 0) { /* This is a UBFM/SBFM. */ - *cost += rtx_cost (XEXP (op0, 0), ZERO_EXTRACT, 0, speed); + *cost += rtx_cost (XEXP (op0, 0), mode, ZERO_EXTRACT, 0, speed); if (speed) *cost += extra_cost->alu.bfx; return true; } - if (GET_MODE_CLASS (GET_MODE (x)) == MODE_INT) + if (GET_MODE_CLASS (mode) == MODE_INT) { /* We possibly get the immediate for free, this is not modelled. */ if (CONST_INT_P (op1) - && aarch64_bitmask_imm (INTVAL (op1), GET_MODE (x))) + && aarch64_bitmask_imm (INTVAL (op1), mode)) { - *cost += rtx_cost (op0, (enum rtx_code) code, 0, speed); + *cost += rtx_cost (op0, mode, (enum rtx_code) code, 0, speed); if (speed) *cost += extra_cost->alu.logical; @@ -6327,8 +6327,8 @@ cost_plus: } /* In both cases we want to cost both operands. */ - *cost += rtx_cost (new_op0, (enum rtx_code) code, 0, speed) - + rtx_cost (op1, (enum rtx_code) code, 1, speed); + *cost += rtx_cost (new_op0, mode, (enum rtx_code) code, 0, speed); + *cost += rtx_cost (op1, mode, (enum rtx_code) code, 1, speed); return true; } @@ -6349,7 +6349,7 @@ cost_plus: /* MVN-shifted-reg. */ if (op0 != x) { - *cost += rtx_cost (op0, (enum rtx_code) code, 0, speed); + *cost += rtx_cost (op0, mode, (enum rtx_code) code, 0, speed); if (speed) *cost += extra_cost->alu.log_shift; @@ -6365,8 +6365,8 @@ cost_plus: rtx newop1 = XEXP (op0, 1); rtx op0_stripped = aarch64_strip_shift (newop0); - *cost += rtx_cost (newop1, (enum rtx_code) code, 1, speed) - + rtx_cost (op0_stripped, XOR, 0, speed); + *cost += rtx_cost (newop1, mode, (enum rtx_code) code, 1, speed); + *cost += rtx_cost (op0_stripped, mode, XOR, 0, speed); if (speed) { @@ -6399,7 +6399,7 @@ cost_plus: && GET_MODE (op0) == SImode && outer == SET) { - int op_cost = rtx_cost (XEXP (x, 0), ZERO_EXTEND, 0, speed); + int op_cost = rtx_cost (op0, VOIDmode, ZERO_EXTEND, 0, speed); if (!op_cost && speed) /* MOV. */ @@ -6410,10 +6410,10 @@ cost_plus: return true; } - else if (MEM_P (XEXP (x, 0))) + else if (MEM_P (op0)) { /* All loads can zero extend to any size for free. */ - *cost = rtx_cost (XEXP (x, 0), ZERO_EXTEND, param, speed); + *cost = rtx_cost (op0, VOIDmode, ZERO_EXTEND, param, speed); return true; } @@ -6483,7 +6483,7 @@ cost_plus: || GET_CODE (op0) == SIGN_EXTEND) op0 = XEXP (op0, 0); - *cost += rtx_cost (op0, ASHIFT, 0, speed); + *cost += rtx_cost (op0, VOIDmode, ASHIFT, 0, speed); return true; } else @@ -6522,7 +6522,7 @@ cost_plus: *cost += extra_cost->alu.shift; } - *cost += rtx_cost (op0, (enum rtx_code) code, 0, speed); + *cost += rtx_cost (op0, mode, (enum rtx_code) code, 0, speed); return true; } else @@ -6593,7 +6593,7 @@ cost_plus: /* We can trust that the immediates used will be correct (there are no by-register forms), so we need only cost op0. */ - *cost += rtx_cost (XEXP (x, 0), (enum rtx_code) code, 0, speed); + *cost += rtx_cost (XEXP (x, 0), VOIDmode, (enum rtx_code) code, 0, speed); return true; case MULT: @@ -6608,13 +6608,13 @@ cost_plus: { if (VECTOR_MODE_P (mode)) *cost += extra_cost->vect.alu; - else if (GET_MODE_CLASS (GET_MODE (x)) == MODE_INT) - *cost += (extra_cost->mult[GET_MODE (x) == DImode].add - + extra_cost->mult[GET_MODE (x) == DImode].idiv); - else if (GET_MODE (x) == DFmode) + else if (GET_MODE_CLASS (mode) == MODE_INT) + *cost += (extra_cost->mult[mode == DImode].add + + extra_cost->mult[mode == DImode].idiv); + else if (mode == DFmode) *cost += (extra_cost->fp[1].mult + extra_cost->fp[1].div); - else if (GET_MODE (x) == SFmode) + else if (mode == SFmode) *cost += (extra_cost->fp[0].mult + extra_cost->fp[0].div); } @@ -6697,9 +6697,9 @@ cost_plus: /* If the remaining parameters are not registers, get the cost to put them into registers. */ - *cost += rtx_cost (op0, FMA, 0, speed); - *cost += rtx_cost (op1, FMA, 1, speed); - *cost += rtx_cost (op2, FMA, 2, speed); + *cost += rtx_cost (op0, mode, FMA, 0, speed); + *cost += rtx_cost (op1, mode, FMA, 1, speed); + *cost += rtx_cost (op2, mode, FMA, 2, speed); return true; case FLOAT: @@ -6758,7 +6758,7 @@ cost_plus: else *cost += extra_cost->fp[GET_MODE (x) == DFmode].toint; } - *cost += rtx_cost (x, (enum rtx_code) code, 0, speed); + *cost += rtx_cost (x, VOIDmode, (enum rtx_code) code, 0, speed); return true; case ABS: @@ -6775,8 +6775,8 @@ cost_plus: /* FABD, which is analogous to FADD. */ if (GET_CODE (op0) == MINUS) { - *cost += rtx_cost (XEXP (op0, 0), MINUS, 0, speed); - + rtx_cost (XEXP (op0, 1), MINUS, 1, speed); + *cost += rtx_cost (XEXP (op0, 0), mode, MINUS, 0, speed); + *cost += rtx_cost (XEXP (op0, 1), mode, MINUS, 1, speed); if (speed) *cost += extra_cost->fp[mode == DFmode].addsub; @@ -6857,10 +6857,10 @@ cost_plus: /* UMULH/SMULH. */ if (speed) *cost += extra_cost->mult[mode == DImode].extend; - *cost += rtx_cost (XEXP (XEXP (XEXP (XEXP (x, 0), 0), 0), 0), - MULT, 0, speed); - *cost += rtx_cost (XEXP (XEXP (XEXP (XEXP (x, 0), 0), 1), 0), - MULT, 1, speed); + *cost += rtx_cost (XEXP (XEXP (XEXP (XEXP (x, 0), 0), 0), 0), + mode, MULT, 0, speed); + *cost += rtx_cost (XEXP (XEXP (XEXP (XEXP (x, 0), 0), 1), 0), + mode, MULT, 1, speed); return true; } @@ -6880,10 +6880,10 @@ cost_plus: calculated for X. This cost is stored in *COST. Returns true if the total cost of X was calculated. */ static bool -aarch64_rtx_costs_wrapper (rtx x, int code, int outer, +aarch64_rtx_costs_wrapper (rtx x, machine_mode mode, int outer, int param, int *cost, bool speed) { - bool result = aarch64_rtx_costs (x, code, outer, param, cost, speed); + bool result = aarch64_rtx_costs (x, mode, outer, param, cost, speed); if (dump_file && (dump_flags & TDF_DETAILS)) { diff --git a/gcc/config/alpha/alpha.c b/gcc/config/alpha/alpha.c index 41c8d94b716..dbd4a82aee7 100644 --- a/gcc/config/alpha/alpha.c +++ b/gcc/config/alpha/alpha.c @@ -1360,10 +1360,10 @@ 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 opno, int *total, +alpha_rtx_costs (rtx x, machine_mode mode, int outer_code, int opno, int *total, bool speed) { - machine_mode mode = GET_MODE (x); + int code = GET_CODE (x); bool float_mode_p = FLOAT_MODE_P (mode); const struct alpha_rtx_cost_data *cost_data; @@ -1428,9 +1428,9 @@ alpha_rtx_costs (rtx x, int code, int outer_code, int opno, int *total, else if (GET_CODE (XEXP (x, 0)) == MULT && const48_operand (XEXP (XEXP (x, 0), 1), VOIDmode)) { - *total = (rtx_cost (XEXP (XEXP (x, 0), 0), + *total = (rtx_cost (XEXP (XEXP (x, 0), 0), mode, (enum rtx_code) outer_code, opno, speed) - + rtx_cost (XEXP (x, 1), + + rtx_cost (XEXP (x, 1), mode, (enum rtx_code) outer_code, opno, speed) + COSTS_N_INSNS (1)); return true; diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c index 61032f128e7..ca2ac4d48c9 100644 --- a/gcc/config/arc/arc.c +++ b/gcc/config/arc/arc.c @@ -4108,9 +4108,11 @@ static void arc_file_start (void) scanned. In either case, *TOTAL contains the cost result. */ static bool -arc_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, - int *total, bool speed) +arc_rtx_costs (rtx x, machine_mode mode, int outer_code, + int opno ATTRIBUTE_UNUSED, int *total, bool speed) { + int code = GET_CODE (x); + switch (code) { /* Small integers are as cheap as registers. */ @@ -4202,7 +4204,8 @@ arc_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, if (CONSTANT_P (XEXP (x, 0))) { *total += (COSTS_N_INSNS (2) - + rtx_cost (XEXP (x, 1), (enum rtx_code) code, 0, speed)); + + rtx_cost (XEXP (x, 1), mode, (enum rtx_code) code, + 0, speed)); return true; } *total = COSTS_N_INSNS (1); @@ -4244,8 +4247,8 @@ arc_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, if (GET_CODE (XEXP (x, 0)) == MULT && _2_4_8_operand (XEXP (XEXP (x, 0), 1), VOIDmode)) { - *total += (rtx_cost (XEXP (x, 1), PLUS, 0, speed) - + rtx_cost (XEXP (XEXP (x, 0), 0), PLUS, 1, speed)); + *total += (rtx_cost (XEXP (x, 1), mode, PLUS, 0, speed) + + rtx_cost (XEXP (XEXP (x, 0), 0), mode, PLUS, 1, speed)); return true; } return false; @@ -4253,8 +4256,8 @@ arc_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, if (GET_CODE (XEXP (x, 1)) == MULT && _2_4_8_operand (XEXP (XEXP (x, 1), 1), VOIDmode)) { - *total += (rtx_cost (XEXP (x, 0), PLUS, 0, speed) - + rtx_cost (XEXP (XEXP (x, 1), 0), PLUS, 1, speed)); + *total += (rtx_cost (XEXP (x, 0), mode, PLUS, 0, speed) + + rtx_cost (XEXP (XEXP (x, 1), 0), mode, PLUS, 1, speed)); return true; } return false; @@ -4269,15 +4272,16 @@ arc_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, /* btst / bbit0 / bbit1: Small integers and registers are free; everything else can be put in a register. */ - *total = (rtx_cost (XEXP (op0, 0), SET, 1, speed) - + rtx_cost (XEXP (op0, 2), SET, 1, speed)); + mode = GET_MODE (XEXP (op0, 0)); + *total = (rtx_cost (XEXP (op0, 0), mode, SET, 1, speed) + + rtx_cost (XEXP (op0, 2), mode, SET, 1, speed)); return true; } if (GET_CODE (op0) == AND && op1 == const0_rtx && satisfies_constraint_C1p (XEXP (op0, 1))) { /* bmsk.f */ - *total = rtx_cost (XEXP (op0, 0), SET, 1, speed); + *total = rtx_cost (XEXP (op0, 0), VOIDmode, SET, 1, speed); return true; } /* add.f */ @@ -4286,8 +4290,9 @@ arc_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, /* op0 might be constant, the inside of op1 is rather unlikely to be so. So swapping the operands might lower the cost. */ - *total = (rtx_cost (op0, PLUS, 1, speed) - + rtx_cost (XEXP (op1, 0), PLUS, 0, speed)); + mode = GET_MODE (op0); + *total = (rtx_cost (op0, mode, PLUS, 1, speed) + + rtx_cost (XEXP (op1, 0), mode, PLUS, 0, speed)); } return false; } @@ -4302,18 +4307,19 @@ arc_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, be put in a register. */ rtx op0 = XEXP (x, 0); - *total = (rtx_cost (XEXP (op0, 0), SET, 1, speed) - + rtx_cost (XEXP (op0, 2), SET, 1, speed)); + mode = GET_MODE (XEXP (op0, 0)); + *total = (rtx_cost (XEXP (op0, 0), mode, SET, 1, speed) + + rtx_cost (XEXP (op0, 2), mode, SET, 1, speed)); return true; } /* Fall through. */ /* scc_insn expands into two insns. */ case GTU: case GEU: case LEU: - if (GET_MODE (x) == SImode) + if (mode == SImode) *total += COSTS_N_INSNS (1); return false; case LTU: /* might use adc. */ - if (GET_MODE (x) == SImode) + if (mode == SImode) *total += COSTS_N_INSNS (1) - 1; return false; default: diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index a7ce0c701d6..1862507cc4f 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -181,7 +181,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, int *, bool); +static bool arm_rtx_costs (rtx, machine_mode, int, int, int *, bool); static int arm_address_cost (rtx, machine_mode, addr_space_t, bool); static int arm_register_move_cost (machine_mode, reg_class_t, reg_class_t); static int arm_memory_move_cost (machine_mode, reg_class_t, bool); @@ -8318,7 +8318,7 @@ arm_rtx_costs_1 (rtx x, enum rtx_code outer, int* total, bool speed) if (REG_P (XEXP (x, 1))) *total = COSTS_N_INSNS (1); /* Need to subtract from 32 */ else if (!CONST_INT_P (XEXP (x, 1))) - *total = rtx_cost (XEXP (x, 1), code, 1, speed); + *total = rtx_cost (XEXP (x, 1), mode, code, 1, speed); /* Fall through */ case ROTATERT: @@ -8330,7 +8330,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, 0, speed); + *total += rtx_cost (XEXP (x, 0), mode, code, 0, speed); if (mode == DImode) { *total += COSTS_N_INSNS (3); @@ -8353,14 +8353,14 @@ arm_rtx_costs_1 (rtx x, enum rtx_code outer, int* total, bool speed) if (CONST_INT_P (XEXP (x, 0)) && const_ok_for_arm (INTVAL (XEXP (x, 0)))) { - *total += rtx_cost (XEXP (x, 1), code, 1, speed); + *total += rtx_cost (XEXP (x, 1), mode, code, 1, speed); return true; } if (CONST_INT_P (XEXP (x, 1)) && const_ok_for_arm (INTVAL (XEXP (x, 1)))) { - *total += rtx_cost (XEXP (x, 0), code, 0, speed); + *total += rtx_cost (XEXP (x, 0), mode, code, 0, speed); return true; } @@ -8377,14 +8377,14 @@ arm_rtx_costs_1 (rtx x, enum rtx_code outer, int* total, bool speed) if (CONST_DOUBLE_P (XEXP (x, 0)) && arm_const_double_rtx (XEXP (x, 0))) { - *total += rtx_cost (XEXP (x, 1), code, 1, speed); + *total += rtx_cost (XEXP (x, 1), mode, code, 1, speed); return true; } if (CONST_DOUBLE_P (XEXP (x, 1)) && arm_const_double_rtx (XEXP (x, 1))) { - *total += rtx_cost (XEXP (x, 0), code, 0, speed); + *total += rtx_cost (XEXP (x, 0), mode, code, 0, speed); return true; } @@ -8398,7 +8398,7 @@ arm_rtx_costs_1 (rtx x, enum rtx_code outer, int* total, bool speed) if (CONST_INT_P (XEXP (x, 0)) && const_ok_for_arm (INTVAL (XEXP (x, 0)))) { - *total += rtx_cost (XEXP (x, 1), code, 1, speed); + *total += rtx_cost (XEXP (x, 1), mode, code, 1, speed); return true; } @@ -8407,8 +8407,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, 0, speed); - *total += rtx_cost (XEXP (XEXP (x, 1), 0), subcode, 0, speed); + *total += rtx_cost (XEXP (x, 0), mode, code, 0, speed); + *total += rtx_cost (XEXP (XEXP (x, 1), 0), mode, subcode, 0, speed); return true; } @@ -8416,23 +8416,24 @@ 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, 0, speed); - *total += rtx_cost (XEXP (x, 1), code, 1, speed); + *total += rtx_cost (XEXP (XEXP (x, 0), 0), mode, code, 0, speed); + *total += rtx_cost (XEXP (x, 1), mode, 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, 0, speed); - *total += rtx_cost (XEXP (XEXP (x, 1), 0), subcode, 0, speed); + *total += rtx_cost (XEXP (x, 0), mode, code, 0, speed); + *total += rtx_cost (XEXP (XEXP (x, 1), 0), mode, 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, 0, speed); + *total = COSTS_N_INSNS (1) + rtx_cost (XEXP (x, 0), mode, code, + 0, speed); if (REG_P (XEXP (XEXP (x, 1), 0)) && REGNO (XEXP (XEXP (x, 1), 0)) != CC_REGNUM) *total += COSTS_N_INSNS (1); @@ -8448,9 +8449,9 @@ arm_rtx_costs_1 (rtx x, enum rtx_code outer, int* total, bool speed) || GET_CODE (XEXP (x, 0)) == SIGN_EXTEND)) { *total = COSTS_N_INSNS (1); - *total += rtx_cost (XEXP (XEXP (x, 0), 0), GET_CODE (XEXP (x, 0)), - 0, speed); - *total += rtx_cost (XEXP (x, 1), code, 1, speed); + *total += rtx_cost (XEXP (XEXP (x, 0), 0), VOIDmode, + GET_CODE (XEXP (x, 0)), 0, speed); + *total += rtx_cost (XEXP (x, 1), mode, code, 1, speed); return true; } @@ -8474,7 +8475,7 @@ arm_rtx_costs_1 (rtx x, enum rtx_code outer, int* total, bool speed) if (CONST_DOUBLE_P (XEXP (x, 1)) && arm_const_double_rtx (XEXP (x, 1))) { - *total += rtx_cost (XEXP (x, 0), code, 0, speed); + *total += rtx_cost (XEXP (x, 0), mode, code, 0, speed); return true; } @@ -8488,7 +8489,8 @@ 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, 1, speed); + *total = COSTS_N_INSNS (1) + rtx_cost (XEXP (x, 1), mode, code, + 1, speed); if (REG_P (XEXP (XEXP (x, 0), 0)) && REGNO (XEXP (XEXP (x, 0), 0)) != CC_REGNUM) *total += COSTS_N_INSNS (1); @@ -8515,7 +8517,7 @@ arm_rtx_costs_1 (rtx x, enum rtx_code outer, int* total, bool speed) if (CONST_INT_P (XEXP (x, 1)) && const_ok_for_op (INTVAL (XEXP (x, 1)), code)) { - *total += rtx_cost (XEXP (x, 0), code, 0, speed); + *total += rtx_cost (XEXP (x, 0), mode, code, 0, speed); return true; } @@ -8526,7 +8528,7 @@ arm_rtx_costs_1 (rtx x, enum rtx_code outer, int* total, bool speed) if (CONST_INT_P (XEXP (x, 1)) && const_ok_for_op (INTVAL (XEXP (x, 1)), code)) { - *total += rtx_cost (XEXP (x, 0), code, 0, speed); + *total += rtx_cost (XEXP (x, 0), mode, code, 0, speed); return true; } subcode = GET_CODE (XEXP (x, 0)); @@ -8534,16 +8536,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, 1, speed); - *total += rtx_cost (XEXP (XEXP (x, 0), 0), subcode, 0, speed); + *total += rtx_cost (XEXP (x, 1), mode, code, 1, speed); + *total += rtx_cost (XEXP (XEXP (x, 0), 0), mode, 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, 1, speed); - *total += rtx_cost (XEXP (XEXP (x, 0), 0), subcode, 0, speed); + *total += rtx_cost (XEXP (x, 1), mode, code, 1, speed); + *total += rtx_cost (XEXP (XEXP (x, 0), 0), mode, subcode, 0, speed); return true; } @@ -8569,7 +8571,8 @@ 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, 0, speed); + *total = rtx_cost (XEXP (XEXP (x, 0), 0), VOIDmode, LSHIFTRT, + 0, speed); return true; } *total = COSTS_N_INSNS (2); /* Plus the cost of the MULT */ @@ -8601,11 +8604,13 @@ 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, 0, speed); + *total += rtx_cost (XEXP (XEXP (x, 0), 0), mode, subcode, + 0, speed); /* Register shifts cost an extra cycle. */ if (!CONST_INT_P (XEXP (XEXP (x, 0), 1))) *total += COSTS_N_INSNS (1) + rtx_cost (XEXP (XEXP (x, 0), 1), - subcode, 1, speed); + mode, subcode, + 1, speed); return true; } } @@ -8626,14 +8631,15 @@ arm_rtx_costs_1 (rtx x, enum rtx_code outer, int* total, bool speed) && REG_P (XEXP (operand, 0)) && REGNO (XEXP (operand, 0)) == CC_REGNUM)) *total += COSTS_N_INSNS (1); - *total += (rtx_cost (XEXP (x, 1), code, 1, speed) - + rtx_cost (XEXP (x, 2), code, 2, speed)); + *total += rtx_cost (XEXP (x, 1), VOIDmode, code, 1, speed); + *total += rtx_cost (XEXP (x, 2), VOIDmode, 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, 0, speed); + *total = COSTS_N_INSNS (2) + rtx_cost (XEXP (x, 0), mode, code, + 0, speed); return true; } goto scc_insn; @@ -8642,7 +8648,8 @@ arm_rtx_costs_1 (rtx x, enum rtx_code outer, int* total, bool speed) if ((!REG_P (XEXP (x, 0)) || REGNO (XEXP (x, 0)) != CC_REGNUM) && mode == SImode && XEXP (x, 1) == const0_rtx) { - *total = COSTS_N_INSNS (2) + rtx_cost (XEXP (x, 0), code, 0, speed); + *total = COSTS_N_INSNS (2) + rtx_cost (XEXP (x, 0), mode, code, + 0, speed); return true; } goto scc_insn; @@ -8651,7 +8658,8 @@ arm_rtx_costs_1 (rtx x, enum rtx_code outer, int* total, bool speed) if ((!REG_P (XEXP (x, 0)) || REGNO (XEXP (x, 0)) != CC_REGNUM) && mode == SImode && XEXP (x, 1) == const0_rtx) { - *total = COSTS_N_INSNS (1) + rtx_cost (XEXP (x, 0), code, 0, speed); + *total = COSTS_N_INSNS (1) + rtx_cost (XEXP (x, 0), mode, code, + 0, speed); return true; } goto scc_insn; @@ -8692,7 +8700,7 @@ arm_rtx_costs_1 (rtx x, enum rtx_code outer, int* total, bool speed) if (CONST_INT_P (XEXP (x, 1)) && const_ok_for_op (INTVAL (XEXP (x, 1)), code)) { - *total += rtx_cost (XEXP (x, 0), code, 0, speed); + *total += rtx_cost (XEXP (x, 0), VOIDmode, code, 0, speed); return true; } @@ -8701,16 +8709,18 @@ 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, 1, speed); - *total += rtx_cost (XEXP (XEXP (x, 0), 0), subcode, 0, speed); + mode = GET_MODE (XEXP (x, 0)); + *total += rtx_cost (XEXP (x, 1), mode, code, 1, speed); + *total += rtx_cost (XEXP (XEXP (x, 0), 0), mode, 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, 1, speed); - *total += rtx_cost (XEXP (XEXP (x, 0), 0), subcode, 0, speed); + mode = GET_MODE (XEXP (x, 0)); + *total += rtx_cost (XEXP (x, 1), mode, code, 1, speed); + *total += rtx_cost (XEXP (XEXP (x, 0), 0), mode, subcode, 0, speed); return true; } @@ -8720,10 +8730,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, 0, speed); + *total = COSTS_N_INSNS (2) + rtx_cost (XEXP (x, 0), mode, code, 0, speed); if (!CONST_INT_P (XEXP (x, 1)) || !const_ok_for_arm (INTVAL (XEXP (x, 1)))) - *total += rtx_cost (XEXP (x, 1), code, 1, speed); + *total += rtx_cost (XEXP (x, 1), mode, code, 1, speed); return true; case ABS: @@ -8800,7 +8810,8 @@ 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, 0, speed); + mode = GET_MODE (XEXP (x, 0)); + *total = COSTS_N_INSNS (1) + rtx_cost (XEXP (x, 0), mode, code, 0, speed); return true; case CONST_INT: @@ -8825,7 +8836,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, 0, speed); + *total += rtx_cost (XEXP (x, 0), mode, code, 0, speed); return true; case CONST_DOUBLE: @@ -8843,7 +8854,8 @@ arm_rtx_costs_1 (rtx x, enum rtx_code outer, int* total, bool speed) if (TARGET_NEON && MEM_P (SET_DEST (x)) && GET_CODE (SET_SRC (x)) == VEC_SELECT) { - *total = rtx_cost (SET_DEST (x), code, 0, speed); + mode = GET_MODE (SET_DEST (x)); + *total = rtx_cost (SET_DEST (x), mode, code, 0, speed); if (!neon_vector_mem_operand (SET_DEST (x), 2, true)) *total += COSTS_N_INSNS (1); return true; @@ -8854,7 +8866,8 @@ arm_rtx_costs_1 (rtx x, enum rtx_code outer, int* total, bool speed) && MEM_P (XEXP (XEXP (SET_SRC (x), 0), 0))) { rtx mem = XEXP (XEXP (SET_SRC (x), 0), 0); - *total = rtx_cost (mem, code, 0, speed); + mode = GET_MODE (SET_DEST (x)); + *total = rtx_cost (mem, mode, code, 0, speed); if (!neon_vector_mem_operand (mem, 2, true)) *total += COSTS_N_INSNS (1); return true; @@ -9077,7 +9090,8 @@ arm_size_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, case ROTATE: if (mode == SImode && REG_P (XEXP (x, 1))) { - *total = COSTS_N_INSNS (2) + rtx_cost (XEXP (x, 0), code, 0, false); + *total = COSTS_N_INSNS (2) + rtx_cost (XEXP (x, 0), mode, code, + 0, false); return true; } /* Fall through */ @@ -9087,15 +9101,17 @@ arm_size_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, case ASHIFTRT: if (mode == DImode && CONST_INT_P (XEXP (x, 1))) { - *total = COSTS_N_INSNS (3) + rtx_cost (XEXP (x, 0), code, 0, false); + *total = COSTS_N_INSNS (3) + rtx_cost (XEXP (x, 0), mode, code, + 0, false); return true; } else if (mode == SImode) { - *total = COSTS_N_INSNS (1) + rtx_cost (XEXP (x, 0), code, 0, false); + *total = COSTS_N_INSNS (1) + rtx_cost (XEXP (x, 0), mode, code, + 0, false); /* Slightly disparage register shifts, but not by much. */ if (!CONST_INT_P (XEXP (x, 1))) - *total += 1 + rtx_cost (XEXP (x, 1), code, 1, false); + *total += 1 + rtx_cost (XEXP (x, 1), mode, code, 1, false); return true; } @@ -9147,8 +9163,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, 0, false); - *total += rtx_cost (XEXP (x, 1), code, 1, false); + *total += rtx_cost (XEXP (XEXP (x, 0), 0), mode, code, 0, false); + *total += rtx_cost (XEXP (x, 1), mode, code, 1, false); return true; } @@ -9326,7 +9342,7 @@ arm_unspec_cost (rtx x, enum rtx_code /* outer_code */, bool speed_p, int *cost) *cost += (ARM_NUM_REGS (GET_MODE (x)) * extra_cost->ldst.store + extra_cost->ldst.store_unaligned); - *cost += rtx_cost (XVECEXP (x, 0, 0), UNSPEC, 0, speed_p); + *cost += rtx_cost (XVECEXP (x, 0, 0), VOIDmode, UNSPEC, 0, speed_p); #ifdef NOT_YET *cost += arm_address_cost (XEXP (XVECEXP (x, 0, 0), 0), GET_MODE (x), ADDR_SPACE_GENERIC, speed_p); @@ -9365,15 +9381,18 @@ arm_unspec_cost (rtx x, enum rtx_code /* outer_code */, bool speed_p, int *cost) if (shift_reg) \ { \ if (speed_p) \ - *cost += extra_cost->alu.arith_shift_reg; \ - *cost += rtx_cost (shift_reg, ASHIFT, 1, speed_p); \ + *cost += extra_cost->alu.arith_shift_reg; \ + *cost += rtx_cost (shift_reg, GET_MODE (shift_reg), \ + ASHIFT, 1, speed_p); \ } \ else if (speed_p) \ - *cost += extra_cost->alu.arith_shift; \ + *cost += extra_cost->alu.arith_shift; \ \ - *cost += (rtx_cost (shift_op, ASHIFT, 0, speed_p) \ + *cost += (rtx_cost (shift_op, GET_MODE (shift_op), \ + ASHIFT, 0, speed_p) \ + rtx_cost (XEXP (x, 1 - IDX), \ - OP, 1, speed_p)); \ + GET_MODE (shift_op), \ + OP, 1, speed_p)); \ return true; \ } \ } \ @@ -9437,7 +9456,8 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, { /* Handle CONST_INT here, since the value doesn't have a mode and we would otherwise be unable to work out the true cost. */ - *cost = rtx_cost (SET_DEST (x), SET, 0, speed_p); + *cost = rtx_cost (SET_DEST (x), GET_MODE (SET_DEST (x)), SET, + 0, speed_p); outer_code = SET; /* Slightly lower the cost of setting a core reg to a constant. This helps break up chains and allows for better scheduling. */ @@ -9544,7 +9564,7 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, if (mode == SImode && REG_P (XEXP (x, 1))) { *cost = (COSTS_N_INSNS (2) - + rtx_cost (XEXP (x, 0), code, 0, speed_p)); + + rtx_cost (XEXP (x, 0), mode, code, 0, speed_p)); if (speed_p) *cost += extra_cost->alu.shift_reg; return true; @@ -9557,7 +9577,7 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, if (mode == DImode && CONST_INT_P (XEXP (x, 1))) { *cost = (COSTS_N_INSNS (3) - + rtx_cost (XEXP (x, 0), code, 0, speed_p)); + + rtx_cost (XEXP (x, 0), mode, code, 0, speed_p)); if (speed_p) *cost += 2 * extra_cost->alu.shift; return true; @@ -9565,11 +9585,11 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, else if (mode == SImode) { *cost = (COSTS_N_INSNS (1) - + rtx_cost (XEXP (x, 0), code, 0, speed_p)); + + rtx_cost (XEXP (x, 0), mode, code, 0, speed_p)); /* Slightly disparage register shifts at -Os, but not by much. */ if (!CONST_INT_P (XEXP (x, 1))) *cost += (speed_p ? extra_cost->alu.shift_reg : 1 - + rtx_cost (XEXP (x, 1), code, 1, speed_p)); + + rtx_cost (XEXP (x, 1), mode, code, 1, speed_p)); return true; } else if (GET_MODE_CLASS (mode) == MODE_INT @@ -9578,12 +9598,12 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, if (code == ASHIFT) { *cost = (COSTS_N_INSNS (1) - + rtx_cost (XEXP (x, 0), code, 0, speed_p)); + + rtx_cost (XEXP (x, 0), mode, code, 0, speed_p)); /* Slightly disparage register shifts at -Os, but not by much. */ if (!CONST_INT_P (XEXP (x, 1))) *cost += (speed_p ? extra_cost->alu.shift_reg : 1 - + rtx_cost (XEXP (x, 1), code, 1, speed_p)); + + rtx_cost (XEXP (x, 1), mode, code, 1, speed_p)); } else if (code == LSHIFTRT || code == ASHIFTRT) { @@ -9593,12 +9613,12 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, *cost = COSTS_N_INSNS (1); if (speed_p) *cost += extra_cost->alu.bfx; - *cost += rtx_cost (XEXP (x, 0), code, 0, speed_p); + *cost += rtx_cost (XEXP (x, 0), mode, code, 0, speed_p); } else { *cost = COSTS_N_INSNS (2); - *cost += rtx_cost (XEXP (x, 0), code, 0, speed_p); + *cost += rtx_cost (XEXP (x, 0), mode, code, 0, speed_p); if (speed_p) { if (CONST_INT_P (XEXP (x, 1))) @@ -9615,7 +9635,7 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, else /* Rotates. */ { *cost = COSTS_N_INSNS (3 + !CONST_INT_P (XEXP (x, 1))); - *cost += rtx_cost (XEXP (x, 0), code, 0, speed_p); + *cost += rtx_cost (XEXP (x, 0), mode, code, 0, speed_p); if (speed_p) { if (CONST_INT_P (XEXP (x, 1))) @@ -9705,9 +9725,9 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, if (GET_CODE (mul_op0) == NEG) mul_op0 = XEXP (mul_op0, 0); - *cost += (rtx_cost (mul_op0, code, 0, speed_p) - + rtx_cost (mul_op1, code, 0, speed_p) - + rtx_cost (sub_op, code, 0, speed_p)); + *cost += (rtx_cost (mul_op0, mode, code, 0, speed_p) + + rtx_cost (mul_op1, mode, code, 0, speed_p) + + rtx_cost (sub_op, mode, code, 0, speed_p)); return true; } @@ -9740,13 +9760,13 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, { if (speed_p) *cost += extra_cost->alu.arith_shift_reg; - *cost += rtx_cost (shift_by_reg, code, 0, speed_p); + *cost += rtx_cost (shift_by_reg, mode, code, 0, speed_p); } else if (speed_p) *cost += extra_cost->alu.arith_shift; - *cost += (rtx_cost (shift_op, code, 0, speed_p) - + rtx_cost (non_shift_op, code, 0, speed_p)); + *cost += rtx_cost (shift_op, mode, code, 0, speed_p); + *cost += rtx_cost (non_shift_op, mode, code, 0, speed_p); return true; } @@ -9756,9 +9776,9 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, /* MLS. */ if (speed_p) *cost += extra_cost->mult[0].add; - *cost += (rtx_cost (XEXP (x, 0), MINUS, 0, speed_p) - + rtx_cost (XEXP (XEXP (x, 1), 0), MULT, 0, speed_p) - + rtx_cost (XEXP (XEXP (x, 1), 1), MULT, 1, speed_p)); + *cost += rtx_cost (XEXP (x, 0), mode, MINUS, 0, speed_p); + *cost += rtx_cost (XEXP (XEXP (x, 1), 0), mode, MULT, 0, speed_p); + *cost += rtx_cost (XEXP (XEXP (x, 1), 1), mode, MULT, 1, speed_p); return true; } @@ -9770,7 +9790,7 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, *cost = COSTS_N_INSNS (insns); if (speed_p) *cost += insns * extra_cost->alu.arith; - *cost += rtx_cost (XEXP (x, 1), code, 1, speed_p); + *cost += rtx_cost (XEXP (x, 1), mode, code, 1, speed_p); return true; } else if (speed_p) @@ -9798,7 +9818,7 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, if (CONST_INT_P (XEXP (x, 0))) { - *cost += rtx_cost (XEXP (x, 1), code, 1, speed_p); + *cost += rtx_cost (XEXP (x, 1), mode, code, 1, speed_p); return true; } @@ -9817,10 +9837,11 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, *cost += 2 * extra_cost->alu.arith; if (GET_CODE (op1) == ZERO_EXTEND) - *cost += rtx_cost (XEXP (op1, 0), ZERO_EXTEND, 0, speed_p); + *cost += rtx_cost (XEXP (op1, 0), VOIDmode, ZERO_EXTEND, + 0, speed_p); else - *cost += rtx_cost (op1, MINUS, 1, speed_p); - *cost += rtx_cost (XEXP (XEXP (x, 0), 0), ZERO_EXTEND, + *cost += rtx_cost (op1, mode, MINUS, 1, speed_p); + *cost += rtx_cost (XEXP (XEXP (x, 0), 0), VOIDmode, ZERO_EXTEND, 0, speed_p); return true; } @@ -9828,9 +9849,9 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, { if (speed_p) *cost += extra_cost->alu.arith + extra_cost->alu.arith_shift; - *cost += (rtx_cost (XEXP (XEXP (x, 0), 0), SIGN_EXTEND, + *cost += (rtx_cost (XEXP (XEXP (x, 0), 0), VOIDmode, SIGN_EXTEND, 0, speed_p) - + rtx_cost (XEXP (x, 1), MINUS, 1, speed_p)); + + rtx_cost (XEXP (x, 1), mode, MINUS, 1, speed_p)); return true; } else if (GET_CODE (XEXP (x, 1)) == ZERO_EXTEND @@ -9841,8 +9862,8 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, + (GET_CODE (XEXP (x, 1)) == ZERO_EXTEND ? extra_cost->alu.arith : extra_cost->alu.arith_shift)); - *cost += (rtx_cost (XEXP (x, 0), MINUS, 0, speed_p) - + rtx_cost (XEXP (XEXP (x, 1), 0), + *cost += (rtx_cost (XEXP (x, 0), mode, MINUS, 0, speed_p) + + rtx_cost (XEXP (XEXP (x, 1), 0), VOIDmode, GET_CODE (XEXP (x, 1)), 0, speed_p)); return true; } @@ -9873,9 +9894,9 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, mul_op1 = XEXP (XEXP (x, 0), 1); add_op = XEXP (x, 1); - *cost += (rtx_cost (mul_op0, code, 0, speed_p) - + rtx_cost (mul_op1, code, 0, speed_p) - + rtx_cost (add_op, code, 0, speed_p)); + *cost += (rtx_cost (mul_op0, mode, code, 0, speed_p) + + rtx_cost (mul_op1, mode, code, 0, speed_p) + + rtx_cost (add_op, mode, code, 0, speed_p)); return true; } @@ -9912,7 +9933,7 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, *cost += insns * extra_cost->alu.arith; /* Slightly penalize a narrow operation as the result may need widening. */ - *cost += 1 + rtx_cost (XEXP (x, 0), PLUS, 0, speed_p); + *cost += 1 + rtx_cost (XEXP (x, 0), mode, PLUS, 0, speed_p); return true; } @@ -9937,9 +9958,9 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, /* UXTA[BH] or SXTA[BH]. */ if (speed_p) *cost += extra_cost->alu.extend_arith; - *cost += (rtx_cost (XEXP (XEXP (x, 0), 0), ZERO_EXTEND, 0, - speed_p) - + rtx_cost (XEXP (x, 1), PLUS, 0, speed_p)); + *cost += (rtx_cost (XEXP (XEXP (x, 0), 0), VOIDmode, ZERO_EXTEND, + 0, speed_p) + + rtx_cost (XEXP (x, 1), mode, PLUS, 0, speed_p)); return true; } @@ -9951,13 +9972,13 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, { if (speed_p) *cost += extra_cost->alu.arith_shift_reg; - *cost += rtx_cost (shift_reg, ASHIFT, 1, speed_p); + *cost += rtx_cost (shift_reg, mode, ASHIFT, 1, speed_p); } else if (speed_p) *cost += extra_cost->alu.arith_shift; - *cost += (rtx_cost (shift_op, ASHIFT, 0, speed_p) - + rtx_cost (XEXP (x, 1), PLUS, 1, speed_p)); + *cost += (rtx_cost (shift_op, mode, ASHIFT, 0, speed_p) + + rtx_cost (XEXP (x, 1), mode, PLUS, 1, speed_p)); return true; } if (GET_CODE (XEXP (x, 0)) == MULT) @@ -9984,19 +10005,19 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, /* SMLA[BT][BT]. */ if (speed_p) *cost += extra_cost->mult[0].extend_add; - *cost += (rtx_cost (XEXP (XEXP (mul_op, 0), 0), + *cost += (rtx_cost (XEXP (XEXP (mul_op, 0), 0), mode, SIGN_EXTEND, 0, speed_p) - + rtx_cost (XEXP (XEXP (mul_op, 1), 0), + + rtx_cost (XEXP (XEXP (mul_op, 1), 0), mode, SIGN_EXTEND, 0, speed_p) - + rtx_cost (XEXP (x, 1), PLUS, 1, speed_p)); + + rtx_cost (XEXP (x, 1), mode, PLUS, 1, speed_p)); return true; } if (speed_p) *cost += extra_cost->mult[0].add; - *cost += (rtx_cost (XEXP (mul_op, 0), MULT, 0, speed_p) - + rtx_cost (XEXP (mul_op, 1), MULT, 1, speed_p) - + rtx_cost (XEXP (x, 1), PLUS, 1, speed_p)); + *cost += (rtx_cost (XEXP (mul_op, 0), mode, MULT, 0, speed_p) + + rtx_cost (XEXP (mul_op, 1), mode, MULT, 1, speed_p) + + rtx_cost (XEXP (x, 1), mode, PLUS, 1, speed_p)); return true; } if (CONST_INT_P (XEXP (x, 1))) @@ -10007,7 +10028,7 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, *cost = COSTS_N_INSNS (insns); if (speed_p) *cost += insns * extra_cost->alu.arith; - *cost += rtx_cost (XEXP (x, 0), PLUS, 0, speed_p); + *cost += rtx_cost (XEXP (x, 0), mode, PLUS, 0, speed_p); return true; } else if (speed_p) @@ -10028,11 +10049,11 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, *cost = COSTS_N_INSNS (1); if (speed_p) *cost += extra_cost->mult[1].extend_add; - *cost += (rtx_cost (XEXP (XEXP (XEXP (x, 0), 0), 0), + *cost += (rtx_cost (XEXP (XEXP (XEXP (x, 0), 0), 0), mode, ZERO_EXTEND, 0, speed_p) - + rtx_cost (XEXP (XEXP (XEXP (x, 0), 1), 0), + + rtx_cost (XEXP (XEXP (XEXP (x, 0), 1), 0), mode, ZERO_EXTEND, 0, speed_p) - + rtx_cost (XEXP (x, 1), PLUS, 1, speed_p)); + + rtx_cost (XEXP (x, 1), mode, PLUS, 1, speed_p)); return true; } @@ -10047,9 +10068,9 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, ? extra_cost->alu.arith : extra_cost->alu.arith_shift)); - *cost += (rtx_cost (XEXP (XEXP (x, 0), 0), ZERO_EXTEND, 0, - speed_p) - + rtx_cost (XEXP (x, 1), PLUS, 1, speed_p)); + *cost += (rtx_cost (XEXP (XEXP (x, 0), 0), VOIDmode, ZERO_EXTEND, + 0, speed_p) + + rtx_cost (XEXP (x, 1), mode, PLUS, 1, speed_p)); return true; } @@ -10093,13 +10114,13 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, { if (speed_p) *cost += extra_cost->alu.log_shift_reg; - *cost += rtx_cost (shift_reg, ASHIFT, 1, speed_p); + *cost += rtx_cost (shift_reg, mode, ASHIFT, 1, speed_p); } else if (speed_p) *cost += extra_cost->alu.log_shift; - *cost += (rtx_cost (shift_op, ASHIFT, 0, speed_p) - + rtx_cost (XEXP (x, 1), code, 1, speed_p)); + *cost += (rtx_cost (shift_op, mode, ASHIFT, 0, speed_p) + + rtx_cost (XEXP (x, 1), mode, code, 1, speed_p)); return true; } @@ -10112,14 +10133,14 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, *cost = COSTS_N_INSNS (insns); if (speed_p) *cost += insns * extra_cost->alu.logical; - *cost += rtx_cost (op0, code, 0, speed_p); + *cost += rtx_cost (op0, mode, code, 0, speed_p); return true; } if (speed_p) *cost += extra_cost->alu.logical; - *cost += (rtx_cost (op0, code, 0, speed_p) - + rtx_cost (XEXP (x, 1), code, 1, speed_p)); + *cost += (rtx_cost (op0, mode, code, 0, speed_p) + + rtx_cost (XEXP (x, 1), mode, code, 1, speed_p)); return true; } @@ -10140,8 +10161,9 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, if (speed_p) *cost += 2 * extra_cost->alu.logical; - *cost += (rtx_cost (XEXP (op0, 0), ZERO_EXTEND, 0, speed_p) - + rtx_cost (XEXP (x, 1), code, 0, speed_p)); + *cost += (rtx_cost (XEXP (op0, 0), VOIDmode, ZERO_EXTEND, + 0, speed_p) + + rtx_cost (XEXP (x, 1), mode, code, 0, speed_p)); return true; } else if (GET_CODE (op0) == SIGN_EXTEND) @@ -10149,8 +10171,9 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, if (speed_p) *cost += extra_cost->alu.logical + extra_cost->alu.log_shift; - *cost += (rtx_cost (XEXP (op0, 0), SIGN_EXTEND, 0, speed_p) - + rtx_cost (XEXP (x, 1), code, 0, speed_p)); + *cost += (rtx_cost (XEXP (op0, 0), VOIDmode, SIGN_EXTEND, + 0, speed_p) + + rtx_cost (XEXP (x, 1), mode, code, 0, speed_p)); return true; } @@ -10178,8 +10201,8 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, if (speed_p) *cost += extra_cost->fp[mode != SFmode].mult; - *cost += (rtx_cost (op0, MULT, 0, speed_p) - + rtx_cost (XEXP (x, 1), MULT, 1, speed_p)); + *cost += (rtx_cost (op0, mode, MULT, 0, speed_p) + + rtx_cost (XEXP (x, 1), mode, MULT, 1, speed_p)); return true; } else if (GET_MODE_CLASS (mode) == MODE_FLOAT) @@ -10209,8 +10232,8 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, /* SMUL[TB][TB]. */ if (speed_p) *cost += extra_cost->mult[0].extend; - *cost += (rtx_cost (XEXP (x, 0), SIGN_EXTEND, 0, speed_p) - + rtx_cost (XEXP (x, 1), SIGN_EXTEND, 0, speed_p)); + *cost += rtx_cost (XEXP (x, 0), mode, SIGN_EXTEND, 0, speed_p); + *cost += rtx_cost (XEXP (x, 1), mode, SIGN_EXTEND, 1, speed_p); return true; } if (speed_p) @@ -10229,9 +10252,9 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, *cost = COSTS_N_INSNS (1); if (speed_p) *cost += extra_cost->mult[1].extend; - *cost += (rtx_cost (XEXP (XEXP (x, 0), 0), + *cost += (rtx_cost (XEXP (XEXP (x, 0), 0), VOIDmode, ZERO_EXTEND, 0, speed_p) - + rtx_cost (XEXP (XEXP (x, 1), 0), + + rtx_cost (XEXP (XEXP (x, 1), 0), VOIDmode, ZERO_EXTEND, 0, speed_p)); return true; } @@ -10269,7 +10292,7 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, if (speed_p) *cost += (extra_cost->alu.log_shift + extra_cost->alu.arith_shift); - *cost += rtx_cost (XEXP (XEXP (x, 0), 0), ABS, 0, speed_p); + *cost += rtx_cost (XEXP (XEXP (x, 0), 0), mode, ABS, 0, speed_p); return true; } @@ -10284,11 +10307,12 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, && REGNO (XEXP (XEXP (x, 0), 0)) == CC_REGNUM && XEXP (XEXP (x, 0), 1) == const0_rtx)) { + mode = GET_MODE (XEXP (XEXP (x, 0), 0)); *cost += (COSTS_N_INSNS (1) - + rtx_cost (XEXP (XEXP (x, 0), 0), COMPARE, 0, - speed_p) - + rtx_cost (XEXP (XEXP (x, 0), 1), COMPARE, 1, - speed_p)); + + rtx_cost (XEXP (XEXP (x, 0), 0), mode, COMPARE, + 0, speed_p) + + rtx_cost (XEXP (XEXP (x, 0), 1), mode, COMPARE, + 1, speed_p)); if (speed_p) *cost += extra_cost->alu.arith; } @@ -10337,11 +10361,11 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, { if (speed_p) *cost += extra_cost->alu.log_shift_reg; - *cost += rtx_cost (shift_reg, ASHIFT, 1, speed_p); + *cost += rtx_cost (shift_reg, mode, ASHIFT, 1, speed_p); } else if (speed_p) *cost += extra_cost->alu.log_shift; - *cost += rtx_cost (shift_op, ASHIFT, 0, speed_p); + *cost += rtx_cost (shift_op, mode, ASHIFT, 0, speed_p); return true; } @@ -10367,10 +10391,10 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, *cost = COSTS_N_INSNS (4); return true; } - int op1cost = rtx_cost (XEXP (x, 1), SET, 1, speed_p); - int op2cost = rtx_cost (XEXP (x, 2), SET, 1, speed_p); + int op1cost = rtx_cost (XEXP (x, 1), mode, SET, 1, speed_p); + int op2cost = rtx_cost (XEXP (x, 2), mode, SET, 1, speed_p); - *cost = rtx_cost (XEXP (x, 0), IF_THEN_ELSE, 0, speed_p); + *cost = rtx_cost (XEXP (x, 0), mode, IF_THEN_ELSE, 0, speed_p); /* Assume that if one arm of the if_then_else is a register, that it will be tied with the result and eliminate the conditional insn. */ @@ -10413,7 +10437,7 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, if (XEXP (x, 1) == CONST0_RTX (op0mode)) { - *cost += rtx_cost (XEXP (x, 0), code, 0, speed_p); + *cost += rtx_cost (XEXP (x, 0), op0mode, code, 0, speed_p); return true; } @@ -10444,7 +10468,7 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, || (GET_CODE (XEXP (x, 0)) == SUBREG && REG_P (SUBREG_REG (XEXP (x, 0)))))) { - *cost = rtx_cost (XEXP (x, 0), COMPARE, 0, speed_p); + *cost = rtx_cost (XEXP (x, 0), op0mode, COMPARE, 0, speed_p); /* Multiply operations that set the flags are often significantly more expensive. */ @@ -10469,14 +10493,15 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, *cost = COSTS_N_INSNS (1); if (shift_reg != NULL) { - *cost += rtx_cost (shift_reg, ASHIFT, 1, speed_p); + *cost += rtx_cost (shift_reg, op0mode, ASHIFT, + 1, speed_p); if (speed_p) *cost += extra_cost->alu.arith_shift_reg; } else if (speed_p) *cost += extra_cost->alu.arith_shift; - *cost += (rtx_cost (shift_op, ASHIFT, 0, speed_p) - + rtx_cost (XEXP (x, 1), COMPARE, 1, speed_p)); + *cost += rtx_cost (shift_op, op0mode, ASHIFT, 0, speed_p); + *cost += rtx_cost (XEXP (x, 1), op0mode, COMPARE, 1, speed_p); return true; } @@ -10486,7 +10511,7 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, if (CONST_INT_P (XEXP (x, 1)) && const_ok_for_op (INTVAL (XEXP (x, 1)), COMPARE)) { - *cost += rtx_cost (XEXP (x, 0), COMPARE, 0, speed_p); + *cost += rtx_cost (XEXP (x, 0), op0mode, COMPARE, 0, speed_p); return true; } return false; @@ -10579,7 +10604,7 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, *cost = COSTS_N_INSNS (3); break; } - *cost += rtx_cost (XEXP (x, 0), code, 0, speed_p); + *cost += rtx_cost (XEXP (x, 0), mode, code, 0, speed_p); return true; } else @@ -10588,7 +10613,7 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, if (CONST_INT_P (XEXP (x, 1)) && const_ok_for_op (INTVAL (XEXP (x, 1)), COMPARE)) { - *cost += rtx_cost (XEXP (x, 0), code, 0, speed_p); + *cost += rtx_cost (XEXP (x, 0), mode, code, 0, speed_p); return true; } @@ -10639,7 +10664,7 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, if ((arm_arch4 || GET_MODE (XEXP (x, 0)) == SImode) && MEM_P (XEXP (x, 0))) { - *cost = rtx_cost (XEXP (x, 0), code, 0, speed_p); + *cost = rtx_cost (XEXP (x, 0), VOIDmode, code, 0, speed_p); if (mode == DImode) *cost += COSTS_N_INSNS (1); @@ -10663,7 +10688,7 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, { /* We have SXTB/SXTH. */ *cost = COSTS_N_INSNS (1); - *cost += rtx_cost (XEXP (x, 0), code, 0, speed_p); + *cost += rtx_cost (XEXP (x, 0), VOIDmode, code, 0, speed_p); if (speed_p) *cost += extra_cost->alu.extend; } @@ -10671,7 +10696,7 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, { /* Needs two shifts. */ *cost = COSTS_N_INSNS (2); - *cost += rtx_cost (XEXP (x, 0), code, 0, speed_p); + *cost += rtx_cost (XEXP (x, 0), VOIDmode, code, 0, speed_p); if (speed_p) *cost += 2 * extra_cost->alu.shift; } @@ -10692,7 +10717,7 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, || GET_MODE (XEXP (x, 0)) == QImode) && MEM_P (XEXP (x, 0))) { - *cost = rtx_cost (XEXP (x, 0), code, 0, speed_p); + *cost = rtx_cost (XEXP (x, 0), VOIDmode, code, 0, speed_p); if (mode == DImode) *cost += COSTS_N_INSNS (1); /* No speed penalty. */ @@ -10716,7 +10741,7 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, { /* We have UXTB/UXTH. */ *cost = COSTS_N_INSNS (1); - *cost += rtx_cost (XEXP (x, 0), code, 0, speed_p); + *cost += rtx_cost (XEXP (x, 0), VOIDmode, code, 0, speed_p); if (speed_p) *cost += extra_cost->alu.extend; } @@ -10727,7 +10752,7 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, shift may merge with a subsequent insn as a shifter op. */ *cost = COSTS_N_INSNS (2); - *cost += rtx_cost (XEXP (x, 0), code, 0, speed_p); + *cost += rtx_cost (XEXP (x, 0), VOIDmode, code, 0, speed_p); if (speed_p) *cost += 2 * extra_cost->alu.shift; } @@ -10871,7 +10896,7 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, *cost = COSTS_N_INSNS (1); if (speed_p) *cost += extra_cost->alu.log_shift; - *cost += rtx_cost (XEXP (x, 0), code, 0, speed_p); + *cost += rtx_cost (XEXP (x, 0), mode, code, 0, speed_p); return true; } /* Fall through. */ @@ -10895,10 +10920,10 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, *cost = COSTS_N_INSNS (1); if (speed_p) *cost += extra_cost->mult[1].extend; - *cost += (rtx_cost (XEXP (XEXP (XEXP (x, 0), 0), 0), ZERO_EXTEND, 0, - speed_p) - + rtx_cost (XEXP (XEXP (XEXP (x, 0), 0), 1), ZERO_EXTEND, - 0, speed_p)); + *cost += (rtx_cost (XEXP (XEXP (XEXP (x, 0), 0), 0), VOIDmode, + ZERO_EXTEND, 0, speed_p) + + rtx_cost (XEXP (XEXP (XEXP (x, 0), 0), 1), VOIDmode, + ZERO_EXTEND, 0, speed_p)); return true; } *cost = LIBCALL_COST (1); @@ -10926,14 +10951,14 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, *cost = COSTS_N_INSNS (1); if (speed_p) *cost += extra_cost->alu.bfx; - *cost += rtx_cost (XEXP (x, 0), code, 0, speed_p); + *cost += rtx_cost (XEXP (x, 0), mode, code, 0, speed_p); return true; } /* Without UBFX/SBFX, need to resort to shift operations. */ *cost = COSTS_N_INSNS (2); if (speed_p) *cost += 2 * extra_cost->alu.shift; - *cost += rtx_cost (XEXP (x, 0), ASHIFT, 0, speed_p); + *cost += rtx_cost (XEXP (x, 0), mode, ASHIFT, 0, speed_p); return true; case FLOAT_EXTEND: @@ -10951,7 +10976,7 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, if (speed_p) *cost += extra_cost->fp[0].widen; } - *cost += rtx_cost (XEXP (x, 0), code, 0, speed_p); + *cost += rtx_cost (XEXP (x, 0), VOIDmode, code, 0, speed_p); return true; } @@ -10964,7 +10989,7 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, *cost = COSTS_N_INSNS (1); if (speed_p) *cost += extra_cost->fp[mode == DFmode].narrow; - *cost += rtx_cost (XEXP (x, 0), code, 0, speed_p); + *cost += rtx_cost (XEXP (x, 0), VOIDmode, code, 0, speed_p); return true; /* Vector modes? */ } @@ -10988,9 +11013,9 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, if (GET_CODE (op2) == NEG) op2 = XEXP (op2, 0); - *cost += rtx_cost (op0, FMA, 0, speed_p); - *cost += rtx_cost (op1, FMA, 1, speed_p); - *cost += rtx_cost (op2, FMA, 2, speed_p); + *cost += rtx_cost (op0, mode, FMA, 0, speed_p); + *cost += rtx_cost (op1, mode, FMA, 1, speed_p); + *cost += rtx_cost (op2, mode, FMA, 2, speed_p); if (speed_p) *cost += extra_cost->fp[mode ==DFmode].fma; @@ -11008,13 +11033,15 @@ arm_new_rtx_costs (rtx x, enum rtx_code code, enum rtx_code outer_code, if (GET_MODE_CLASS (mode) == MODE_INT) { *cost = COSTS_N_INSNS (1); + mode = GET_MODE (XEXP (x, 0)); if (speed_p) - *cost += extra_cost->fp[GET_MODE (XEXP (x, 0)) == DFmode].toint; + *cost += extra_cost->fp[mode == DFmode].toint; /* Strip of the 'cost' of rounding towards zero. */ if (GET_CODE (XEXP (x, 0)) == FIX) - *cost += rtx_cost (XEXP (XEXP (x, 0), 0), code, 0, speed_p); + *cost += rtx_cost (XEXP (XEXP (x, 0), 0), mode, code, + 0, speed_p); else - *cost += rtx_cost (XEXP (x, 0), code, 0, speed_p); + *cost += rtx_cost (XEXP (x, 0), mode, code, 0, speed_p); /* ??? Increase the cost to deal with transferring from FP -> CORE registers? */ return true; @@ -11074,10 +11101,11 @@ arm_new_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 opno ATTRIBUTE_UNUSED, - int *total, bool speed) +arm_rtx_costs (rtx x, machine_mode mode ATTRIBUTE_UNUSED, int outer_code, + int opno ATTRIBUTE_UNUSED, int *total, bool speed) { bool result; + int code = GET_CODE (x); if (TARGET_OLD_RTX_COSTS || (!current_tune->insn_extra_cost && !TARGET_NEW_GENERIC_COSTS)) @@ -11158,7 +11186,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, 0, speed); + *total += rtx_cost (XEXP (x, 0), mode, code, 0, speed); return true; } diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c index 4baa356986a..a4564612586 100644 --- a/gcc/config/avr/avr.c +++ b/gcc/config/avr/avr.c @@ -169,7 +169,7 @@ static struct machine_function * avr_init_machine_status (void); /* Prototypes for hook implementors if needed before their implementation. */ -static bool avr_rtx_costs (rtx, int, int, int, int*, bool); +static bool avr_rtx_costs (rtx, machine_mode, int, int, int*, bool); /* Allocate registers from r25 to r8 for parameters for function calls. */ @@ -2697,10 +2697,11 @@ avr_final_prescan_insn (rtx_insn *insn, rtx *operand ATTRIBUTE_UNUSED, if (set) fprintf (asm_out_file, "/* DEBUG: cost = %d. */\n", - set_src_cost (SET_SRC (set), optimize_insn_for_speed_p ())); + set_src_cost (SET_SRC (set), GET_MODE (SET_DEST (set)), + optimize_insn_for_speed_p ())); else fprintf (asm_out_file, "/* DEBUG: pattern-cost = %d. */\n", - rtx_cost (PATTERN (insn), INSN, 0, + rtx_cost (PATTERN (insn), VOIDmode, INSN, 0, optimize_insn_for_speed_p())); } } @@ -9910,7 +9911,7 @@ avr_operand_rtx_cost (rtx x, machine_mode mode, enum rtx_code outer, } total = 0; - avr_rtx_costs (x, code, outer, opno, &total, speed); + avr_rtx_costs (x, mode, outer, opno, &total, speed); return total; } @@ -9921,11 +9922,10 @@ avr_operand_rtx_cost (rtx x, machine_mode mode, enum rtx_code outer, In either case, *TOTAL contains the cost result. */ static bool -avr_rtx_costs_1 (rtx x, int codearg, int outer_code ATTRIBUTE_UNUSED, +avr_rtx_costs_1 (rtx x, machine_mode mode, int outer_code ATTRIBUTE_UNUSED, int opno ATTRIBUTE_UNUSED, int *total, bool speed) { - enum rtx_code code = (enum rtx_code) codearg; - machine_mode mode = GET_MODE (x); + enum rtx_code code = GET_CODE (x); HOST_WIDE_INT val; switch (code) @@ -9986,13 +9986,15 @@ avr_rtx_costs_1 (rtx x, int codearg, int outer_code ATTRIBUTE_UNUSED, 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, 0, speed); + *total += avr_operand_rtx_cost (XEXP (x, 0), GET_MODE (XEXP (x, 0)), + 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, 0, speed); + *total += avr_operand_rtx_cost (XEXP (x, 0), GET_MODE (XEXP (x, 0)), + code, 0, speed); return true; case PLUS: @@ -10698,13 +10700,15 @@ avr_rtx_costs_1 (rtx x, int codearg, int outer_code ATTRIBUTE_UNUSED, 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, 1, speed); + *total += avr_operand_rtx_cost (XEXP (x, 1), QImode, 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, 1, speed); + *total += avr_operand_rtx_cost (XEXP (x, 1), HImode, code, + 1, speed); else if (INTVAL (XEXP (x, 1)) != 0) *total += COSTS_N_INSNS (1); break; @@ -10718,7 +10722,8 @@ avr_rtx_costs_1 (rtx x, int codearg, int outer_code ATTRIBUTE_UNUSED, 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, 1, speed); + *total += avr_operand_rtx_cost (XEXP (x, 1), SImode, code, + 1, speed); else if (INTVAL (XEXP (x, 1)) != 0) *total += COSTS_N_INSNS (3); break; @@ -10726,7 +10731,8 @@ avr_rtx_costs_1 (rtx x, int codearg, int outer_code ATTRIBUTE_UNUSED, default: return false; } - *total += avr_operand_rtx_cost (XEXP (x, 0), mode, code, 0, speed); + *total += avr_operand_rtx_cost (XEXP (x, 0), GET_MODE (XEXP (x, 0)), + code, 0, speed); return true; case TRUNCATE: @@ -10753,10 +10759,10 @@ avr_rtx_costs_1 (rtx x, int codearg, int outer_code ATTRIBUTE_UNUSED, /* Implement `TARGET_RTX_COSTS'. */ static bool -avr_rtx_costs (rtx x, int codearg, int outer_code, +avr_rtx_costs (rtx x, machine_mode mode, int outer_code, int opno, int *total, bool speed) { - bool done = avr_rtx_costs_1 (x, codearg, outer_code, + bool done = avr_rtx_costs_1 (x, mode, outer_code, opno, total, speed); if (avr_log.rtx_costs) diff --git a/gcc/config/bfin/bfin.c b/gcc/config/bfin/bfin.c index 3119fe7c9a2..ea3e6679cb3 100644 --- a/gcc/config/bfin/bfin.c +++ b/gcc/config/bfin/bfin.c @@ -2797,10 +2797,10 @@ bfin_legitimate_constant_p (machine_mode mode ATTRIBUTE_UNUSED, rtx x) } static bool -bfin_rtx_costs (rtx x, int code_i, int outer_code_i, int opno, int *total, - bool speed) +bfin_rtx_costs (rtx x, machine_mode mode, int outer_code_i, int opno, + int *total, bool speed) { - enum rtx_code code = (enum rtx_code) code_i; + enum rtx_code code = GET_CODE (x); enum rtx_code outer_code = (enum rtx_code) outer_code_i; int cost2 = COSTS_N_INSNS (1); rtx op0, op1; @@ -2839,7 +2839,7 @@ bfin_rtx_costs (rtx x, int code_i, int outer_code_i, int opno, int *total, case PLUS: op0 = XEXP (x, 0); op1 = XEXP (x, 1); - if (GET_MODE (x) == SImode) + if (mode == SImode) { if (GET_CODE (op0) == MULT && GET_CODE (XEXP (op0, 1)) == CONST_INT) @@ -2848,35 +2848,36 @@ bfin_rtx_costs (rtx x, int code_i, int outer_code_i, int opno, int *total, if (val == 2 || val == 4) { *total = cost2; - *total += rtx_cost (XEXP (op0, 0), outer_code, opno, speed); - *total += rtx_cost (op1, outer_code, opno, speed); + *total += rtx_cost (XEXP (op0, 0), mode, outer_code, + opno, speed); + *total += rtx_cost (op1, mode, outer_code, opno, speed); return true; } } *total = cost2; if (GET_CODE (op0) != REG && (GET_CODE (op0) != SUBREG || GET_CODE (SUBREG_REG (op0)) != REG)) - *total += set_src_cost (op0, speed); + *total += set_src_cost (op0, mode, speed); #if 0 /* We'd like to do this for accuracy, but it biases the loop optimizer towards creating too many induction variables. */ if (!reg_or_7bit_operand (op1, SImode)) - *total += set_src_cost (op1, speed); + *total += set_src_cost (op1, mode, speed); #endif } - else if (GET_MODE (x) == DImode) + else if (mode == DImode) { *total = 6 * cost2; if (GET_CODE (op1) != CONST_INT || !satisfies_constraint_Ks7 (op1)) - *total += rtx_cost (op1, PLUS, 1, speed); + *total += rtx_cost (op1, mode, PLUS, 1, speed); if (GET_CODE (op0) != REG && (GET_CODE (op0) != SUBREG || GET_CODE (SUBREG_REG (op0)) != REG)) - *total += rtx_cost (op0, PLUS, 0, speed); + *total += rtx_cost (op0, mode, PLUS, 0, speed); } return true; case MINUS: - if (GET_MODE (x) == DImode) + if (mode == DImode) *total = 6 * cost2; else *total = cost2; @@ -2885,7 +2886,7 @@ bfin_rtx_costs (rtx x, int code_i, int outer_code_i, int opno, int *total, case ASHIFT: case ASHIFTRT: case LSHIFTRT: - if (GET_MODE (x) == DImode) + if (mode == DImode) *total = 6 * cost2; else *total = cost2; @@ -2894,7 +2895,7 @@ bfin_rtx_costs (rtx x, int code_i, int outer_code_i, int opno, int *total, op1 = XEXP (x, 1); if (GET_CODE (op0) != REG && (GET_CODE (op0) != SUBREG || GET_CODE (SUBREG_REG (op0)) != REG)) - *total += rtx_cost (op0, code, 0, speed); + *total += rtx_cost (op0, mode, code, 0, speed); return true; @@ -2919,26 +2920,26 @@ bfin_rtx_costs (rtx x, int code_i, int outer_code_i, int opno, int *total, if (GET_CODE (op0) != REG && (GET_CODE (op0) != SUBREG || GET_CODE (SUBREG_REG (op0)) != REG)) - *total += rtx_cost (op0, code, 0, speed); + *total += rtx_cost (op0, mode, code, 0, speed); - if (GET_MODE (x) == DImode) + if (mode == DImode) { *total = 2 * cost2; return true; } *total = cost2; - if (GET_MODE (x) != SImode) + if (mode != SImode) return true; if (code == AND) { if (! rhs_andsi3_operand (XEXP (x, 1), SImode)) - *total += rtx_cost (XEXP (x, 1), code, 1, speed); + *total += rtx_cost (XEXP (x, 1), mode, code, 1, speed); } else { if (! regorlog2_operand (XEXP (x, 1), SImode)) - *total += rtx_cost (XEXP (x, 1), code, 1, speed); + *total += rtx_cost (XEXP (x, 1), mode, code, 1, speed); } return true; @@ -2978,10 +2979,10 @@ bfin_rtx_costs (rtx x, int code_i, int outer_code_i, int opno, int *total, if (GET_CODE (op0) != REG && (GET_CODE (op0) != SUBREG || GET_CODE (SUBREG_REG (op0)) != REG)) - *total += rtx_cost (op0, MULT, 0, speed); + *total += rtx_cost (op0, mode, MULT, 0, speed); if (GET_CODE (op1) != REG && (GET_CODE (op1) != SUBREG || GET_CODE (SUBREG_REG (op1)) != REG)) - *total += rtx_cost (op1, MULT, 1, speed); + *total += rtx_cost (op1, mode, MULT, 1, speed); } return true; diff --git a/gcc/config/c6x/c6x.c b/gcc/config/c6x/c6x.c index de49d8b33b9..936161c3d16 100644 --- a/gcc/config/c6x/c6x.c +++ b/gcc/config/c6x/c6x.c @@ -6045,11 +6045,12 @@ 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 opno, int *total, +c6x_rtx_costs (rtx x, machine_mode mode, int outer_code, int opno, int *total, bool speed) { int cost2 = COSTS_N_INSNS (1); rtx op0, op1; + int code = GET_CODE (x); switch (code) { @@ -6078,12 +6079,12 @@ c6x_rtx_costs (rtx x, int code, int outer_code, int opno, int *total, case TRUNCATE: /* Recognize a mult_highpart operation. */ - if ((GET_MODE (x) == HImode || GET_MODE (x) == SImode) + if ((mode == HImode || mode == SImode) && GET_CODE (XEXP (x, 0)) == LSHIFTRT - && GET_MODE (XEXP (x, 0)) == GET_MODE_2XWIDER_MODE (GET_MODE (x)) + && GET_MODE (XEXP (x, 0)) == GET_MODE_2XWIDER_MODE (mode) && GET_CODE (XEXP (XEXP (x, 0), 0)) == MULT && GET_CODE (XEXP (XEXP (x, 0), 1)) == CONST_INT - && INTVAL (XEXP (XEXP (x, 0), 1)) == GET_MODE_BITSIZE (GET_MODE (x))) + && INTVAL (XEXP (XEXP (x, 0), 1)) == GET_MODE_BITSIZE (mode)) { rtx mul = XEXP (XEXP (x, 0), 0); rtx op0 = XEXP (mul, 0); @@ -6093,15 +6094,16 @@ c6x_rtx_costs (rtx x, int code, int outer_code, int opno, int *total, if ((code0 == code1 && (code0 == SIGN_EXTEND || code0 == ZERO_EXTEND)) - || (GET_MODE (x) == HImode + || (mode == HImode && code0 == ZERO_EXTEND && code1 == SIGN_EXTEND)) { - if (GET_MODE (x) == HImode) + if (mode == HImode) *total = COSTS_N_INSNS (2); else *total = COSTS_N_INSNS (12); - *total += rtx_cost (XEXP (op0, 0), code0, 0, speed); - *total += rtx_cost (XEXP (op1, 0), code1, 0, speed); + mode = GET_MODE (XEXP (op0, 0)); + *total += rtx_cost (XEXP (op0, 0), mode, code0, 0, speed); + *total += rtx_cost (XEXP (op1, 0), mode, code1, 0, speed); return true; } } @@ -6110,7 +6112,7 @@ c6x_rtx_costs (rtx x, int code, int outer_code, int opno, int *total, case ASHIFT: case ASHIFTRT: case LSHIFTRT: - if (GET_MODE (x) == DImode) + if (mode == DImode) *total = COSTS_N_INSNS (CONSTANT_P (XEXP (x, 1)) ? 4 : 15); else *total = COSTS_N_INSNS (1); @@ -6121,16 +6123,16 @@ c6x_rtx_costs (rtx x, int code, int outer_code, int opno, int *total, *total = COSTS_N_INSNS (1); op0 = code == PLUS ? XEXP (x, 0) : XEXP (x, 1); op1 = code == PLUS ? XEXP (x, 1) : XEXP (x, 0); - if (GET_MODE_SIZE (GET_MODE (x)) <= UNITS_PER_WORD - && INTEGRAL_MODE_P (GET_MODE (x)) + if (GET_MODE_SIZE (mode) <= UNITS_PER_WORD + && INTEGRAL_MODE_P (mode) && GET_CODE (op0) == MULT && GET_CODE (XEXP (op0, 1)) == CONST_INT && (INTVAL (XEXP (op0, 1)) == 2 || INTVAL (XEXP (op0, 1)) == 4 || (code == PLUS && INTVAL (XEXP (op0, 1)) == 8))) { - *total += rtx_cost (XEXP (op0, 0), ASHIFT, 0, speed); - *total += rtx_cost (op1, (enum rtx_code) code, 1, speed); + *total += rtx_cost (XEXP (op0, 0), mode, ASHIFT, 0, speed); + *total += rtx_cost (op1, mode, (enum rtx_code) code, 1, speed); return true; } return false; @@ -6138,21 +6140,21 @@ c6x_rtx_costs (rtx x, int code, int outer_code, int opno, int *total, case MULT: op0 = XEXP (x, 0); op1 = XEXP (x, 1); - if (GET_MODE (x) == DFmode) + if (mode == DFmode) { if (TARGET_FP) *total = COSTS_N_INSNS (speed ? 10 : 1); else *total = COSTS_N_INSNS (speed ? 200 : 4); } - else if (GET_MODE (x) == SFmode) + else if (mode == SFmode) { if (TARGET_FP) *total = COSTS_N_INSNS (speed ? 4 : 1); else *total = COSTS_N_INSNS (speed ? 100 : 4); } - else if (GET_MODE (x) == DImode) + else if (mode == DImode) { if (TARGET_MPY32 && GET_CODE (op0) == GET_CODE (op1) @@ -6167,7 +6169,7 @@ c6x_rtx_costs (rtx x, int code, int outer_code, int opno, int *total, /* Maybe improve this laster. */ *total = COSTS_N_INSNS (20); } - else if (GET_MODE (x) == SImode) + else if (mode == SImode) { if (((GET_CODE (op0) == ZERO_EXTEND || GET_CODE (op0) == SIGN_EXTEND @@ -6195,15 +6197,15 @@ c6x_rtx_costs (rtx x, int code, int outer_code, int opno, int *total, else *total = COSTS_N_INSNS (6); } - else if (GET_MODE (x) == HImode) + else if (mode == HImode) *total = COSTS_N_INSNS (speed ? 2 : 1); if (GET_CODE (op0) != REG && (GET_CODE (op0) != SUBREG || GET_CODE (SUBREG_REG (op0)) != REG)) - *total += rtx_cost (op0, MULT, 0, speed); + *total += rtx_cost (op0, mode, MULT, 0, speed); if (op1 && GET_CODE (op1) != REG && (GET_CODE (op1) != SUBREG || GET_CODE (SUBREG_REG (op1)) != REG)) - *total += rtx_cost (op1, MULT, 1, speed); + *total += rtx_cost (op1, mode, MULT, 1, speed); return true; case UDIV: @@ -6221,7 +6223,7 @@ c6x_rtx_costs (rtx x, int code, int outer_code, int opno, int *total, && 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, + *total = rtx_cost (XEXP (x, 1), VOIDmode, (enum rtx_code) outer_code, opno, speed); return false; } diff --git a/gcc/config/cris/cris.c b/gcc/config/cris/cris.c index 0773b7ad0a0..b7fa1e627ca 100644 --- a/gcc/config/cris/cris.c +++ b/gcc/config/cris/cris.c @@ -146,7 +146,7 @@ static reg_class_t cris_preferred_reload_class (rtx, reg_class_t); static int cris_register_move_cost (machine_mode, reg_class_t, reg_class_t); static int cris_memory_move_cost (machine_mode, reg_class_t, bool); -static bool cris_rtx_costs (rtx, int, int, int, int *, bool); +static bool cris_rtx_costs (rtx, machine_mode, int, int, int *, bool); static int cris_address_cost (rtx, machine_mode, addr_space_t, bool); static bool cris_pass_by_reference (cumulative_args_t, machine_mode, const_tree, bool); @@ -2097,9 +2097,11 @@ 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 opno, int *total, - bool speed) +cris_rtx_costs (rtx x, machine_mode mode, int outer_code, int opno, + int *total, bool speed) { + int code = GET_CODE (x); + switch (code) { case CONST_INT: @@ -2129,7 +2131,7 @@ cris_rtx_costs (rtx x, int code, int outer_code, int opno, int *total, return true; case CONST_DOUBLE: - if (x != CONST0_RTX (GET_MODE (x) == VOIDmode ? DImode : GET_MODE (x))) + if (x != CONST0_RTX (mode == VOIDmode ? DImode : mode)) *total = 12; else /* Make 0.0 cheap, else test-insns will not be used. */ @@ -2191,9 +2193,9 @@ cris_rtx_costs (rtx x, int code, int outer_code, int opno, int *total, && !satisfies_constraint_I (XEXP (x, 1))) { *total - = (rtx_cost (XEXP (x, 0), (enum rtx_code) outer_code, + = (rtx_cost (XEXP (x, 0), mode, (enum rtx_code) outer_code, opno, speed) + 2 - + 2 * GET_MODE_NUNITS (GET_MODE (XEXP (x, 0)))); + + 2 * GET_MODE_NUNITS (mode)); return true; } return false; @@ -2204,7 +2206,8 @@ cris_rtx_costs (rtx x, int code, int outer_code, int opno, int *total, /* fall through */ case ZERO_EXTEND: case SIGN_EXTEND: - *total = rtx_cost (XEXP (x, 0), (enum rtx_code) outer_code, opno, speed); + *total = rtx_cost (XEXP (x, 0), VOIDmode, (enum rtx_code) outer_code, + opno, speed); return true; default: diff --git a/gcc/config/epiphany/epiphany.c b/gcc/config/epiphany/epiphany.c index f0889bca99b..692fc7476fa 100644 --- a/gcc/config/epiphany/epiphany.c +++ b/gcc/config/epiphany/epiphany.c @@ -765,9 +765,12 @@ epiphany_arg_partial_bytes (cumulative_args_t cum, machine_mode mode, scanned. In either case, *TOTAL contains the cost result. */ static bool -epiphany_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, +epiphany_rtx_costs (rtx x, machine_mode mode, int outer_code, + int opno ATTRIBUTE_UNUSED, int *total, bool speed ATTRIBUTE_UNUSED) { + int code = GET_CODE (x); + switch (code) { /* Small integers in the right context are as cheap as registers. */ @@ -808,7 +811,7 @@ epiphany_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, return true; case COMPARE: - switch (GET_MODE (x)) + switch (mode) { /* There are a number of single-insn combiner patterns that use the flag side effects of arithmetic. */ diff --git a/gcc/config/frv/frv.c b/gcc/config/frv/frv.c index 7b8ec2f445d..9be5d3f619c 100644 --- a/gcc/config/frv/frv.c +++ b/gcc/config/frv/frv.c @@ -378,8 +378,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, int*, - bool); +static bool frv_rtx_costs (rtx, machine_mode, int, int, + int*, bool); static int frv_register_move_cost (machine_mode, reg_class_t, reg_class_t); static int frv_memory_move_cost (machine_mode, @@ -9450,12 +9450,14 @@ frv_in_small_data_p (const_tree decl) static bool frv_rtx_costs (rtx x, - int code ATTRIBUTE_UNUSED, - int outer_code ATTRIBUTE_UNUSED, + machine_mode mode, + int outer_code, int opno ATTRIBUTE_UNUSED, int *total, bool speed ATTRIBUTE_UNUSED) { + int code = GET_CODE (x); + if (outer_code == MEM) { /* Don't differentiate between memory addresses. All the ones @@ -9493,16 +9495,16 @@ frv_rtx_costs (rtx x, case NOT: case NEG: case COMPARE: - if (GET_MODE (x) == SImode) + if (mode == SImode) *total = COSTS_N_INSNS (1); - else if (GET_MODE (x) == DImode) + else if (mode == DImode) *total = COSTS_N_INSNS (2); else *total = COSTS_N_INSNS (3); return true; case MULT: - if (GET_MODE (x) == SImode) + if (mode == SImode) *total = COSTS_N_INSNS (2); else *total = COSTS_N_INSNS (6); /* guess */ diff --git a/gcc/config/h8300/h8300.c b/gcc/config/h8300/h8300.c index 1f25b858a89..0abb92c2681 100644 --- a/gcc/config/h8300/h8300.c +++ b/gcc/config/h8300/h8300.c @@ -1240,9 +1240,11 @@ h8300_shift_costs (rtx x) /* Worker function for TARGET_RTX_COSTS. */ static bool -h8300_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, - int *total, bool speed) +h8300_rtx_costs (rtx x, machine_mode mode ATTRIBUTE_UNUSED, int outer_code, + int opno ATTRIBUTE_UNUSED, int *total, bool speed) { + int code = GET_CODE (x); + if (TARGET_H8300SX && outer_code == MEM) { /* Estimate the number of execution states needed to calculate diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index bf38bce50c1..112eb1c6ef7 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -42241,13 +42241,12 @@ ix86_set_reg_reg_cost (machine_mode mode) scanned. In either case, *TOTAL contains the cost result. */ static bool -ix86_rtx_costs (rtx x, int code_i, int outer_code_i, int opno, int *total, - bool speed) +ix86_rtx_costs (rtx x, machine_mode mode, int outer_code_i, int opno, + int *total, bool speed) { rtx mask; - enum rtx_code code = (enum rtx_code) code_i; + enum rtx_code code = GET_CODE (x); enum rtx_code outer_code = (enum rtx_code) outer_code_i; - machine_mode mode = GET_MODE (x); const struct processor_costs *cost = speed ? ix86_cost : &ix86_size_cost; switch (code) @@ -42378,7 +42377,7 @@ ix86_rtx_costs (rtx x, int code_i, int outer_code_i, int opno, int *total, if (CONSTANT_P (XEXP (x, 1))) { *total = (cost->fabs - + rtx_cost (XEXP (x, 0), code, 0, speed) + + rtx_cost (XEXP (x, 0), mode, code, 0, speed) + (speed ? 2 : COSTS_N_BYTES (16))); return true; } @@ -42434,18 +42433,18 @@ ix86_rtx_costs (rtx x, int code_i, int outer_code_i, int opno, int *total, /* ??? 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, 1, speed); + *total += rtx_cost (XEXP (x, 1), mode, 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, 0, speed); + *total += rtx_cost (sub, mode, FMA, 0, speed); sub = XEXP (x, 2); if (GET_CODE (sub) == NEG) sub = XEXP (sub, 0); - *total += rtx_cost (sub, FMA, 2, speed); + *total += rtx_cost (sub, mode, FMA, 2, speed); return true; } @@ -42535,8 +42534,8 @@ ix86_rtx_costs (rtx x, int code_i, int outer_code_i, int opno, int *total, *total = (cost->mult_init[MODE_INDEX (mode)] + nbits * cost->mult_bit - + rtx_cost (op0, outer_code, opno, speed) - + rtx_cost (op1, outer_code, opno, speed)); + + rtx_cost (op0, mode, outer_code, opno, speed) + + rtx_cost (op1, mode, outer_code, opno, speed)); return true; } @@ -42570,11 +42569,12 @@ ix86_rtx_costs (rtx x, int code_i, int outer_code_i, int opno, int *total, if (val == 2 || val == 4 || val == 8) { *total = cost->lea; - *total += rtx_cost (XEXP (XEXP (x, 0), 1), + *total += rtx_cost (XEXP (XEXP (x, 0), 1), mode, + outer_code, opno, speed); + *total += rtx_cost (XEXP (XEXP (XEXP (x, 0), 0), 0), mode, outer_code, opno, speed); - *total += rtx_cost (XEXP (XEXP (XEXP (x, 0), 0), 0), + *total += rtx_cost (XEXP (x, 1), mode, outer_code, opno, speed); - *total += rtx_cost (XEXP (x, 1), outer_code, opno, speed); return true; } } @@ -42585,20 +42585,22 @@ ix86_rtx_costs (rtx x, int code_i, int outer_code_i, int opno, int *total, if (val == 2 || val == 4 || val == 8) { *total = cost->lea; - *total += rtx_cost (XEXP (XEXP (x, 0), 0), + *total += rtx_cost (XEXP (XEXP (x, 0), 0), mode, + outer_code, opno, speed); + *total += rtx_cost (XEXP (x, 1), mode, 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), + *total += rtx_cost (XEXP (XEXP (x, 0), 0), mode, + outer_code, opno, speed); + *total += rtx_cost (XEXP (XEXP (x, 0), 1), mode, outer_code, opno, speed); - *total += rtx_cost (XEXP (XEXP (x, 0), 1), + *total += rtx_cost (XEXP (x, 1), mode, outer_code, opno, speed); - *total += rtx_cost (XEXP (x, 1), outer_code, opno, speed); return true; } } @@ -42631,9 +42633,9 @@ ix86_rtx_costs (rtx x, int code_i, int outer_code_i, int opno, int *total, && GET_MODE_SIZE (mode) > UNITS_PER_WORD) { *total = (cost->add * 2 - + (rtx_cost (XEXP (x, 0), outer_code, opno, speed) + + (rtx_cost (XEXP (x, 0), mode, outer_code, opno, speed) << (GET_MODE (XEXP (x, 0)) != DImode)) - + (rtx_cost (XEXP (x, 1), outer_code, opno, speed) + + (rtx_cost (XEXP (x, 1), mode, outer_code, opno, speed) << (GET_MODE (XEXP (x, 1)) != DImode))); return true; } @@ -42681,9 +42683,11 @@ ix86_rtx_costs (rtx x, int code_i, int outer_code_i, int opno, int *total, { /* This kind of construct is implemented using test[bwl]. Treat it as if we had an AND. */ + mode = GET_MODE (XEXP (XEXP (x, 0), 0)); *total = (cost->add - + rtx_cost (XEXP (XEXP (x, 0), 0), outer_code, opno, speed) - + rtx_cost (const1_rtx, outer_code, opno, speed)); + + rtx_cost (XEXP (XEXP (x, 0), 0), mode, outer_code, + opno, speed) + + rtx_cost (const1_rtx, mode, outer_code, opno, speed)); return true; } @@ -42739,7 +42743,7 @@ ix86_rtx_costs (rtx x, int code_i, int outer_code_i, int opno, int *total, /* This is masked instruction, assume the same cost, as nonmasked variant. */ if (TARGET_AVX512F && register_operand (mask, GET_MODE (mask))) - *total = rtx_cost (XEXP (x, 0), outer_code, opno, speed); + *total = rtx_cost (XEXP (x, 0), mode, outer_code, opno, speed); else *total = cost->fabs; return true; diff --git a/gcc/config/ia64/ia64.c b/gcc/config/ia64/ia64.c index 64fbe21636a..fef6839e0d2 100644 --- a/gcc/config/ia64/ia64.c +++ b/gcc/config/ia64/ia64.c @@ -233,7 +233,7 @@ static int ia64_register_move_cost (machine_mode, reg_class_t, reg_class_t); static int ia64_memory_move_cost (machine_mode mode, reg_class_t, bool); -static bool ia64_rtx_costs (rtx, int, int, int, int *, bool); +static bool ia64_rtx_costs (rtx, machine_mode, 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); @@ -5590,9 +5590,12 @@ ia64_print_operand_punct_valid_p (unsigned char code) /* ??? This is incomplete. */ static bool -ia64_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, +ia64_rtx_costs (rtx x, machine_mode mode, int outer_code, + int opno ATTRIBUTE_UNUSED, int *total, bool speed ATTRIBUTE_UNUSED) { + int code = GET_CODE (x); + switch (code) { case CONST_INT: @@ -5636,9 +5639,9 @@ ia64_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, which normally involves copies. Plus there's the latency of the multiply itself, and the latency of the instructions to transfer integer regs to FP regs. */ - if (FLOAT_MODE_P (GET_MODE (x))) + if (FLOAT_MODE_P (mode)) *total = COSTS_N_INSNS (4); - else if (GET_MODE_SIZE (GET_MODE (x)) > 2) + else if (GET_MODE_SIZE (mode) > 2) *total = COSTS_N_INSNS (10); else *total = COSTS_N_INSNS (2); @@ -5646,7 +5649,7 @@ ia64_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, case PLUS: case MINUS: - if (FLOAT_MODE_P (GET_MODE (x))) + if (FLOAT_MODE_P (mode)) { *total = COSTS_N_INSNS (4); return true; diff --git a/gcc/config/iq2000/iq2000.c b/gcc/config/iq2000/iq2000.c index 90c73b86a22..79087becd6b 100644 --- a/gcc/config/iq2000/iq2000.c +++ b/gcc/config/iq2000/iq2000.c @@ -166,7 +166,7 @@ static bool iq2000_return_in_memory (const_tree, const_tree); static void iq2000_setup_incoming_varargs (cumulative_args_t, machine_mode, tree, int *, int); -static bool iq2000_rtx_costs (rtx, int, int, int, int *, bool); +static bool iq2000_rtx_costs (rtx, machine_mode, int, int, int *, bool); static int iq2000_address_cost (rtx, machine_mode, addr_space_t, bool); static section *iq2000_select_section (tree, int, unsigned HOST_WIDE_INT); @@ -3306,11 +3306,11 @@ iq2000_legitimize_address (rtx xinsn, rtx old_x ATTRIBUTE_UNUSED, static bool -iq2000_rtx_costs (rtx x, int code, int outer_code ATTRIBUTE_UNUSED, +iq2000_rtx_costs (rtx x, machine_mode mode, int outer_code ATTRIBUTE_UNUSED, int opno ATTRIBUTE_UNUSED, int * total, bool speed ATTRIBUTE_UNUSED) { - machine_mode mode = GET_MODE (x); + int code = GET_CODE (x); switch (code) { diff --git a/gcc/config/lm32/lm32.c b/gcc/config/lm32/lm32.c index 55d0d209f23..2402583f485 100644 --- a/gcc/config/lm32/lm32.c +++ b/gcc/config/lm32/lm32.c @@ -81,7 +81,7 @@ static bool lm32_in_small_data_p (const_tree); static void lm32_setup_incoming_varargs (cumulative_args_t cum, machine_mode mode, tree type, int *pretend_size, int no_rtl); -static bool lm32_rtx_costs (rtx x, int code, int outer_code, int opno, +static bool lm32_rtx_costs (rtx x, machine_mode mode, int outer_code, int opno, int *total, bool speed); static bool lm32_can_eliminate (const int, const int); static bool @@ -934,10 +934,10 @@ 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 opno ATTRIBUTE_UNUSED, - int *total, bool speed) +lm32_rtx_costs (rtx x, machine_mode mode, int outer_code, + int opno ATTRIBUTE_UNUSED, int *total, bool speed) { - machine_mode mode = GET_MODE (x); + int code = GET_CODE (x); bool small_mode; const int arithmetic_latency = 1; diff --git a/gcc/config/m32c/m32c.c b/gcc/config/m32c/m32c.c index 3bf87c5eef6..40da261e448 100644 --- a/gcc/config/m32c/m32c.c +++ b/gcc/config/m32c/m32c.c @@ -2222,9 +2222,11 @@ m32c_memory_move_cost (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 opno ATTRIBUTE_UNUSED, +m32c_rtx_costs (rtx x, machine_mode mode, int outer_code, + int opno ATTRIBUTE_UNUSED, int *total, bool speed ATTRIBUTE_UNUSED) { + int code = GET_CODE (x); switch (code) { case REG: @@ -2292,7 +2294,7 @@ m32c_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, default: /* Reasonable default. */ - if (TARGET_A16 && GET_MODE(x) == SImode) + if (TARGET_A16 && mode == SImode) *total += COSTS_N_INSNS (2); break; } diff --git a/gcc/config/m32r/m32r.c b/gcc/config/m32r/m32r.c index 2d77002377f..72cdfd8a5d5 100644 --- a/gcc/config/m32r/m32r.c +++ b/gcc/config/m32r/m32r.c @@ -98,7 +98,7 @@ static bool m32r_function_value_regno_p (const unsigned int); static void m32r_setup_incoming_varargs (cumulative_args_t, machine_mode, tree, int *, int); static void init_idents (void); -static bool m32r_rtx_costs (rtx, int, int, int, int *, bool speed); +static bool m32r_rtx_costs (rtx, machine_mode, int, int, int *, bool speed); static int m32r_memory_move_cost (machine_mode, reg_class_t, bool); static bool m32r_pass_by_reference (cumulative_args_t, machine_mode, const_tree, bool); @@ -1361,10 +1361,13 @@ m32r_memory_move_cost (machine_mode mode, } static bool -m32r_rtx_costs (rtx x, int code, int outer_code ATTRIBUTE_UNUSED, +m32r_rtx_costs (rtx x, machine_mode mode ATTRIBUTE_UNUSED, + int outer_code ATTRIBUTE_UNUSED, int opno ATTRIBUTE_UNUSED, int *total, bool speed ATTRIBUTE_UNUSED) { + int code = GET_CODE (x); + switch (code) { /* Small integers are as cheap as registers. 4 byte values can be diff --git a/gcc/config/m68k/m68k.c b/gcc/config/m68k/m68k.c index 4e39d201a54..4bd20a5ff36 100644 --- a/gcc/config/m68k/m68k.c +++ b/gcc/config/m68k/m68k.c @@ -165,7 +165,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, machine_mode); -static bool m68k_rtx_costs (rtx, int, int, int, int *, bool); +static bool m68k_rtx_costs (rtx, machine_mode, int, int, int *, bool); #if M68K_HONOR_TARGET_STRICT_ALIGNMENT static bool m68k_return_in_memory (const_tree, const_tree); #endif @@ -2787,9 +2787,12 @@ const_int_cost (HOST_WIDE_INT i) } static bool -m68k_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, +m68k_rtx_costs (rtx x, machine_mode mode, int outer_code, + int opno ATTRIBUTE_UNUSED, int *total, bool speed ATTRIBUTE_UNUSED) { + int code = GET_CODE (x); + switch (code) { case CONST_INT: @@ -2846,7 +2849,7 @@ m68k_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, case PLUS: /* An lea costs about three times as much as a simple add. */ - if (GET_MODE (x) == SImode + if (mode == SImode && GET_CODE (XEXP (x, 1)) == REG && GET_CODE (XEXP (x, 0)) == MULT && GET_CODE (XEXP (XEXP (x, 0), 0)) == REG @@ -2902,9 +2905,9 @@ m68k_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, case MULT: if ((GET_CODE (XEXP (x, 0)) == ZERO_EXTEND || GET_CODE (XEXP (x, 0)) == SIGN_EXTEND) - && GET_MODE (x) == SImode) + && mode == SImode) *total = COSTS_N_INSNS (MULW_COST); - else if (GET_MODE (x) == QImode || GET_MODE (x) == HImode) + else if (mode == QImode || mode == HImode) *total = COSTS_N_INSNS (MULW_COST); else *total = COSTS_N_INSNS (MULL_COST); @@ -2914,7 +2917,7 @@ m68k_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, case UDIV: case MOD: case UMOD: - if (GET_MODE (x) == QImode || GET_MODE (x) == HImode) + if (mode == QImode || mode == HImode) *total = COSTS_N_INSNS (DIVW_COST); /* div.w */ else if (TARGET_CF_HWDIV) *total = COSTS_N_INSNS (18); diff --git a/gcc/config/mcore/mcore.c b/gcc/config/mcore/mcore.c index a18b0429f45..1ba27d09714 100644 --- a/gcc/config/mcore/mcore.c +++ b/gcc/config/mcore/mcore.c @@ -136,7 +136,7 @@ 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, +static bool mcore_rtx_costs (rtx, machine_mode, int, int, int *, bool); static void mcore_external_libcall (rtx); static bool mcore_return_in_memory (const_tree, const_tree); @@ -528,9 +528,12 @@ mcore_ior_cost (rtx x) } static bool -mcore_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, +mcore_rtx_costs (rtx x, machine_mode mode ATTRIBUTE_UNUSED, int outer_code, + int opno ATTRIBUTE_UNUSED, int * total, bool speed ATTRIBUTE_UNUSED) { + int code = GET_CODE (x); + switch (code) { case CONST_INT: diff --git a/gcc/config/mep/mep.c b/gcc/config/mep/mep.c index bfdd2dc6be5..2d343b30263 100644 --- a/gcc/config/mep/mep.c +++ b/gcc/config/mep/mep.c @@ -231,7 +231,7 @@ static void mep_move_ready_insn (rtx_insn **, int, rtx_insn *); static int mep_sched_reorder (FILE *, int, rtx_insn **, int *, int); static rtx_insn *mep_make_bundle (rtx, rtx_insn *); static void mep_bundle_insns (rtx_insn *); -static bool mep_rtx_cost (rtx, int, int, int, int *, bool); +static bool mep_rtx_cost (rtx, machine_mode, int, int, int *, bool); static int mep_address_cost (rtx, machine_mode, addr_space_t, bool); static void mep_setup_incoming_varargs (cumulative_args_t, machine_mode, tree, int *, int); @@ -7109,10 +7109,13 @@ mep_expand_binary_intrinsic (int ATTRIBUTE_UNUSED immediate, } static bool -mep_rtx_cost (rtx x, int code, int outer_code ATTRIBUTE_UNUSED, +mep_rtx_cost (rtx x, machine_mode mode ATTRIBUTE_UNUSED, + int outer_code ATTRIBUTE_UNUSED, int opno ATTRIBUTE_UNUSED, int *total, bool ATTRIBUTE_UNUSED speed_t) { + int code = GET_CODE (x); + switch (code) { case CONST_INT: diff --git a/gcc/config/microblaze/microblaze.c b/gcc/config/microblaze/microblaze.c index 8ed3bfa40e7..da9005ee021 100644 --- a/gcc/config/microblaze/microblaze.c +++ b/gcc/config/microblaze/microblaze.c @@ -1231,11 +1231,11 @@ 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, +microblaze_rtx_costs (rtx x, machine_mode mode, int outer_code ATTRIBUTE_UNUSED, int opno ATTRIBUTE_UNUSED, int *total, bool speed ATTRIBUTE_UNUSED) { - machine_mode mode = GET_MODE (x); + int code = GET_CODE (x); switch (code) { diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c index 078bfdcef37..31756d702a9 100644 --- a/gcc/config/mips/mips.c +++ b/gcc/config/mips/mips.c @@ -2415,7 +2415,7 @@ mips_legitimate_address_p (machine_mode mode, rtx x, bool strict_p) return mips_classify_address (&addr, x, mode, strict_p); } -/* Return true if X is a legitimate $sp-based address for mode MDOE. */ +/* Return true if X is a legitimate $sp-based address for mode MODE. */ bool mips_stack_address_p (rtx x, machine_mode mode) @@ -3708,8 +3708,8 @@ mips_binary_cost (rtx x, int single_cost, int double_cost, bool speed) else cost = single_cost; return (cost - + set_src_cost (XEXP (x, 0), speed) - + rtx_cost (XEXP (x, 1), GET_CODE (x), 1, speed)); + + set_src_cost (XEXP (x, 0), GET_MODE (x), speed) + + rtx_cost (XEXP (x, 1), GET_MODE (x), GET_CODE (x), 1, speed)); } /* Return the cost of floating-point multiplications of mode MODE. */ @@ -3810,10 +3810,10 @@ mips_set_reg_reg_cost (machine_mode mode) /* Implement TARGET_RTX_COSTS. */ static bool -mips_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, - int *total, bool speed) +mips_rtx_costs (rtx x, machine_mode mode, int outer_code, + int opno ATTRIBUTE_UNUSED, int *total, bool speed) { - machine_mode mode = GET_MODE (x); + int code = GET_CODE (x); bool float_mode_p = FLOAT_MODE_P (mode); int cost; rtx addr; @@ -3912,7 +3912,7 @@ mips_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, for a word or doubleword operation, so we cannot rely on the result of mips_build_integer. */ else if (!TARGET_MIPS16 - && (outer_code == SET || mode == VOIDmode)) + && (outer_code == SET || GET_MODE (x) == VOIDmode)) cost = 1; *total = COSTS_N_INSNS (cost); return true; @@ -3958,7 +3958,7 @@ mips_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, && UINTVAL (XEXP (x, 1)) == 0xffffffff) { *total = (mips_zero_extend_cost (mode, XEXP (x, 0)) - + set_src_cost (XEXP (x, 0), speed)); + + set_src_cost (XEXP (x, 0), mode, speed)); return true; } if (ISA_HAS_CINS && CONST_INT_P (XEXP (x, 1))) @@ -3968,7 +3968,8 @@ mips_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, && CONST_INT_P (XEXP (op, 1)) && mask_low_and_shift_p (mode, XEXP (x, 1), XEXP (op, 1), 32)) { - *total = COSTS_N_INSNS (1) + set_src_cost (XEXP (op, 0), speed); + *total = COSTS_N_INSNS (1); + *total += set_src_cost (XEXP (op, 0), mode, speed); return true; } } @@ -3980,8 +3981,8 @@ mips_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, { cost = GET_MODE_SIZE (mode) > UNITS_PER_WORD ? 2 : 1; *total = (COSTS_N_INSNS (cost) - + set_src_cost (XEXP (XEXP (x, 0), 0), speed) - + set_src_cost (XEXP (XEXP (x, 1), 0), speed)); + + set_src_cost (XEXP (XEXP (x, 0), 0), mode, speed) + + set_src_cost (XEXP (XEXP (x, 1), 0), mode, speed)); return true; } @@ -4017,7 +4018,7 @@ mips_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, case LO_SUM: /* Low-part immediates need an extended MIPS16 instruction. */ *total = (COSTS_N_INSNS (TARGET_MIPS16 ? 2 : 1) - + set_src_cost (XEXP (x, 0), speed)); + + set_src_cost (XEXP (x, 0), mode, speed)); return true; case LT: @@ -4055,17 +4056,17 @@ mips_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, if (GET_CODE (op0) == MULT && GET_CODE (XEXP (op0, 0)) == NEG) { *total = (mips_fp_mult_cost (mode) - + set_src_cost (XEXP (XEXP (op0, 0), 0), speed) - + set_src_cost (XEXP (op0, 1), speed) - + set_src_cost (op1, speed)); + + set_src_cost (XEXP (XEXP (op0, 0), 0), mode, speed) + + set_src_cost (XEXP (op0, 1), mode, speed) + + set_src_cost (op1, mode, speed)); return true; } if (GET_CODE (op1) == MULT) { *total = (mips_fp_mult_cost (mode) - + set_src_cost (op0, speed) - + set_src_cost (XEXP (op1, 0), speed) - + set_src_cost (XEXP (op1, 1), speed)); + + set_src_cost (op0, mode, speed) + + set_src_cost (XEXP (op1, 0), mode, speed) + + set_src_cost (XEXP (op1, 1), mode, speed)); return true; } } @@ -4093,8 +4094,8 @@ mips_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, if (const_immlsa_operand (op2, mode)) { *total = (COSTS_N_INSNS (1) - + set_src_cost (XEXP (XEXP (x, 0), 0), speed) - + set_src_cost (XEXP (x, 1), speed)); + + set_src_cost (XEXP (XEXP (x, 0), 0), mode, speed) + + set_src_cost (XEXP (x, 1), mode, speed)); return true; } } @@ -4117,9 +4118,9 @@ mips_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, && GET_CODE (XEXP (op, 0)) == MULT) { *total = (mips_fp_mult_cost (mode) - + set_src_cost (XEXP (XEXP (op, 0), 0), speed) - + set_src_cost (XEXP (XEXP (op, 0), 1), speed) - + set_src_cost (XEXP (op, 1), speed)); + + set_src_cost (XEXP (XEXP (op, 0), 0), mode, speed) + + set_src_cost (XEXP (XEXP (op, 0), 1), mode, speed) + + set_src_cost (XEXP (op, 1), mode, speed)); return true; } } @@ -4161,10 +4162,10 @@ mips_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, if (outer_code == SQRT || GET_CODE (XEXP (x, 1)) == SQRT) /* An rsqrt<mode>a or rsqrt<mode>b pattern. Count the division as being free. */ - *total = set_src_cost (XEXP (x, 1), speed); + *total = set_src_cost (XEXP (x, 1), mode, speed); else *total = (mips_fp_div_cost (mode) - + set_src_cost (XEXP (x, 1), speed)); + + set_src_cost (XEXP (x, 1), mode, speed)); return true; } /* Fall through. */ @@ -4192,7 +4193,8 @@ mips_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, && CONST_INT_P (XEXP (x, 1)) && exact_log2 (INTVAL (XEXP (x, 1))) >= 0) { - *total = COSTS_N_INSNS (2) + set_src_cost (XEXP (x, 0), speed); + *total = COSTS_N_INSNS (2); + *total += set_src_cost (XEXP (x, 0), mode, speed); return true; } *total = COSTS_N_INSNS (mips_idiv_insns ()); @@ -4215,7 +4217,7 @@ mips_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, && GET_MODE (XEXP (x, 0)) == QImode && GET_CODE (XEXP (XEXP (x, 0), 0)) == PLUS) { - *total = set_src_cost (XEXP (XEXP (x, 0), 0), speed); + *total = set_src_cost (XEXP (XEXP (x, 0), 0), VOIDmode, speed); return true; } *total = mips_zero_extend_cost (mode, XEXP (x, 0)); @@ -4258,9 +4260,10 @@ mips_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, if (ISA_HAS_R6DMUL && GET_CODE (op) == ZERO_EXTEND && GET_MODE (op) == DImode) - *total += rtx_cost (op, MULT, i, speed); + *total += rtx_cost (op, DImode, MULT, i, speed); else - *total += rtx_cost (XEXP (op, 0), GET_CODE (op), 0, speed); + *total += rtx_cost (XEXP (op, 0), VOIDmode, GET_CODE (op), + 0, speed); } return true; diff --git a/gcc/config/mmix/mmix.c b/gcc/config/mmix/mmix.c index 871e4cd40d3..57f0659d462 100644 --- a/gcc/config/mmix/mmix.c +++ b/gcc/config/mmix/mmix.c @@ -149,7 +149,7 @@ static void mmix_setup_incoming_varargs (cumulative_args_t, 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, int *, bool); +static bool mmix_rtx_costs (rtx, machine_mode, int, int, int *, bool); static int mmix_register_move_cost (machine_mode, reg_class_t, reg_class_t); static rtx mmix_struct_value_rtx (tree, int); @@ -1174,7 +1174,7 @@ mmix_reversible_cc_mode (machine_mode mode) static bool mmix_rtx_costs (rtx x ATTRIBUTE_UNUSED, - int code ATTRIBUTE_UNUSED, + machine_mode mode ATTRIBUTE_UNUSED, int outer_code ATTRIBUTE_UNUSED, int opno ATTRIBUTE_UNUSED, int *total ATTRIBUTE_UNUSED, diff --git a/gcc/config/mn10300/mn10300.c b/gcc/config/mn10300/mn10300.c index 349ed5a5c8a..7abc61dabf1 100644 --- a/gcc/config/mn10300/mn10300.c +++ b/gcc/config/mn10300/mn10300.c @@ -2227,7 +2227,7 @@ mn10300_address_cost (rtx x, machine_mode mode ATTRIBUTE_UNUSED, return speed ? 2 : 6; default: - return rtx_cost (x, MEM, 0, speed); + return rtx_cost (x, Pmode, MEM, 0, speed); } } @@ -2341,13 +2341,14 @@ mn10300_memory_move_cost (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 opno ATTRIBUTE_UNUSED, - int *ptotal, bool speed) +mn10300_rtx_costs (rtx x, machine_mode mode, 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. */ HOST_WIDE_INT i = 0x12345678; int total; + int code = GET_CODE (x); switch (code) { @@ -2433,7 +2434,7 @@ mn10300_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, i = INTVAL (XEXP (x, 1)); if (i == 1 || i == 4) { - total = 1 + rtx_cost (XEXP (x, 0), PLUS, 0, speed); + total = 1 + rtx_cost (XEXP (x, 0), mode, PLUS, 0, speed); goto alldone; } } @@ -2489,7 +2490,7 @@ mn10300_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, break; case MEM: - total = mn10300_address_cost (XEXP (x, 0), GET_MODE (x), + total = mn10300_address_cost (XEXP (x, 0), mode, MEM_ADDR_SPACE (x), speed); if (speed) total = COSTS_N_INSNS (2 + total); diff --git a/gcc/config/msp430/msp430.c b/gcc/config/msp430/msp430.c index 19849473e34..9d0e4a0e128 100644 --- a/gcc/config/msp430/msp430.c +++ b/gcc/config/msp430/msp430.c @@ -1004,17 +1004,19 @@ msp430_legitimate_constant (machine_mode mode, rtx x) #undef TARGET_RTX_COSTS #define TARGET_RTX_COSTS msp430_rtx_costs -static bool msp430_rtx_costs (rtx x ATTRIBUTE_UNUSED, - int code, - int outer_code ATTRIBUTE_UNUSED, - int opno ATTRIBUTE_UNUSED, - int * total, - bool speed ATTRIBUTE_UNUSED) +static bool msp430_rtx_costs (rtx x ATTRIBUTE_UNUSED, + machine_mode mode, + int outer_code ATTRIBUTE_UNUSED, + int opno ATTRIBUTE_UNUSED, + int * total, + bool speed ATTRIBUTE_UNUSED) { + int code = GET_CODE (x); + switch (code) { case SIGN_EXTEND: - if (GET_MODE (x) == SImode && outer_code == SET) + if (mode == SImode && outer_code == SET) { *total = COSTS_N_INSNS (4); return true; diff --git a/gcc/config/nds32/nds32-cost.c b/gcc/config/nds32/nds32-cost.c index 7afdc4be7e2..d25c41ab0c7 100644 --- a/gcc/config/nds32/nds32-cost.c +++ b/gcc/config/nds32/nds32-cost.c @@ -64,12 +64,14 @@ bool nds32_rtx_costs_impl (rtx x, - int code, + machine_mode mode ATTRIBUTE_UNUSED, int outer_code, int opno ATTRIBUTE_UNUSED, int *total, bool speed) { + int code = GET_CODE (x); + /* According to 'speed', goto suitable cost model section. */ if (speed) goto performance_cost; diff --git a/gcc/config/nds32/nds32-protos.h b/gcc/config/nds32/nds32-protos.h index 620d897535a..199e7037458 100644 --- a/gcc/config/nds32/nds32-protos.h +++ b/gcc/config/nds32/nds32-protos.h @@ -144,7 +144,7 @@ extern bool nds32_isr_function_p (tree); /* Auxiliary functions for cost calculation. */ -extern bool nds32_rtx_costs_impl (rtx, int, int, int, int *, bool); +extern bool nds32_rtx_costs_impl (rtx, machine_mode, int, int, int *, bool); extern int nds32_address_cost_impl (rtx, machine_mode, addr_space_t, bool); /* ------------------------------------------------------------------------ */ diff --git a/gcc/config/nds32/nds32.c b/gcc/config/nds32/nds32.c index 9b42325bcbc..56ba24a20d5 100644 --- a/gcc/config/nds32/nds32.c +++ b/gcc/config/nds32/nds32.c @@ -2100,13 +2100,13 @@ nds32_memory_move_cost (machine_mode mode ATTRIBUTE_UNUSED, Refer to gcc/rtlanal.c for more information. */ static bool nds32_rtx_costs (rtx x, - int code, + machine_mode mode, int outer_code, int opno, int *total, bool speed) { - return nds32_rtx_costs_impl (x, code, outer_code, opno, total, speed); + return nds32_rtx_costs_impl (x, mode, outer_code, opno, total, speed); } static int diff --git a/gcc/config/nios2/nios2.c b/gcc/config/nios2/nios2.c index 84d8ed7c055..4b614db9891 100644 --- a/gcc/config/nios2/nios2.c +++ b/gcc/config/nios2/nios2.c @@ -1090,10 +1090,13 @@ nios2_simple_const_p (const_rtx cst) cost has been computed, and false if subexpressions should be scanned. In either case, *TOTAL contains the cost result. */ static bool -nios2_rtx_costs (rtx x, int code, int outer_code ATTRIBUTE_UNUSED, +nios2_rtx_costs (rtx x, machine_mode mode ATTRIBUTE_UNUSED, + int outer_code ATTRIBUTE_UNUSED, int opno ATTRIBUTE_UNUSED, int *total, bool speed ATTRIBUTE_UNUSED) { + int code = GET_CODE (x); + switch (code) { case CONST_INT: diff --git a/gcc/config/pa/pa.c b/gcc/config/pa/pa.c index a92239075d7..03ac6f220a2 100644 --- a/gcc/config/pa/pa.c +++ b/gcc/config/pa/pa.c @@ -106,7 +106,7 @@ static void fix_range (const char *); static int hppa_register_move_cost (machine_mode mode, reg_class_t, reg_class_t); static int hppa_address_cost (rtx, machine_mode mode, addr_space_t, bool); -static bool hppa_rtx_costs (rtx, int, int, int, int *, bool); +static bool hppa_rtx_costs (rtx, machine_mode, int, int, int *, bool); static inline rtx force_mode (machine_mode, rtx); static void pa_reorg (void); static void pa_combine_instructions (void); @@ -1480,10 +1480,12 @@ hppa_address_cost (rtx X, machine_mode mode ATTRIBUTE_UNUSED, scanned. In either case, *TOTAL contains the cost result. */ static bool -hppa_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, +hppa_rtx_costs (rtx x, machine_mode mode, int outer_code, + int opno ATTRIBUTE_UNUSED, int *total, bool speed ATTRIBUTE_UNUSED) { int factor; + int code = GET_CODE (x); switch (code) { @@ -1515,14 +1517,14 @@ hppa_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, return true; case MULT: - if (GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT) + if (GET_MODE_CLASS (mode) == MODE_FLOAT) { *total = COSTS_N_INSNS (3); return true; } /* A mode size N times larger than SImode needs O(N*N) more insns. */ - factor = GET_MODE_SIZE (GET_MODE (x)) / 4; + factor = GET_MODE_SIZE (mode) / 4; if (factor == 0) factor = 1; @@ -1533,7 +1535,7 @@ hppa_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, return true; case DIV: - if (GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT) + if (GET_MODE_CLASS (mode) == MODE_FLOAT) { *total = COSTS_N_INSNS (14); return true; @@ -1544,7 +1546,7 @@ hppa_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, case MOD: case UMOD: /* A mode size N times larger than SImode needs O(N*N) more insns. */ - factor = GET_MODE_SIZE (GET_MODE (x)) / 4; + factor = GET_MODE_SIZE (mode) / 4; if (factor == 0) factor = 1; @@ -1553,7 +1555,7 @@ hppa_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, case PLUS: /* this includes shNadd insns */ case MINUS: - if (GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT) + if (GET_MODE_CLASS (mode) == MODE_FLOAT) { *total = COSTS_N_INSNS (3); return true; @@ -1561,7 +1563,7 @@ hppa_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, /* A size N times larger than UNITS_PER_WORD needs N times as many insns, taking N times as long. */ - factor = GET_MODE_SIZE (GET_MODE (x)) / UNITS_PER_WORD; + factor = GET_MODE_SIZE (mode) / UNITS_PER_WORD; if (factor == 0) factor = 1; *total = factor * COSTS_N_INSNS (1); diff --git a/gcc/config/pdp11/pdp11.c b/gcc/config/pdp11/pdp11.c index 2730400083d..cba2b35d03a 100644 --- a/gcc/config/pdp11/pdp11.c +++ b/gcc/config/pdp11/pdp11.c @@ -158,7 +158,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, int *, bool); +static bool pdp11_rtx_costs (rtx, machine_mode, 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 (machine_mode, const_rtx); @@ -910,10 +910,12 @@ pdp11_register_move_cost (machine_mode mode ATTRIBUTE_UNUSED, } static bool -pdp11_rtx_costs (rtx x, int code, int outer_code ATTRIBUTE_UNUSED, +pdp11_rtx_costs (rtx x, machine_mode mode, int outer_code ATTRIBUTE_UNUSED, int opno ATTRIBUTE_UNUSED, int *total, bool speed ATTRIBUTE_UNUSED) { + int code = GET_CODE (x); + switch (code) { case CONST_INT: @@ -972,9 +974,9 @@ pdp11_rtx_costs (rtx x, int code, int outer_code ATTRIBUTE_UNUSED, return false; case SIGN_EXTEND: - if (GET_MODE (x) == HImode) + if (mode == HImode) *total = COSTS_N_INSNS (1); - else if (GET_MODE (x) == SImode) + else if (mode == SImode) *total = COSTS_N_INSNS (6); else *total = COSTS_N_INSNS (2); @@ -985,14 +987,14 @@ pdp11_rtx_costs (rtx x, int code, int outer_code ATTRIBUTE_UNUSED, case ASHIFTRT: if (optimize_size) *total = COSTS_N_INSNS (1); - else if (GET_MODE (x) == QImode) + else if (mode == QImode) { if (GET_CODE (XEXP (x, 1)) != CONST_INT) *total = COSTS_N_INSNS (8); /* worst case */ else *total = COSTS_N_INSNS (INTVAL (XEXP (x, 1))); } - else if (GET_MODE (x) == HImode) + else if (mode == HImode) { if (GET_CODE (XEXP (x, 1)) == CONST_INT) { @@ -1004,7 +1006,7 @@ pdp11_rtx_costs (rtx x, int code, int outer_code ATTRIBUTE_UNUSED, else *total = COSTS_N_INSNS (10); /* worst case */ } - else if (GET_MODE (x) == SImode) + else if (mode == SImode) { if (GET_CODE (XEXP (x, 1)) == CONST_INT) *total = COSTS_N_INSNS (2.5 + 0.5 * INTVAL (XEXP (x, 1))); diff --git a/gcc/config/rl78/rl78.c b/gcc/config/rl78/rl78.c index efa4b0bdaa2..eb07ca3b6d9 100644 --- a/gcc/config/rl78/rl78.c +++ b/gcc/config/rl78/rl78.c @@ -4153,20 +4153,22 @@ rl78_return_in_memory (const_tree type, const_tree fntype ATTRIBUTE_UNUSED) #define TARGET_RTX_COSTS rl78_rtx_costs static bool -rl78_rtx_costs (rtx x, - int code, - int outer_code ATTRIBUTE_UNUSED, - int opno ATTRIBUTE_UNUSED, - int * total, - bool speed ATTRIBUTE_UNUSED) +rl78_rtx_costs (rtx x, + machine_mode mode, + int outer_code ATTRIBUTE_UNUSED, + int opno ATTRIBUTE_UNUSED, + int * total, + bool speed ATTRIBUTE_UNUSED) { + int code = GET_CODE (x); + if (code == IF_THEN_ELSE) { *total = COSTS_N_INSNS (10); return true; } - if (GET_MODE (x) == SImode) + if (mode == SImode) { switch (code) { diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c index c570d98e8c4..23fc6863eca 100644 --- a/gcc/config/rs6000/rs6000.c +++ b/gcc/config/rs6000/rs6000.c @@ -1108,7 +1108,7 @@ static tree rs6000_handle_struct_attribute (tree *, tree, tree, int, bool *); static tree rs6000_builtin_vectorized_libmass (tree, tree, tree); static void rs6000_emit_set_long_const (rtx, HOST_WIDE_INT); static int rs6000_memory_move_cost (machine_mode, reg_class_t, bool); -static bool rs6000_debug_rtx_costs (rtx, int, int, int, int *, bool); +static bool rs6000_debug_rtx_costs (rtx, machine_mode, int, int, int *, bool); static int rs6000_debug_address_cost (rtx, machine_mode, addr_space_t, bool); static int rs6000_debug_adjust_cost (rtx_insn *, rtx, rtx_insn *, int); @@ -30629,10 +30629,10 @@ rs6000_xcoff_encode_section_info (tree decl, rtx rtl, int first) scanned. In either case, *TOTAL contains the cost result. */ static bool -rs6000_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, - int *total, bool speed) +rs6000_rtx_costs (rtx x, machine_mode mode, int outer_code, + int opno ATTRIBUTE_UNUSED, int *total, bool speed) { - machine_mode mode = GET_MODE (x); + int code = GET_CODE (x); switch (code) { @@ -30953,16 +30953,16 @@ rs6000_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, /* 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 opno, int *total, - bool speed) +rs6000_debug_rtx_costs (rtx x, machine_mode mode, int outer_code, + int opno, int *total, bool speed) { - bool ret = rs6000_rtx_costs (x, code, outer_code, opno, total, speed); + bool ret = rs6000_rtx_costs (x, mode, outer_code, opno, total, speed); fprintf (stderr, - "\nrs6000_rtx_costs, return = %s, code = %s, outer_code = %s, " + "\nrs6000_rtx_costs, return = %s, mode = %s, outer_code = %s, " "opno = %d, total = %d, speed = %s, x:\n", ret ? "complete" : "scan inner", - GET_RTX_NAME (code), + GET_MODE_NAME (mode), GET_RTX_NAME (outer_code), opno, *total, diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c index 0bc490a6736..e9e9bc96835 100644 --- a/gcc/config/s390/s390.c +++ b/gcc/config/s390/s390.c @@ -3301,13 +3301,14 @@ s390_memory_move_cost (machine_mode mode ATTRIBUTE_UNUSED, /* Compute a (partial) cost for rtx X. Return true if the complete cost has been computed, and false if subexpressions should be scanned. In either case, *TOTAL contains the cost result. - CODE contains GET_CODE (x), OUTER_CODE contains the code - of the superexpression of x. */ + OUTER_CODE contains the code of the superexpression of x. */ static bool -s390_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, +s390_rtx_costs (rtx x, machine_mode mode, int outer_code, + int opno ATTRIBUTE_UNUSED, int *total, bool speed ATTRIBUTE_UNUSED) { + int code = GET_CODE (x); switch (code) { case CONST: @@ -3338,7 +3339,7 @@ s390_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, return false; case MULT: - switch (GET_MODE (x)) + switch (mode) { case SImode: { @@ -3397,7 +3398,7 @@ s390_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, return false; case FMA: - switch (GET_MODE (x)) + switch (mode) { case DFmode: *total = s390_cost->madbr; @@ -3411,18 +3412,18 @@ s390_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, /* Negate in the third argument is free: FMSUB. */ if (GET_CODE (XEXP (x, 2)) == NEG) { - *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)); + *total += (rtx_cost (XEXP (x, 0), mode, FMA, 0, speed) + + rtx_cost (XEXP (x, 1), mode, FMA, 1, speed) + + rtx_cost (XEXP (XEXP (x, 2), 0), mode, FMA, 2, speed)); return true; } return false; case UDIV: case UMOD: - if (GET_MODE (x) == TImode) /* 128 bit division */ + if (mode == TImode) /* 128 bit division */ *total = s390_cost->dlgr; - else if (GET_MODE (x) == DImode) + else if (mode == DImode) { rtx right = XEXP (x, 1); if (GET_CODE (right) == ZERO_EXTEND) /* 64 by 32 bit division */ @@ -3430,13 +3431,13 @@ s390_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, else /* 64 by 64 bit division */ *total = s390_cost->dlgr; } - else if (GET_MODE (x) == SImode) /* 32 bit division */ + else if (mode == SImode) /* 32 bit division */ *total = s390_cost->dlr; return false; case DIV: case MOD: - if (GET_MODE (x) == DImode) + if (mode == DImode) { rtx right = XEXP (x, 1); if (GET_CODE (right) == ZERO_EXTEND) /* 64 by 32 bit division */ @@ -3447,26 +3448,26 @@ s390_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, else /* 64 by 64 bit division */ *total = s390_cost->dsgr; } - else if (GET_MODE (x) == SImode) /* 32 bit division */ + else if (mode == SImode) /* 32 bit division */ *total = s390_cost->dlr; - else if (GET_MODE (x) == SFmode) + else if (mode == SFmode) { *total = s390_cost->debr; } - else if (GET_MODE (x) == DFmode) + else if (mode == DFmode) { *total = s390_cost->ddbr; } - else if (GET_MODE (x) == TFmode) + else if (mode == TFmode) { *total = s390_cost->dxbr; } return false; case SQRT: - if (GET_MODE (x) == SFmode) + if (mode == SFmode) *total = s390_cost->sqebr; - else if (GET_MODE (x) == DFmode) + else if (mode == DFmode) *total = s390_cost->sqdbr; else /* TFmode */ *total = s390_cost->sqxbr; diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c index 5f6558c75a0..71f3a5d7414 100644 --- a/gcc/config/sh/sh.c +++ b/gcc/config/sh/sh.c @@ -275,7 +275,7 @@ static int addsubcosts (rtx); static int multcosts (rtx); static bool unspec_caller_rtx_p (rtx); static bool sh_cannot_copy_insn_p (rtx_insn *); -static bool sh_rtx_costs (rtx, int, int, int, int *, bool); +static bool sh_rtx_costs (rtx, machine_mode, int, int, int *, bool); static int sh_address_cost (rtx, machine_mode, addr_space_t, bool); static int sh_pr_n_sets (void); static rtx sh_allocate_initial_value (rtx); @@ -3280,7 +3280,7 @@ and_xor_ior_costs (rtx x, int code) || satisfies_constraint_J16 (XEXP (x, 1))) return 1; else - return 1 + rtx_cost (XEXP (x, 1), AND, 1, !optimize_size); + return 1 + rtx_cost (XEXP (x, 1), GET_MODE (x), AND, 1, !optimize_size); } /* These constants are single cycle extu.[bw] instructions. */ @@ -3420,9 +3420,12 @@ multcosts (rtx x ATTRIBUTE_UNUSED) cost has been computed, and false if subexpressions should be scanned. In either case, *TOTAL contains the cost result. */ static bool -sh_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, +sh_rtx_costs (rtx x, machine_mode mode ATTRIBUTE_UNUSED, int outer_code, + int opno ATTRIBUTE_UNUSED, int *total, bool speed ATTRIBUTE_UNUSED) { + int code = GET_CODE (x); + switch (code) { /* The lower-subreg pass decides whether to split multi-word regs diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c index 42e12c2f9b6..0ea5102d9bf 100644 --- a/gcc/config/sparc/sparc.c +++ b/gcc/config/sparc/sparc.c @@ -588,7 +588,7 @@ static rtx sparc_tls_get_addr (void); static rtx sparc_tls_got (void); static int sparc_register_move_cost (machine_mode, reg_class_t, reg_class_t); -static bool sparc_rtx_costs (rtx, int, int, int, int *, bool); +static bool sparc_rtx_costs (rtx, machine_mode, int, int, int *, bool); static rtx sparc_function_value (const_tree, const_tree, bool); static rtx sparc_libcall_value (machine_mode, const_rtx); static bool sparc_function_value_regno_p (const unsigned int); @@ -10925,10 +10925,11 @@ 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 opno ATTRIBUTE_UNUSED, +sparc_rtx_costs (rtx x, machine_mode mode, int outer_code, + int opno ATTRIBUTE_UNUSED, int *total, bool speed ATTRIBUTE_UNUSED) { - machine_mode mode = GET_MODE (x); + int code = GET_CODE (x); bool float_mode_p = FLOAT_MODE_P (mode); switch (code) @@ -10952,7 +10953,7 @@ sparc_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, return true; case CONST_DOUBLE: - if (GET_MODE (x) == VOIDmode + if (mode == VOIDmode && ((CONST_DOUBLE_HIGH (x) == 0 && CONST_DOUBLE_LOW (x) < 0x1000) || (CONST_DOUBLE_HIGH (x) == -1 @@ -11004,12 +11005,12 @@ sparc_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, sub = XEXP (x, 0); if (GET_CODE (sub) == NEG) sub = XEXP (sub, 0); - *total += rtx_cost (sub, FMA, 0, speed); + *total += rtx_cost (sub, mode, FMA, 0, speed); sub = XEXP (x, 2); if (GET_CODE (sub) == NEG) sub = XEXP (sub, 0); - *total += rtx_cost (sub, FMA, 2, speed); + *total += rtx_cost (sub, mode, FMA, 2, speed); return true; } @@ -11128,7 +11129,7 @@ sparc_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, case IOR: /* Handle the NAND vector patterns. */ - if (sparc_vector_mode_supported_p (GET_MODE (x)) + if (sparc_vector_mode_supported_p (mode) && GET_CODE (XEXP (x, 0)) == NOT && GET_CODE (XEXP (x, 1)) == NOT) { diff --git a/gcc/config/spu/spu.c b/gcc/config/spu/spu.c index 5ff1083b70d..2470728e6f8 100644 --- a/gcc/config/spu/spu.c +++ b/gcc/config/spu/spu.c @@ -5235,11 +5235,11 @@ spu_asm_globalize_label (FILE * file, const char *name) } static bool -spu_rtx_costs (rtx x, int code, int outer_code ATTRIBUTE_UNUSED, +spu_rtx_costs (rtx x, machine_mode mode, int outer_code ATTRIBUTE_UNUSED, int opno ATTRIBUTE_UNUSED, int *total, bool speed ATTRIBUTE_UNUSED) { - machine_mode mode = GET_MODE (x); + int code = GET_CODE (x); int cost = COSTS_N_INSNS (2); /* Folding to a CONST_VECTOR will use extra space but there might diff --git a/gcc/config/stormy16/stormy16.c b/gcc/config/stormy16/stormy16.c index a491cb2700d..9d243f6f209 100644 --- a/gcc/config/stormy16/stormy16.c +++ b/gcc/config/stormy16/stormy16.c @@ -77,7 +77,6 @@ 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, machine_mode, int); -static bool xstormy16_rtx_costs (rtx, int, int, int, int *, bool); static int xstormy16_address_cost (rtx, machine_mode, addr_space_t, bool); static bool xstormy16_return_in_memory (const_tree, const_tree); @@ -88,10 +87,13 @@ static GTY(()) section *bss100_section; scanned. In either case, *TOTAL contains the cost result. */ static bool -xstormy16_rtx_costs (rtx x, int code, int outer_code ATTRIBUTE_UNUSED, +xstormy16_rtx_costs (rtx x, machine_mode mode ATTRIBUTE_UNUSED, + int outer_code ATTRIBUTE_UNUSED, int opno ATTRIBUTE_UNUSED, int *total, bool speed ATTRIBUTE_UNUSED) { + int code = GET_CODE (x); + switch (code) { case CONST_INT: diff --git a/gcc/config/tilegx/tilegx.c b/gcc/config/tilegx/tilegx.c index 68af9947985..8ceb41e4f50 100644 --- a/gcc/config/tilegx/tilegx.c +++ b/gcc/config/tilegx/tilegx.c @@ -551,9 +551,11 @@ tilegx_gimplify_va_arg_expr (tree valist, tree type, gimple_seq *pre_p, /* Implement TARGET_RTX_COSTS. */ static bool -tilegx_rtx_costs (rtx x, int code, int outer_code, int opno, int *total, - bool speed) +tilegx_rtx_costs (rtx x, machine_mode mode, int outer_code, int opno, + int *total, bool speed) { + int code = GET_CODE (x); + switch (code) { case CONST_INT: @@ -620,9 +622,9 @@ tilegx_rtx_costs (rtx x, int code, int outer_code, int opno, int *total, if (GET_CODE (XEXP (x, 0)) == MULT && cint_248_operand (XEXP (XEXP (x, 0), 1), VOIDmode)) { - *total = (rtx_cost (XEXP (XEXP (x, 0), 0), + *total = (rtx_cost (XEXP (XEXP (x, 0), 0), mode, (enum rtx_code) outer_code, opno, speed) - + rtx_cost (XEXP (x, 1), + + rtx_cost (XEXP (x, 1), mode, (enum rtx_code) outer_code, opno, speed) + COSTS_N_INSNS (1)); return true; diff --git a/gcc/config/tilepro/tilepro.c b/gcc/config/tilepro/tilepro.c index 29302a6d3a5..e68d075717a 100644 --- a/gcc/config/tilepro/tilepro.c +++ b/gcc/config/tilepro/tilepro.c @@ -493,9 +493,11 @@ tilepro_gimplify_va_arg_expr (tree valist, tree type, gimple_seq * pre_p, /* Implement TARGET_RTX_COSTS. */ static bool -tilepro_rtx_costs (rtx x, int code, int outer_code, int opno, int *total, - bool speed) +tilepro_rtx_costs (rtx x, machine_mode mode, int outer_code, int opno, + int *total, bool speed) { + int code = GET_CODE (x); + switch (code) { case CONST_INT: @@ -562,9 +564,9 @@ tilepro_rtx_costs (rtx x, int code, int outer_code, int opno, int *total, if (GET_CODE (XEXP (x, 0)) == MULT && cint_248_operand (XEXP (XEXP (x, 0), 1), VOIDmode)) { - *total = (rtx_cost (XEXP (XEXP (x, 0), 0), + *total = (rtx_cost (XEXP (XEXP (x, 0), 0), mode, (enum rtx_code) outer_code, opno, speed) - + rtx_cost (XEXP (x, 1), + + rtx_cost (XEXP (x, 1), mode, (enum rtx_code) outer_code, opno, speed) + COSTS_N_INSNS (1)); return true; diff --git a/gcc/config/v850/v850.c b/gcc/config/v850/v850.c index 3dcd8923635..77e0a5f8587 100644 --- a/gcc/config/v850/v850.c +++ b/gcc/config/v850/v850.c @@ -354,13 +354,10 @@ const_costs (rtx r, enum rtx_code c) } static bool -v850_rtx_costs (rtx x, - int codearg, - int outer_code ATTRIBUTE_UNUSED, - int opno ATTRIBUTE_UNUSED, - int * total, bool speed) +v850_rtx_costs (rtx x, machine_mode mode, int outer_code, + int opno ATTRIBUTE_UNUSED, int *total, bool speed) { - enum rtx_code code = (enum rtx_code) codearg; + enum rtx_code code = GET_CODE (x); switch (code) { @@ -384,9 +381,7 @@ v850_rtx_costs (rtx x, case MULT: if (TARGET_V850E - && ( GET_MODE (x) == SImode - || GET_MODE (x) == HImode - || GET_MODE (x) == QImode)) + && (mode == SImode || mode == HImode || mode == QImode)) { if (GET_CODE (XEXP (x, 1)) == REG) *total = 4; diff --git a/gcc/config/vax/vax.c b/gcc/config/vax/vax.c index 06f16191925..72dfa62a54b 100644 --- a/gcc/config/vax/vax.c +++ b/gcc/config/vax/vax.c @@ -67,7 +67,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, machine_mode, addr_space_t, bool); -static bool vax_rtx_costs (rtx, int, int, int, int *, bool); +static bool vax_rtx_costs (rtx, machine_mode, int, int, int *, bool); static rtx vax_function_arg (cumulative_args_t, machine_mode, const_tree, bool); static void vax_function_arg_advance (cumulative_args_t, machine_mode, @@ -767,10 +767,11 @@ vax_address_cost (rtx x, machine_mode mode ATTRIBUTE_UNUSED, costs on a per cpu basis. */ static bool -vax_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, +vax_rtx_costs (rtx x, machine_mode mode, int outer_code, + int opno ATTRIBUTE_UNUSED, int *total, bool speed ATTRIBUTE_UNUSED) { - machine_mode mode = GET_MODE (x); + int code = GET_CODE (x); int i = 0; /* may be modified in switch */ const char *fmt = GET_RTX_FORMAT (code); /* may be modified in switch */ @@ -810,7 +811,7 @@ vax_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, return true; case CONST_DOUBLE: - if (GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT) + if (GET_MODE_CLASS (mode) == MODE_FLOAT) *total = vax_float_literal (x) ? 5 : 8; else *total = ((CONST_DOUBLE_HIGH (x) == 0 @@ -998,7 +999,7 @@ vax_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, { case CONST_INT: if ((unsigned HOST_WIDE_INT)INTVAL (op) > 63 - && GET_MODE (x) != QImode) + && mode != QImode) *total += 1; /* 2 on VAX 2 */ break; case CONST: diff --git a/gcc/config/visium/visium.c b/gcc/config/visium/visium.c index 29d52fa830e..da48d10e056 100644 --- a/gcc/config/visium/visium.c +++ b/gcc/config/visium/visium.c @@ -186,7 +186,7 @@ static int visium_register_move_cost (enum machine_mode, reg_class_t, static int visium_memory_move_cost (enum machine_mode, reg_class_t, bool); -static bool visium_rtx_costs (rtx, int, int, int, int *, bool); +static bool visium_rtx_costs (rtx, machine_mode, int, int, int *, bool); static void visium_option_override (void); @@ -1883,11 +1883,11 @@ visium_memory_move_cost (enum machine_mode mode, /* Return the relative costs of expression X. */ static bool -visium_rtx_costs (rtx x, int code, int outer_code ATTRIBUTE_UNUSED, +visium_rtx_costs (rtx x, machine_mode mode, int outer_code ATTRIBUTE_UNUSED, int opno ATTRIBUTE_UNUSED, int *total, bool speed ATTRIBUTE_UNUSED) { - enum machine_mode mode = GET_MODE (x); + int code = GET_CODE (x); switch (code) { diff --git a/gcc/config/xtensa/xtensa.c b/gcc/config/xtensa/xtensa.c index 0cb100eb87e..efcc2fbbba5 100644 --- a/gcc/config/xtensa/xtensa.c +++ b/gcc/config/xtensa/xtensa.c @@ -142,7 +142,7 @@ static unsigned int xtensa_multibss_section_type_flags (tree, const char *, int) ATTRIBUTE_UNUSED; static section *xtensa_select_rtx_section (machine_mode, rtx, unsigned HOST_WIDE_INT); -static bool xtensa_rtx_costs (rtx, int, int, int, int *, bool); +static bool xtensa_rtx_costs (rtx, machine_mode, int, int, int *, bool); static int xtensa_register_move_cost (machine_mode, reg_class_t, reg_class_t); static int xtensa_memory_move_cost (machine_mode, reg_class_t, bool); @@ -3566,9 +3566,12 @@ xtensa_memory_move_cost (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 opno ATTRIBUTE_UNUSED, +xtensa_rtx_costs (rtx x, machine_mode mode, int outer_code, + int opno ATTRIBUTE_UNUSED, int *total, bool speed ATTRIBUTE_UNUSED) { + int code = GET_CODE (x); + switch (code) { case CONST_INT: @@ -3638,9 +3641,9 @@ xtensa_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, case MEM: { int num_words = - (GET_MODE_SIZE (GET_MODE (x)) > UNITS_PER_WORD) ? 2 : 1; + (GET_MODE_SIZE (mode) > UNITS_PER_WORD) ? 2 : 1; - if (memory_address_p (GET_MODE (x), XEXP ((x), 0))) + if (memory_address_p (mode, XEXP ((x), 0))) *total = COSTS_N_INSNS (num_words); else *total = COSTS_N_INSNS (2*num_words); @@ -3657,13 +3660,13 @@ xtensa_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, return true; case NOT: - *total = COSTS_N_INSNS ((GET_MODE (x) == DImode) ? 3 : 2); + *total = COSTS_N_INSNS (mode == DImode ? 3 : 2); return true; case AND: case IOR: case XOR: - if (GET_MODE (x) == DImode) + if (mode == DImode) *total = COSTS_N_INSNS (2); else *total = COSTS_N_INSNS (1); @@ -3672,7 +3675,7 @@ xtensa_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, case ASHIFT: case ASHIFTRT: case LSHIFTRT: - if (GET_MODE (x) == DImode) + if (mode == DImode) *total = COSTS_N_INSNS (50); else *total = COSTS_N_INSNS (1); @@ -3680,10 +3683,9 @@ xtensa_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, case ABS: { - machine_mode xmode = GET_MODE (x); - if (xmode == SFmode) + if (mode == SFmode) *total = COSTS_N_INSNS (TARGET_HARD_FLOAT ? 1 : 50); - else if (xmode == DFmode) + else if (mode == DFmode) *total = COSTS_N_INSNS (50); else *total = COSTS_N_INSNS (4); @@ -3693,10 +3695,9 @@ xtensa_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, case PLUS: case MINUS: { - machine_mode xmode = GET_MODE (x); - if (xmode == SFmode) + if (mode == SFmode) *total = COSTS_N_INSNS (TARGET_HARD_FLOAT ? 1 : 50); - else if (xmode == DFmode || xmode == DImode) + else if (mode == DFmode || mode == DImode) *total = COSTS_N_INSNS (50); else *total = COSTS_N_INSNS (1); @@ -3704,17 +3705,16 @@ xtensa_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, } case NEG: - *total = COSTS_N_INSNS ((GET_MODE (x) == DImode) ? 4 : 2); + *total = COSTS_N_INSNS (mode == DImode ? 4 : 2); return true; case MULT: { - machine_mode xmode = GET_MODE (x); - if (xmode == SFmode) + if (mode == SFmode) *total = COSTS_N_INSNS (TARGET_HARD_FLOAT ? 4 : 50); - else if (xmode == DFmode) + else if (mode == DFmode) *total = COSTS_N_INSNS (50); - else if (xmode == DImode) + else if (mode == DImode) *total = COSTS_N_INSNS (TARGET_MUL32_HIGH ? 10 : 50); else if (TARGET_MUL32) *total = COSTS_N_INSNS (4); @@ -3730,13 +3730,12 @@ xtensa_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, case DIV: case MOD: { - machine_mode xmode = GET_MODE (x); - if (xmode == SFmode) + if (mode == SFmode) { *total = COSTS_N_INSNS (TARGET_HARD_FLOAT_DIV ? 8 : 50); return true; } - else if (xmode == DFmode) + else if (mode == DFmode) { *total = COSTS_N_INSNS (50); return true; @@ -3747,8 +3746,7 @@ xtensa_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, case UDIV: case UMOD: { - machine_mode xmode = GET_MODE (x); - if (xmode == DImode) + if (mode == DImode) *total = COSTS_N_INSNS (50); else if (TARGET_DIV32) *total = COSTS_N_INSNS (32); @@ -3758,7 +3756,7 @@ xtensa_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, } case SQRT: - if (GET_MODE (x) == SFmode) + if (mode == SFmode) *total = COSTS_N_INSNS (TARGET_HARD_FLOAT_SQRT ? 8 : 50); else *total = COSTS_N_INSNS (50); |