diff --git a/gcc/passes.def b/gcc/passes.def index c8903b4ec16..3e44797b10f 100644 --- a/gcc/passes.def +++ b/gcc/passes.def @@ -259,7 +259,7 @@ along with GCC; see the file COPYING3. If not see NEXT_PASS (pass_lim); NEXT_PASS (pass_walloca, false); NEXT_PASS (pass_pre); - NEXT_PASS (pass_sink_code); + NEXT_PASS (pass_sink_code, false /* unsplit edges */); NEXT_PASS (pass_sancov); NEXT_PASS (pass_asan); NEXT_PASS (pass_tsan); @@ -349,7 +349,7 @@ along with GCC; see the file COPYING3. If not see /* After late CD DCE we rewrite no longer addressed locals into SSA form if possible. */ NEXT_PASS (pass_forwprop); - NEXT_PASS (pass_sink_code); + NEXT_PASS (pass_sink_code, true /* unsplit edges */); NEXT_PASS (pass_phiopt, false /* early_p */); NEXT_PASS (pass_fold_builtins); NEXT_PASS (pass_optimize_widening_mul); diff --git a/gcc/testsuite/gcc.dg/gimplefe-37.c b/gcc/testsuite/gcc.dg/gimplefe-37.c index d3ea186d7f9..12f6f64fc2c 100644 --- a/gcc/testsuite/gcc.dg/gimplefe-37.c +++ b/gcc/testsuite/gcc.dg/gimplefe-37.c @@ -22,6 +22,6 @@ main (int argc) /* { dg-final { scan-tree-dump-times " \\\[count: 3" 2 "optimized" } } */ -/* { dg-final { scan-tree-dump-times " \\\[count: 2" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-times " \\\[count: \[12\]" 1 "optimized" } } */ /* { dg-final { scan-tree-dump-times "goto ; \\\[33\\\.33%\\\]" 1 "optimized" } } */ /* { dg-final { scan-tree-dump-times "goto ; \\\[66\\\.67%\\\]" 1 "optimized" } } */ diff --git a/gcc/tree-ssa-sink.cc b/gcc/tree-ssa-sink.cc index 66d7ae89e90..1c226406feb 100644 --- a/gcc/tree-ssa-sink.cc +++ b/gcc/tree-ssa-sink.cc @@ -822,14 +822,21 @@ class pass_sink_code : public gimple_opt_pass { public: pass_sink_code (gcc::context *ctxt) - : gimple_opt_pass (pass_data_sink_code, ctxt) + : gimple_opt_pass (pass_data_sink_code, ctxt), unsplit_edges (false) {} /* opt_pass methods: */ virtual bool gate (function *) { return flag_tree_sink != 0; } virtual unsigned int execute (function *); opt_pass *clone (void) { return new pass_sink_code (m_ctxt); } + void set_pass_param (unsigned n, bool param) + { + gcc_assert (n == 0); + unsplit_edges = param; + } +private: + bool unsplit_edges; }; // class pass_sink_code unsigned int @@ -837,11 +844,13 @@ pass_sink_code::execute (function *fun) { loop_optimizer_init (LOOPS_NORMAL); split_edges_for_insertion (); + /* Arrange for the critical edge splitting to be undone if requested. */ + unsigned todo = unsplit_edges ? TODO_cleanup_cfg : 0; connect_infinite_loops_to_exit (); memset (&sink_stats, 0, sizeof (sink_stats)); calculate_dominance_info (CDI_DOMINATORS); calculate_dominance_info (CDI_POST_DOMINATORS); - unsigned todo = sink_code_in_bb (EXIT_BLOCK_PTR_FOR_FN (fun)); + todo |= sink_code_in_bb (EXIT_BLOCK_PTR_FOR_FN (fun)); statistics_counter_event (fun, "Sunk statements", sink_stats.sunk); statistics_counter_event (fun, "Commoned stores", sink_stats.commoned); free_dominance_info (CDI_POST_DOMINATORS);