From 0e8853eefb91d4a81bb45eb25db4dd95dc2cf1c4 Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Sat, 3 Aug 2013 10:23:55 +0200 Subject: [PATCH] ipa-cp.c (gather_context_independent_values): Use ipa_get_param_move_cost. * 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 --- gcc/ChangeLog | 22 ++++++++++++ gcc/ipa-cp.c | 51 ++++++++------------------ gcc/ipa-inline-analysis.c | 5 +-- gcc/ipa-prop.c | 59 +++++++++++++++++++++---------- gcc/ipa-prop.h | 12 +++++++ gcc/testsuite/ChangeLog | 12 +++++++ gcc/testsuite/gcc.dg/ipa/ipa-1.c | 2 +- gcc/testsuite/gcc.dg/ipa/ipa-2.c | 2 +- gcc/testsuite/gcc.dg/ipa/ipa-3.c | 6 ++-- gcc/testsuite/gcc.dg/ipa/ipa-4.c | 2 +- gcc/testsuite/gcc.dg/ipa/ipa-5.c | 4 +-- gcc/testsuite/gcc.dg/ipa/ipa-7.c | 2 +- gcc/testsuite/gcc.dg/ipa/ipa-8.c | 4 +-- gcc/testsuite/gcc.dg/ipa/ipcp-1.c | 2 +- gcc/testsuite/gcc.dg/ipa/ipcp-2.c | 4 +-- gcc/testsuite/gcc.dg/ipa/ipcp-4.c | 4 +-- gcc/tree-inline.c | 40 +++++++++++++++++---- 17 files changed, 153 insertions(+), 80 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9d6a6c8921a..f54c696bcf1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,25 @@ +2013-08-02 Jan Hubicka + + * 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 PR rtl-optimization/58048 diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c index 73f9d6ed4aa..b463a62f72a 100644 --- a/gcc/ipa-cp.c +++ b/gcc/ipa-cp.c @@ -1758,13 +1758,12 @@ gather_context_independent_values (struct ipa_node_params *info, } 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) { @@ -1933,8 +1932,8 @@ estimate_local_effects (struct cgraph_node *node) { 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); } @@ -1990,8 +1989,8 @@ estimate_local_effects (struct cgraph_node *node) { 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 " : "", @@ -2480,36 +2479,17 @@ gather_edges_for_value (struct ipcp_value *val, int caller_count) 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"); @@ -2697,7 +2677,7 @@ create_specialized_node (struct cgraph_node *node, { 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); } @@ -2781,8 +2761,8 @@ find_more_scalar_values_for_callers_subset (struct cgraph_node *node, { 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"); } @@ -3352,9 +3332,8 @@ decide_about_value (struct cgraph_node *node, int index, HOST_WIDE_INT offset, { 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); diff --git a/gcc/ipa-inline-analysis.c b/gcc/ipa-inline-analysis.c index 9a3629285fb..518d3b99ba9 100644 --- a/gcc/ipa-inline-analysis.c +++ b/gcc/ipa-inline-analysis.c @@ -1101,12 +1101,13 @@ inline_node_duplication_hook (struct cgraph_node *src, 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; diff --git a/gcc/ipa-prop.c b/gcc/ipa-prop.c index bf9e903ca80..ef4dff72542 100644 --- a/gcc/ipa-prop.c +++ b/gcc/ipa-prop.c @@ -130,16 +130,14 @@ ipa_populate_param_decls (struct cgraph_node *node, 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++; } } @@ -151,6 +149,7 @@ count_formal_params (tree fndecl) { tree parm; int count = 0; + gcc_assert (gimple_has_body_p (fndecl)); for (parm = DECL_ARGUMENTS (fndecl); parm; parm = DECL_CHAIN (parm)) count++; @@ -158,6 +157,33 @@ count_formal_params (tree fndecl) 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. */ @@ -169,15 +195,8 @@ ipa_initialize_node_params (struct cgraph_node *node) 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); } } @@ -3064,6 +3083,7 @@ ipa_get_vector_of_formal_parms (tree fndecl) 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)) @@ -3856,6 +3876,9 @@ ipa_write_node_info (struct output_block *ob, struct cgraph_node *node) 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); @@ -3896,8 +3919,11 @@ ipa_read_node_info (struct lto_input_block *ib, struct cgraph_node *node, 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; @@ -4049,13 +4075,8 @@ ipa_prop_read_jump_functions (void) 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 diff --git a/gcc/ipa-prop.h b/gcc/ipa-prop.h index e3836e0d09a..2ccac2f3ede 100644 --- a/gcc/ipa-prop.h +++ b/gcc/ipa-prop.h @@ -320,6 +320,7 @@ struct ipa_param_descriptor 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; }; @@ -377,9 +378,19 @@ ipa_get_param_count (struct ipa_node_params *info) 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. */ @@ -653,6 +664,7 @@ int ipa_get_param_decl_index (struct ipa_node_params *, tree); 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: */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f5ec9cff0a5..2f942edede6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,15 @@ +2013-08-02 Jan Hubicka + + * 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 PR rtl-optimization/58048 diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-1.c b/gcc/testsuite/gcc.dg/ipa/ipa-1.c index 3517b035f1c..3cc32da1c98 100644 --- a/gcc/testsuite/gcc.dg/ipa/ipa-1.c +++ b/gcc/testsuite/gcc.dg/ipa/ipa-1.c @@ -25,7 +25,7 @@ int main () /* { 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" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-2.c b/gcc/testsuite/gcc.dg/ipa/ipa-2.c index 122a4a0181a..7f14d42a03a 100644 --- a/gcc/testsuite/gcc.dg/ipa/ipa-2.c +++ b/gcc/testsuite/gcc.dg/ipa/ipa-2.c @@ -23,5 +23,5 @@ int main () /* { 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" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-3.c b/gcc/testsuite/gcc.dg/ipa/ipa-3.c index e15f084b400..36fd5067892 100644 --- a/gcc/testsuite/gcc.dg/ipa/ipa-3.c +++ b/gcc/testsuite/gcc.dg/ipa/ipa-3.c @@ -29,8 +29,8 @@ int main () /* { 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" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-4.c b/gcc/testsuite/gcc.dg/ipa/ipa-4.c index 88716dd8f4c..566b3297136 100644 --- a/gcc/testsuite/gcc.dg/ipa/ipa-4.c +++ b/gcc/testsuite/gcc.dg/ipa/ipa-4.c @@ -26,5 +26,5 @@ int main () /* { 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" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-5.c b/gcc/testsuite/gcc.dg/ipa/ipa-5.c index d599d3187fe..daa64fada6f 100644 --- a/gcc/testsuite/gcc.dg/ipa/ipa-5.c +++ b/gcc/testsuite/gcc.dg/ipa/ipa-5.c @@ -28,6 +28,6 @@ int main () } /* { 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" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-7.c b/gcc/testsuite/gcc.dg/ipa/ipa-7.c index c8b510046a1..271a34a3d60 100644 --- a/gcc/testsuite/gcc.dg/ipa/ipa-7.c +++ b/gcc/testsuite/gcc.dg/ipa/ipa-7.c @@ -27,7 +27,7 @@ int main () /* { 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" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-8.c b/gcc/testsuite/gcc.dg/ipa/ipa-8.c index dcbed13a0ed..d138cf26330 100644 --- a/gcc/testsuite/gcc.dg/ipa/ipa-8.c +++ b/gcc/testsuite/gcc.dg/ipa/ipa-8.c @@ -23,9 +23,9 @@ int main () /* { 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" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/ipcp-1.c b/gcc/testsuite/gcc.dg/ipa/ipcp-1.c index 0f50ff9276a..a2ffd420203 100644 --- a/gcc/testsuite/gcc.dg/ipa/ipcp-1.c +++ b/gcc/testsuite/gcc.dg/ipa/ipcp-1.c @@ -46,7 +46,7 @@ main (int argc, char *argv[]) /* { 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" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/ipcp-2.c b/gcc/testsuite/gcc.dg/ipa/ipcp-2.c index c6dcdf0af52..62f564f216a 100644 --- a/gcc/testsuite/gcc.dg/ipa/ipcp-2.c +++ b/gcc/testsuite/gcc.dg/ipa/ipcp-2.c @@ -94,6 +94,6 @@ top2 (int q) } /* { 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" } } */ diff --git a/gcc/testsuite/gcc.dg/ipa/ipcp-4.c b/gcc/testsuite/gcc.dg/ipa/ipcp-4.c index 59018ca6b1e..462cade498e 100644 --- a/gcc/testsuite/gcc.dg/ipa/ipcp-4.c +++ b/gcc/testsuite/gcc.dg/ipa/ipcp-4.c @@ -61,8 +61,8 @@ main (int argc, char *argv[]) /* { 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" } } */ diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c index be3917a32e3..2ebcd0d7a3e 100644 --- a/gcc/tree-inline.c +++ b/gcc/tree-inline.c @@ -5150,17 +5150,43 @@ tree_function_versioning (tree old_decl, tree new_decl, { 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. */