+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.
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;
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++)
{
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)
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)
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);
}
-/* 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
}
-/* 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);
}
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);
/* 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)
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;
+}
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,