summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortejohnson <tejohnson@138bc75d-0d04-0410-961f-82ee72b054a4>2013-05-02 13:20:47 +0000
committertejohnson <tejohnson@138bc75d-0d04-0410-961f-82ee72b054a4>2013-05-02 13:20:47 +0000
commit7007400071d3afc1525ca1691c93ae77c509349f (patch)
treee9eaf4c390a4ad7d8e3e0600f9736eb3868af2dc
parent4817649a7d71cac4236204ad8eecc15dee6bd6d9 (diff)
downloadgcc-7007400071d3afc1525ca1691c93ae77c509349f.tar.gz
Follow-on patch to r197595 to complete the replacement of truncating divides
in profile scaling code with rounding divide equivalents using helper routines in basic-block.h. In addition to bootstrap and profiledbootstrap builds and tests (with and without LTO), I built and tested performance of the SPEC cpu2006 benchmarks with FDO on a Nehalem system. I didn't see any performance changes that looked significant. 2013-05-02 Teresa Johnson <tejohnson@google.com> * loop-unswitch.c (unswitch_loop): Use helper routines with rounding divides. * cfg.c (update_bb_profile_for_threading): Ditto. * tree-inline.c (copy_bb): Ditto. (copy_edges_for_bb): Ditto. (initialize_cfun): Ditto. (copy_cfg_body): Ditto. (expand_call_inline): Ditto. * ipa-inline-analysis.c (estimate_edge_size_and_time): Ditto. (estimate_node_size_and_time): Ditto. (inline_merge_summary): Ditto. * cgraphclones.c (cgraph_clone_edge): Ditto. (cgraph_clone_node): Ditto. * sched-rgn.c (compute_dom_prob_ps): Ditto. (compute_trg_info): Ditto. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@198532 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog18
-rw-r--r--gcc/cfg.c3
-rw-r--r--gcc/cgraphclones.c6
-rw-r--r--gcc/ipa-inline-analysis.c9
-rw-r--r--gcc/loop-unswitch.c6
-rw-r--r--gcc/sched-rgn.c6
-rw-r--r--gcc/tree-inline.c30
7 files changed, 40 insertions, 38 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index de05eeb1c3c..023c6b924b4 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,21 @@
+2013-05-02 Teresa Johnson <tejohnson@google.com>
+
+ * loop-unswitch.c (unswitch_loop): Use helper routines with rounding
+ divides.
+ * cfg.c (update_bb_profile_for_threading): Ditto.
+ * tree-inline.c (copy_bb): Ditto.
+ (copy_edges_for_bb): Ditto.
+ (initialize_cfun): Ditto.
+ (copy_cfg_body): Ditto.
+ (expand_call_inline): Ditto.
+ * ipa-inline-analysis.c (estimate_edge_size_and_time): Ditto.
+ (estimate_node_size_and_time): Ditto.
+ (inline_merge_summary): Ditto.
+ * cgraphclones.c (cgraph_clone_edge): Ditto.
+ (cgraph_clone_node): Ditto.
+ * sched-rgn.c (compute_dom_prob_ps): Ditto.
+ (compute_trg_info): Ditto.
+
2013-05-02 Ian Bolton <ian.bolton@arm.com>
* config/aarch64/aarch64.md (movsi_aarch64): Only allow to/from
diff --git a/gcc/cfg.c b/gcc/cfg.c
index 6405f93f429..9c6c939139c 100644
--- a/gcc/cfg.c
+++ b/gcc/cfg.c
@@ -848,8 +848,7 @@ update_bb_profile_for_threading (basic_block bb, int edge_frequency,
/* Compute the probability of TAKEN_EDGE being reached via threaded edge.
Watch for overflows. */
if (bb->frequency)
- /* Update to use GCOV_COMPUTE_SCALE. */
- prob = edge_frequency * REG_BR_PROB_BASE / bb->frequency;
+ prob = GCOV_COMPUTE_SCALE (edge_frequency, bb->frequency);
else
prob = 0;
if (prob > taken_edge->probability)
diff --git a/gcc/cgraphclones.c b/gcc/cgraphclones.c
index fa6a9113a1e..f015f18666c 100644
--- a/gcc/cgraphclones.c
+++ b/gcc/cgraphclones.c
@@ -102,8 +102,7 @@ cgraph_clone_edge (struct cgraph_edge *e, struct cgraph_node *n,
int freq_scale, bool update_original)
{
struct cgraph_edge *new_edge;
- /* Update this to use GCOV_COMPUTE_SCALE. */
- gcov_type count = e->count * count_scale / REG_BR_PROB_BASE;
+ gcov_type count = apply_probability (e->count, count_scale);
gcov_type freq;
/* We do not want to ignore loop nest after frequency drops to 0. */
@@ -205,8 +204,7 @@ cgraph_clone_node (struct cgraph_node *n, tree decl, gcov_type count, int freq,
if (new_node->count > n->count)
count_scale = REG_BR_PROB_BASE;
else
- /* Update to use GCOV_COMPUTE_SCALE. */
- count_scale = new_node->count * REG_BR_PROB_BASE / n->count;
+ count_scale = GCOV_COMPUTE_SCALE (new_node->count, n->count);
}
else
count_scale = 0;
diff --git a/gcc/ipa-inline-analysis.c b/gcc/ipa-inline-analysis.c
index 138433cdf1a..8d66325237b 100644
--- a/gcc/ipa-inline-analysis.c
+++ b/gcc/ipa-inline-analysis.c
@@ -2790,8 +2790,7 @@ estimate_edge_size_and_time (struct cgraph_edge *e, int *size, int *time,
&& hints && cgraph_maybe_hot_edge_p (e))
*hints |= INLINE_HINT_indirect_call;
*size += call_size * INLINE_SIZE_SCALE;
- /* Update to use apply_probability(). */
- *time += call_time * prob / REG_BR_PROB_BASE
+ *time += apply_probability ((gcov_type) call_time, prob)
* e->frequency * (INLINE_TIME_SCALE / CGRAPH_FREQ_BASE);
if (*time > MAX_TIME * INLINE_TIME_SCALE)
*time = MAX_TIME * INLINE_TIME_SCALE;
@@ -2901,8 +2900,7 @@ estimate_node_size_and_time (struct cgraph_node *node,
inline_param_summary);
gcc_checking_assert (prob >= 0);
gcc_checking_assert (prob <= REG_BR_PROB_BASE);
- /* Update to use apply_probability(). */
- time += ((gcov_type) e->time * prob) / REG_BR_PROB_BASE;
+ time += apply_probability ((gcov_type) e->time, prob);
}
if (time > MAX_TIME * INLINE_TIME_SCALE)
time = MAX_TIME * INLINE_TIME_SCALE;
@@ -3311,8 +3309,7 @@ inline_merge_summary (struct cgraph_edge *edge)
int prob = predicate_probability (callee_info->conds,
&e->predicate,
clause, es->param);
- /* Update to use apply_probability(). */
- add_time = ((gcov_type) add_time * prob) / REG_BR_PROB_BASE;
+ add_time = apply_probability ((gcov_type) add_time, prob);
if (add_time > MAX_TIME * INLINE_TIME_SCALE)
add_time = MAX_TIME * INLINE_TIME_SCALE;
if (prob != REG_BR_PROB_BASE
diff --git a/gcc/loop-unswitch.c b/gcc/loop-unswitch.c
index e5f1bdc190b..213e74d515a 100644
--- a/gcc/loop-unswitch.c
+++ b/gcc/loop-unswitch.c
@@ -436,12 +436,10 @@ unswitch_loop (struct loop *loop, basic_block unswitch_on, rtx cond, rtx cinsn)
emit_insn_after (seq, BB_END (switch_bb));
e = make_edge (switch_bb, true_edge->dest, 0);
e->probability = prob;
- /* Update to use apply_probability(). */
- e->count = latch_edge->count * prob / REG_BR_PROB_BASE;
+ e->count = apply_probability (latch_edge->count, prob);
e = make_edge (switch_bb, FALLTHRU_EDGE (unswitch_on)->dest, EDGE_FALLTHRU);
e->probability = false_edge->probability;
- /* Update to use apply_probability(). */
- e->count = latch_edge->count * (false_edge->probability) / REG_BR_PROB_BASE;
+ e->count = apply_probability (latch_edge->count, false_edge->probability);
if (irred_flag)
{
diff --git a/gcc/sched-rgn.c b/gcc/sched-rgn.c
index 6eb00e93adc..3f5b4ba178b 100644
--- a/gcc/sched-rgn.c
+++ b/gcc/sched-rgn.c
@@ -1441,8 +1441,7 @@ compute_dom_prob_ps (int bb)
FOR_EACH_EDGE (out_edge, out_ei, in_edge->src->succs)
bitmap_set_bit (pot_split[bb], EDGE_TO_BIT (out_edge));
- /* Update to use apply_probability(). */
- prob[bb] += ((prob[pred_bb] * in_edge->probability) / REG_BR_PROB_BASE);
+ prob[bb] += combine_probabilities (prob[pred_bb], in_edge->probability);
}
bitmap_set_bit (dom[bb], bb);
@@ -1515,8 +1514,7 @@ compute_trg_info (int trg)
int tf = prob[trg], cf = prob[i];
/* In CFGs with low probability edges TF can possibly be zero. */
- /* Update to use GCOV_COMPUTE_SCALE. */
- sp->src_prob = (tf ? ((cf * REG_BR_PROB_BASE) / tf) : 0);
+ sp->src_prob = (tf ? GCOV_COMPUTE_SCALE (cf, tf) : 0);
sp->is_valid = (sp->src_prob >= min_spec_prob);
}
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 3abaadc5d2e..a650f0dc7c1 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -1519,13 +1519,11 @@ copy_bb (copy_body_data *id, basic_block bb, int frequency_scale,
basic_block_info automatically. */
copy_basic_block = create_basic_block (NULL, (void *) 0,
(basic_block) prev->aux);
- /* Update to use apply_scale(). */
- copy_basic_block->count = bb->count * count_scale / REG_BR_PROB_BASE;
+ copy_basic_block->count = apply_scale (bb->count, count_scale);
/* We are going to rebuild frequencies from scratch. These values
have just small importance to drive canonicalize_loop_headers. */
- /* Update to use EDGE_FREQUENCY. */
- freq = ((gcov_type)bb->frequency * frequency_scale / REG_BR_PROB_BASE);
+ freq = apply_scale ((gcov_type)bb->frequency, frequency_scale);
/* We recompute frequencies after inlining, so this is quite safe. */
if (freq > BB_FREQ_MAX)
@@ -1891,8 +1889,7 @@ copy_edges_for_bb (basic_block bb, gcov_type count_scale, basic_block ret_bb,
&& old_edge->dest->aux != EXIT_BLOCK_PTR)
flags |= EDGE_FALLTHRU;
new_edge = make_edge (new_bb, (basic_block) old_edge->dest->aux, flags);
- /* Update to use apply_scale(). */
- new_edge->count = old_edge->count * count_scale / REG_BR_PROB_BASE;
+ new_edge->count = apply_scale (old_edge->count, count_scale);
new_edge->probability = old_edge->probability;
}
@@ -2066,10 +2063,10 @@ initialize_cfun (tree new_fndecl, tree callee_fndecl, gcov_type count)
struct function *src_cfun = DECL_STRUCT_FUNCTION (callee_fndecl);
gcov_type count_scale;
- /* Update to use GCOV_COMPUTE_SCALE. */
if (ENTRY_BLOCK_PTR_FOR_FUNCTION (src_cfun)->count)
- count_scale = (REG_BR_PROB_BASE * count
- / ENTRY_BLOCK_PTR_FOR_FUNCTION (src_cfun)->count);
+ count_scale
+ = GCOV_COMPUTE_SCALE (count,
+ ENTRY_BLOCK_PTR_FOR_FUNCTION (src_cfun)->count);
else
count_scale = REG_BR_PROB_BASE;
@@ -2253,10 +2250,10 @@ copy_cfg_body (copy_body_data * id, gcov_type count, int frequency_scale,
int incoming_frequency = 0;
gcov_type incoming_count = 0;
- /* Update to use GCOV_COMPUTE_SCALE. */
if (ENTRY_BLOCK_PTR_FOR_FUNCTION (src_cfun)->count)
- count_scale = (REG_BR_PROB_BASE * count
- / ENTRY_BLOCK_PTR_FOR_FUNCTION (src_cfun)->count);
+ count_scale
+ = GCOV_COMPUTE_SCALE (count,
+ ENTRY_BLOCK_PTR_FOR_FUNCTION (src_cfun)->count);
else
count_scale = REG_BR_PROB_BASE;
@@ -2278,11 +2275,9 @@ copy_cfg_body (copy_body_data * id, gcov_type count, int frequency_scale,
incoming_frequency += EDGE_FREQUENCY (e);
incoming_count += e->count;
}
- /* Update to use apply_scale(). */
- incoming_count = incoming_count * count_scale / REG_BR_PROB_BASE;
- /* Update to use EDGE_FREQUENCY. */
+ incoming_count = apply_scale (incoming_count, count_scale);
incoming_frequency
- = incoming_frequency * frequency_scale / REG_BR_PROB_BASE;
+ = apply_scale ((gcov_type)incoming_frequency, frequency_scale);
ENTRY_BLOCK_PTR->count = incoming_count;
ENTRY_BLOCK_PTR->frequency = incoming_frequency;
}
@@ -4114,8 +4109,7 @@ expand_call_inline (basic_block bb, gimple stmt, copy_body_data *id)
a self-referential call; if we're calling ourselves, we need to
duplicate our body before altering anything. */
copy_body (id, bb->count,
- /* Update to use GCOV_COMPUTE_SCALE. */
- cg_edge->frequency * REG_BR_PROB_BASE / CGRAPH_FREQ_BASE,
+ GCOV_COMPUTE_SCALE (cg_edge->frequency, CGRAPH_FREQ_BASE),
bb, return_block, NULL, NULL);
/* Reset the escaped solution. */