ipa-prop.c (ipa_cst_from_jfunc): New function.

2011-05-13  Martin Jambor  <mjambor@suse.cz>

	* ipa-prop.c (ipa_cst_from_jfunc): New function.
	* ipa-prop.h (ipa_cst_from_jfunc): Declare.
	* ipa-inline-analysis.c (evaluate_conditions_for_edge): Use it.
	(evaluate_conditions_for_ipcp_clone): Removed.
	(estimate_ipcp_clone_size_and_time): Accept vector of known constants.
	* ipa-cp.c (ipcp_estimate_growth): Build vector of known constants.
	* ipa-inline.h (estimate_ipcp_clone_size_and_time): Update.

From-SVN: r173739
This commit is contained in:
Martin Jambor 2011-05-14 00:01:59 +02:00 committed by Martin Jambor
parent d61d771f3b
commit 411a20d66c
6 changed files with 55 additions and 40 deletions

View File

@ -1,3 +1,13 @@
2011-05-13 Martin Jambor <mjambor@suse.cz>
* ipa-prop.c (ipa_cst_from_jfunc): New function.
* ipa-prop.h (ipa_cst_from_jfunc): Declare.
* ipa-inline-analysis.c (evaluate_conditions_for_edge): Use it.
(evaluate_conditions_for_ipcp_clone): Removed.
(estimate_ipcp_clone_size_and_time): Accept vector of known constants.
* ipa-cp.c (ipcp_estimate_growth): Build vector of known constants.
* ipa-inline.h (estimate_ipcp_clone_size_and_time): Update.
2011-05-13 Eric Botcazou <ebotcazou@adacore.com>
* cfgrtl.c (cfg_layout_redirect_edge_and_branch): Adjust dump message.

View File

@ -1068,6 +1068,7 @@ ipcp_estimate_growth (struct cgraph_node *node)
int removable_args = 0;
bool need_original
= !cgraph_will_be_removed_from_program_if_no_direct_calls (node);
VEC (tree, heap) *known_vals = NULL;
struct ipa_node_params *info;
int i, count;
int growth;
@ -1085,6 +1086,7 @@ ipcp_estimate_growth (struct cgraph_node *node)
info = IPA_NODE_REF (node);
count = ipa_get_param_count (info);
VEC_safe_grow_cleared (tree, heap, known_vals, count);
if (node->local.can_change_signature)
for (i = 0; i < count; i++)
{
@ -1095,14 +1097,18 @@ ipcp_estimate_growth (struct cgraph_node *node)
removable_args++;
if (lat->type == IPA_CONST_VALUE)
removable_args++;
{
removable_args++;
VEC_replace (tree, known_vals, i, lat->constant);
}
}
/* We make just very simple estimate of savings for removal of operand from
call site. Precise cost is difficult to get, as our size metric counts
constants and moves as free. Generally we are looking for cases that
small function is called very many times. */
estimate_ipcp_clone_size_and_time (node, &growth, NULL);
estimate_ipcp_clone_size_and_time (node, known_vals, &growth, NULL);
VEC_free (tree, heap, known_vals);
growth = growth
- removable_args * redirectable_node_callers;
if (growth < 0)

View File

