From: Jan Hubicka Date: Fri, 28 Apr 2017 13:04:48 +0000 (+0200) Subject: ipa-cp.c (perform_estimation_of_a_value): Turn time to sreal. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ab38481ceff08c995ade3e88eccee6ab92914a44;p=gcc.git ipa-cp.c (perform_estimation_of_a_value): Turn time to sreal. * ipa-cp.c (perform_estimation_of_a_value): Turn time to sreal. (estimate_local_effects): Likewise. * ipa-inline.c (compute_inlined_call_time, want_inline_small_function_p, edge_badness, inline_small_functions, dump_overall_stats): LIkewise. * ipa-inline.h (edge_growth_cache_entry, estimate_time_after_inlining, estimate_ipcp_clone_size_and_time, do_estimate_edge_time, do_estimate_edge_time, estimate_edge_time): Likewise. * ipa-inline-analysis.c (estimate_node_size_and_time, estimate_ipcp_clone_size_and_time, do_estimate_edge_time): Likewise. (estimate_time_after_inlining): Remove. From-SVN: r247380 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b1b094b120e..977517eabd8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,16 @@ +2017-04-28 Jan Hubicka + + * ipa-cp.c (perform_estimation_of_a_value): Turn time to sreal. + (estimate_local_effects): Likewise. + * ipa-inline.c (compute_inlined_call_time, want_inline_small_function_p, + edge_badness, inline_small_functions, dump_overall_stats): LIkewise. + * ipa-inline.h (edge_growth_cache_entry, estimate_time_after_inlining, + estimate_ipcp_clone_size_and_time, do_estimate_edge_time, + do_estimate_edge_time, estimate_edge_time): Likewise. + * ipa-inline-analysis.c (estimate_node_size_and_time, + estimate_ipcp_clone_size_and_time, do_estimate_edge_time): Likewise. + (estimate_time_after_inlining): Remove. + 2017-04-28 Martin Liska * doc/gcov.texi: Enhance documentation of gcov. diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c index d31e2c30a46..26ae8fcd2aa 100644 --- a/gcc/ipa-cp.c +++ b/gcc/ipa-cp.c @@ -2792,16 +2792,20 @@ static void perform_estimation_of_a_value (cgraph_node *node, vec known_csts, vec known_contexts, vec known_aggs_ptrs, - int base_time, int removable_params_cost, + sreal base_time, int removable_params_cost, int est_move_cost, ipcp_value_base *val) { - int time, size, time_benefit; + int size, time_benefit; + sreal time; inline_hints hints; estimate_ipcp_clone_size_and_time (node, known_csts, known_contexts, known_aggs_ptrs, &size, &time, &hints); - time_benefit = base_time - time + base_time -= time; + if (base_time > 65535) + base_time = 65535; + time_benefit = base_time.to_int () + devirtualization_time_bonus (node, known_csts, known_contexts, known_aggs_ptrs) + hint_time_bonus (hints) @@ -2832,15 +2836,15 @@ estimate_local_effects (struct cgraph_node *node) vec known_aggs; vec known_aggs_ptrs; bool always_const; - int base_time = inline_summaries->get (node)->time.to_int (); + sreal base_time = inline_summaries->get (node)->time.to_int (); int removable_params_cost; if (!count || !ipcp_versionable_function_p (node)) return; if (dump_file && (dump_flags & TDF_DETAILS)) - fprintf (dump_file, "\nEstimating effects for %s/%i, base_time: %i.\n", - node->name (), node->order, base_time); + fprintf (dump_file, "\nEstimating effects for %s/%i, base_time: %f.\n", + node->name (), node->order, base_time.to_double ()); always_const = gather_context_independent_values (info, &known_csts, &known_contexts, &known_aggs, @@ -2853,7 +2857,8 @@ estimate_local_effects (struct cgraph_node *node) { struct caller_statistics stats; inline_hints hints; - int time, size; + sreal time; + int size; init_caller_stats (&stats); node->call_for_symbol_thunks_and_aliases (gather_caller_stats, &stats, @@ -2867,7 +2872,7 @@ estimate_local_effects (struct cgraph_node *node) if (dump_file) fprintf (dump_file, " - context independent values, size: %i, " - "time_benefit: %i\n", size, base_time - time); + "time_benefit: %f\n", size, (base_time - time).to_double ()); if (size <= 0 || node->local.local) { @@ -2878,7 +2883,7 @@ estimate_local_effects (struct cgraph_node *node) fprintf (dump_file, " Decided to specialize for all " "known contexts, code not going to grow.\n"); } - else if (good_cloning_opportunity_p (node, base_time - time, + else if (good_cloning_opportunity_p (node, (base_time - time).to_int (), stats.freq_sum, stats.count_sum, size)) { diff --git a/gcc/ipa-inline-analysis.c b/gcc/ipa-inline-analysis.c index 2cf594429bb..e211d32fb58 100644 --- a/gcc/ipa-inline-analysis.c +++ b/gcc/ipa-inline-analysis.c @@ -3260,7 +3260,7 @@ estimate_node_size_and_time (struct cgraph_node *node, vec known_vals, vec known_contexts, vec known_aggs, - int *ret_size, int *ret_min_size, int *ret_time, + int *ret_size, int *ret_min_size, sreal *ret_time, inline_hints *ret_hints, vec inline_param_summary) @@ -3336,14 +3336,14 @@ estimate_node_size_and_time (struct cgraph_node *node, known_vals, known_contexts, known_aggs); gcc_checking_assert (size >= 0); gcc_checking_assert (time >= 0); - time = RDIV (time, INLINE_TIME_SCALE); + time = time / INLINE_TIME_SCALE; size = RDIV (size, INLINE_SIZE_SCALE); min_size = RDIV (min_size, INLINE_SIZE_SCALE); if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "\n size:%i time:%f\n", (int) size, time.to_double ()); if (ret_time) - *ret_time = time.to_int (); + *ret_time = time; if (ret_size) *ret_size = size; if (ret_min_size) @@ -3365,7 +3365,7 @@ estimate_ipcp_clone_size_and_time (struct cgraph_node *node, vec known_contexts, vec known_aggs, - int *ret_size, int *ret_time, + int *ret_size, sreal *ret_time, inline_hints *hints) { clause_t clause; @@ -3800,10 +3800,10 @@ simple_edge_hints (struct cgraph_edge *edge) When caching, also update the cache entry. Compute both time and size, since we always need both metrics eventually. */ -int +sreal do_estimate_edge_time (struct cgraph_edge *edge) { - int time; + sreal time; int size; inline_hints hints; struct cgraph_node *callee; @@ -3845,7 +3845,7 @@ do_estimate_edge_time (struct cgraph_edge *edge) inline_summaries->get (edge->callee)->min_size = min_size; if ((int) edge_growth_cache.length () <= edge->uid) edge_growth_cache.safe_grow_cleared (symtab->edges_max_uid); - edge_growth_cache[edge->uid].time = time + (time >= 0); + edge_growth_cache[edge->uid].time = time; edge_growth_cache[edge->uid].size = size + (size >= 0); hints |= simple_edge_hints (edge); @@ -3933,26 +3933,6 @@ do_estimate_edge_hints (struct cgraph_edge *edge) return hints; } - -/* Estimate self time of the function NODE after inlining EDGE. */ - -int -estimate_time_after_inlining (struct cgraph_node *node, - struct cgraph_edge *edge) -{ - struct inline_edge_summary *es = inline_edge_summary (edge); - if (!es->predicate || !false_predicate_p (es->predicate)) - { - sreal time = - inline_summaries->get (node)->time + estimate_edge_time (edge); - if (time < 0) - time = 0; - return time.to_int (); - } - return inline_summaries->get (node)->time.to_int (); -} - - /* Estimate the size of NODE after inlining EDGE which should be an edge to either NODE or a call inlined into NODE. */ diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c index f50d29b6a5d..2bbe46a97d2 100644 --- a/gcc/ipa-inline.c +++ b/gcc/ipa-inline.c @@ -663,13 +663,12 @@ compute_uninlined_call_time (struct inline_summary *callee_info, inline sreal compute_inlined_call_time (struct cgraph_edge *edge, - int edge_time) + sreal time) { cgraph_node *caller = (edge->caller->global.inlined_to ? edge->caller->global.inlined_to : edge->caller); sreal caller_time = inline_summaries->get (caller)->time; - sreal time = edge_time; if (edge->count && caller->count) time *= (sreal)edge->count / caller->count; @@ -753,14 +752,6 @@ want_inline_small_function_p (struct cgraph_edge *e, bool report) int growth = estimate_edge_growth (e); inline_hints hints = estimate_edge_hints (e); bool big_speedup = big_speedup_p (e); -/* - fprintf (stderr, "%i %i %i\n",growth,hints,big_speedup); - dump_inline_summary (stderr, e->caller->global.inlined_to ? e->caller->global.inlined_to : e->caller); - dump_inline_summary (stderr, e->callee); - sreal time = compute_uninlined_call_time (inline_summaries->get (e->callee), - e); - sreal inlined_time = compute_inlined_call_time (e, estimate_edge_time (e)); - fprintf (stderr, "%f %f\n", time.to_double (), inlined_time.to_double ());*/ if (growth <= 0) ; @@ -1019,7 +1010,8 @@ static sreal edge_badness (struct cgraph_edge *edge, bool dump) { sreal badness; - int growth, edge_time; + int growth; + sreal edge_time; struct cgraph_node *callee = edge->callee->ultimate_alias_target (); struct inline_summary *callee_info = inline_summaries->get (callee); inline_hints hints; @@ -1033,7 +1025,7 @@ edge_badness (struct cgraph_edge *edge, bool dump) gcc_checking_assert (edge_time >= 0); /* FIXME: -1 to care of rounding issues should go away once cache is migrated. to sreals. */ - gcc_checking_assert (edge_time - 1 <= callee_info->time); + gcc_checking_assert (edge_time <= callee_info->time); gcc_checking_assert (growth <= callee_info->size); if (dump) @@ -1043,9 +1035,9 @@ edge_badness (struct cgraph_edge *edge, bool dump) edge->caller->order, xstrdup_for_dump (callee->name ()), edge->callee->order); - fprintf (dump_file, " size growth %i, time %i ", + fprintf (dump_file, " size growth %i, time %f ", growth, - edge_time); + edge_time.to_double ()); dump_inline_hints (dump_file, hints); if (big_speedup_p (edge)) fprintf (dump_file, " big_speedup"); @@ -1883,7 +1875,7 @@ inline_small_functions (void) sreal cached_badness = edge_badness (edge, false); int old_size_est = estimate_edge_size (edge); - int old_time_est = estimate_edge_time (edge); + sreal old_time_est = estimate_edge_time (edge); int old_hints_est = estimate_edge_hints (edge); reset_edge_growth_cache (edge); @@ -2250,20 +2242,20 @@ inline_to_all_callers (struct cgraph_node *node, void *data) static void dump_overall_stats (void) { - int64_t sum_weighted = 0, sum = 0; + sreal sum_weighted = 0, sum = 0; struct cgraph_node *node; FOR_EACH_DEFINED_FUNCTION (node) if (!node->global.inlined_to && !node->alias) { - int time = inline_summaries->get (node)->time.to_double (); + sreal time = inline_summaries->get (node)->time; sum += time; sum_weighted += time * node->count; } fprintf (dump_file, "Overall time estimate: " - "%" PRId64" weighted by profile: " - "%" PRId64"\n", sum, sum_weighted); + "%f weighted by profile: " + "%f\n", sum.to_double (), sum_weighted.to_double ()); } /* Output some useful stats about inlining. */ diff --git a/gcc/ipa-inline.h b/gcc/ipa-inline.h index 077f0cc936b..8acf4d7ce55 100644 --- a/gcc/ipa-inline.h +++ b/gcc/ipa-inline.h @@ -232,7 +232,8 @@ extern vec inline_edge_summary_vec; struct edge_growth_cache_entry { - int time, size; + sreal time; + int size; inline_hints hints; }; @@ -249,19 +250,18 @@ void inline_write_summary (void); void inline_free_summary (void); void inline_analyze_function (struct cgraph_node *node); void initialize_inline_failed (struct cgraph_edge *); -int estimate_time_after_inlining (struct cgraph_node *, struct cgraph_edge *); int estimate_size_after_inlining (struct cgraph_node *, struct cgraph_edge *); void estimate_ipcp_clone_size_and_time (struct cgraph_node *, vec, vec, vec, - int *, int *, inline_hints *); + int *, sreal *, inline_hints *); int estimate_growth (struct cgraph_node *); bool growth_likely_positive (struct cgraph_node *, int); void inline_merge_summary (struct cgraph_edge *edge); void inline_update_overall_summary (struct cgraph_node *node); int do_estimate_edge_size (struct cgraph_edge *edge); -int do_estimate_edge_time (struct cgraph_edge *edge); +sreal do_estimate_edge_time (struct cgraph_edge *edge); inline_hints do_estimate_edge_hints (struct cgraph_edge *edge); void initialize_growth_caches (void); void free_growth_caches (void); @@ -314,14 +314,14 @@ estimate_edge_growth (struct cgraph_edge *edge) /* Return estimated callee runtime increase after inlining EDGE. */ -static inline int +static inline sreal estimate_edge_time (struct cgraph_edge *edge) { - int ret; + sreal ret; if ((int)edge_growth_cache.length () <= edge->uid - || !(ret = edge_growth_cache[edge->uid].time)) + || !edge_growth_cache[edge->uid].size) return do_estimate_edge_time (edge); - return ret - (ret > 0); + return edge_growth_cache[edge->uid].time; }