diff options
author | Martin Liska <mliska@suse.cz> | 2018-09-03 09:51:56 +0200 |
---|---|---|
committer | Martin Liska <marxin@gcc.gnu.org> | 2018-09-03 07:51:56 +0000 |
commit | add4cbca8cf60d1108959de10a6c4b66d90464dc (patch) | |
tree | 42056a80e427e22c26a9f90994acf4d459f9b414 /gcc/tree-cfg.c | |
parent | 106fd43fee5e964ddf3017cfd3de1046978d490d (diff) | |
download | gcc-add4cbca8cf60d1108959de10a6c4b66d90464dc.zip gcc-add4cbca8cf60d1108959de10a6c4b66d90464dc.tar.gz gcc-add4cbca8cf60d1108959de10a6c4b66d90464dc.tar.bz2 |
Make __builtin_expect effective in switch statements (PR middle-end/PR59521).
2018-09-03 Martin Liska <mliska@suse.cz>
PR middle-end/59521
* predict.c (set_even_probabilities): Add likely_edges
argument and handle cases where we have precisely one
likely edge.
(combine_predictions_for_bb): Catch also likely_edges.
(tree_predict_by_opcode): Handle gswitch statements.
* tree-cfg.h (find_case_label_for_value): New declaration.
(find_taken_edge_switch_expr): Likewise.
* tree-switch-conversion.c (switch_decision_tree::balance_case_nodes):
Find pivot in decision tree based on probabily, not by number of
nodes.
2018-09-03 Martin Liska <mliska@suse.cz>
PR middle-end/59521
* c-c++-common/pr59521-1.c: New test.
* c-c++-common/pr59521-2.c: New test.
* gcc.dg/tree-prof/pr59521-3.c: New test.
From-SVN: r264050
Diffstat (limited to 'gcc/tree-cfg.c')
-rw-r--r-- | gcc/tree-cfg.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index cf12cb1..87979bc 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -171,8 +171,6 @@ static bool gimple_can_merge_blocks_p (basic_block, basic_block); static void remove_bb (basic_block); static edge find_taken_edge_computed_goto (basic_block, tree); static edge find_taken_edge_cond_expr (const gcond *, tree); -static edge find_taken_edge_switch_expr (const gswitch *, tree); -static tree find_case_label_for_value (const gswitch *, tree); static void lower_phi_internal_fn (); void @@ -2436,7 +2434,7 @@ find_taken_edge_cond_expr (const gcond *cond_stmt, tree val) If VAL is NULL_TREE, then the current value of SWITCH_STMT's index is used. */ -static edge +edge find_taken_edge_switch_expr (const gswitch *switch_stmt, tree val) { basic_block dest_bb; @@ -2466,7 +2464,7 @@ find_taken_edge_switch_expr (const gswitch *switch_stmt, tree val) We can make optimal use here of the fact that the case labels are sorted: We can do a binary search for a case matching VAL. */ -static tree +tree find_case_label_for_value (const gswitch *switch_stmt, tree val) { size_t low, high, n = gimple_switch_num_labels (switch_stmt); |