OSDN Git Service

* predict.c (compute_function_frequency): Export.
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 18 Nov 2009 13:09:15 +0000 (13:09 +0000)
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 18 Nov 2009 13:09:15 +0000 (13:09 +0000)
* predict.h (compute_function_frequency): Declare.
* tree-optimize.c (execute_fixup_cfg): Rescale frequencies.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154291 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/predict.c
gcc/predict.h
gcc/tree-optimize.c

index a28276c..443ce2e 100644 (file)
@@ -1,3 +1,9 @@
+2009-11-18  Jan Hubicka  <jh@suse.cz>
+
+       * predict.c (compute_function_frequency): Export.
+       * predict.h (compute_function_frequency): Declare.
+       * tree-optimize.c (execute_fixup_cfg): Rescale frequencies.
+
 2009-11-18  Martin Jambor  <mjambor@suse.cz>
 
        * passes.c (ipa_write_summaries): Call renumber_gimple_stmt_uids
 2009-11-18  Martin Jambor  <mjambor@suse.cz>
 
        * passes.c (ipa_write_summaries): Call renumber_gimple_stmt_uids
index becff10..df85906 100644 (file)
@@ -77,7 +77,6 @@ static sreal real_zero, real_one, real_almost_one, real_br_prob_base,
 static void combine_predictions_for_insn (rtx, basic_block);
 static void dump_prediction (FILE *, enum br_predictor, int, basic_block, int);
 static void predict_paths_leading_to (basic_block, enum br_predictor, enum prediction);
 static void combine_predictions_for_insn (rtx, basic_block);
 static void dump_prediction (FILE *, enum br_predictor, int, basic_block, int);
 static void predict_paths_leading_to (basic_block, enum br_predictor, enum prediction);
-static void compute_function_frequency (void);
 static void choose_function_section (void);
 static bool can_predict_insn_p (const_rtx);
 
 static void choose_function_section (void);
 static bool can_predict_insn_p (const_rtx);
 
@@ -2145,7 +2144,7 @@ estimate_bb_frequencies (void)
 }
 
 /* Decide whether function is hot, cold or unlikely executed.  */
 }
 
 /* Decide whether function is hot, cold or unlikely executed.  */
-static void
+void
 compute_function_frequency (void)
 {
   basic_block bb;
 compute_function_frequency (void)
 {
   basic_block bb;
index 0e04041..18e57d7 100644 (file)
@@ -41,5 +41,6 @@ extern void estimate_bb_frequencies (void);
 extern const char *predictor_name (enum br_predictor);
 extern tree build_predict_expr (enum br_predictor, enum prediction);
 extern void tree_estimate_probability (void);
 extern const char *predictor_name (enum br_predictor);
 extern tree build_predict_expr (enum br_predictor, enum prediction);
 extern void tree_estimate_probability (void);
+extern void compute_function_frequency (void);
 
 #endif  /* GCC_PREDICT_H */
 
 #endif  /* GCC_PREDICT_H */
index 7affd16..61d687d 100644 (file)
@@ -245,36 +245,51 @@ execute_fixup_cfg (void)
   basic_block bb;
   gimple_stmt_iterator gsi;
   int todo = gimple_in_ssa_p (cfun) ? TODO_verify_ssa : 0;
   basic_block bb;
   gimple_stmt_iterator gsi;
   int todo = gimple_in_ssa_p (cfun) ? TODO_verify_ssa : 0;
+  gcov_type count_scale;
+  edge e;
+  edge_iterator ei;
 
 
-  if (cfun->eh)
-    FOR_EACH_BB (bb)
-      {
-       for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
-         {
-           gimple stmt = gsi_stmt (gsi);
-           tree decl = is_gimple_call (stmt)
-                       ? gimple_call_fndecl (stmt)
-                       : NULL;
-
-           if (decl
-               && gimple_call_flags (stmt) & (ECF_CONST
-                                              | ECF_PURE 
-                                              | ECF_LOOPING_CONST_OR_PURE))
-             {
-               if (gimple_in_ssa_p (cfun))
-                 {
-                   todo |= TODO_update_ssa | TODO_cleanup_cfg;
-                   mark_symbols_for_renaming (stmt);
-                   update_stmt (stmt);
-                 }
-             }
-
-           maybe_clean_eh_stmt (stmt);
-         }
-
-       if (gimple_purge_dead_eh_edges (bb))
-          todo |= TODO_cleanup_cfg;
-      }
+  if (ENTRY_BLOCK_PTR->count)
+    count_scale = (cgraph_node (current_function_decl)->count * REG_BR_PROB_BASE
+                  + ENTRY_BLOCK_PTR->count / 2) / ENTRY_BLOCK_PTR->count;
+  else
+    count_scale = REG_BR_PROB_BASE;
+
+  FOR_EACH_BB (bb)
+    {
+      bb->count = (bb->count * count_scale
+                  + REG_BR_PROB_BASE / 2) / REG_BR_PROB_BASE;
+      for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
+       {
+         gimple stmt = gsi_stmt (gsi);
+         tree decl = is_gimple_call (stmt)
+                     ? gimple_call_fndecl (stmt)
+                     : NULL;
+
+         if (decl
+             && gimple_call_flags (stmt) & (ECF_CONST
+                                            | ECF_PURE 
+                                            | ECF_LOOPING_CONST_OR_PURE))
+           {
+             if (gimple_in_ssa_p (cfun))
+               {
+                 todo |= TODO_update_ssa | TODO_cleanup_cfg;
+                 mark_symbols_for_renaming (stmt);
+                 update_stmt (stmt);
+               }
+           }
+
+         maybe_clean_eh_stmt (stmt);
+       }
+
+      if (gimple_purge_dead_eh_edges (bb))
+       todo |= TODO_cleanup_cfg;
+      FOR_EACH_EDGE (e, ei, bb->succs)
+        e->count = (e->count * count_scale
+                   + REG_BR_PROB_BASE / 2) / REG_BR_PROB_BASE;
+    }
+  if (count_scale != REG_BR_PROB_BASE)
+    compute_function_frequency ();
 
   /* Dump a textual representation of the flowgraph.  */
   if (dump_file)
 
   /* Dump a textual representation of the flowgraph.  */
   if (dump_file)