* 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
+2017-04-28 Jan Hubicka <hubicka@ucw.cz>
+
+ * 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 <mliska@suse.cz>
* doc/gcov.texi: Enhance documentation of gcov.
perform_estimation_of_a_value (cgraph_node *node, vec<tree> known_csts,
vec<ipa_polymorphic_call_context> known_contexts,
vec<ipa_agg_jump_function_p> 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)
vec<ipa_agg_jump_function> known_aggs;
vec<ipa_agg_jump_function_p> 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,
{
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,
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)
{
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))
{
vec<tree> known_vals,
vec<ipa_polymorphic_call_context> known_contexts,
vec<ipa_agg_jump_function_p> 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>
inline_param_summary)
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)
vec<ipa_polymorphic_call_context>
known_contexts,
vec<ipa_agg_jump_function_p> known_aggs,
- int *ret_size, int *ret_time,
+ int *ret_size, sreal *ret_time,
inline_hints *hints)
{
clause_t clause;
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;
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);
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. */
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;
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)
;
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;
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)
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");
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);
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. */
struct edge_growth_cache_entry
{
- int time, size;
+ sreal time;
+ int size;
inline_hints hints;
};
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<tree>,
vec<ipa_polymorphic_call_context>,
vec<ipa_agg_jump_function_p>,
- 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);
/* 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;
}