From 35cd23ebb6d05e1325bd165679be44192f51ba05 Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Fri, 17 Nov 2017 18:41:10 +0100 Subject: [PATCH] ipa-cp.c (update_profiling_info): Handle conversion to local profile. * ipa-cp.c (update_profiling_info): Handle conversion to local profile. * tree-cfg.c (execute_fixup_cfg): Do fixup same way as inliner does. From-SVN: r254885 --- gcc/ChangeLog | 6 ++++++ gcc/ipa-cp.c | 20 +++++++++++++------- gcc/tree-cfg.c | 17 ++++------------- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8dde55ce2f2..da0066e0054 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2017-11-17 Jan Hubicka + + * ipa-cp.c (update_profiling_info): Handle conversion to local + profile. + * tree-cfg.c (execute_fixup_cfg): Do fixup same way as inliner does. + 2017-11-17 Jeff Law * gimple-ssa-evrp.c (class evrp_range_analyzer): New class extracted diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c index bc1e3ae799d..4421abf0b33 100644 --- a/gcc/ipa-cp.c +++ b/gcc/ipa-cp.c @@ -3695,16 +3695,22 @@ update_profiling_info (struct cgraph_node *orig_node, } } - new_node->count = new_sum; - remainder = orig_node_count - new_sum; + if (!new_sum.nonzero_p ()) + { + new_sum = new_sum.global0 (); + new_node->count = new_sum; + remainder = orig_node->count; + } + else + { + remainder = orig_node_count - new_sum; + if (!remainder.nonzero_p ()) + remainder = orig_node_count.global0 (); + } orig_node->count = remainder; for (cs = new_node->callees; cs; cs = cs->next_callee) - /* FIXME: why we care about non-zero frequency here? */ - if (cs->frequency ()) - cs->count = cs->count.apply_scale (new_sum, orig_node_count); - else - cs->count = profile_count::zero (); + cs->count = cs->count.apply_scale (new_sum, orig_node_count); for (cs = orig_node->callees; cs; cs = cs->next_callee) cs->count = cs->count.apply_scale (remainder, orig_node_count); diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index f44855024a3..491ac059c59 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -9227,14 +9227,13 @@ execute_fixup_cfg (void) gimple_stmt_iterator gsi; int todo = 0; cgraph_node *node = cgraph_node::get (current_function_decl); - profile_count num = node->count.ipa (); + profile_count num = node->count; profile_count den = ENTRY_BLOCK_PTR_FOR_FN (cfun)->count; - bool scale = num.initialized_p () && den.ipa_p () - && (den.nonzero_p () || num == profile_count::zero ()) - && !(num == den.ipa ()); + bool scale = num.initialized_p () && !(num == den); if (scale) { + profile_count::adjust_for_ipa_scaling (&num, &den); ENTRY_BLOCK_PTR_FOR_FN (cfun)->count = node->count; EXIT_BLOCK_PTR_FOR_FN (cfun)->count = EXIT_BLOCK_PTR_FOR_FN (cfun)->count.apply_scale (num, den); @@ -9243,15 +9242,7 @@ execute_fixup_cfg (void) FOR_EACH_BB_FN (bb, cfun) { if (scale) - { - if (num == profile_count::zero ()) - { - if (!(bb->count == profile_count::zero ())) - bb->count = bb->count.global0 (); - } - else - bb->count = bb->count.apply_scale (num, den); - } + bb->count = bb->count.apply_scale (num, den); for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi);) { gimple *stmt = gsi_stmt (gsi); -- 2.30.2