Hi,
when splitting functions, tree-inline determined correctly entry count of the
new function part, but then in case entry block of new function part is in a
loop it scales body which is not suposed to happen.

Bootstrapped/regtested x86_64-linux, comitted.

        * tree-inline.cc (copy_cfg_body): Fix profile of split functions.

diff --git a/gcc/tree-inline.cc b/gcc/tree-inline.cc
index b2570517343..dee2dfc2620 100644
--- a/gcc/tree-inline.cc
+++ b/gcc/tree-inline.cc
@@ -3084,7 +3084,7 @@ copy_cfg_body (copy_body_data * id,
   /* Register specific tree functions.  */
   gimple_register_cfg_hooks ();
 
-  /* If we are inlining just region of the function, make sure to connect
+  /* If we are offlining region of the function, make sure to connect
      new entry to ENTRY_BLOCK_PTR_FOR_FN (cfun).  Since new entry can be
      part of loop, we must compute frequency and probability of
      ENTRY_BLOCK_PTR_FOR_FN (cfun) based on the frequencies and
@@ -3093,12 +3093,14 @@ copy_cfg_body (copy_body_data * id,
     {
       edge e;
       edge_iterator ei;
-      den = profile_count::zero ();
+      ENTRY_BLOCK_PTR_FOR_FN (cfun)->count = profile_count::zero ();
 
       FOR_EACH_EDGE (e, ei, new_entry->preds)
        if (!e->src->aux)
-         den += e->count ();
-      ENTRY_BLOCK_PTR_FOR_FN (cfun)->count = den;
+         ENTRY_BLOCK_PTR_FOR_FN (cfun)->count += e->count ();
+      /* Do not scale - the profile of offlined region should
+        remain unchanged.  */
+      num = den = profile_count::one ();
     }
 
   profile_count::adjust_for_ipa_scaling (&num, &den);

Reply via email to