+2017-10-09 Segher Boessenkool <segher@kernel.crashing.org>
+
+ * cfgrtl.c (rtl_account_profile_record): Replace insn_rtx_cost with
+ insn_cost.
+ * combine.c (uid_insn_cost): Adjust comment.
+ (combine_validate_cost): Adjust comment. Use pattern_cost instead
+ of insn_rtx_cost
+ (combine_instructions): Use insn_cost instead of insn_rtx_cost.
+ * dse.c (find_shift_sequence): Ditto.
+ * ifcvt.c (cheap_bb_rtx_cost_p): Ditto.
+ (bb_valid_for_noce_process_p): Use pattern_cost.
+ * rtl.h (insn_rtx_cost): Delete.
+ (pattern_cost): New prototype.
+ (insn_cost): New prototype.
+ * rtlanal.c (insn_rtx_cost): Rename to...
+ (pattern_cost): ... this.
+ (insn_cost): New.
+
2017-10-09 Uros Bizjak <ubizjak@gmail.com>
* config/i386/i386.md (*jcc_2): Remove insn pattern.
FOR_BB_INSNS (bb, insn)
if (INSN_P (insn))
{
- record->size[after_pass]
- += insn_rtx_cost (PATTERN (insn), false);
+ record->size[after_pass] += insn_cost (insn, false);
if (bb->count.initialized_p ())
record->time[after_pass]
- += insn_rtx_cost (PATTERN (insn), true) * bb->count.to_gcov_type ();
+ += insn_cost (insn, true) * bb->count.to_gcov_type ();
else if (profile_status_for_fn (cfun) == PROFILE_GUESSED)
record->time[after_pass]
- += insn_rtx_cost (PATTERN (insn), true) * bb->frequency;
+ += insn_cost (insn, true) * bb->frequency;
}
}
static int max_uid_known;
-/* The following array records the insn_rtx_cost for every insn
+/* The following array records the insn_cost for every insn
in the instruction stream. */
static int *uid_insn_cost;
#define SUBST_LINK(oldval, newval) do_SUBST_LINK (&oldval, newval)
\f
/* Subroutine of try_combine. Determine whether the replacement patterns
- NEWPAT, NEWI2PAT and NEWOTHERPAT are cheaper according to insn_rtx_cost
+ NEWPAT, NEWI2PAT and NEWOTHERPAT are cheaper according to insn_cost
than the original sequence I0, I1, I2, I3 and undobuf.other_insn. Note
that I0, I1 and/or NEWI2PAT may be NULL_RTX. Similarly, NEWOTHERPAT and
undobuf.other_insn may also both be NULL_RTX. Return false if the cost
old_cost -= i1_cost;
- /* Calculate the replacement insn_rtx_costs. */
- new_i3_cost = insn_rtx_cost (newpat, optimize_this_for_speed_p);
+ /* Calculate the replacement pattern_costs. */
+ new_i3_cost = pattern_cost (newpat, optimize_this_for_speed_p);
if (newi2pat)
{
- new_i2_cost = insn_rtx_cost (newi2pat, optimize_this_for_speed_p);
+ new_i2_cost = pattern_cost (newi2pat, optimize_this_for_speed_p);
new_cost = (new_i2_cost > 0 && new_i3_cost > 0)
? new_i2_cost + new_i3_cost : 0;
}
int old_other_cost, new_other_cost;
old_other_cost = INSN_COST (undobuf.other_insn);
- new_other_cost = insn_rtx_cost (newotherpat, optimize_this_for_speed_p);
+ new_other_cost = pattern_cost (newotherpat, optimize_this_for_speed_p);
if (old_other_cost > 0 && new_other_cost > 0)
{
old_cost += old_other_cost;
set_nonzero_bits_and_sign_copies (XEXP (links, 0), NULL_RTX,
insn);
- /* Record the current insn_rtx_cost of this instruction. */
+ /* Record the current insn_cost of this instruction. */
if (NONJUMP_INSN_P (insn))
- INSN_COST (insn) = insn_rtx_cost (PATTERN (insn),
- optimize_this_for_speed_p);
+ INSN_COST (insn) = insn_cost (insn, optimize_this_for_speed_p);
if (dump_file)
{
fprintf (dump_file, "insn_cost %d for ", INSN_COST (insn));
cost = 0;
for (insn = shift_seq; insn != NULL_RTX; insn = NEXT_INSN (insn))
if (INSN_P (insn))
- cost += insn_rtx_cost (PATTERN (insn), speed);
+ cost += insn_cost (insn, speed);
/* The computation up to here is essentially independent
of the arguments and could be precomputed. It may
return count;
}
-/* Determine whether the total insn_rtx_cost on non-jump insns in
+/* Determine whether the total insn_cost on non-jump insns in
basic block BB is less than MAX_COST. This function returns
false if the cost of any instruction could not be estimated.
: REG_BR_PROB_BASE;
/* Set scale to REG_BR_PROB_BASE to void the identical scaling
- applied to insn_rtx_cost when optimizing for size. Only do
+ applied to insn_cost when optimizing for size. Only do
this after combine because if-conversion might interfere with
passes before combine.
{
if (NONJUMP_INSN_P (insn))
{
- int cost = insn_rtx_cost (PATTERN (insn), speed) * REG_BR_PROB_BASE;
+ int cost = insn_cost (insn, speed) * REG_BR_PROB_BASE;
if (cost == 0)
return false;
if (first_insn == last_insn)
{
*simple_p = noce_operand_ok (SET_DEST (first_set));
- *cost += insn_rtx_cost (first_set, speed_p);
+ *cost += pattern_cost (first_set, speed_p);
return *simple_p;
}
/* The regs that are live out of test_bb. */
bitmap test_bb_live_out = df_get_live_out (test_bb);
- int potential_cost = insn_rtx_cost (last_set, speed_p);
+ int potential_cost = pattern_cost (last_set, speed_p);
rtx_insn *insn;
FOR_BB_INSNS (test_bb, insn)
{
|| reg_overlap_mentioned_p (SET_DEST (sset), cond))
goto free_bitmap_and_fail;
- potential_cost += insn_rtx_cost (sset, speed_p);
+ potential_cost += pattern_cost (sset, speed_p);
bitmap_set_bit (test_bb_temps, REGNO (SET_DEST (sset)));
}
}
extern rtx_insn *find_first_parameter_load (rtx_insn *, rtx_insn *);
extern bool keep_with_call_p (const rtx_insn *);
extern bool label_is_jump_target_p (const_rtx, const rtx_insn *);
-extern int insn_rtx_cost (rtx, bool);
+extern int pattern_cost (rtx, bool);
+extern int insn_cost (rtx_insn *, bool);
extern unsigned seq_cost (const rtx_insn *, bool);
/* Given an insn and condition, return a canonical description of
? 1 : bitwidth - floor_log2 (nonzero) - 1;
}
-/* Calculate the rtx_cost of a single instruction. A return value of
+/* Calculate the rtx_cost of a single instruction pattern. A return value of
zero indicates an instruction pattern without a known cost. */
int
-insn_rtx_cost (rtx pat, bool speed)
+pattern_cost (rtx pat, bool speed)
{
int i, cost;
rtx set;
return cost > 0 ? cost : COSTS_N_INSNS (1);
}
+/* Calculate the cost of a single instruction. A return value of zero
+ indicates an instruction pattern without a known cost. */
+
+int
+insn_cost (rtx_insn *insn, bool speed)
+{
+ return pattern_cost (PATTERN (insn), speed);
+}
+
/* Returns estimate on cost of computing SEQ. */
unsigned