From bf8e217d02b5849f8be35910e510e252a9415847 Mon Sep 17 00:00:00 2001 From: rguenth Date: Thu, 14 Aug 2014 13:14:24 +0000 Subject: [PATCH] 2014-08-14 Richard Biener PR tree-optimization/62081 * tree-ssa-loop.c (pass_fix_loops): New pass. (pass_tree_loop::gate): Do not fixup loops here. * tree-pass.h (make_pass_fix_loops): Declare. * passes.def: Schedule pass_fix_loops before GIMPLE loop passes. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@213961 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 8 ++++++++ gcc/passes.def | 5 ++++- gcc/tree-pass.h | 1 + gcc/tree-ssa-loop.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 4 files changed, 63 insertions(+), 4 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index fe1412905f7..db09e06b45d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,13 @@ 2014-08-14 Richard Biener + PR tree-optimization/62081 + * tree-ssa-loop.c (pass_fix_loops): New pass. + (pass_tree_loop::gate): Do not fixup loops here. + * tree-pass.h (make_pass_fix_loops): Declare. + * passes.def: Schedule pass_fix_loops before GIMPLE loop passes. + +2014-08-14 Richard Biener + * tree.c (type_hash_lookup, type_hash_add): Merge into ... (type_hash_canon): ... this and avoid 2nd lookup for the add. diff --git a/gcc/passes.def b/gcc/passes.def index f13df6cff26..334c670c1c6 100644 --- a/gcc/passes.def +++ b/gcc/passes.def @@ -200,7 +200,10 @@ along with GCC; see the file COPYING3. If not see NEXT_PASS (pass_asan); NEXT_PASS (pass_tsan); /* Pass group that runs when 1) enabled, 2) there are loops - in the function. */ + in the function. Make sure to run pass_fix_loops before + to discover/remove loops before running the gate function + of pass_tree_loop. */ + NEXT_PASS (pass_fix_loops); NEXT_PASS (pass_tree_loop); PUSH_INSERT_PASSES_WITHIN (pass_tree_loop) NEXT_PASS (pass_tree_loop_init); diff --git a/gcc/tree-pass.h b/gcc/tree-pass.h index 1477d1f5906..ed109c3545e 100644 --- a/gcc/tree-pass.h +++ b/gcc/tree-pass.h @@ -349,6 +349,7 @@ extern gimple_opt_pass *make_pass_sra_early (gcc::context *ctxt); extern gimple_opt_pass *make_pass_early_ipa_sra (gcc::context *ctxt); extern gimple_opt_pass *make_pass_tail_recursion (gcc::context *ctxt); extern gimple_opt_pass *make_pass_tail_calls (gcc::context *ctxt); +extern gimple_opt_pass *make_pass_fix_loops (gcc::context *ctxt); extern gimple_opt_pass *make_pass_tree_loop (gcc::context *ctxt); extern gimple_opt_pass *make_pass_tree_no_loop (gcc::context *ctxt); extern gimple_opt_pass *make_pass_tree_loop_init (gcc::context *ctxt); diff --git a/gcc/tree-ssa-loop.c b/gcc/tree-ssa-loop.c index d0c9980b35b..7d1f68e38b5 100644 --- a/gcc/tree-ssa-loop.c +++ b/gcc/tree-ssa-loop.c @@ -43,6 +43,56 @@ along with GCC; see the file COPYING3. If not see #include "tree-vectorizer.h" +/* A pass making sure loops are fixed up. */ + +namespace { + +const pass_data pass_data_fix_loops = +{ + GIMPLE_PASS, /* type */ + "fix_loops", /* name */ + OPTGROUP_LOOP, /* optinfo_flags */ + TV_TREE_LOOP, /* tv_id */ + PROP_cfg, /* properties_required */ + 0, /* properties_provided */ + 0, /* properties_destroyed */ + 0, /* todo_flags_start */ + 0, /* todo_flags_finish */ +}; + +class pass_fix_loops : public gimple_opt_pass +{ +public: + pass_fix_loops (gcc::context *ctxt) + : gimple_opt_pass (pass_data_fix_loops, ctxt) + {} + + /* opt_pass methods: */ + virtual bool gate (function *) { return flag_tree_loop_optimize; } + + virtual unsigned int execute (function *fn); +}; // class pass_fix_loops + +unsigned int +pass_fix_loops::execute (function *) +{ + if (loops_state_satisfies_p (LOOPS_NEED_FIXUP)) + { + calculate_dominance_info (CDI_DOMINATORS); + fix_loop_structure (NULL); + } + return 0; +} + +} // anon namespace + +gimple_opt_pass * +make_pass_fix_loops (gcc::context *ctxt) +{ + return new pass_fix_loops (ctxt); +} + + /* Gate for loop pass group. The group is controlled by -ftree-loop-optimize but we also avoid running it when the IL doesn't contain any loop. */ @@ -57,9 +107,6 @@ gate_loop (function *fn) if (!loops_for_fn (fn)) return true; - /* Make sure to drop / re-discover loops when necessary. */ - if (loops_state_satisfies_p (LOOPS_NEED_FIXUP)) - fix_loop_structure (NULL); return number_of_loops (fn) > 1; } -- 2.11.4.GIT