diff options
Diffstat (limited to 'gcc/rtl-ssa')
-rw-r--r-- | gcc/rtl-ssa/changes.cc | 26 | ||||
-rw-r--r-- | gcc/rtl-ssa/insns.cc | 3 |
2 files changed, 18 insertions, 11 deletions
diff --git a/gcc/rtl-ssa/changes.cc b/gcc/rtl-ssa/changes.cc index f2be119..5f3a0f0 100644 --- a/gcc/rtl-ssa/changes.cc +++ b/gcc/rtl-ssa/changes.cc @@ -173,21 +173,29 @@ rtl_ssa::changes_are_worthwhile (array_slice<insn_change *const> changes, bool strict_p) { unsigned int old_cost = 0; - unsigned int new_cost = 0; sreal weighted_old_cost = 0; - sreal weighted_new_cost = 0; auto entry_count = ENTRY_BLOCK_PTR_FOR_FN (cfun)->count; + { + undo_recog_changes undo (0); + for (insn_change *change : changes) + { + // Count zero for the old cost if the old instruction was a no-op + // move or had an unknown cost. This should reduce the chances of + // making an unprofitable change. + old_cost += change->old_cost (); + basic_block cfg_bb = change->bb ()->cfg_bb (); + if (optimize_bb_for_speed_p (cfg_bb)) + weighted_old_cost += (cfg_bb->count.to_sreal_scale (entry_count) + * change->old_cost ()); + + } + } + unsigned int new_cost = 0; + sreal weighted_new_cost = 0; for (insn_change *change : changes) { - // Count zero for the old cost if the old instruction was a no-op - // move or had an unknown cost. This should reduce the chances of - // making an unprofitable change. - old_cost += change->old_cost (); basic_block cfg_bb = change->bb ()->cfg_bb (); bool for_speed = optimize_bb_for_speed_p (cfg_bb); - if (for_speed) - weighted_old_cost += (cfg_bb->count.to_sreal_scale (entry_count) - * change->old_cost ()); if (!change->is_deletion () && INSN_CODE (change->rtl ()) != NOOP_MOVE_INSN_CODE) { diff --git a/gcc/rtl-ssa/insns.cc b/gcc/rtl-ssa/insns.cc index bfc6683..4af79be 100644 --- a/gcc/rtl-ssa/insns.cc +++ b/gcc/rtl-ssa/insns.cc @@ -49,14 +49,13 @@ void insn_info::calculate_cost () const { basic_block cfg_bb = BLOCK_FOR_INSN (m_rtl); - temporarily_undo_changes (0); + undo_recog_changes (0); if (INSN_CODE (m_rtl) == NOOP_MOVE_INSN_CODE) // insn_cost also uses 0 to mean "don't know". Callers that // want to distinguish the cases will need to check INSN_CODE. m_cost_or_uid = 0; else m_cost_or_uid = insn_cost (m_rtl, optimize_bb_for_speed_p (cfg_bb)); - redo_changes (0); } // Add NOTE to the instruction's notes. |