ipa-cp.c (ipcp_compute_node_scale): Work around completely wrong profile updates.
authorJan Hubicka <jh@suse.cz>
Mon, 23 Nov 2009 20:01:29 +0000 (21:01 +0100)
committerJan Hubicka <hubicka@gcc.gnu.org>
Mon, 23 Nov 2009 20:01:29 +0000 (20:01 +0000)
* ipa-cp.c (ipcp_compute_node_scale): Work around completely
wrong profile updates.
* predict.c (counts_to_freqs): Be expected for ENTRY/EXIT block
having largest frequency.
* ira-live.c (ira_implicitly_set_insn_hard_regs): Silecne
used uninitalized warning.
* tree-optimize.c (execute_fixup_cfg): Rescale entry and exit block
frequencies.

From-SVN: r154462

gcc/ChangeLog
gcc/ipa-cp.c
gcc/ira-lives.c
gcc/predict.c
gcc/tree-optimize.c

index bce59754feb3e2ac2842a3a8bbd968a873e2b21d..b8378a58b12bdd42e2c8f746eae87415850620d5 100644 (file)
@@ -1,3 +1,14 @@
+2009-11-23  Jan Hubicka  <jh@suse.cz>
+
+       * ipa-cp.c (ipcp_compute_node_scale): Work around completely
+       wrong profile updates.
+       * predict.c (counts_to_freqs): Be expected for ENTRY/EXIT block
+       having largest frequency.
+       * ira-live.c (ira_implicitly_set_insn_hard_regs): Silecne
+       used uninitalized warning.
+       * tree-optimize.c (execute_fixup_cfg): Rescale entry and exit block
+       frequencies.
+
 2009-11-23  Uros Bizjak  <ubizjak@gmail.com>
 
        * config/alpha/alpha.md (*cmp_sadd_sidi): Use gen_lowpart instead
index 4b632c0d9fb52389d84a9a99e4516bfc00b0bf7f..2af2c7f2d6fb9abc167aec4eda5f6c6e2f85a8bd 100644 (file)
@@ -578,7 +578,13 @@ build_const_val (struct ipcp_lattice *lat, tree tree_type)
 
 /* Compute the proper scale for NODE.  It is the ratio between the number of
    direct calls (represented on the incoming cgraph_edges) and sum of all
-   invocations of NODE (represented as count in cgraph_node).  */
+   invocations of NODE (represented as count in cgraph_node).
+
+   FIXME: This code is wrong.  Since the callers can be also clones and
+   the clones are not scaled yet, the sums gets unrealistically high.
+   To properly compute the counts, we would need to do propagation across
+   callgraph (as external call to A might imply call to non-clonned B
+   if A's clone calls clonned B).  */
 static void
 ipcp_compute_node_scale (struct cgraph_node *node)
 {
@@ -589,6 +595,12 @@ ipcp_compute_node_scale (struct cgraph_node *node)
   /* Compute sum of all counts of callers. */
   for (cs = node->callers; cs != NULL; cs = cs->next_caller)
     sum += cs->count;
+  /* Work around the unrealistically high sum problem.  We just don't want
+     the non-cloned body to have negative or very low frequency.  Since
+     majority of execution time will be spent in clones anyway, this should
+     give good enough profile.  */
+  if (sum > node->count * 9 / 10)
+    sum = node->count * 9 / 10;
   if (node->count == 0)
     ipcp_set_node_scale (node, 0);
   else
index c67e89cbd792dfd06aadab11000fc6d5898eb471..ea241f4732cad0d407106dad2455ff8ccea37f9f 100644 (file)
@@ -745,7 +745,7 @@ single_reg_operand_class (int op_num)
 void
 ira_implicitly_set_insn_hard_regs (HARD_REG_SET *set)
 {
-  int i, c, regno;
+  int i, c, regno = 0;
   bool ignore_p;
   enum reg_class cl;
   rtx op;
index df859066b96bdc1b599014d9b608047a9d004321..058901e5903d2813fff149b51676caf30bb67735 100644 (file)
@@ -2020,7 +2020,7 @@ counts_to_freqs (void)
   gcov_type count_max, true_count_max = 0;
   basic_block bb;
 
-  FOR_EACH_BB (bb)
+  FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb)
     true_count_max = MAX (bb->count, true_count_max);
 
   count_max = MAX (true_count_max, 1);
index 61d687daa13a22cb92575f04e58d236ea5e2e8cb..778658a70b47dc1cbb2b78f211b7a41dd570b021 100644 (file)
@@ -255,6 +255,10 @@ execute_fixup_cfg (void)
   else
     count_scale = REG_BR_PROB_BASE;
 
+  ENTRY_BLOCK_PTR->count = cgraph_node (current_function_decl)->count;
+  EXIT_BLOCK_PTR->count = (EXIT_BLOCK_PTR->count * count_scale
+                          + REG_BR_PROB_BASE / 2) / REG_BR_PROB_BASE;
+
   FOR_EACH_BB (bb)
     {
       bb->count = (bb->count * count_scale