cgraphbuild.c (compute_call_stmt_bb_frequency): Use counts when these are more inform...
authorJan Hubicka <hubicka@ucw.cz>
Mon, 12 Oct 2015 06:08:06 +0000 (08:08 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Mon, 12 Oct 2015 06:08:06 +0000 (06:08 +0000)
* cgraphbuild.c (compute_call_stmt_bb_frequency): Use
counts when these are more informative.

From-SVN: r228703

gcc/ChangeLog
gcc/cgraphbuild.c

index 931dedeec604e40e4eeff7c671ab3e113fd4fa5e..5d38bf67c982916cadb9d90d72b9a567d3c38390 100644 (file)
@@ -1,3 +1,8 @@
+2015-10-11  Jan Hubicka  <hubicka@ucw.cz>
+
+       * cgraphbuild.c (compute_call_stmt_bb_frequency): Use
+       counts when these are more informative.
+
 2015-10-11  Jan Hubicka  <hubicka@ucw.cz>
 
        * tree-profile.c (tree_profiling): Do not clear
index 33b01be83acfdd456514aaaf9cbb66ed1664ca86..a7b4af6d9fb3aa44347f8ea5ae1a7be83bd6d013 100644 (file)
@@ -202,15 +202,21 @@ compute_call_stmt_bb_frequency (tree decl, basic_block bb)
 {
   int entry_freq = ENTRY_BLOCK_PTR_FOR_FN
                     (DECL_STRUCT_FUNCTION (decl))->frequency;
-  int freq = bb->frequency;
+  gcov_type entry_count = ENTRY_BLOCK_PTR_FOR_FN
+                           (DECL_STRUCT_FUNCTION (decl))->count;
+  gcov_type freq = bb->frequency;
 
   if (profile_status_for_fn (DECL_STRUCT_FUNCTION (decl)) == PROFILE_ABSENT)
     return CGRAPH_FREQ_BASE;
 
-  if (!entry_freq)
-    entry_freq = 1, freq++;
-
-  freq = freq * CGRAPH_FREQ_BASE / entry_freq;
+  if (entry_count > entry_freq)
+    freq = RDIV (bb->count * CGRAPH_FREQ_BASE, entry_count);
+  else
+    {
+      if (!entry_freq)
+        entry_freq = 1, freq++;
+      freq = RDIV (freq * CGRAPH_FREQ_BASE, entry_freq);
+    }
   if (freq > CGRAPH_FREQ_MAX)
     freq = CGRAPH_FREQ_MAX;