diff --git a/gcc/calls.c b/gcc/calls.c index 345331f..a34da07 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -813,11 +813,26 @@ call_expr_flags (const_tree t) Set REG_PARM_SEEN if we encounter a register parameter. */ +/* RTXes used while computing costs. */ +struct cost_rtxes { + /* Source and target registers. */ + rtx source; + rtx target; + /* A SET of TARGET. */ + rtx set; +}; + + static void precompute_register_parameters (int num_actuals, struct arg_data *args, int *reg_parm_seen) { int i; + static struct cost_rtxes cost_rtx; + + cost_rtx.target = gen_rtx_REG (word_mode, FIRST_PSEUDO_REGISTER); + cost_rtx.source = gen_rtx_REG (word_mode, FIRST_PSEUDO_REGISTER + 1); + cost_rtx.set = gen_rtx_SET (VOIDmode, cost_rtx.target, cost_rtx.source); *reg_parm_seen = 0; @@ -825,6 +840,8 @@ precompute_register_parameters (int num_actuals, struct arg_data *args, if (args[i].reg != 0 && ! args[i].pass_on_stack) { *reg_parm_seen = 1; + PUT_MODE (cost_rtx.target, args[i].mode); + PUT_MODE (cost_rtx.source, args[i].mode); if (args[i].value == 0) { @@ -872,8 +889,13 @@ precompute_register_parameters (int num_actuals, struct arg_data *args, || (GET_CODE (args[i].value) == SUBREG && REG_P (SUBREG_REG (args[i].value))))) && args[i].mode != BLKmode - && set_src_cost (args[i].value, optimize_insn_for_speed_p ()) - > COSTS_N_INSNS (1) + && (args[i].mode != VOIDmode + && optimize + && CONSTANT_P (args[i].value) + && (set_src_cost (args[i].value, + optimize_insn_for_speed_p ()) + > set_src_cost (cost_rtx.set, + optimize_insn_for_speed_p ()))) && ((*reg_parm_seen && targetm.small_register_classes_for_mode_p (args[i].mode)) || optimize)) diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index 4e0cba8..91ece7b 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -5083,6 +5083,7 @@ aarch64_rtx_costs (rtx x, int code, int outer ATTRIBUTE_UNUSED, int n_minus_1 = (GET_MODE_SIZE (GET_MODE (op0)) - 1) / UNITS_PER_WORD; *cost = COSTS_N_INSNS (n_minus_1 + 1); + *cost = COSTS_N_INSNS (3); } else /* Cost is just the cost of the RHS of the set. */