diff options
Diffstat (limited to 'gcc/loop.c')
-rw-r--r-- | gcc/loop.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/gcc/loop.c b/gcc/loop.c index 5e85248718d..b9b285648bc 100644 --- a/gcc/loop.c +++ b/gcc/loop.c @@ -66,6 +66,8 @@ Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA #include "optabs.h" #include "cfgloop.h" #include "ggc.h" +#include "timevar.h" +#include "tree-pass.h" /* Get the loop info pointer of a loop. */ #define LOOP_INFO(LOOP) ((struct loop_info *) (LOOP)->aux) @@ -11807,3 +11809,66 @@ debug_loops (const struct loops *loops) { flow_loops_dump (loops, stderr, loop_dump_aux, 1); } + +static bool +gate_handle_loop_optimize (void) +{ + return (optimize > 0 && flag_loop_optimize); +} + +/* Move constant computations out of loops. */ +static void +rest_of_handle_loop_optimize (void) +{ + int do_prefetch; + + /* CFG is no longer maintained up-to-date. */ + free_bb_for_insn (); + profile_status = PROFILE_ABSENT; + + do_prefetch = flag_prefetch_loop_arrays ? LOOP_PREFETCH : 0; + + if (flag_rerun_loop_opt) + { + cleanup_barriers (); + + /* We only want to perform unrolling once. */ + loop_optimize (get_insns (), dump_file, 0); + + /* The first call to loop_optimize makes some instructions + trivially dead. We delete those instructions now in the + hope that doing so will make the heuristics in loop work + better and possibly speed up compilation. */ + delete_trivially_dead_insns (get_insns (), max_reg_num ()); + + /* The regscan pass is currently necessary as the alias + analysis code depends on this information. */ + reg_scan (get_insns (), max_reg_num ()); + } + cleanup_barriers (); + loop_optimize (get_insns (), dump_file, do_prefetch); + + /* Loop can create trivially dead instructions. */ + delete_trivially_dead_insns (get_insns (), max_reg_num ()); + find_basic_blocks (get_insns ()); +} + +struct tree_opt_pass pass_loop_optimize = +{ + "old-loop", /* name */ + gate_handle_loop_optimize, /* gate */ + rest_of_handle_loop_optimize, /* execute */ + NULL, /* sub */ + NULL, /* next */ + 0, /* static_pass_number */ + TV_LOOP, /* tv_id */ + 0, /* properties_required */ + 0, /* properties_provided */ + 0, /* properties_destroyed */ + 0, /* todo_flags_start */ + TODO_dump_func | + TODO_ggc_collect, /* todo_flags_finish */ + 'L' /* letter */ +}; + + |