summaryrefslogtreecommitdiff
path: root/gcc/tree-cfgcleanup.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/tree-cfgcleanup.c')
-rw-r--r--gcc/tree-cfgcleanup.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/gcc/tree-cfgcleanup.c b/gcc/tree-cfgcleanup.c
index 8bb5e237395..c6e5c8da03c 100644
--- a/gcc/tree-cfgcleanup.c
+++ b/gcc/tree-cfgcleanup.c
@@ -155,8 +155,6 @@ cleanup_control_expr_graph (basic_block bb, gimple_stmt_iterator gsi,
}
if (!warned)
fold_undefer_and_ignore_overflow_warnings ();
- if (taken_edge->probability > REG_BR_PROB_BASE)
- taken_edge->probability = REG_BR_PROB_BASE;
}
else
taken_edge = single_succ_edge (bb);
@@ -638,6 +636,19 @@ fixup_noreturn_call (gimple *stmt)
return changed;
}
+/* Return true if we want to merge BB1 and BB2 into a single block. */
+
+static bool
+want_merge_blocks_p (basic_block bb1, basic_block bb2)
+{
+ if (!can_merge_blocks_p (bb1, bb2))
+ return false;
+ gimple_stmt_iterator gsi = gsi_last_nondebug_bb (bb1);
+ if (gsi_end_p (gsi) || !stmt_can_terminate_bb_p (gsi_stmt (gsi)))
+ return true;
+ return bb1->count.ok_for_merging (bb2->count);
+}
+
/* Tries to cleanup cfg in basic block BB. Returns true if anything
changes. */
@@ -654,7 +665,7 @@ cleanup_tree_cfg_bb (basic_block bb)
This happens when we visit BBs in a non-optimal order and
avoids quadratic behavior with adjusting stmts BB pointer. */
if (single_pred_p (bb)
- && can_merge_blocks_p (single_pred (bb), bb))
+ && want_merge_blocks_p (single_pred (bb), bb))
/* But make sure we _do_ visit it. When we remove unreachable paths
ending in a backedge we fail to mark the destinations predecessors
as changed. */
@@ -664,7 +675,7 @@ cleanup_tree_cfg_bb (basic_block bb)
conditional branches (due to the elimination of single-valued PHI
nodes). */
else if (single_succ_p (bb)
- && can_merge_blocks_p (bb, single_succ (bb)))
+ && want_merge_blocks_p (bb, single_succ (bb)))
{
merge_blocks (bb, single_succ (bb));
return true;
@@ -1205,7 +1216,8 @@ execute_cleanup_cfg_post_optimizing (void)
}
maybe_remove_unreachable_handlers ();
cleanup_dead_labels ();
- group_case_labels ();
+ if (group_case_labels ())
+ todo |= TODO_cleanup_cfg;
if ((flag_compare_debug_opt || flag_compare_debug)
&& flag_dump_final_insns)
{