ipa-cp.c (update_profiling_info): Handle conversion to local profile.
authorJan Hubicka <hubicka@ucw.cz>
Fri, 17 Nov 2017 17:41:10 +0000 (18:41 +0100)
committerJan Hubicka <hubicka@gcc.gnu.org>
Fri, 17 Nov 2017 17:41:10 +0000 (17:41 +0000)
* 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
gcc/ipa-cp.c
gcc/tree-cfg.c

index 8dde55ce2f23aaf89c1e396848ad84a94763fa0e..da0066e00547579614d5b3c263c05c3abccd8e0f 100644 (file)
@@ -1,3 +1,9 @@
+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>
 
        * gimple-ssa-evrp.c (class evrp_range_analyzer): New class extracted
index bc1e3ae799d873af6eb4ee5f5a11da7fc5cf339c..4421abf0b334571baadab32f1f6597031cf31a06 100644 (file)
@@ -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);
index f44855024a32654821bda7507688a62498de54c3..491ac059c59112d36ec0e37a2224cfc278d55a39 100644 (file)
@@ -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);