* ipa-inline-analysis.c: Fix formatting.

From-SVN: r194769
This commit is contained in:
Jan Hubicka 2013-01-01 17:22:10 +01:00 committed by Jan Hubicka
parent 2a5195d965
commit 42d573997e
2 changed files with 539 additions and 540 deletions

View File

@ -1,3 +1,7 @@
2013-01-01 Jan Hubicka <jh@suse.cz>
* ipa-inline-analysis.c: Fix formatting.
2013-01-01 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/55831

View File

@ -1,5 +1,5 @@
/* Inlining decision heuristics.
Copyright (C) 2003, 2004, 2007, 2008, 2009, 2010, 2011
Copyright (C) 2003, 2004, 2007, 2008, 2009, 2010, 2011, 2012, 2013
Free Software Foundation, Inc.
Contributed by Jan Hubicka
@ -127,8 +127,7 @@ static void inline_node_duplication_hook (struct cgraph_node *,
struct cgraph_node *, void *);
static void inline_edge_removal_hook (struct cgraph_edge *, void *);
static void inline_edge_duplication_hook (struct cgraph_edge *,
struct cgraph_edge *,
void *);
struct cgraph_edge *, void *);
/* VECtor holding inline summaries.
In GGC memory because conditions might point to constant trees. */
@ -200,6 +199,7 @@ false_predicate_p (struct predicate *p)
/* Return predicate that is set true when function is not inlined. */
static inline struct predicate
not_inlined_predicate (void)
{
@ -336,14 +336,15 @@ add_clause (conditions conditions, struct predicate *p, clause_t clause)
cc1 = &(*conditions)[c1 - predicate_first_dynamic_condition];
/* We have no way to represent !CHANGED and !IS_NOT_CONSTANT
and thus there is no point for looking for them. */
if (cc1->code == CHANGED
|| cc1->code == IS_NOT_CONSTANT)
if (cc1->code == CHANGED || cc1->code == IS_NOT_CONSTANT)
continue;
for (c2 = c1 + 1; c2 <= NUM_CONDITIONS; c2++)
if (clause & (1 << c2))
{
condition *cc1 = &(*conditions)[c1 - predicate_first_dynamic_condition];
condition *cc2 = &(*conditions)[c2 - predicate_first_dynamic_condition];
condition *cc1 =
&(*conditions)[c1 - predicate_first_dynamic_condition];
condition *cc2 =
&(*conditions)[c2 - predicate_first_dynamic_condition];
if (cc1->operand_num == cc2->operand_num
&& cc1->val == cc2->val
&& cc2->code != IS_NOT_CONSTANT
@ -423,7 +424,8 @@ predicates_equal_p (struct predicate *p, struct predicate *p2)
/* Return P | P2. */
static struct predicate
or_predicates (conditions conditions, struct predicate *p, struct predicate *p2)
or_predicates (conditions conditions,
struct predicate *p, struct predicate *p2)
{
struct predicate out = true_predicate ();
int i, j;
@ -508,12 +510,14 @@ predicate_probability (conditions conds,
{
if (i2 >= predicate_first_dynamic_condition)
{
condition *c = &(*conds)[i2 - predicate_first_dynamic_condition];
condition *c =
&(*conds)[i2 - predicate_first_dynamic_condition];
if (c->code == CHANGED
&& (c->operand_num
< (int) inline_param_summary.length ()))
&& (c->operand_num <
(int) inline_param_summary.length ()))
{
int iprob = inline_param_summary[c->operand_num].change_prob;
int iprob =
inline_param_summary[c->operand_num].change_prob;
this_prob = MAX (this_prob, iprob);
}
else
@ -692,14 +696,16 @@ account_size_time (struct inline_summary *summary, int size, int time,
e = &(*summary->entry)[0];
gcc_assert (!e->predicate.clause[0]);
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, "\t\tReached limit on number of entries, ignoring the predicate.");
fprintf (dump_file,
"\t\tReached limit on number of entries, "
"ignoring the predicate.");
}
if (dump_file && (dump_flags & TDF_DETAILS) && (time || size))
{
fprintf (dump_file, "\t\tAccounting size:%3.2f, time:%3.2f on %spredicate:",
fprintf (dump_file,
"\t\tAccounting size:%3.2f, time:%3.2f on %spredicate:",
((double) size) / INLINE_SIZE_SCALE,
((double)time) / INLINE_TIME_SCALE,
found ? "" : "new ");
((double) time) / INLINE_TIME_SCALE, found ? "" : "new ");
dump_predicate (dump_file, summary->conds, pred);
}
if (!found)
@ -744,8 +750,7 @@ edge_set_predicate (struct cgraph_edge *e, struct predicate *predicate)
static void
set_hint_predicate (struct predicate **p, struct predicate new_predicate)
{
if (false_predicate_p (&new_predicate)
|| true_predicate_p (&new_predicate))
if (false_predicate_p (&new_predicate) || true_predicate_p (&new_predicate))
{
if (*p)
pool_free (edge_predicate_pool, *p);
@ -771,7 +776,8 @@ static clause_t
evaluate_conditions_for_known_args (struct cgraph_node *node,
bool inline_p,
vec<tree> known_vals,
vec<ipa_agg_jump_function_p> known_aggs)
vec<ipa_agg_jump_function_p>
known_aggs)
{
clause_t clause = inline_p ? 0 : 1 << predicate_not_inlined_condition;
struct inline_summary *info = inline_summary (node);
@ -801,8 +807,7 @@ evaluate_conditions_for_known_args (struct cgraph_node *node,
if (c->code == CHANGED
&& !c->by_ref
&& (known_vals[c->operand_num]
== error_mark_node))
&& (known_vals[c->operand_num] == error_mark_node))
continue;
if (known_aggs.exists ())
@ -828,8 +833,7 @@ evaluate_conditions_for_known_args (struct cgraph_node *node,
if (c->code == IS_NOT_CONSTANT || c->code == CHANGED)
continue;
res = fold_binary_to_constant (c->code, boolean_type_node, val, c->val);
if (res
&& integer_zerop (res))
if (res && integer_zerop (res))
continue;
clause |= 1 << (i + predicate_first_dynamic_condition);
}
@ -846,7 +850,8 @@ evaluate_properties_for_edge (struct cgraph_edge *e, bool inline_p,
vec<tree> *known_binfos_ptr,
vec<ipa_agg_jump_function_p> *known_aggs_ptr)
{
struct cgraph_node *callee = cgraph_function_or_thunk_node (e->callee, NULL);
struct cgraph_node *callee =
cgraph_function_or_thunk_node (e->callee, NULL);
struct inline_summary *info = inline_summary (callee);
vec<tree> known_vals = vNULL;
vec<ipa_agg_jump_function_p> known_aggs = vNULL;
@ -860,8 +865,7 @@ evaluate_properties_for_edge (struct cgraph_edge *e, bool inline_p,
if (ipa_node_params_vector.exists ()
&& !e->call_stmt_cannot_inline_p
&& ((clause_ptr && info->conds)
|| known_vals_ptr || known_binfos_ptr))
&& ((clause_ptr && info->conds) || known_vals_ptr || known_binfos_ptr))
{
struct ipa_node_params *parms_info;
struct ipa_edge_args *args = IPA_EDGE_REF (e);
@ -888,7 +892,8 @@ evaluate_properties_for_edge (struct cgraph_edge *e, bool inline_p,
{
if (known_vals.exists () && TREE_CODE (cst) != TREE_BINFO)
known_vals[i] = cst;
else if (known_binfos_ptr != NULL && TREE_CODE (cst) == TREE_BINFO)
else if (known_binfos_ptr != NULL
&& TREE_CODE (cst) == TREE_BINFO)
(*known_binfos_ptr)[i] = cst;
}
else if (inline_p && !es->param[i].change_prob)
@ -940,8 +945,7 @@ inline_summary_alloc (void)
inline_edge_summary_vec.safe_grow_cleared (cgraph_edge_max_uid + 1);
if (!edge_predicate_pool)
edge_predicate_pool = create_alloc_pool ("edge predicates",
sizeof (struct predicate),
10);
sizeof (struct predicate), 10);
}
/* We are called multiple time for given function; clear
@ -1005,7 +1009,8 @@ reset_inline_summary (struct cgraph_node *node)
/* Hook that is called by cgraph.c when a node is removed. */
static void
inline_node_removal_hook (struct cgraph_node *node, void *data ATTRIBUTE_UNUSED)
inline_node_removal_hook (struct cgraph_node *node,
void *data ATTRIBUTE_UNUSED)
{
struct inline_summary *info;
if (vec_safe_length (inline_summary_vec) <= (unsigned) node->uid)
@ -1054,8 +1059,7 @@ remap_hint_predicate_after_duplication (struct predicate **p,
return;
new_predicate = remap_predicate_after_duplication (*p,
possible_truths,
info);
possible_truths, info);
/* We do not want to free previous predicate; it is used by node origin. */
*p = NULL;
set_hint_predicate (p, new_predicate);
@ -1065,22 +1069,21 @@ remap_hint_predicate_after_duplication (struct predicate **p,
/* Hook that is called by cgraph.c when a node is duplicated. */
static void
inline_node_duplication_hook (struct cgraph_node *src, struct cgraph_node *dst,
inline_node_duplication_hook (struct cgraph_node *src,
struct cgraph_node *dst,
ATTRIBUTE_UNUSED void *data)
{
struct inline_summary *info;
inline_summary_alloc ();
info = inline_summary (dst);
memcpy (info, inline_summary (src),
sizeof (struct inline_summary));
memcpy (info, inline_summary (src), sizeof (struct inline_summary));
/* TODO: as an optimization, we may avoid copying conditions
that are known to be false or true. */
info->conds = vec_safe_copy (info->conds);
/* When there are any replacements in the function body, see if we can figure
out that something was optimized out. */
if (ipa_node_params_vector.exists ()
&& dst->clone.tree_map)
if (ipa_node_params_vector.exists () && dst->clone.tree_map)
{
vec<size_time_entry, va_gc> *entry = info->entry;
/* Use SRC parm info since it may not be copied yet. */
@ -1104,9 +1107,7 @@ inline_node_duplication_hook (struct cgraph_node *src, struct cgraph_node *dst,
for (j = 0; vec_safe_iterate (dst->clone.tree_map, j, &r); j++)
{
if (r->old_tree == t
&& r->replace_p
&& !r->ref_p)
if (r->old_tree == t && r->replace_p && !r->ref_p)
{
known_vals[i] = r->new_tree;
break;
@ -1114,7 +1115,8 @@ inline_node_duplication_hook (struct cgraph_node *src, struct cgraph_node *dst,
}
}
possible_truths = evaluate_conditions_for_known_args (dst, false,
known_vals, vNULL);
known_vals,
vNULL);
known_vals.release ();
account_size_time (info, 0, 0, &true_pred);
@ -1181,21 +1183,17 @@ inline_node_duplication_hook (struct cgraph_node *src, struct cgraph_node *dst,
edge_set_predicate (edge, &new_predicate);
}
remap_hint_predicate_after_duplication (&info->loop_iterations,
possible_truths,
info);
possible_truths, info);
remap_hint_predicate_after_duplication (&info->loop_stride,
possible_truths,
info);
possible_truths, info);
remap_hint_predicate_after_duplication (&info->array_index,
possible_truths,
info);
possible_truths, info);
/* If inliner or someone after inliner will ever start producing
non-trivial clones, we will get trouble with lack of information
about updating self sizes, because size vectors already contains
sizes of the calees. */
gcc_assert (!inlined_to_p
|| !optimized_out_size);
gcc_assert (!inlined_to_p || !optimized_out_size);
}
else
{
@ -1226,7 +1224,8 @@ inline_node_duplication_hook (struct cgraph_node *src, struct cgraph_node *dst,
/* Hook that is called by cgraph.c when a node is duplicated. */
static void
inline_edge_duplication_hook (struct cgraph_edge *src, struct cgraph_edge *dst,
inline_edge_duplication_hook (struct cgraph_edge *src,
struct cgraph_edge *dst,
ATTRIBUTE_UNUSED void *data)
{
struct inline_edge_summary *info;
@ -1234,8 +1233,7 @@ inline_edge_duplication_hook (struct cgraph_edge *src, struct cgraph_edge *dst,
inline_summary_alloc ();
info = inline_edge_summary (dst);
srcinfo = inline_edge_summary (src);
memcpy (info, srcinfo,
sizeof (struct inline_edge_summary));
memcpy (info, srcinfo, sizeof (struct inline_edge_summary));
info->predicate = NULL;
edge_set_predicate (dst, srcinfo->predicate);
info->param = srcinfo->param.copy ();
@ -1245,7 +1243,8 @@ inline_edge_duplication_hook (struct cgraph_edge *src, struct cgraph_edge *dst,
/* Keep edge cache consistent across edge removal. */
static void
inline_edge_removal_hook (struct cgraph_edge *edge, void *data ATTRIBUTE_UNUSED)
inline_edge_removal_hook (struct cgraph_edge *edge,
void *data ATTRIBUTE_UNUSED)
{
if (edge_growth_cache.exists ())
reset_edge_growth_cache (edge);
@ -1286,19 +1285,18 @@ dump_inline_edge_summary (FILE * f, int indent, struct cgraph_node *node,
for (edge = node->callees; edge; edge = edge->next_callee)
{
struct inline_edge_summary *es = inline_edge_summary (edge);
struct cgraph_node *callee = cgraph_function_or_thunk_node (edge->callee, NULL);
struct cgraph_node *callee =
cgraph_function_or_thunk_node (edge->callee, NULL);
int i;
fprintf (f, "%*s%s/%i %s\n%*s loop depth:%2i freq:%4i size:%2i time: %2i callee size:%2i stack:%2i",
indent, "", cgraph_node_name (callee),
callee->uid,
!edge->inline_failed ? "inlined"
: cgraph_inline_failed_string (edge->inline_failed),
indent, "",
es->loop_depth,
edge->frequency,
es->call_stmt_size,
es->call_stmt_time,
fprintf (f,
"%*s%s/%i %s\n%*s loop depth:%2i freq:%4i size:%2i"
" time: %2i callee size:%2i stack:%2i",
indent, "", cgraph_node_name (callee), callee->uid,
!edge->inline_failed
? "inlined" : cgraph_inline_failed_string (edge-> inline_failed),
indent, "", es->loop_depth, edge->frequency,
es->call_stmt_size, es->call_stmt_time,
(int) inline_summary (callee)->size / INLINE_SIZE_SCALE,
(int) inline_summary (callee)->estimated_stack_size);
@ -1339,9 +1337,7 @@ dump_inline_edge_summary (FILE * f, int indent, struct cgraph_node *node,
" time: %2i",
indent, "",
es->loop_depth,
edge->frequency,
es->call_stmt_size,
es->call_stmt_time);
edge->frequency, es->call_stmt_size, es->call_stmt_time);
if (es->predicate)
{
fprintf (f, "predicate: ");
@ -1367,22 +1363,17 @@ dump_inline_summary (FILE * f, struct cgraph_node *node)
fprintf (f, " always_inline");
if (s->inlinable)
fprintf (f, " inlinable");
fprintf (f, "\n self time: %i\n",
s->self_time);
fprintf (f, "\n self time: %i\n", s->self_time);
fprintf (f, " global time: %i\n", s->time);
fprintf (f, " self size: %i\n",
s->self_size);
fprintf (f, " self size: %i\n", s->self_size);
fprintf (f, " global size: %i\n", s->size);
fprintf (f, " self stack: %i\n",
(int) s->estimated_self_stack_size);
fprintf (f, " global stack: %i\n",
(int) s->estimated_stack_size);
fprintf (f, " global stack: %i\n", (int) s->estimated_stack_size);
if (s->growth)
fprintf (f, " estimated growth:%i\n",
(int) s->growth);
fprintf (f, " estimated growth:%i\n", (int) s->growth);
if (s->scc_no)
fprintf (f, " In SCC: %i\n",
(int) s->scc_no);
fprintf (f, " In SCC: %i\n", (int) s->scc_no);
for (i = 0; vec_safe_iterate (s->entry, i, &e); i++)
{
fprintf (f, " size:%f, time:%f, predicate:",
@ -1662,7 +1653,8 @@ eliminated_by_inlining_prob (gimple stmt)
|| (TREE_CODE (TREE_OPERAND (inner_lhs, 0)) == SSA_NAME
&& SSA_NAME_VAR (TREE_OPERAND (inner_lhs, 0))
&& TREE_CODE (SSA_NAME_VAR (TREE_OPERAND
(inner_lhs, 0))) == RESULT_DECL))))
(inner_lhs,
0))) == RESULT_DECL))))
lhs_free = true;
if (lhs_free
&& (is_gimple_reg (rhs) || is_gimple_min_invariant (rhs)))
@ -1696,8 +1688,7 @@ set_cond_stmt_execution_predicate (struct ipa_node_params *info,
tree op2;
last = last_stmt (bb);
if (!last
|| gimple_code (last) != GIMPLE_COND)
if (!last || gimple_code (last) != GIMPLE_COND)
return;
if (!is_gimple_ip_invariant (gimple_cond_rhs (last)))
return;
@ -1743,10 +1734,10 @@ set_cond_stmt_execution_predicate (struct ipa_node_params *info,
|| gimple_call_num_args (set_stmt) != 1)
return;
op2 = gimple_call_arg (set_stmt, 0);
if (!unmodified_parm_or_parm_agg_item (info, set_stmt, op2, &index, &aggpos))
if (!unmodified_parm_or_parm_agg_item
(info, set_stmt, op2, &index, &aggpos))
return;
FOR_EACH_EDGE (e, ei, bb->succs)
if (e->flags & EDGE_FALSE_VALUE)
FOR_EACH_EDGE (e, ei, bb->succs) if (e->flags & EDGE_FALSE_VALUE)
{
struct predicate p = add_condition (summary, index, &aggpos,
IS_NOT_CONSTANT, NULL_TREE);
@ -1774,8 +1765,7 @@ set_switch_stmt_execution_predicate (struct ipa_node_params *info,
size_t case_idx;
last = last_stmt (bb);
if (!last
|| gimple_code (last) != GIMPLE_SWITCH)
if (!last || gimple_code (last) != GIMPLE_SWITCH)
return;
op = gimple_switch_index (last);
if (!unmodified_parm_or_parm_agg_item (info, last, op, &index, &aggpos))
@ -1906,15 +1896,13 @@ will_be_nonconstant_expr_predicate (struct ipa_node_params *info,
expr = TREE_OPERAND (expr, 0);
parm = unmodified_parm (NULL, expr);
if (parm
&& (index = ipa_get_param_decl_index (info, parm)) >= 0)
if (parm && (index = ipa_get_param_decl_index (info, parm)) >= 0)
return add_condition (summary, index, NULL, CHANGED, NULL_TREE);
if (is_gimple_min_invariant (expr))
return false_predicate ();
if (TREE_CODE (expr) == SSA_NAME)
return nonconstant_names[SSA_NAME_VERSION (expr)];
if (BINARY_CLASS_P (expr)
|| COMPARISON_CLASS_P (expr))
if (BINARY_CLASS_P (expr) || COMPARISON_CLASS_P (expr))
{
struct predicate p1 = will_be_nonconstant_expr_predicate
(info, summary, TREE_OPERAND (expr, 0),
@ -2018,7 +2006,8 @@ will_be_nonconstant_predicate (struct ipa_node_params *info,
}
if (is_load)
op_non_const = add_condition (summary, base_index, &aggpos, CHANGED, NULL);
op_non_const =
add_condition (summary, base_index, &aggpos, CHANGED, NULL);
else
op_non_const = false_predicate ();
FOR_EACH_SSA_TREE_OPERAND (use, stmt, iter, SSA_OP_USE)
@ -2026,8 +2015,7 @@ will_be_nonconstant_predicate (struct ipa_node_params *info,
tree parm = unmodified_parm (stmt, use);
int index;
if (parm
&& (index = ipa_get_param_decl_index (info, parm)) >= 0)
if (parm && (index = ipa_get_param_decl_index (info, parm)) >= 0)
{
if (index != base_index)
p = add_condition (summary, index, NULL, CHANGED, NULL_TREE);
@ -2055,15 +2043,16 @@ struct record_modified_bb_info
set except for info->stmt. */
static bool
record_modified (ao_ref *ao ATTRIBUTE_UNUSED, tree vdef,
void *data)
record_modified (ao_ref *ao ATTRIBUTE_UNUSED, tree vdef, void *data)
{
struct record_modified_bb_info *info = (struct record_modified_bb_info *) data;
struct record_modified_bb_info *info =
(struct record_modified_bb_info *) data;
if (SSA_NAME_DEF_STMT (vdef) == info->stmt)
return false;
bitmap_set_bit (info->bb_set,
SSA_NAME_IS_DEFAULT_DEF (vdef)
? ENTRY_BLOCK_PTR->index : gimple_bb (SSA_NAME_DEF_STMT (vdef))->index);
? ENTRY_BLOCK_PTR->index
: gimple_bb (SSA_NAME_DEF_STMT (vdef))->index);
return false;
}
@ -2081,6 +2070,7 @@ param_change_prob (gimple stmt, int i)
basic_block bb = gimple_bb (stmt);
tree base;
/* Global invariants neve change. */
if (is_gimple_min_invariant (op))
return 0;
/* We would have to do non-trivial analysis to really work out what
@ -2256,13 +2246,12 @@ array_index_predicate (struct inline_summary *info,
struct predicate p = false_predicate ();
while (handled_component_p (op))
{
if (TREE_CODE (op) == ARRAY_REF
|| TREE_CODE (op) == ARRAY_RANGE_REF)
if (TREE_CODE (op) == ARRAY_REF || TREE_CODE (op) == ARRAY_RANGE_REF)
{
if (TREE_CODE (TREE_OPERAND (op, 1)) == SSA_NAME)
p = or_predicates (info->conds, &p,
&nonconstant_names[
SSA_NAME_VERSION (TREE_OPERAND (op, 1))]);
&nonconstant_names[SSA_NAME_VERSION
(TREE_OPERAND (op, 1))]);
}
op = TREE_OPERAND (op, 0);
}
@ -2304,7 +2293,8 @@ estimate_function_body_sizes (struct cgraph_node *node, bool early)
if (ipa_node_params_vector.exists ())
{
parms_info = IPA_NODE_REF (node);
nonconstant_names.safe_grow_cleared(SSANAMES (my_function)->length());
nonconstant_names.safe_grow_cleared
(SSANAMES (my_function)->length ());
}
}
@ -2384,24 +2374,31 @@ estimate_function_body_sizes (struct cgraph_node *node, bool early)
fprintf (dump_file, " ");
print_gimple_stmt (dump_file, stmt, 0, 0);
fprintf (dump_file, "\t\tfreq:%3.2f size:%3i time:%3i\n",
((double)freq)/CGRAPH_FREQ_BASE, this_size, this_time);
((double) freq) / CGRAPH_FREQ_BASE, this_size,
this_time);
}
if (gimple_assign_load_p (stmt) && nonconstant_names.exists ())
{
struct predicate this_array_index;
this_array_index = array_index_predicate (info, nonconstant_names,
this_array_index =
array_index_predicate (info, nonconstant_names,
gimple_assign_rhs1 (stmt));
if (!false_predicate_p (&this_array_index))
array_index = and_predicates (info->conds, &array_index, &this_array_index);
array_index =
and_predicates (info->conds, &array_index,
&this_array_index);
}
if (gimple_store_p (stmt) && nonconstant_names.exists ())
{
struct predicate this_array_index;
this_array_index = array_index_predicate (info, nonconstant_names,
this_array_index =
array_index_predicate (info, nonconstant_names,
gimple_get_lhs (stmt));
if (!false_predicate_p (&this_array_index))
array_index = and_predicates (info->conds, &array_index, &this_array_index);
array_index =
and_predicates (info->conds, &array_index,
&this_array_index);
}
@ -2458,7 +2455,8 @@ estimate_function_body_sizes (struct cgraph_node *node, bool early)
prob = eliminated_by_inlining_prob (stmt);
if (prob == 1 && dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, "\t\t50%% will be eliminated by inlining\n");
fprintf (dump_file,
"\t\t50%% will be eliminated by inlining\n");
if (prob == 2 && dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, "\t\tWill be eliminated by inlining\n");
@ -2530,16 +2528,19 @@ estimate_function_body_sizes (struct cgraph_node *node, bool early)
{
predicate will_be_nonconstant
= will_be_nonconstant_expr_predicate (parms_info, info,
niter_desc.niter, nonconstant_names);
niter_desc.niter,
nonconstant_names);
if (!true_predicate_p (&will_be_nonconstant))
will_be_nonconstant = and_predicates (info->conds,
&bb_predicate,
&will_be_nonconstant);
if (!true_predicate_p (&will_be_nonconstant)
&& !false_predicate_p (&will_be_nonconstant))
/* This is slightly inprecise. We may want to represent each loop with
independent predicate. */
loop_iterations = and_predicates (info->conds, &loop_iterations, &will_be_nonconstant);
/* This is slightly inprecise. We may want to represent each
loop with independent predicate. */
loop_iterations =
and_predicates (info->conds, &loop_iterations,
&will_be_nonconstant);
}
exits.release ();
@ -2547,7 +2548,8 @@ estimate_function_body_sizes (struct cgraph_node *node, bool early)
{
gimple_stmt_iterator gsi;
bb_predicate = *(struct predicate *) body[i]->aux;
for (gsi = gsi_start_bb (body[i]); !gsi_end_p (gsi); gsi_next (&gsi))
for (gsi = gsi_start_bb (body[i]); !gsi_end_p (gsi);
gsi_next (&gsi))
{
gimple stmt = gsi_stmt (gsi);
affine_iv iv;
@ -2558,27 +2560,33 @@ estimate_function_body_sizes (struct cgraph_node *node, bool early)
{
predicate will_be_nonconstant;
if (!simple_iv (loop, loop_containing_stmt (stmt), use, &iv, true)
if (!simple_iv
(loop, loop_containing_stmt (stmt), use, &iv, true)
|| is_gimple_min_invariant (iv.step))
continue;
will_be_nonconstant
= will_be_nonconstant_expr_predicate (parms_info, info,
iv.step, nonconstant_names);
iv.step,
nonconstant_names);
if (!true_predicate_p (&will_be_nonconstant))
will_be_nonconstant = and_predicates (info->conds,
will_be_nonconstant
= and_predicates (info->conds,
&bb_predicate,
&will_be_nonconstant);
if (!true_predicate_p (&will_be_nonconstant)
&& !false_predicate_p (&will_be_nonconstant))
/* This is slightly inprecise. We may want to represent each loop with
independent predicate. */
loop_stride = and_predicates (info->conds, &loop_stride, &will_be_nonconstant);
/* This is slightly inprecise. We may want to represent
each loop with independent predicate. */
loop_stride =
and_predicates (info->conds, &loop_stride,
&will_be_nonconstant);
}
}
}
free (body);
}
set_hint_predicate (&inline_summary (node)->loop_iterations, loop_iterations);
set_hint_predicate (&inline_summary (node)->loop_iterations,
loop_iterations);
set_hint_predicate (&inline_summary (node)->loop_stride, loop_stride);
scev_finalize ();
}
@ -2691,8 +2699,7 @@ compute_inline_parameters (struct cgraph_node *node, bool early)
info->estimated_stack_size = info->estimated_self_stack_size;
#ifdef ENABLE_CHECKING
inline_update_overall_summary (node);
gcc_assert (info->time == info->self_time
&& info->size == info->self_size);
gcc_assert (info->time == info->self_time && info->size == info->self_size);
#endif
pop_cfun ();
@ -2776,7 +2783,6 @@ estimate_edge_size_and_time (struct cgraph_edge *e, int *size, int *time,
vec<tree> known_binfos,
vec<ipa_agg_jump_function_p> known_aggs,
inline_hints *hints)
{
struct inline_edge_summary *es = inline_edge_summary (e);
int call_size = es->call_stmt_size;
@ -2784,8 +2790,7 @@ estimate_edge_size_and_time (struct cgraph_edge *e, int *size, int *time,
if (!e->callee
&& estimate_edge_devirt_benefit (e, &call_size, &call_time,
known_vals, known_binfos, known_aggs)
&& hints
&& cgraph_maybe_hot_edge_p (e))
&& hints && cgraph_maybe_hot_edge_p (e))
*hints |= INLINE_HINT_indirect_call;
*size += call_size * INLINE_SIZE_SCALE;
*time += call_time * prob / REG_BR_PROB_BASE
@ -2812,26 +2817,29 @@ estimate_calls_size_and_time (struct cgraph_node *node, int *size, int *time,
for (e = node->callees; e; e = e->next_callee)
{
struct inline_edge_summary *es = inline_edge_summary (e);
if (!es->predicate || evaluate_predicate (es->predicate, possible_truths))
if (!es->predicate
|| evaluate_predicate (es->predicate, possible_truths))
{
if (e->inline_failed)
{
/* Predicates of calls shall not use NOT_CHANGED codes,
sowe do not need to compute probabilities. */
estimate_edge_size_and_time (e, size, time, REG_BR_PROB_BASE,
known_vals, known_binfos, known_aggs,
hints);
known_vals, known_binfos,
known_aggs, hints);
}
else
estimate_calls_size_and_time (e->callee, size, time, hints,
possible_truths,
known_vals, known_binfos, known_aggs);
known_vals, known_binfos,
known_aggs);
}
}
for (e = node->indirect_calls; e; e = e->next_callee)
{
struct inline_edge_summary *es = inline_edge_summary (e);
if (!es->predicate || evaluate_predicate (es->predicate, possible_truths))
if (!es->predicate
|| evaluate_predicate (es->predicate, possible_truths))
estimate_edge_size_and_time (e, size, time, REG_BR_PROB_BASE,
known_vals, known_binfos, known_aggs,
hints);
@ -2861,14 +2869,11 @@ estimate_node_size_and_time (struct cgraph_node *node,
inline_hints hints = 0;
int i;
if (dump_file
&& (dump_flags & TDF_DETAILS))
if (dump_file && (dump_flags & TDF_DETAILS))
{
bool found = false;
fprintf (dump_file, " Estimating body: %s/%i\n"
" Known to be false: ",
cgraph_node_name (node),
node->uid);
" Known to be false: ", cgraph_node_name (node), node->uid);
for (i = predicate_not_inlined_condition;
i < (predicate_first_dynamic_condition
@ -2929,8 +2934,7 @@ estimate_node_size_and_time (struct cgraph_node *node,
time = RDIV (time, INLINE_TIME_SCALE);
size = RDIV (size, INLINE_SIZE_SCALE);
if (dump_file
&& (dump_flags & TDF_DETAILS))
if (dump_file && (dump_flags & TDF_DETAILS))
fprintf (dump_file, "\n size:%i time:%i\n", (int) size, (int) time);
if (ret_time)
*ret_time = time;
@ -2982,8 +2986,7 @@ remap_predicate (struct inline_summary *info,
struct predicate *p,
vec<int> operand_map,
vec<int> offset_map,
clause_t possible_truths,
struct predicate *toplev_predicate)
clause_t possible_truths, struct predicate *toplev_predicate)
{
int i;
struct predicate out = true_predicate ();
@ -3011,7 +3014,8 @@ remap_predicate (struct inline_summary *info,
struct condition *c;
c = &(*callee_info->conds)[cond
- predicate_first_dynamic_condition];
-
predicate_first_dynamic_condition];
/* See if we can remap condition operand to caller's operand.
Otherwise give up. */
if (!operand_map.exists ()
@ -3035,8 +3039,7 @@ remap_predicate (struct inline_summary *info,
offset_delta = 0;
}
gcc_assert (!c->agg_contents
|| c->by_ref
|| offset_delta == 0);
|| c->by_ref || offset_delta == 0);
ap.offset = c->offset + offset_delta;
ap.agg_contents = c->agg_contents;
ap.by_ref = c->by_ref;
@ -3065,8 +3068,7 @@ remap_predicate (struct inline_summary *info,
Compute peak stack usage. */
static void
inline_update_callee_summaries (struct cgraph_node *node,
int depth)
inline_update_callee_summaries (struct cgraph_node *node, int depth)
{
struct cgraph_edge *e;
struct inline_summary *callee_info = inline_summary (node);
@ -3078,8 +3080,7 @@ inline_update_callee_summaries (struct cgraph_node *node,
+ caller_info->estimated_self_stack_size;
peak = callee_info->stack_frame_offset
+ callee_info->estimated_self_stack_size;
if (inline_summary (node->global.inlined_to)->estimated_stack_size
< peak)
if (inline_summary (node->global.inlined_to)->estimated_stack_size < peak)
inline_summary (node->global.inlined_to)->estimated_stack_size = peak;
cgraph_propagate_frequency (node);
for (e = node->callees; e; e = e->next_callee)
@ -3163,8 +3164,7 @@ remap_edge_summaries (struct cgraph_edge *inlined_edge,
{
p = remap_predicate (info, callee_info,
es->predicate, operand_map, offset_map,
possible_truths,
toplev_predicate);
possible_truths, toplev_predicate);
edge_set_predicate (e, &p);
/* TODO: We should remove the edge for code that will be
optimized out, but we need to keep verifiers and tree-inline
@ -3227,17 +3227,13 @@ remap_hint_predicate (struct inline_summary *info,
p = remap_predicate (info, callee_info,
*hint,
operand_map, offset_map,
possible_truths,
toplev_predicate);
if (!false_predicate_p (&p)
&& !true_predicate_p (&p))
possible_truths, toplev_predicate);
if (!false_predicate_p (&p) && !true_predicate_p (&p))
{
if (!*hint)
set_hint_predicate (hint, p);
else
**hint = and_predicates (info->conds,
*hint,
&p);
**hint = and_predicates (info->conds, *hint, &p);
}
}
@ -3333,16 +3329,13 @@ inline_merge_summary (struct cgraph_edge *edge)
offset_map, clause, &toplev_predicate);
remap_hint_predicate (info, callee_info,
&callee_info->loop_iterations,
operand_map, offset_map,
clause, &toplev_predicate);
operand_map, offset_map, clause, &toplev_predicate);
remap_hint_predicate (info, callee_info,
&callee_info->loop_stride,
operand_map, offset_map,
clause, &toplev_predicate);
operand_map, offset_map, clause, &toplev_predicate);
remap_hint_predicate (info, callee_info,
&callee_info->array_index,
operand_map, offset_map,
clause, &toplev_predicate);
operand_map, offset_map, clause, &toplev_predicate);
inline_update_callee_summaries (edge->callee,
inline_edge_summary (edge)->loop_depth);
@ -3386,8 +3379,7 @@ simple_edge_hints (struct cgraph_edge *edge)
{
int hints = 0;
struct cgraph_node *to = (edge->caller->global.inlined_to
? edge->caller->global.inlined_to
: edge->caller);
? edge->caller->global.inlined_to : edge->caller);
if (inline_summary (to)->scc_no
&& inline_summary (to)->scc_no == inline_summary (edge->callee)->scc_no
&& !cgraph_edge_recursive_p (edge))
@ -3537,7 +3529,8 @@ estimate_time_after_inlining (struct cgraph_node *node,
struct inline_edge_summary *es = inline_edge_summary (edge);
if (!es->predicate || !false_predicate_p (es->predicate))
{
gcov_type time = inline_summary (node)->time + estimate_edge_time (edge);
gcov_type time =
inline_summary (node)->time + estimate_edge_time (edge);
if (time < 0)
time = 0;
if (time > MAX_TIME)
@ -3741,8 +3734,7 @@ read_inline_edge_summary (struct lto_input_block *ib, struct cgraph_edge *e)
{
es->param.safe_grow_cleared (length);
for (i = 0; i < length; i++)
es->param[i].change_prob
= streamer_read_uhwi (ib);
es->param[i].change_prob = streamer_read_uhwi (ib);
}
}
@ -3946,7 +3938,10 @@ inline_write_summary (void)
size_time_entry *e;
struct condition *c;
streamer_write_uhwi (ob, lto_symtab_encoder_encode (encoder, (symtab_node)node));
streamer_write_uhwi (ob,
lto_symtab_encoder_encode (encoder,
(symtab_node)
node));
streamer_write_hwi (ob, info->estimated_self_stack_size);
streamer_write_hwi (ob, info->self_size);
streamer_write_hwi (ob, info->self_time);