* ipa-cp.c (gather_context_independent_values): Use ipa_get_param_move_cost.
(get_replacement_map): Remove PARAM; move parameter folding into tree-inline.c
(create_specialized_node): Update.
* ipa-prop.c (ipa_populate_param_decls): Do not look for origins;
assert that we have gimple body; update move_cost.
(count_formal_params): Assert that we have gimple body.
(ipa_dump_param): New function.
(ipa_alloc_node_params): Break out from ...
(ipa_initialize_node_params): ... here.
(ipa_get_vector_of_formal_parms): ICE when used in WPA.
(ipa_write_node_info): Stream move costs.
(ipa_read_node_info): Read move costs.
(ipa_update_after_lto_read): Do not recompute node params.
* ipa-prop.h (ipa_param_descriptor): Add move_cost.
(ipa_get_param): Check we are not in WPA.
(ipa_get_param_move_cost): New.
* tree-inline.c (tree_function_versioning): Fold replacement as needed.
* ipa-inline-analysis.c (inline_node_duplication_hook): Expect only
parm numbers to be present.
* gcc.dg/ipa/ipa-1.c: Update.
* gcc.dg/ipa/ipa-2.c: Update.
* gcc.dg/ipa/ipa-3.c: Update.
* gcc.dg/ipa/ipa-4.c: Update.
* gcc.dg/ipa/ipa-5.c: Update.
* gcc.dg/ipa/ipa-7.c: Update.
* gcc.dg/ipa/ipa-8.c: Update.
* gcc.dg/ipa/ipcp-1.c: Update.
* gcc.dg/ipa/ipcp-2.c: Update.
From-SVN: r201462
+2013-08-02 Jan Hubicka <jh@suse.cz>
+
+ * ipa-cp.c (gather_context_independent_values): Use ipa_get_param_move_cost.
+ (get_replacement_map): Remove PARAM; move parameter folding into tree-inline.c
+ (create_specialized_node): Update.
+ * ipa-prop.c (ipa_populate_param_decls): Do not look for origins;
+ assert that we have gimple body; update move_cost.
+ (count_formal_params): Assert that we have gimple body.
+ (ipa_dump_param): New function.
+ (ipa_alloc_node_params): Break out from ...
+ (ipa_initialize_node_params): ... here.
+ (ipa_get_vector_of_formal_parms): ICE when used in WPA.
+ (ipa_write_node_info): Stream move costs.
+ (ipa_read_node_info): Read move costs.
+ (ipa_update_after_lto_read): Do not recompute node params.
+ * ipa-prop.h (ipa_param_descriptor): Add move_cost.
+ (ipa_get_param): Check we are not in WPA.
+ (ipa_get_param_move_cost): New.
+ * tree-inline.c (tree_function_versioning): Fold replacement as needed.
+ * ipa-inline-analysis.c (inline_node_duplication_hook): Expect only
+ parm numbers to be present.
+
2013-08-02 Vladimir Makarov <vmakarov@redhat.com>
PR rtl-optimization/58048
}
else if (removable_params_cost
&& !ipa_is_param_used (info, i))
- *removable_params_cost
- += estimate_move_cost (TREE_TYPE (ipa_get_param (info, i)));
+ *removable_params_cost += ipa_get_param_move_cost (info, i);
}
else if (removable_params_cost
&& !ipa_is_param_used (info, i))
*removable_params_cost
- += estimate_move_cost (TREE_TYPE (ipa_get_param (info, i)));
+ += ipa_get_param_move_cost (info, i);
if (known_aggs)
{
{
fprintf (dump_file, " - estimates for value ");
print_ipcp_constant_value (dump_file, val->value);
- fprintf (dump_file, " for parameter ");
- print_generic_expr (dump_file, ipa_get_param (info, i), 0);
+ fprintf (dump_file, " for ");
+ ipa_dump_param (dump_file, info, i);
fprintf (dump_file, ": time_benefit: %i, size: %i\n",
time_benefit, size);
}
{
fprintf (dump_file, " - estimates for value ");
print_ipcp_constant_value (dump_file, val->value);
- fprintf (dump_file, " for parameter ");
- print_generic_expr (dump_file, ipa_get_param (info, i), 0);
+ fprintf (dump_file, " for ");
+ ipa_dump_param (dump_file, info, i);
fprintf (dump_file, "[%soffset: " HOST_WIDE_INT_PRINT_DEC
"]: time_benefit: %i, size: %i\n",
plats->aggs_by_ref ? "ref " : "",
Return it or NULL if for some reason it cannot be created. */
static struct ipa_replace_map *
-get_replacement_map (tree value, tree parm, int parm_num)
+get_replacement_map (struct ipa_node_params *info, tree value, int parm_num)
{
- tree req_type = TREE_TYPE (parm);
struct ipa_replace_map *replace_map;
- if (!useless_type_conversion_p (req_type, TREE_TYPE (value)))
- {
- if (fold_convertible_p (req_type, value))
- value = fold_build1 (NOP_EXPR, req_type, value);
- else if (TYPE_SIZE (req_type) == TYPE_SIZE (TREE_TYPE (value)))
- value = fold_build1 (VIEW_CONVERT_EXPR, req_type, value);
- else
- {
- if (dump_file)
- {
- fprintf (dump_file, " const ");
- print_generic_expr (dump_file, value, 0);
- fprintf (dump_file, " can't be converted to param ");
- print_generic_expr (dump_file, parm, 0);
- fprintf (dump_file, "\n");
- }
- return NULL;
- }
- }
replace_map = ggc_alloc_ipa_replace_map ();
if (dump_file)
{
- fprintf (dump_file, " replacing param ");
- print_generic_expr (dump_file, parm, 0);
+ fprintf (dump_file, " replacing ");
+ ipa_dump_param (dump_file, info, parm_num);
+
fprintf (dump_file, " with const ");
print_generic_expr (dump_file, value, 0);
fprintf (dump_file, "\n");
{
struct ipa_replace_map *replace_map;
- replace_map = get_replacement_map (t, ipa_get_param (info, i), i);
+ replace_map = get_replacement_map (info, t, i);
if (replace_map)
vec_safe_push (replace_trees, replace_map);
}
{
fprintf (dump_file, " adding an extra known scalar value ");
print_ipcp_constant_value (dump_file, newval);
- fprintf (dump_file, " for parameter ");
- print_generic_expr (dump_file, ipa_get_param (info, i), 0);
+ fprintf (dump_file, " for ");
+ ipa_dump_param (dump_file, info, i);
fprintf (dump_file, "\n");
}
{
fprintf (dump_file, " - considering value ");
print_ipcp_constant_value (dump_file, val->value);
- fprintf (dump_file, " for parameter ");
- print_generic_expr (dump_file, ipa_get_param (IPA_NODE_REF (node),
- index), 0);
+ fprintf (dump_file, " for ");
+ ipa_dump_param (dump_file, IPA_NODE_REF (node), index);
if (offset != -1)
fprintf (dump_file, ", offset: " HOST_WIDE_INT_PRINT_DEC, offset);
fprintf (dump_file, " (caller_count: %i)\n", caller_count);
known_vals.safe_grow_cleared (count);
for (i = 0; i < count; i++)
{
- tree t = ipa_get_param (parms_info, i);
struct ipa_replace_map *r;
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 && r->parm_num == i)
+ || (r->old_tree && r->old_tree == ipa_get_param (parms_info, i)))
+ && r->replace_p && !r->ref_p)
{
known_vals[i] = r->new_tree;
break;
tree parm;
int param_num;
- /* We do not copy DECL_ARGUMENTS to virtual clones. */
- while (node->clone_of)
- node = node->clone_of;
-
fndecl = node->symbol.decl;
+ gcc_assert (gimple_has_body_p (fndecl));
fnargs = DECL_ARGUMENTS (fndecl);
param_num = 0;
for (parm = fnargs; parm; parm = DECL_CHAIN (parm))
{
descriptors[param_num].decl = parm;
+ descriptors[param_num].move_cost = estimate_move_cost (TREE_TYPE (parm));
param_num++;
}
}
{
tree parm;
int count = 0;
+ gcc_assert (gimple_has_body_p (fndecl));
for (parm = DECL_ARGUMENTS (fndecl); parm; parm = DECL_CHAIN (parm))
count++;
return count;
}
+/* Return the declaration of Ith formal parameter of the function corresponding
+ to INFO. Note there is no setter function as this array is built just once
+ using ipa_initialize_node_params. */
+
+void
+ipa_dump_param (FILE *file, struct ipa_node_params *info, int i)
+{
+ fprintf (file, "param #%i", i);
+ if (info->descriptors[i].decl)
+ {
+ fprintf (file, " ");
+ print_generic_expr (file, info->descriptors[i].decl, 0);
+ }
+}
+
+/* Initialize the ipa_node_params structure associated with NODE
+ to hold PARAM_COUNT parameters. */
+
+void
+ipa_alloc_node_params (struct cgraph_node *node, int param_count)
+{
+ struct ipa_node_params *info = IPA_NODE_REF (node);
+
+ if (!info->descriptors.exists () && param_count)
+ info->descriptors.safe_grow_cleared (param_count);
+}
+
/* Initialize the ipa_node_params structure associated with NODE by counting
the function parameters, creating the descriptors and populating their
param_decls. */
if (!info->descriptors.exists ())
{
- int param_count;
- gcc_assert (!node->clone_of);
-
- param_count = count_formal_params (node->symbol.decl);
- if (param_count)
- {
- info->descriptors.safe_grow_cleared (param_count);
- ipa_populate_param_decls (node, info->descriptors);
- }
+ ipa_alloc_node_params (node, count_formal_params (node->symbol.decl));
+ ipa_populate_param_decls (node, info->descriptors);
}
}
int count;
tree parm;
+ gcc_assert (!flag_wpa);
count = count_formal_params (fndecl);
args.create (count);
for (parm = DECL_ARGUMENTS (fndecl); parm; parm = DECL_CHAIN (parm))
node_ref = lto_symtab_encoder_encode (encoder, (symtab_node) node);
streamer_write_uhwi (ob, node_ref);
+ streamer_write_uhwi (ob, ipa_get_param_count (info));
+ for (j = 0; j < ipa_get_param_count (info); j++)
+ streamer_write_uhwi (ob, ipa_get_param_move_cost (info, j));
bp = bitpack_create (ob->main_stream);
gcc_assert (info->uses_analysis_done
|| ipa_get_param_count (info) == 0);
struct cgraph_edge *e;
struct bitpack_d bp;
- ipa_initialize_node_params (node);
+ ipa_alloc_node_params (node, streamer_read_uhwi (ib));
+ for (k = 0; k < ipa_get_param_count (info); k++)
+ info->descriptors[k].move_cost = streamer_read_uhwi (ib);
+
bp = streamer_read_bitpack (ib);
if (ipa_get_param_count (info) != 0)
info->uses_analysis_done = true;
void
ipa_update_after_lto_read (void)
{
- struct cgraph_node *node;
-
ipa_check_create_node_params ();
ipa_check_create_edge_args ();
-
- FOR_EACH_DEFINED_FUNCTION (node)
- ipa_initialize_node_params (node);
}
void
says how many there are. If any use could not be described by means of
ipa-prop structures, this is IPA_UNDESCRIBED_USE. */
int controlled_uses;
+ unsigned int move_cost : 31;
/* The parameter is used. */
unsigned used : 1;
};
static inline tree
ipa_get_param (struct ipa_node_params *info, int i)
{
+ gcc_checking_assert (!flag_wpa);
return info->descriptors[i].decl;
}
+/* Return the move cost of Ith formal parameter of the function corresponding
+ to INFO. */
+
+static inline int
+ipa_get_param_move_cost (struct ipa_node_params *info, int i)
+{
+ return info->descriptors[i].move_cost;
+}
+
/* Set the used flag corresponding to the Ith formal parameter of the function
associated with INFO to VAL. */
tree ipa_value_from_jfunc (struct ipa_node_params *info,
struct ipa_jump_func *jfunc);
unsigned int ipcp_transform_function (struct cgraph_node *node);
+void ipa_dump_param (FILE *, struct ipa_node_params *info, int i);
/* From tree-sra.c: */
+2013-08-02 Jan Hubicka <jh@suse.cz>
+
+ * gcc.dg/ipa/ipa-1.c: Update.
+ * gcc.dg/ipa/ipa-2.c: Update.
+ * gcc.dg/ipa/ipa-3.c: Update.
+ * gcc.dg/ipa/ipa-4.c: Update.
+ * gcc.dg/ipa/ipa-5.c: Update.
+ * gcc.dg/ipa/ipa-7.c: Update.
+ * gcc.dg/ipa/ipa-8.c: Update.
+ * gcc.dg/ipa/ipcp-1.c: Update.
+ * gcc.dg/ipa/ipcp-2.c: Update.
+
2013-08-02 Vladimir Makarov <vmakarov@redhat.com>
PR rtl-optimization/58048
/* { dg-final { scan-ipa-dump "Creating a specialized node of f" "cp" } } */
-/* { dg-final { scan-ipa-dump "replacing param a with const 7" "cp" } } */
+/* { dg-final { scan-ipa-dump "replacing param .0 a with const 7" "cp" } } */
/* { dg-final { cleanup-ipa-dump "cp" } } */
/* { dg-final { scan-ipa-dump "Creating a specialized node of f" "cp" } } */
-/* { dg-final { scan-ipa-dump "replacing param a with const 7" "cp" } } */
+/* { dg-final { scan-ipa-dump "replacing param .0 a with const 7" "cp" } } */
/* { dg-final { cleanup-ipa-dump "cp" } } */
/* { dg-final { scan-ipa-dump "Creating a specialized node of f" "cp" } } */
-/* { dg-final { scan-ipa-dump "replacing param a with const 7" "cp" } } */
+/* { dg-final { scan-ipa-dump "replacing param .0 a with const 7" "cp" } } */
/* { dg-final { scan-ipa-dump "Creating a specialized node of g" "cp" } } */
-/* { dg-final { scan-ipa-dump "replacing param b with const 7" "cp" } } */
-/* { dg-final { scan-ipa-dump "replacing param c with const 3" "cp" } } */
+/* { dg-final { scan-ipa-dump "replacing param .0 b with const 7" "cp" } } */
+/* { dg-final { scan-ipa-dump "replacing param .1 c with const 3" "cp" } } */
/* { dg-final { cleanup-ipa-dump "cp" } } */
/* { dg-final { scan-ipa-dump "Creating a specialized node of f" "cp" } } */
-/* { dg-final { scan-ipa-dump-times "replacing param a with const 7" 1 "cp" } } */
+/* { dg-final { scan-ipa-dump-times "replacing param .0 a with const 7" 1 "cp" } } */
/* { dg-final { cleanup-ipa-dump "cp" } } */
}
/* { dg-final { scan-ipa-dump-times "Creating a specialized node" 3 "cp" } } */
-/* { dg-final { scan-ipa-dump "replacing param c with const 3" "cp" } } */
-/* { dg-final { scan-ipa-dump "replacing param a with const 7" "cp" } } */
+/* { dg-final { scan-ipa-dump "replacing param .1 c with const 3" "cp" } } */
+/* { dg-final { scan-ipa-dump "replacing param .0 a with const 7" "cp" } } */
/* { dg-final { cleanup-ipa-dump "cp" } } */
/* { dg-final { scan-ipa-dump "Creating a specialized node of f" "cp" } } */
-/* { dg-final { scan-ipa-dump-times "replacing param . with const 7" 1 "cp" } } */
+/* { dg-final { scan-ipa-dump-times "replacing param .. . with const 7" 1 "cp" } } */
/* { dg-final { cleanup-ipa-dump "cp" } } */
/* { dg-final { scan-ipa-dump "Creating a specialized node of f" "cp" } } */
-/* { dg-final { scan-ipa-dump "replacing param a with const 7" "cp" } } */
+/* { dg-final { scan-ipa-dump "replacing param .0 a with const 7" "cp" } } */
/* { dg-final { scan-ipa-dump "Creating a specialized node of g" "cp" } } */
-/* { dg-final { scan-ipa-dump "replacing param b with const 7" "cp" } } */
+/* { dg-final { scan-ipa-dump "replacing param .0 b with const 7" "cp" } } */
/* { dg-final { cleanup-ipa-dump "cp" } } */
/* { dg-final { scan-ipa-dump "Creating a specialized node of f.*for all known contexts" "cp" } } */
-/* { dg-final { scan-ipa-dump "replacing param a with const 7" "cp" } } */
+/* { dg-final { scan-ipa-dump "replacing param .0 a with const 7" "cp" } } */
/* { dg-final { cleanup-ipa-dump "cp" } } */
}
/* { dg-final { scan-ipa-dump-times "Creating a specialized node of foo" 1 "cp" } } */
-/* { dg-final { scan-ipa-dump-times "replacing param p with const 0" 3 "cp" } } */
-/* { dg-final { scan-ipa-dump "replacing param s with const 4" "cp" } } */
+/* { dg-final { scan-ipa-dump-times "replacing param .. p with const 0" 3 "cp" } } */
+/* { dg-final { scan-ipa-dump "replacing param .0 s with const 4" "cp" } } */
/* { dg-final { cleanup-ipa-dump "cp" } } */
/* { dg-final { scan-ipa-dump "Creating a specialized node of g1.*for all known contexts" "cp" } } */
/* { dg-final { scan-ipa-dump "Creating a specialized node of g2.*for all known contexts" "cp" } } */
/* { dg-final { scan-ipa-dump-not "Creating a specialized node of h.*for all known contexts" "cp" } } */
-/* { dg-final { scan-ipa-dump-times "replacing param a with const 7" 2 "cp" } } */
-/* { dg-final { scan-ipa-dump "replacing param a with const 11" "cp" } } */
+/* { dg-final { scan-ipa-dump-times "replacing param .0 a with const 7" 2 "cp" } } */
+/* { dg-final { scan-ipa-dump "replacing param .0 a with const 11" "cp" } } */
/* { dg-final { cleanup-ipa-dump "cp" } } */
{
int i = replace_info->parm_num;
tree parm;
+ tree req_type;
+
for (parm = DECL_ARGUMENTS (old_decl); i; parm = DECL_CHAIN (parm))
i --;
replace_info->old_tree = parm;
+ req_type = TREE_TYPE (parm);
+ if (!useless_type_conversion_p (req_type, TREE_TYPE (replace_info->new_tree)))
+ {
+ if (fold_convertible_p (req_type, replace_info->new_tree))
+ replace_info->new_tree = fold_build1 (NOP_EXPR, req_type, replace_info->new_tree);
+ else if (TYPE_SIZE (req_type) == TYPE_SIZE (TREE_TYPE (replace_info->new_tree)))
+ replace_info->new_tree = fold_build1 (VIEW_CONVERT_EXPR, req_type, replace_info->new_tree);
+ else
+ {
+ if (dump_file)
+ {
+ fprintf (dump_file, " const ");
+ print_generic_expr (dump_file, replace_info->new_tree, 0);
+ fprintf (dump_file, " can't be converted to param ");
+ print_generic_expr (dump_file, parm, 0);
+ fprintf (dump_file, "\n");
+ }
+ replace_info->old_tree = NULL;
+ }
+ }
+ }
+ else
+ gcc_assert (TREE_CODE (replace_info->old_tree) == PARM_DECL);
+ if (replace_info->old_tree)
+ {
+ init = setup_one_parameter (&id, replace_info->old_tree,
+ replace_info->new_tree, id.src_fn,
+ NULL,
+ &vars);
+ if (init)
+ init_stmts.safe_push (init);
}
- gcc_assert (TREE_CODE (replace_info->old_tree) == PARM_DECL);
- init = setup_one_parameter (&id, replace_info->old_tree,
- replace_info->new_tree, id.src_fn,
- NULL,
- &vars);
- if (init)
- init_stmts.safe_push (init);
}
}
/* Copy the function's arguments. */