1 /* Loop optimizations over tree-ssa.
2 Copyright (C) 2003 Free Software Foundation, Inc.
4 This file is part of GCC.
6 GCC is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 GCC is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING. If not, write to the Free
18 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
23 #include "coretypes.h"
28 #include "hard-reg-set.h"
29 #include "basic-block.h"
31 #include "diagnostic.h"
32 #include "basic-block.h"
33 #include "tree-flow.h"
34 #include "tree-dump.h"
35 #include "tree-pass.h"
39 #include "tree-inline.h"
40 #include "tree-scalar-evolution.h"
42 /* The loop tree currently optimized. */
44 struct loops
*current_loops
;
46 /* Initializes the loop structures. DUMP is the file to that the details
47 about the analysis should be dumped. */
50 tree_loop_optimizer_init (FILE *dump
)
52 struct loops
*loops
= loop_optimizer_init (dump
);
57 /* Creation of preheaders may create redundant phi nodes if the loop is
58 entered by more than one edge, but the initial value of the induction
59 variable is the same on all of them. */
60 kill_redundant_phi_nodes ();
61 rewrite_into_ssa (false);
62 bitmap_clear (vars_to_rename
);
64 rewrite_into_loop_closed_ssa ();
65 #ifdef ENABLE_CHECKING
66 verify_loop_closed_ssa ();
72 /* The loop superpass. */
77 return flag_tree_loop_optimize
!= 0;
80 struct tree_opt_pass pass_loop
=
87 0, /* static_pass_number */
88 TV_TREE_LOOP
, /* tv_id */
89 PROP_cfg
, /* properties_required */
90 0, /* properties_provided */
91 0, /* properties_destroyed */
92 TODO_ggc_collect
, /* todo_flags_start */
93 TODO_dump_func
| TODO_verify_ssa
| TODO_ggc_collect
/* todo_flags_finish */
96 /* Loop optimizer initialization. */
99 tree_ssa_loop_init (void)
101 current_loops
= tree_loop_optimizer_init (dump_file
);
104 scev_initialize (current_loops
);
107 struct tree_opt_pass pass_loop_init
=
109 "loopinit", /* name */
111 tree_ssa_loop_init
, /* execute */
114 0, /* static_pass_number */
116 PROP_cfg
, /* properties_required */
117 0, /* properties_provided */
118 0, /* properties_destroyed */
119 0, /* todo_flags_start */
120 TODO_dump_func
/* todo_flags_finish */
123 /* Loop invariant motion pass. */
126 tree_ssa_loop_im (void)
131 tree_ssa_lim (current_loops
);
135 gate_tree_ssa_loop_im (void)
137 return flag_tree_lim
!= 0;
140 struct tree_opt_pass pass_lim
=
143 gate_tree_ssa_loop_im
, /* gate */
144 tree_ssa_loop_im
, /* execute */
147 0, /* static_pass_number */
149 PROP_cfg
, /* properties_required */
150 0, /* properties_provided */
151 0, /* properties_destroyed */
152 0, /* todo_flags_start */
153 TODO_dump_func
/* todo_flags_finish */
156 /* Loop autovectorization. */
159 tree_vectorize (void)
164 bitmap_clear (vars_to_rename
);
165 vectorize_loops (current_loops
);
169 gate_tree_vectorize (void)
171 return flag_tree_vectorize
!= 0;
174 struct tree_opt_pass pass_vectorize
=
177 gate_tree_vectorize
, /* gate */
178 tree_vectorize
, /* execute */
181 0, /* static_pass_number */
182 TV_TREE_VECTORIZATION
, /* tv_id */
183 PROP_cfg
| PROP_ssa
, /* properties_required */
184 0, /* properties_provided */
185 0, /* properties_destroyed */
186 0, /* todo_flags_start */
187 TODO_dump_func
/* todo_flags_finish */
190 /* Loop optimizer finalization. */
193 tree_ssa_loop_done (void)
200 #ifdef ENABLE_CHECKING
201 verify_loop_closed_ssa ();
204 loop_optimizer_finalize (current_loops
,
205 (dump_flags
& TDF_DETAILS
? dump_file
: NULL
));
206 current_loops
= NULL
;
210 struct tree_opt_pass pass_loop_done
=
212 "loopdone", /* name */
214 tree_ssa_loop_done
, /* execute */
217 0, /* static_pass_number */
219 PROP_cfg
, /* properties_required */
220 0, /* properties_provided */
221 0, /* properties_destroyed */
222 0, /* todo_flags_start */
223 TODO_dump_func
/* todo_flags_finish */