@ -592,7 +592,6 @@ evaluate_conditions_for_edge (struct cgraph_edge *e, bool inline_p)
struct ipa_node_params *parms_info;
struct ipa_edge_args *args = IPA_EDGE_REF (e);
int i, count = ipa_get_cs_argument_count (args);
struct ipcp_lattice lat;
VEC (tree, heap) *known_vals = NULL;
if (e->caller->global.inlined_to)
@ -603,9 +602,10 @@ evaluate_conditions_for_edge (struct cgraph_edge *e, bool inline_p)
VEC_safe_grow_cleared (tree, heap, known_vals, count);
for (i = 0; i < count; i++)
{
ipa_lattice_from_jfunc (parms_info, &lat, ipa_get_ith_jump_func (args, i));
if (lat.type == IPA_CONST_VALUE)
VEC_replace (tree, known_vals, i, lat.constant);
tree cst = ipa_cst_from_jfunc (parms_info,
ipa_get_ith_jump_func (args, i));
if (cst)
VEC_replace (tree, known_vals, i, cst);
}
clause = evaluate_conditions_for_known_args (e->callee,
inline_p, known_vals);
@ -619,31 +619,6 @@ evaluate_conditions_for_edge (struct cgraph_edge *e, bool inline_p)
}
/* Work out what conditions might be true at invocation of NODE
that is (future) ipa-cp clone. */
static clause_t
evaluate_conditions_for_ipcp_clone (struct cgraph_node *node)
{
struct ipa_node_params *parms_info = IPA_NODE_REF (node);
int i, count = ipa_get_param_count (parms_info);
struct ipcp_lattice *lat;
VEC (tree, heap) *known_vals = NULL;
clause_t clause;
VEC_safe_grow_cleared (tree, heap, known_vals, count);
for (i = 0; i < count; i++)
{
lat = ipa_get_lattice (parms_info, i);
if (lat->type == IPA_CONST_VALUE)
VEC_replace (tree, known_vals, i, lat->constant);
}
clause = evaluate_conditions_for_known_args (node, false, known_vals);
VEC_free (tree, heap, known_vals);
return clause;
}
/* Allocate the inline summary vector or resize it to cover all cgraph nodes. */
static void
@ -1823,18 +1798,19 @@ estimate_node_size_and_time (struct cgraph_node *node,
}
/* Estimate size and time needed to execute callee of EDGE assuming
that parameters known to be constant at caller of EDGE are
propagated. If INLINE_P is true, it is assumed that call will
be inlined. */
/* Estimate size and time needed to execute callee of EDGE assuming that
parameters known to be constant at caller of EDGE are propagated.
KNOWN_VALs is a vector of assumed known constant values for parameters. */
void
estimate_ipcp_clone_size_and_time (struct cgraph_node *node,
VEC (tree, heap) *known_vals,
int *ret_size, int *ret_time)
{
estimate_node_size_and_time (node,
evaluate_conditions_for_ipcp_clone (node),
ret_size, ret_time);
clause_t clause;
clause = evaluate_conditions_for_known_args (node, false, known_vals);
estimate_node_size_and_time (node, clause, ret_size, ret_time);
}

View File

@ -149,7 +149,9 @@ void inline_free_summary (void);
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 *, int *, int *);
void estimate_ipcp_clone_size_and_time (struct cgraph_node *,
VEC (tree, heap) *known_vals,
int *, int *);
int do_estimate_growth (struct cgraph_node *);
void inline_merge_summary (struct cgraph_edge *edge);
int do_estimate_edge_growth (struct cgraph_edge *edge);

View File

@ -3002,6 +3002,7 @@ ipa_update_after_lto_read (void)
/* Given the jump function JFUNC, compute the lattice LAT that describes the
value coming down the callsite. INFO describes the caller node so that
pass-through jump functions can be evaluated. */
void
ipa_lattice_from_jfunc (struct ipa_node_params *info, struct ipcp_lattice *lat,
struct ipa_jump_func *jfunc)
@ -3061,3 +3062,19 @@ ipa_lattice_from_jfunc (struct ipa_node_params *info, struct ipcp_lattice *lat,
else
lat->type = IPA_BOTTOM;
}
/* Determine whether JFUNC evaluates to a constant and if so, return it.
Otherwise return NULL. INFO describes the caller node so that pass-through
jump functions can be evaluated. */
tree
ipa_cst_from_jfunc (struct ipa_node_params *info, struct ipa_jump_func *jfunc)
{
struct ipcp_lattice lat;
ipa_lattice_from_jfunc (info, &lat, jfunc);
if (lat.type == IPA_CONST_VALUE)
return lat.constant;
else
return NULL_TREE;
}

View File

@ -521,8 +521,12 @@ void ipa_prop_write_jump_functions (cgraph_node_set set);
void ipa_prop_read_jump_functions (void);
void ipa_update_after_lto_read (void);
int ipa_get_param_decl_index (struct ipa_node_params *, tree);
void ipa_lattice_from_jfunc (struct ipa_node_params *info, struct ipcp_lattice *lat,
void ipa_lattice_from_jfunc (struct ipa_node_params *info,
struct ipcp_lattice *lat,
struct ipa_jump_func *jfunc);
tree ipa_cst_from_jfunc (struct ipa_node_params *info,
struct ipa_jump_func *jfunc);
/* From tree-sra.c: */
tree build_ref_for_offset (location_t, tree, HOST_WIDE_INT, tree,