summaryrefslogtreecommitdiff
path: root/gcc/expmed.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/expmed.c')
-rw-r--r--gcc/expmed.c52
1 files changed, 29 insertions, 23 deletions
diff --git a/gcc/expmed.c b/gcc/expmed.c
index 6fb5807f6e9..b865382e0c3 100644
--- a/gcc/expmed.c
+++ b/gcc/expmed.c
@@ -145,7 +145,8 @@ init_expmed_one_conv (struct init_expmed_rtl *all, machine_mode to_mode,
which = (to_size < from_size ? all->trunc : all->zext);
PUT_MODE (all->reg, from_mode);
- set_convert_cost (to_mode, from_mode, speed, set_src_cost (which, speed));
+ set_convert_cost (to_mode, from_mode, speed,
+ set_src_cost (which, to_mode, speed));
}
static void
@@ -174,15 +175,15 @@ init_expmed_one_mode (struct init_expmed_rtl *all,
PUT_MODE (all->zext, mode);
PUT_MODE (all->trunc, mode);
- set_add_cost (speed, mode, set_src_cost (all->plus, speed));
- set_neg_cost (speed, mode, set_src_cost (all->neg, speed));
- set_mul_cost (speed, mode, set_src_cost (all->mult, speed));
- set_sdiv_cost (speed, mode, set_src_cost (all->sdiv, speed));
- set_udiv_cost (speed, mode, set_src_cost (all->udiv, speed));
+ set_add_cost (speed, mode, set_src_cost (all->plus, mode, speed));
+ set_neg_cost (speed, mode, set_src_cost (all->neg, mode, speed));
+ set_mul_cost (speed, mode, set_src_cost (all->mult, mode, speed));
+ set_sdiv_cost (speed, mode, set_src_cost (all->sdiv, mode, speed));
+ set_udiv_cost (speed, mode, set_src_cost (all->udiv, mode, speed));
- set_sdiv_pow2_cheap (speed, mode, (set_src_cost (all->sdiv_32, speed)
+ set_sdiv_pow2_cheap (speed, mode, (set_src_cost (all->sdiv_32, mode, speed)
<= 2 * add_cost (speed, mode)));
- set_smod_pow2_cheap (speed, mode, (set_src_cost (all->smod_32, speed)
+ set_smod_pow2_cheap (speed, mode, (set_src_cost (all->smod_32, mode, speed)
<= 4 * add_cost (speed, mode)));
set_shift_cost (speed, mode, 0, 0);
@@ -199,10 +200,13 @@ init_expmed_one_mode (struct init_expmed_rtl *all,
XEXP (all->shift, 1) = all->cint[m];
XEXP (all->shift_mult, 1) = all->pow2[m];
- set_shift_cost (speed, mode, m, set_src_cost (all->shift, speed));
- set_shiftadd_cost (speed, mode, m, set_src_cost (all->shift_add, speed));
- set_shiftsub0_cost (speed, mode, m, set_src_cost (all->shift_sub0, speed));
- set_shiftsub1_cost (speed, mode, m, set_src_cost (all->shift_sub1, speed));
+ set_shift_cost (speed, mode, m, set_src_cost (all->shift, mode, speed));
+ set_shiftadd_cost (speed, mode, m, set_src_cost (all->shift_add, mode,
+ speed));
+ set_shiftsub0_cost (speed, mode, m, set_src_cost (all->shift_sub0, mode,
+ speed));
+ set_shiftsub1_cost (speed, mode, m, set_src_cost (all->shift_sub1, mode,
+ speed));
}
if (SCALAR_INT_MODE_P (mode))
@@ -222,9 +226,9 @@ init_expmed_one_mode (struct init_expmed_rtl *all,
XEXP (all->wide_lshr, 1) = GEN_INT (mode_bitsize);
set_mul_widen_cost (speed, wider_mode,
- set_src_cost (all->wide_mult, speed));
+ set_src_cost (all->wide_mult, wider_mode, speed));
set_mul_highpart_cost (speed, mode,
- set_src_cost (all->wide_trunc, speed));
+ set_src_cost (all->wide_trunc, mode, speed));
}
}
}
@@ -266,7 +270,7 @@ init_expmed (void)
for (speed = 0; speed < 2; speed++)
{
crtl->maybe_hot_insn_p = speed;
- set_zero_cost (speed, set_src_cost (const0_rtx, speed));
+ set_zero_cost (speed, set_src_cost (const0_rtx, mode, speed));
for (mode = MIN_MODE_INT; mode <= MAX_MODE_INT;
mode = (machine_mode)(mode + 1))
@@ -3207,7 +3211,8 @@ expand_mult (machine_mode mode, rtx op0, rtx op1, rtx target,
Exclude cost of op0 from max_cost to match the cost
calculation of the synth_mult. */
coeff = -(unsigned HOST_WIDE_INT) coeff;
- max_cost = (set_src_cost (gen_rtx_MULT (mode, fake_reg, op1), speed)
+ max_cost = (set_src_cost (gen_rtx_MULT (mode, fake_reg, op1),
+ mode, speed)
- neg_cost (speed, mode));
if (max_cost <= 0)
goto skip_synth;
@@ -3232,7 +3237,7 @@ expand_mult (machine_mode mode, rtx op0, rtx op1, rtx target,
/* Exclude cost of op0 from max_cost to match the cost
calculation of the synth_mult. */
- max_cost = set_src_cost (gen_rtx_MULT (mode, fake_reg, op1), speed);
+ max_cost = set_src_cost (gen_rtx_MULT (mode, fake_reg, op1), mode, speed);
if (choose_mult_variant (mode, coeff, &algorithm, &variant, max_cost))
return expand_mult_const (mode, op0, coeff, target,
&algorithm, variant);
@@ -3273,7 +3278,8 @@ mult_by_coeff_cost (HOST_WIDE_INT coeff, machine_mode mode, bool speed)
enum mult_variant variant;
rtx fake_reg = gen_raw_REG (mode, LAST_VIRTUAL_REGISTER + 1);
- max_cost = set_src_cost (gen_rtx_MULT (mode, fake_reg, fake_reg), speed);
+ max_cost = set_src_cost (gen_rtx_MULT (mode, fake_reg, fake_reg),
+ mode, speed);
if (choose_mult_variant (mode, coeff, &algorithm, &variant, max_cost))
return algorithm.cost.cost;
else
@@ -3699,7 +3705,7 @@ expand_smod_pow2 (machine_mode mode, rtx op0, HOST_WIDE_INT d)
temp = gen_rtx_LSHIFTRT (mode, result, shift);
if (optab_handler (lshr_optab, mode) == CODE_FOR_nothing
- || (set_src_cost (temp, optimize_insn_for_speed_p ())
+ || (set_src_cost (temp, mode, optimize_insn_for_speed_p ())
> COSTS_N_INSNS (2)))
{
temp = expand_binop (mode, xor_optab, op0, signmask,
@@ -5503,7 +5509,7 @@ emit_store_flag (rtx target, enum rtx_code code, rtx op0, rtx op1,
/* For the reverse comparison, use either an addition or a XOR. */
if (want_add
- && rtx_cost (GEN_INT (normalizep), PLUS, 1,
+ && rtx_cost (GEN_INT (normalizep), mode, PLUS, 1,
optimize_insn_for_speed_p ()) == 0)
{
tem = emit_store_flag_1 (subtarget, rcode, op0, op1, mode, 0,
@@ -5514,7 +5520,7 @@ emit_store_flag (rtx target, enum rtx_code code, rtx op0, rtx op1,
target, 0, OPTAB_WIDEN);
}
else if (!want_add
- && rtx_cost (trueval, XOR, 1,
+ && rtx_cost (trueval, mode, XOR, 1,
optimize_insn_for_speed_p ()) == 0)
{
tem = emit_store_flag_1 (subtarget, rcode, op0, op1, mode, 0,
@@ -5606,7 +5612,7 @@ emit_store_flag (rtx target, enum rtx_code code, rtx op0, rtx op1,
/* Again, for the reverse comparison, use either an addition or a XOR. */
if (want_add
- && rtx_cost (GEN_INT (normalizep), PLUS, 1,
+ && rtx_cost (GEN_INT (normalizep), mode, PLUS, 1,
optimize_insn_for_speed_p ()) == 0)
{
tem = emit_store_flag_1 (subtarget, rcode, op0, op1, mode, 0,
@@ -5617,7 +5623,7 @@ emit_store_flag (rtx target, enum rtx_code code, rtx op0, rtx op1,
target, 0, OPTAB_WIDEN);
}
else if (!want_add
- && rtx_cost (trueval, XOR, 1,
+ && rtx_cost (trueval, mode, XOR, 1,
optimize_insn_for_speed_p ()) == 0)
{
tem = emit_store_flag_1 (subtarget, rcode, op0, op1, mode, 0,