@@ -1338,13 +1338,13 @@ init_optimization_passes (void)
NEXT_PASS (pass_cd_dce);
NEXT_PASS (pass_early_ipa_sra);
NEXT_PASS (pass_tail_recursion);
- NEXT_PASS (pass_convert_switch);
NEXT_PASS (pass_cleanup_eh);
NEXT_PASS (pass_profile);
NEXT_PASS (pass_local_pure_const);
/* Split functions creates parts that are not run through
early optimizations again. It is thus good idea to do this
late. */
+ NEXT_PASS (pass_convert_switch);
NEXT_PASS (pass_split_functions);
}
NEXT_PASS (pass_release_ssa_names);
@@ -1355,6 +1355,7 @@ init_optimization_passes (void)
NEXT_PASS (pass_ipa_tree_profile);
{
struct opt_pass **p = &pass_ipa_tree_profile.pass.sub;
+ NEXT_PASS (pass_feedback_convert_switch);
NEXT_PASS (pass_feedback_split_functions);
}
NEXT_PASS (pass_ipa_increase_alignment);
@@ -489,6 +489,7 @@ extern struct gimple_opt_pass pass_early_inline;
extern struct gimple_opt_pass pass_inline_parameters;
extern struct gimple_opt_pass pass_update_address_taken;
extern struct gimple_opt_pass pass_convert_switch;
+extern struct gimple_opt_pass pass_feedback_convert_switch;
/* The root of the compilation pass tree, once constructed. */
extern struct opt_pass *all_passes, *all_small_ipa_passes, *all_lowering_passes,
@@ -1460,7 +1460,9 @@ do_switchconv (void)
static bool
switchconv_gate (void)
{
- return flag_tree_switch_conversion != 0;
+ return (flag_tree_switch_conversion != 0
+ && !profile_arc_flag
+ && !flag_branch_probabilities);
}
struct gimple_opt_pass pass_convert_switch =
@@ -1485,3 +1487,35 @@ struct gimple_opt_pass pass_convert_switch =
| TODO_verify_flow /* todo_flags_finish */
}
};
+
+/* The pass gate. */
+
+static bool
+feedback_switchconv_gate (void)
+{
+ return (flag_tree_switch_conversion != 0
+ && flag_branch_probabilities);
+}
+
+struct gimple_opt_pass pass_feedback_convert_switch =
+{
+ {
+ GIMPLE_PASS,
+ "switchconv", /* name */
+ OPTGROUP_NONE, /* optinfo_flags */
+ feedback_switchconv_gate, /* gate */
+ do_switchconv, /* execute */
+ NULL, /* sub */
+ NULL, /* next */
+ 0, /* static_pass_number */
+ TV_TREE_SWITCH_CONVERSION, /* tv_id */
+ PROP_cfg | PROP_ssa, /* properties_required */
+ 0, /* properties_provided */
+ 0, /* properties_destroyed */
+ 0, /* todo_flags_start */
+ TODO_update_ssa
+ | TODO_verify_ssa
+ | TODO_verify_stmts
+ | TODO_verify_flow /* todo_flags_finish */
+ }
+};