diff options
author | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-08-29 08:40:01 +0000 |
---|---|---|
committer | hubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-08-29 08:40:01 +0000 |
commit | 1add270f257ff60ccd170441dc267fbdd2f3ba73 (patch) | |
tree | 42efa153d20247d1235c077d9e83fe93cb6e2be6 /gcc/predict.c | |
parent | eb8b313af81929e569d7729872ebb95db543c480 (diff) | |
download | gcc-1add270f257ff60ccd170441dc267fbdd2f3ba73.tar.gz |
* cp-gimplify.c (cp_gimplify_expr): Add PRED_CONTINUE heuristic.
* tree-pass.h (pass_strip_predict_hints): Declare.
* predict.c (strip_builtin_expect): Rename to ...
(strip_predict_hints): ... this one; strip also GIMPLE_PREDICT.
(tree_bb_level_predictions): Do not remove GIMPLE_PREDICT.
(tree_estimate_probability): Do not strip builtin_expect.
(pass_strip_predict_hints): New pass.
* tree-inline.c (expand_call_inline): When inlining cold function, predict
it as unlikely.
* passes.c (init_optimization_passes): Add pass_strip_predict_hints.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@139755 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/predict.c')
-rw-r--r-- | gcc/predict.c | 69 |
1 files changed, 46 insertions, 23 deletions
diff --git a/gcc/predict.c b/gcc/predict.c index 69ebe6b98b3..610772314b3 100644 --- a/gcc/predict.c +++ b/gcc/predict.c @@ -1176,9 +1176,10 @@ expr_expected_value (tree expr, bitmap visited) } -/* Get rid of all builtin_expect calls we no longer need. */ -static void -strip_builtin_expect (void) +/* Get rid of all builtin_expect calls and GIMPLE_PREDICT statements + we no longer need. */ +static unsigned int +strip_predict_hints (void) { basic_block bb; gimple ass_stmt; @@ -1187,28 +1188,34 @@ strip_builtin_expect (void) FOR_EACH_BB (bb) { gimple_stmt_iterator bi; - for (bi = gsi_start_bb (bb); !gsi_end_p (bi); gsi_next (&bi)) + for (bi = gsi_start_bb (bb); !gsi_end_p (bi);) { gimple stmt = gsi_stmt (bi); - tree fndecl; - - if (gimple_code (stmt) != GIMPLE_CALL) - continue; - fndecl = gimple_call_fndecl (stmt); - - if (fndecl - && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL - && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_EXPECT - && gimple_call_num_args (stmt) == 2) + if (gimple_code (stmt) == GIMPLE_PREDICT) + { + gsi_remove (&bi, true); + continue; + } + else if (gimple_code (stmt) == GIMPLE_CALL) { - var = gimple_call_lhs (stmt); - ass_stmt = gimple_build_assign (var, gimple_call_arg (stmt, 0)); + tree fndecl = gimple_call_fndecl (stmt); - gsi_replace (&bi, ass_stmt, true); + if (fndecl + && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL + && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_EXPECT + && gimple_call_num_args (stmt) == 2) + { + var = gimple_call_lhs (stmt); + ass_stmt = gimple_build_assign (var, gimple_call_arg (stmt, 0)); + + gsi_replace (&bi, ass_stmt, true); + } } + gsi_next (&bi); } } + return 0; } /* Predict using opcode of the last statement in basic block. */ @@ -1434,7 +1441,7 @@ tree_bb_level_predictions (void) { gimple_stmt_iterator gsi; - for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi);) + for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi)) { gimple stmt = gsi_stmt (gsi); tree decl; @@ -1455,11 +1462,9 @@ tree_bb_level_predictions (void) { predict_paths_leading_to (bb, gimple_predict_predictor (stmt), gimple_predict_outcome (stmt)); - gsi_remove (&gsi, true); - continue; + /* Keep GIMPLE_PREDICT around so early inlining will propagate + hints to callers. */ } - - gsi_next (&gsi); } } } @@ -1587,7 +1592,6 @@ tree_estimate_probability (void) pointer_map_destroy (bb_predictions); bb_predictions = NULL; - strip_builtin_expect (); estimate_bb_frequencies (); free_dominance_info (CDI_POST_DOMINATORS); remove_fake_exit_edges (); @@ -2084,3 +2088,22 @@ struct gimple_opt_pass pass_profile = TODO_ggc_collect | TODO_verify_ssa /* todo_flags_finish */ } }; + +struct gimple_opt_pass pass_strip_predict_hints = +{ + { + GIMPLE_PASS, + "", /* name */ + NULL, /* gate */ + strip_predict_hints, /* execute */ + NULL, /* sub */ + NULL, /* next */ + 0, /* static_pass_number */ + TV_BRANCH_PROB, /* tv_id */ + PROP_cfg, /* properties_required */ + 0, /* properties_provided */ + 0, /* properties_destroyed */ + 0, /* todo_flags_start */ + TODO_ggc_collect | TODO_verify_ssa /* todo_flags_finish */ + } +}; |