diff options
author | tejohnson <tejohnson@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-04-08 17:39:10 +0000 |
---|---|---|
committer | tejohnson <tejohnson@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-04-08 17:39:10 +0000 |
commit | f9d4b7f4943df04e4362f7cde1fb6c6de22283ef (patch) | |
tree | ffb943825496db918422c6ebe357dcdcc5207a4b /gcc/cfgloopmanip.c | |
parent | 3f4737cd41c1ae5451f9bd34414d33b3214d6dec (diff) | |
download | gcc-f9d4b7f4943df04e4362f7cde1fb6c6de22283ef.tar.gz |
First phase of unifying the computation of profile scale factors/probabilities
and the actual scaling to use rounding divides:
- Add new macro GCOV_COMPUTE_SCALE to basic-block.h to compute the scale
factor/probability via a rounding divide.
- Change all locations that already perform rounding divides (inline or via RDIV)
to use the appropriate helper: GCOV_COMPUTE_SCALE, apply_probability or
combine_probabilities.
- Change ipa-cp.c truncating divides to use rounding divides.
- Add comments to all other locations (currently using truncating divides) to
switch them to one of the helpers so they use a rounding divide.
Next phase will be to replace the locations using truncating divides, marked
with a comment here, into rounding divides via the helper methods.
2013-04-08 Teresa Johnson <tejohnson@google.com>
* basic-block.h (GCOV_COMPUTE_SCALE): Define.
* ipa-inline-analysis.c (param_change_prob): Use helper rounding divide
methods.
(estimate_edge_size_and_time): Add comment to suggest using rounding
methods.
(estimate_node_size_and_time): Ditto.
(remap_edge_change_prob): Use helper rounding divide methods.
* value-prof.c (gimple_divmod_fixed_value_transform): Ditto.
(gimple_mod_pow2_value_transform): Ditto.
(gimple_mod_subtract_transform): Ditto.
(gimple_ic_transform): Ditto.
(gimple_stringops_transform): Ditto.
* stmt.c (conditional_probability): Ditto.
(emit_case_dispatch_table): Ditto.
* lto-cgraph.c (merge_profile_summaries): Ditto.
* tree-optimize.c (execute_fixup_cfg): Ditto.
* cfgcleanup.c (try_forward_edges): Ditto.
* cfgloopmanip.c (scale_loop_profile): Ditto.
(loopify): Ditto.
(duplicate_loop_to_header_edge): Ditto.
(lv_adjust_loop_entry_edge): Ditto.
* tree-vect-loop.c (vect_transform_loop): Ditto.
* profile.c (compute_branch_probabilities): Ditto.
* cfgbuild.c (compute_outgoing_frequencies): Ditto.
* lto-streamer-in.c (input_cfg): Ditto.
* gimple-streamer-in.c (input_bb): Ditto.
* ipa-cp.c (update_profiling_info): Ditto.
(update_specialized_profile): Ditto.
* tree-vect-loop-manip.c (slpeel_tree_peel_loop_to_edge): Ditto.
* cfg.c (update_bb_profile_for_threading): Add comment to suggest using
rounding methods.
* sched-rgn.c (compute_dom_prob_ps): Ditto.
(compute_trg_info): Ditto.
* cfgrtl.c (force_nonfallthru_and_redirect): Ditto.
(purge_dead_edges): Ditto.
* loop-unswitch.c (unswitch_loop): Ditto.
* cgraphclones.c (cgraph_clone_edge): Ditto.
(cgraph_clone_node): Ditto.
* tree-inline.c (copy_bb): Ditto.
(copy_edges_for_bb): Ditto.
(initialize_cfun): Ditto.
(copy_cfg_body): Ditto.
(expand_call_inline): Ditto.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@197595 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cfgloopmanip.c')
-rw-r--r-- | gcc/cfgloopmanip.c | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/gcc/cfgloopmanip.c b/gcc/cfgloopmanip.c index 3e53aa0dddf..13efb7515f9 100644 --- a/gcc/cfgloopmanip.c +++ b/gcc/cfgloopmanip.c @@ -502,7 +502,7 @@ scale_loop_profile (struct loop *loop, int scale, gcov_type iteration_bound) /* See if loop is predicted to iterate too many times. */ if (iteration_bound && iterations > 0 - && RDIV (iterations * scale, REG_BR_PROB_BASE) > iteration_bound) + && apply_probability (iterations, scale) > iteration_bound) { /* Fixing loop profile for different trip count is not trivial; the exit probabilities has to be updated to match and frequencies propagated down @@ -563,7 +563,8 @@ scale_loop_profile (struct loop *loop, int scale, gcov_type iteration_bound) count_in += e->count; if (count_in != 0) - scale = RDIV (count_in * iteration_bound * REG_BR_PROB_BASE, loop->header->count); + scale = GCOV_COMPUTE_SCALE (count_in * iteration_bound, + loop->header->count); } else if (loop->header->frequency) { @@ -574,7 +575,8 @@ scale_loop_profile (struct loop *loop, int scale, gcov_type iteration_bound) freq_in += EDGE_FREQUENCY (e); if (freq_in != 0) - scale = RDIV (freq_in * iteration_bound * REG_BR_PROB_BASE, loop->header->frequency); + scale = GCOV_COMPUTE_SCALE (freq_in * iteration_bound, + loop->header->frequency); } if (!scale) scale = 1; @@ -890,7 +892,7 @@ loopify (edge latch_edge, edge header_edge, switch_bb->count = cnt; FOR_EACH_EDGE (e, ei, switch_bb->succs) { - e->count = RDIV (switch_bb->count * e->probability, REG_BR_PROB_BASE); + e->count = apply_probability (switch_bb->count, e->probability); } } scale_loop_frequencies (loop, false_scale, REG_BR_PROB_BASE); @@ -1199,8 +1201,9 @@ duplicate_loop_to_header_edge (struct loop *loop, edge e, { /* The blocks that are dominated by a removed exit edge ORIG have frequencies scaled by this. */ - scale_after_exit = RDIV (REG_BR_PROB_BASE * REG_BR_PROB_BASE, - REG_BR_PROB_BASE - orig->probability); + scale_after_exit + = GCOV_COMPUTE_SCALE (REG_BR_PROB_BASE, + REG_BR_PROB_BASE - orig->probability); bbs_to_scale = BITMAP_ALLOC (NULL); for (i = 0; i < n; i++) { @@ -1231,12 +1234,12 @@ duplicate_loop_to_header_edge (struct loop *loop, edge e, frequency should be reduced by prob_pass_wont_exit. Caller should've managed the flags so all except for original loop has won't exist set. */ - scale_act = RDIV (wanted_freq * REG_BR_PROB_BASE, freq_in); + scale_act = GCOV_COMPUTE_SCALE (wanted_freq, freq_in); /* Now simulate the duplication adjustments and compute header frequency of the last copy. */ for (i = 0; i < ndupl; i++) - wanted_freq = RDIV (wanted_freq * scale_step[i], REG_BR_PROB_BASE); - scale_main = RDIV (wanted_freq * REG_BR_PROB_BASE, freq_in); + wanted_freq = combine_probabilities (wanted_freq, scale_step[i]); + scale_main = GCOV_COMPUTE_SCALE (wanted_freq, freq_in); } else if (is_latch) { @@ -1248,16 +1251,16 @@ duplicate_loop_to_header_edge (struct loop *loop, edge e, for (i = 0; i < ndupl; i++) { scale_main += p; - p = RDIV (p * scale_step[i], REG_BR_PROB_BASE); + p = combine_probabilities (p, scale_step[i]); } - scale_main = RDIV (REG_BR_PROB_BASE * REG_BR_PROB_BASE, scale_main); - scale_act = RDIV (scale_main * prob_pass_main, REG_BR_PROB_BASE); + scale_main = GCOV_COMPUTE_SCALE (REG_BR_PROB_BASE, scale_main); + scale_act = combine_probabilities (scale_main, prob_pass_main); } else { scale_main = REG_BR_PROB_BASE; for (i = 0; i < ndupl; i++) - scale_main = RDIV (scale_main * scale_step[i], REG_BR_PROB_BASE); + scale_main = combine_probabilities (scale_main, scale_step[i]); scale_act = REG_BR_PROB_BASE - prob_pass_thru; } for (i = 0; i < ndupl; i++) @@ -1378,7 +1381,7 @@ duplicate_loop_to_header_edge (struct loop *loop, edge e, if (flags & DLTHE_FLAG_UPDATE_FREQ) { scale_bbs_frequencies_int (new_bbs, n, scale_act, REG_BR_PROB_BASE); - scale_act = RDIV (scale_act * scale_step[j], REG_BR_PROB_BASE); + scale_act = combine_probabilities (scale_act, scale_step[j]); } } free (new_bbs); @@ -1638,8 +1641,8 @@ lv_adjust_loop_entry_edge (basic_block first_head, basic_block second_head, current_ir_type () == IR_GIMPLE ? EDGE_TRUE_VALUE : 0); e1->probability = then_prob; e->probability = REG_BR_PROB_BASE - then_prob; - e1->count = RDIV (e->count * e1->probability, REG_BR_PROB_BASE); - e->count = RDIV (e->count * e->probability, REG_BR_PROB_BASE); + e1->count = apply_probability (e->count, e1->probability); + e->count = apply_probability (e->count, e->probability); set_immediate_dominator (CDI_DOMINATORS, first_head, new_head); set_immediate_dominator (CDI_DOMINATORS, second_head, new_head); |