This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Fix profile updating in ipa-cp and fixup_cfg
- From: Jan Hubicka <hubicka at ucw dot cz>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 17 Nov 2017 20:48:08 +0100
- Subject: Fix profile updating in ipa-cp and fixup_cfg
- Authentication-results: sourceware.org; auth=none
Hi,
this patch makes ipa-cp to not drop profile to 0 when clonning across
all active apths and tree-cfg to do same profile updating as tree-inline.
I will factor out the common code as a followup.
Bootstrapped/regtested x86_64-linux.
* ipa-cp.c (update_profiling_info): Handle conversion to local
profile.
* tree-cfg.c (execute_fixup_cfg): Do fixup same way as inliner does.
Index: ipa-cp.c
===================================================================
--- ipa-cp.c (revision 254884)
+++ ipa-cp.c (working copy)
@@ -3695,16 +3695,22 @@ update_profiling_info (struct cgraph_nod
}
}
- 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);
Index: tree-cfg.c
===================================================================
--- tree-cfg.c (revision 254884)
+++ tree-cfg.c (working copy)
@@ -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);