summaryrefslogtreecommitdiff
path: root/gcc/tree-optimize.c
diff options
context:
space:
mode:
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2009-11-18 13:09:15 +0000
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2009-11-18 13:09:15 +0000
commit63aab97df901f60f2e854e6ad3e7e47fd72e74ae (patch)
tree5ccc2b57b37b756a5c2cf26a4da08e0c6de03283 /gcc/tree-optimize.c
parent8e78b58c2aa924fed285f175b325da48f2f4e631 (diff)
downloadgcc-63aab97df901f60f2e854e6ad3e7e47fd72e74ae.tar.gz
* predict.c (compute_function_frequency): Export.
* 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
Diffstat (limited to 'gcc/tree-optimize.c')
-rw-r--r--gcc/tree-optimize.c73
1 files changed, 44 insertions, 29 deletions
diff --git a/gcc/tree-optimize.c b/gcc/tree-optimize.c
index 7affd1627c5..61d687daa13 100644
--- a/gcc/tree-optimize.c
+++ b/gcc/tree-optimize.c
@@ -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;
+ 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)