On Wed, 18 Jun 2014, Richard Biener wrote: > > This removes the special dce_loop pass in favor of dealing with > scev and niter estimates in dce generally. Likewise it makes > copyprop always cleanup after itself, dealing with scev and niter > estimates. It also makes copyprop not unconditionally schedule > a cfg-cleanup but only do so if copyprop did any transform. > > Bootstrap and regtest running on x86_64-unknown-linux-gnu.
I have applied the following with the testsuite adjustments needed for gcc.dg/vect/dump-tree-dceloop-pr26359.c. Richard. 2014-06-18 Richard Biener <rguent...@suse.de> * tree-pass.h (make_pass_dce_loop): Remove. * passes.def: Replace pass_dce_loop with pass_dce. * tree-ssa-dce.c (perform_tree_ssa_dce): If something changed free niter estimates and reset the scev cache. (tree_ssa_dce_loop, pass_data_dce_loop, pass_dce_loop, make_pass_dce_loop): Remove. * tree-ssa-copy.c: Include tree-ssa-loop-niter.h. (fini_copy_prop): Return whether something changed. Always let substitute_and_fold perform DCE and free niter estimates and reset the scev cache if so. (execute_copy_prop): If sth changed schedule cleanup-cfg. (pass_data_copy_prop): Do not unconditionally schedule cleanup-cfg or update-ssa. * gcc.dg/vect/vect.exp: Remove dump-tree-dceloop-* processing. * gcc.dg/vect/dump-tree-dceloop-pr26359.c: Rename to ... * gcc.dg/vect/pr26359.c: ... this and adjust appropriately. Index: gcc/tree-pass.h =================================================================== *** gcc/tree-pass.h (revision 211738) --- gcc/tree-pass.h (working copy) *************** extern gimple_opt_pass *make_pass_build_ *** 382,388 **** extern gimple_opt_pass *make_pass_build_ealias (gcc::context *ctxt); extern gimple_opt_pass *make_pass_dominator (gcc::context *ctxt); extern gimple_opt_pass *make_pass_dce (gcc::context *ctxt); - extern gimple_opt_pass *make_pass_dce_loop (gcc::context *ctxt); extern gimple_opt_pass *make_pass_cd_dce (gcc::context *ctxt); extern gimple_opt_pass *make_pass_call_cdce (gcc::context *ctxt); extern gimple_opt_pass *make_pass_merge_phi (gcc::context *ctxt); --- 382,387 ---- Index: gcc/passes.def =================================================================== *** gcc/passes.def (revision 211738) --- gcc/passes.def (working copy) *************** along with GCC; see the file COPYING3. *** 203,209 **** NEXT_PASS (pass_tree_loop_init); NEXT_PASS (pass_lim); NEXT_PASS (pass_copy_prop); ! NEXT_PASS (pass_dce_loop); NEXT_PASS (pass_tree_unswitch); NEXT_PASS (pass_scev_cprop); NEXT_PASS (pass_record_bounds); --- 206,212 ---- NEXT_PASS (pass_tree_loop_init); NEXT_PASS (pass_lim); NEXT_PASS (pass_copy_prop); ! NEXT_PASS (pass_dce); NEXT_PASS (pass_tree_unswitch); NEXT_PASS (pass_scev_cprop); NEXT_PASS (pass_record_bounds); *************** along with GCC; see the file COPYING3. *** 215,221 **** NEXT_PASS (pass_graphite_transforms); NEXT_PASS (pass_lim); NEXT_PASS (pass_copy_prop); ! NEXT_PASS (pass_dce_loop); POP_INSERT_PASSES () NEXT_PASS (pass_iv_canon); NEXT_PASS (pass_parallelize_loops); --- 218,224 ---- NEXT_PASS (pass_graphite_transforms); NEXT_PASS (pass_lim); NEXT_PASS (pass_copy_prop); ! NEXT_PASS (pass_dce); POP_INSERT_PASSES () NEXT_PASS (pass_iv_canon); NEXT_PASS (pass_parallelize_loops); *************** along with GCC; see the file COPYING3. *** 224,230 **** Please do not add any other passes in between. */ NEXT_PASS (pass_vectorize); PUSH_INSERT_PASSES_WITHIN (pass_vectorize) ! NEXT_PASS (pass_dce_loop); POP_INSERT_PASSES () NEXT_PASS (pass_predcom); NEXT_PASS (pass_complete_unroll); --- 227,233 ---- Please do not add any other passes in between. */ NEXT_PASS (pass_vectorize); PUSH_INSERT_PASSES_WITHIN (pass_vectorize) ! NEXT_PASS (pass_dce); POP_INSERT_PASSES () NEXT_PASS (pass_predcom); NEXT_PASS (pass_complete_unroll); Index: gcc/tree-ssa-dce.c =================================================================== *** gcc/tree-ssa-dce.c (revision 211738) --- gcc/tree-ssa-dce.c (working copy) *************** perform_tree_ssa_dce (bool aggressive) *** 1479,1485 **** tree_dce_done (aggressive); if (something_changed) ! return TODO_update_ssa | TODO_cleanup_cfg; return 0; } --- 1479,1490 ---- tree_dce_done (aggressive); if (something_changed) ! { ! free_numbers_of_iterations_estimates (); ! if (scev_initialized_p) ! scev_reset (); ! return TODO_update_ssa | TODO_cleanup_cfg; ! } return 0; } *************** tree_ssa_dce (void) *** 1491,1509 **** } static unsigned int - tree_ssa_dce_loop (void) - { - unsigned int todo; - todo = perform_tree_ssa_dce (/*aggressive=*/false); - if (todo) - { - free_numbers_of_iterations_estimates (); - scev_reset (); - } - return todo; - } - - static unsigned int tree_ssa_cd_dce (void) { return perform_tree_ssa_dce (/*aggressive=*/optimize >= 2); --- 1496,1501 ---- *************** make_pass_dce (gcc::context *ctxt) *** 1548,1591 **** } namespace { - - const pass_data pass_data_dce_loop = - { - GIMPLE_PASS, /* type */ - "dceloop", /* name */ - OPTGROUP_NONE, /* optinfo_flags */ - true, /* has_execute */ - TV_TREE_DCE, /* tv_id */ - ( PROP_cfg | PROP_ssa ), /* properties_required */ - 0, /* properties_provided */ - 0, /* properties_destroyed */ - 0, /* todo_flags_start */ - 0, /* todo_flags_finish */ - }; - - class pass_dce_loop : public gimple_opt_pass - { - public: - pass_dce_loop (gcc::context *ctxt) - : gimple_opt_pass (pass_data_dce_loop, ctxt) - {} - - /* opt_pass methods: */ - opt_pass * clone () { return new pass_dce_loop (m_ctxt); } - virtual bool gate (function *) { return flag_tree_dce != 0; } - virtual unsigned int execute (function *) { return tree_ssa_dce_loop (); } - - }; // class pass_dce_loop - - } // anon namespace - - gimple_opt_pass * - make_pass_dce_loop (gcc::context *ctxt) - { - return new pass_dce_loop (ctxt); - } - - namespace { const pass_data pass_data_cd_dce = { --- 1540,1545 ---- Index: gcc/tree-ssa-copy.c =================================================================== *** gcc/tree-ssa-copy.c (revision 211738) --- gcc/tree-ssa-copy.c (working copy) *************** along with GCC; see the file COPYING3. *** 45,50 **** --- 45,52 ---- #include "cfgloop.h" #include "tree-scalar-evolution.h" #include "tree-ssa-dom.h" + #include "tree-ssa-loop-niter.h" + /* This file implements the copy propagation pass and provides a handful of interfaces for performing const/copy propagation and *************** get_value (tree name) *** 542,548 **** /* Deallocate memory used in copy propagation and do final substitution. */ ! static void fini_copy_prop (void) { unsigned i; --- 544,550 ---- /* Deallocate memory used in copy propagation and do final substitution. */ ! static bool fini_copy_prop (void) { unsigned i; *************** fini_copy_prop (void) *** 594,603 **** } } ! /* Don't do DCE if SCEV is initialized. It would destroy the scev cache. */ ! substitute_and_fold (get_value, NULL, !scev_initialized_p ()); free (copy_of); } --- 596,612 ---- } } ! bool changed = substitute_and_fold (get_value, NULL, true); ! if (changed) ! { ! free_numbers_of_iterations_estimates (); ! if (scev_initialized_p ()) ! scev_reset (); ! } free (copy_of); + + return changed; } *************** execute_copy_prop (void) *** 639,645 **** { init_copy_prop (); ssa_propagate (copy_prop_visit_stmt, copy_prop_visit_phi_node); ! fini_copy_prop (); return 0; } --- 648,655 ---- { init_copy_prop (); ssa_propagate (copy_prop_visit_stmt, copy_prop_visit_phi_node); ! if (fini_copy_prop ()) ! return TODO_cleanup_cfg; return 0; } *************** const pass_data pass_data_copy_prop = *** 656,662 **** 0, /* properties_provided */ 0, /* properties_destroyed */ 0, /* todo_flags_start */ ! ( TODO_cleanup_cfg | TODO_update_ssa ), /* todo_flags_finish */ }; class pass_copy_prop : public gimple_opt_pass --- 666,672 ---- 0, /* properties_provided */ 0, /* properties_destroyed */ 0, /* todo_flags_start */ ! 0, /* todo_flags_finish */ }; class pass_copy_prop : public gimple_opt_pass