Commit 35cd23eb by Jan Hubicka Committed by Jan Hubicka

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
parent 6566b0fb
2017-11-17 Jan Hubicka <hubicka@ucw.cz>
* 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 <law@redhat.com> 2017-11-17 Jeff Law <law@redhat.com>
* gimple-ssa-evrp.c (class evrp_range_analyzer): New class extracted * gimple-ssa-evrp.c (class evrp_range_analyzer): New class extracted
...@@ -3695,16 +3695,22 @@ update_profiling_info (struct cgraph_node *orig_node, ...@@ -3695,16 +3695,22 @@ update_profiling_info (struct cgraph_node *orig_node,
} }
} }
new_node->count = new_sum; if (!new_sum.nonzero_p ())
remainder = orig_node_count - new_sum; {
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; orig_node->count = remainder;
for (cs = new_node->callees; cs; cs = cs->next_callee) for (cs = new_node->callees; cs; cs = cs->next_callee)
/* FIXME: why we care about non-zero frequency here? */ cs->count = cs->count.apply_scale (new_sum, orig_node_count);
if (cs->frequency ())
cs->count = cs->count.apply_scale (new_sum, orig_node_count);
else
cs->count = profile_count::zero ();
for (cs = orig_node->callees; cs; cs = cs->next_callee) for (cs = orig_node->callees; cs; cs = cs->next_callee)
cs->count = cs->count.apply_scale (remainder, orig_node_count); cs->count = cs->count.apply_scale (remainder, orig_node_count);
......
...@@ -9227,14 +9227,13 @@ execute_fixup_cfg (void) ...@@ -9227,14 +9227,13 @@ execute_fixup_cfg (void)
gimple_stmt_iterator gsi; gimple_stmt_iterator gsi;
int todo = 0; int todo = 0;
cgraph_node *node = cgraph_node::get (current_function_decl); 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; profile_count den = ENTRY_BLOCK_PTR_FOR_FN (cfun)->count;
bool scale = num.initialized_p () && den.ipa_p () bool scale = num.initialized_p () && !(num == den);
&& (den.nonzero_p () || num == profile_count::zero ())
&& !(num == den.ipa ());
if (scale) if (scale)
{ {
profile_count::adjust_for_ipa_scaling (&num, &den);
ENTRY_BLOCK_PTR_FOR_FN (cfun)->count = node->count; ENTRY_BLOCK_PTR_FOR_FN (cfun)->count = node->count;
EXIT_BLOCK_PTR_FOR_FN (cfun)->count EXIT_BLOCK_PTR_FOR_FN (cfun)->count
= EXIT_BLOCK_PTR_FOR_FN (cfun)->count.apply_scale (num, den); = EXIT_BLOCK_PTR_FOR_FN (cfun)->count.apply_scale (num, den);
...@@ -9243,15 +9242,7 @@ execute_fixup_cfg (void) ...@@ -9243,15 +9242,7 @@ execute_fixup_cfg (void)
FOR_EACH_BB_FN (bb, cfun) FOR_EACH_BB_FN (bb, cfun)
{ {
if (scale) if (scale)
{ bb->count = bb->count.apply_scale (num, den);
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);
}
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi);) for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi);)
{ {
gimple *stmt = gsi_stmt (gsi); gimple *stmt = gsi_stmt (gsi);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment