annotate gcc/tree-ssa-loop.c @ 144:8f4e72ab4e11

fix segmentation fault caused by nothing next cur_op to end
author Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Sun, 23 Dec 2018 21:23:56 +0900
parents 84e7813d76e9
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 /* Loop optimizations over tree-ssa.
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2 Copyright (C) 2003-2018 Free Software Foundation, Inc.
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
3
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 This file is part of GCC.
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
5
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 GCC is free software; you can redistribute it and/or modify it
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 under the terms of the GNU General Public License as published by the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 Free Software Foundation; either version 3, or (at your option) any
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 later version.
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
10
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 GCC is distributed in the hope that it will be useful, but WITHOUT
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 for more details.
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
15
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 along with GCC; see the file COPYING3. If not see
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 <http://www.gnu.org/licenses/>. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 #include "config.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 #include "system.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 #include "coretypes.h"
111
kono
parents: 67
diff changeset
23 #include "backend.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 #include "tree.h"
111
kono
parents: 67
diff changeset
25 #include "gimple.h"
kono
parents: 67
diff changeset
26 #include "tree-pass.h"
kono
parents: 67
diff changeset
27 #include "memmodel.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 #include "tm_p.h"
111
kono
parents: 67
diff changeset
29 #include "fold-const.h"
kono
parents: 67
diff changeset
30 #include "gimple-iterator.h"
kono
parents: 67
diff changeset
31 #include "tree-ssa-loop-ivopts.h"
kono
parents: 67
diff changeset
32 #include "tree-ssa-loop-manip.h"
kono
parents: 67
diff changeset
33 #include "tree-ssa-loop-niter.h"
kono
parents: 67
diff changeset
34 #include "tree-ssa-loop.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 #include "cfgloop.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 #include "tree-inline.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 #include "tree-scalar-evolution.h"
111
kono
parents: 67
diff changeset
38 #include "tree-vectorizer.h"
kono
parents: 67
diff changeset
39 #include "omp-general.h"
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
40 #include "diagnostic-core.h"
111
kono
parents: 67
diff changeset
41 #include "stringpool.h"
kono
parents: 67
diff changeset
42 #include "attribs.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
43
111
kono
parents: 67
diff changeset
44
kono
parents: 67
diff changeset
45 /* A pass making sure loops are fixed up. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
46
111
kono
parents: 67
diff changeset
47 namespace {
kono
parents: 67
diff changeset
48
kono
parents: 67
diff changeset
49 const pass_data pass_data_fix_loops =
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 {
111
kono
parents: 67
diff changeset
51 GIMPLE_PASS, /* type */
kono
parents: 67
diff changeset
52 "fix_loops", /* name */
kono
parents: 67
diff changeset
53 OPTGROUP_LOOP, /* optinfo_flags */
kono
parents: 67
diff changeset
54 TV_TREE_LOOP, /* tv_id */
kono
parents: 67
diff changeset
55 PROP_cfg, /* properties_required */
kono
parents: 67
diff changeset
56 0, /* properties_provided */
kono
parents: 67
diff changeset
57 0, /* properties_destroyed */
kono
parents: 67
diff changeset
58 0, /* todo_flags_start */
kono
parents: 67
diff changeset
59 0, /* todo_flags_finish */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 };
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
61
111
kono
parents: 67
diff changeset
62 class pass_fix_loops : public gimple_opt_pass
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 {
111
kono
parents: 67
diff changeset
64 public:
kono
parents: 67
diff changeset
65 pass_fix_loops (gcc::context *ctxt)
kono
parents: 67
diff changeset
66 : gimple_opt_pass (pass_data_fix_loops, ctxt)
kono
parents: 67
diff changeset
67 {}
kono
parents: 67
diff changeset
68
kono
parents: 67
diff changeset
69 /* opt_pass methods: */
kono
parents: 67
diff changeset
70 virtual bool gate (function *) { return flag_tree_loop_optimize; }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
71
111
kono
parents: 67
diff changeset
72 virtual unsigned int execute (function *fn);
kono
parents: 67
diff changeset
73 }; // class pass_fix_loops
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
74
111
kono
parents: 67
diff changeset
75 unsigned int
kono
parents: 67
diff changeset
76 pass_fix_loops::execute (function *)
kono
parents: 67
diff changeset
77 {
kono
parents: 67
diff changeset
78 if (loops_state_satisfies_p (LOOPS_NEED_FIXUP))
kono
parents: 67
diff changeset
79 {
kono
parents: 67
diff changeset
80 calculate_dominance_info (CDI_DOMINATORS);
kono
parents: 67
diff changeset
81 fix_loop_structure (NULL);
kono
parents: 67
diff changeset
82 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 return 0;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
84 }
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
85
111
kono
parents: 67
diff changeset
86 } // anon namespace
kono
parents: 67
diff changeset
87
kono
parents: 67
diff changeset
88 gimple_opt_pass *
kono
parents: 67
diff changeset
89 make_pass_fix_loops (gcc::context *ctxt)
kono
parents: 67
diff changeset
90 {
kono
parents: 67
diff changeset
91 return new pass_fix_loops (ctxt);
kono
parents: 67
diff changeset
92 }
kono
parents: 67
diff changeset
93
kono
parents: 67
diff changeset
94
kono
parents: 67
diff changeset
95 /* Gate for loop pass group. The group is controlled by -ftree-loop-optimize
kono
parents: 67
diff changeset
96 but we also avoid running it when the IL doesn't contain any loop. */
kono
parents: 67
diff changeset
97
kono
parents: 67
diff changeset
98 static bool
kono
parents: 67
diff changeset
99 gate_loop (function *fn)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
100 {
111
kono
parents: 67
diff changeset
101 if (!flag_tree_loop_optimize)
kono
parents: 67
diff changeset
102 return false;
kono
parents: 67
diff changeset
103
kono
parents: 67
diff changeset
104 /* For -fdump-passes which runs before loop discovery print the
kono
parents: 67
diff changeset
105 state of -ftree-loop-optimize. */
kono
parents: 67
diff changeset
106 if (!loops_for_fn (fn))
kono
parents: 67
diff changeset
107 return true;
kono
parents: 67
diff changeset
108
kono
parents: 67
diff changeset
109 return number_of_loops (fn) > 1;
kono
parents: 67
diff changeset
110 }
kono
parents: 67
diff changeset
111
kono
parents: 67
diff changeset
112 /* The loop superpass. */
kono
parents: 67
diff changeset
113
kono
parents: 67
diff changeset
114 namespace {
kono
parents: 67
diff changeset
115
kono
parents: 67
diff changeset
116 const pass_data pass_data_tree_loop =
kono
parents: 67
diff changeset
117 {
kono
parents: 67
diff changeset
118 GIMPLE_PASS, /* type */
kono
parents: 67
diff changeset
119 "loop", /* name */
kono
parents: 67
diff changeset
120 OPTGROUP_LOOP, /* optinfo_flags */
kono
parents: 67
diff changeset
121 TV_TREE_LOOP, /* tv_id */
kono
parents: 67
diff changeset
122 PROP_cfg, /* properties_required */
kono
parents: 67
diff changeset
123 0, /* properties_provided */
kono
parents: 67
diff changeset
124 0, /* properties_destroyed */
kono
parents: 67
diff changeset
125 0, /* todo_flags_start */
kono
parents: 67
diff changeset
126 0, /* todo_flags_finish */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
127 };
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
128
111
kono
parents: 67
diff changeset
129 class pass_tree_loop : public gimple_opt_pass
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
130 {
111
kono
parents: 67
diff changeset
131 public:
kono
parents: 67
diff changeset
132 pass_tree_loop (gcc::context *ctxt)
kono
parents: 67
diff changeset
133 : gimple_opt_pass (pass_data_tree_loop, ctxt)
kono
parents: 67
diff changeset
134 {}
kono
parents: 67
diff changeset
135
kono
parents: 67
diff changeset
136 /* opt_pass methods: */
kono
parents: 67
diff changeset
137 virtual bool gate (function *fn) { return gate_loop (fn); }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
138
111
kono
parents: 67
diff changeset
139 }; // class pass_tree_loop
kono
parents: 67
diff changeset
140
kono
parents: 67
diff changeset
141 } // anon namespace
kono
parents: 67
diff changeset
142
kono
parents: 67
diff changeset
143 gimple_opt_pass *
kono
parents: 67
diff changeset
144 make_pass_tree_loop (gcc::context *ctxt)
kono
parents: 67
diff changeset
145 {
kono
parents: 67
diff changeset
146 return new pass_tree_loop (ctxt);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
147 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
148
111
kono
parents: 67
diff changeset
149 /* Gate for oacc kernels pass group. */
kono
parents: 67
diff changeset
150
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
151 static bool
111
kono
parents: 67
diff changeset
152 gate_oacc_kernels (function *fn)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
153 {
111
kono
parents: 67
diff changeset
154 if (!flag_openacc)
kono
parents: 67
diff changeset
155 return false;
kono
parents: 67
diff changeset
156
kono
parents: 67
diff changeset
157 if (!lookup_attribute ("oacc kernels", DECL_ATTRIBUTES (fn->decl)))
kono
parents: 67
diff changeset
158 return false;
kono
parents: 67
diff changeset
159
kono
parents: 67
diff changeset
160 struct loop *loop;
kono
parents: 67
diff changeset
161 FOR_EACH_LOOP (loop, 0)
kono
parents: 67
diff changeset
162 if (loop->in_oacc_kernels_region)
kono
parents: 67
diff changeset
163 return true;
kono
parents: 67
diff changeset
164
kono
parents: 67
diff changeset
165 return false;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
166 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
167
111
kono
parents: 67
diff changeset
168 /* The oacc kernels superpass. */
kono
parents: 67
diff changeset
169
kono
parents: 67
diff changeset
170 namespace {
kono
parents: 67
diff changeset
171
kono
parents: 67
diff changeset
172 const pass_data pass_data_oacc_kernels =
kono
parents: 67
diff changeset
173 {
kono
parents: 67
diff changeset
174 GIMPLE_PASS, /* type */
kono
parents: 67
diff changeset
175 "oacc_kernels", /* name */
kono
parents: 67
diff changeset
176 OPTGROUP_LOOP, /* optinfo_flags */
kono
parents: 67
diff changeset
177 TV_TREE_LOOP, /* tv_id */
kono
parents: 67
diff changeset
178 PROP_cfg, /* properties_required */
kono
parents: 67
diff changeset
179 0, /* properties_provided */
kono
parents: 67
diff changeset
180 0, /* properties_destroyed */
kono
parents: 67
diff changeset
181 0, /* todo_flags_start */
kono
parents: 67
diff changeset
182 0, /* todo_flags_finish */
kono
parents: 67
diff changeset
183 };
kono
parents: 67
diff changeset
184
kono
parents: 67
diff changeset
185 class pass_oacc_kernels : public gimple_opt_pass
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
186 {
111
kono
parents: 67
diff changeset
187 public:
kono
parents: 67
diff changeset
188 pass_oacc_kernels (gcc::context *ctxt)
kono
parents: 67
diff changeset
189 : gimple_opt_pass (pass_data_oacc_kernels, ctxt)
kono
parents: 67
diff changeset
190 {}
kono
parents: 67
diff changeset
191
kono
parents: 67
diff changeset
192 /* opt_pass methods: */
kono
parents: 67
diff changeset
193 virtual bool gate (function *fn) { return gate_oacc_kernels (fn); }
kono
parents: 67
diff changeset
194
kono
parents: 67
diff changeset
195 }; // class pass_oacc_kernels
kono
parents: 67
diff changeset
196
kono
parents: 67
diff changeset
197 } // anon namespace
kono
parents: 67
diff changeset
198
kono
parents: 67
diff changeset
199 gimple_opt_pass *
kono
parents: 67
diff changeset
200 make_pass_oacc_kernels (gcc::context *ctxt)
kono
parents: 67
diff changeset
201 {
kono
parents: 67
diff changeset
202 return new pass_oacc_kernels (ctxt);
kono
parents: 67
diff changeset
203 }
kono
parents: 67
diff changeset
204
kono
parents: 67
diff changeset
205 /* The ipa oacc superpass. */
kono
parents: 67
diff changeset
206
kono
parents: 67
diff changeset
207 namespace {
kono
parents: 67
diff changeset
208
kono
parents: 67
diff changeset
209 const pass_data pass_data_ipa_oacc =
kono
parents: 67
diff changeset
210 {
kono
parents: 67
diff changeset
211 SIMPLE_IPA_PASS, /* type */
kono
parents: 67
diff changeset
212 "ipa_oacc", /* name */
kono
parents: 67
diff changeset
213 OPTGROUP_LOOP, /* optinfo_flags */
kono
parents: 67
diff changeset
214 TV_TREE_LOOP, /* tv_id */
kono
parents: 67
diff changeset
215 PROP_cfg, /* properties_required */
kono
parents: 67
diff changeset
216 0, /* properties_provided */
kono
parents: 67
diff changeset
217 0, /* properties_destroyed */
kono
parents: 67
diff changeset
218 0, /* todo_flags_start */
kono
parents: 67
diff changeset
219 0, /* todo_flags_finish */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
220 };
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
221
111
kono
parents: 67
diff changeset
222 class pass_ipa_oacc : public simple_ipa_opt_pass
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
223 {
111
kono
parents: 67
diff changeset
224 public:
kono
parents: 67
diff changeset
225 pass_ipa_oacc (gcc::context *ctxt)
kono
parents: 67
diff changeset
226 : simple_ipa_opt_pass (pass_data_ipa_oacc, ctxt)
kono
parents: 67
diff changeset
227 {}
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
228
111
kono
parents: 67
diff changeset
229 /* opt_pass methods: */
kono
parents: 67
diff changeset
230 virtual bool gate (function *)
kono
parents: 67
diff changeset
231 {
kono
parents: 67
diff changeset
232 return (optimize
kono
parents: 67
diff changeset
233 && flag_openacc
kono
parents: 67
diff changeset
234 /* Don't bother doing anything if the program has errors. */
kono
parents: 67
diff changeset
235 && !seen_error ());
kono
parents: 67
diff changeset
236 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
237
111
kono
parents: 67
diff changeset
238 }; // class pass_ipa_oacc
kono
parents: 67
diff changeset
239
kono
parents: 67
diff changeset
240 } // anon namespace
kono
parents: 67
diff changeset
241
kono
parents: 67
diff changeset
242 simple_ipa_opt_pass *
kono
parents: 67
diff changeset
243 make_pass_ipa_oacc (gcc::context *ctxt)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
244 {
111
kono
parents: 67
diff changeset
245 return new pass_ipa_oacc (ctxt);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
246 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
247
111
kono
parents: 67
diff changeset
248 /* The ipa oacc kernels pass. */
kono
parents: 67
diff changeset
249
kono
parents: 67
diff changeset
250 namespace {
kono
parents: 67
diff changeset
251
kono
parents: 67
diff changeset
252 const pass_data pass_data_ipa_oacc_kernels =
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
253 {
111
kono
parents: 67
diff changeset
254 SIMPLE_IPA_PASS, /* type */
kono
parents: 67
diff changeset
255 "ipa_oacc_kernels", /* name */
kono
parents: 67
diff changeset
256 OPTGROUP_LOOP, /* optinfo_flags */
kono
parents: 67
diff changeset
257 TV_TREE_LOOP, /* tv_id */
kono
parents: 67
diff changeset
258 PROP_cfg, /* properties_required */
kono
parents: 67
diff changeset
259 0, /* properties_provided */
kono
parents: 67
diff changeset
260 0, /* properties_destroyed */
kono
parents: 67
diff changeset
261 0, /* todo_flags_start */
kono
parents: 67
diff changeset
262 0, /* todo_flags_finish */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
263 };
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
264
111
kono
parents: 67
diff changeset
265 class pass_ipa_oacc_kernels : public simple_ipa_opt_pass
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
266 {
111
kono
parents: 67
diff changeset
267 public:
kono
parents: 67
diff changeset
268 pass_ipa_oacc_kernels (gcc::context *ctxt)
kono
parents: 67
diff changeset
269 : simple_ipa_opt_pass (pass_data_ipa_oacc_kernels, ctxt)
kono
parents: 67
diff changeset
270 {}
kono
parents: 67
diff changeset
271
kono
parents: 67
diff changeset
272 }; // class pass_ipa_oacc_kernels
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
273
111
kono
parents: 67
diff changeset
274 } // anon namespace
kono
parents: 67
diff changeset
275
kono
parents: 67
diff changeset
276 simple_ipa_opt_pass *
kono
parents: 67
diff changeset
277 make_pass_ipa_oacc_kernels (gcc::context *ctxt)
kono
parents: 67
diff changeset
278 {
kono
parents: 67
diff changeset
279 return new pass_ipa_oacc_kernels (ctxt);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
280 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
281
111
kono
parents: 67
diff changeset
282 /* The no-loop superpass. */
kono
parents: 67
diff changeset
283
kono
parents: 67
diff changeset
284 namespace {
kono
parents: 67
diff changeset
285
kono
parents: 67
diff changeset
286 const pass_data pass_data_tree_no_loop =
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
287 {
111
kono
parents: 67
diff changeset
288 GIMPLE_PASS, /* type */
kono
parents: 67
diff changeset
289 "no_loop", /* name */
kono
parents: 67
diff changeset
290 OPTGROUP_NONE, /* optinfo_flags */
kono
parents: 67
diff changeset
291 TV_TREE_NOLOOP, /* tv_id */
kono
parents: 67
diff changeset
292 PROP_cfg, /* properties_required */
kono
parents: 67
diff changeset
293 0, /* properties_provided */
kono
parents: 67
diff changeset
294 0, /* properties_destroyed */
kono
parents: 67
diff changeset
295 0, /* todo_flags_start */
kono
parents: 67
diff changeset
296 0, /* todo_flags_finish */
kono
parents: 67
diff changeset
297 };
kono
parents: 67
diff changeset
298
kono
parents: 67
diff changeset
299 class pass_tree_no_loop : public gimple_opt_pass
kono
parents: 67
diff changeset
300 {
kono
parents: 67
diff changeset
301 public:
kono
parents: 67
diff changeset
302 pass_tree_no_loop (gcc::context *ctxt)
kono
parents: 67
diff changeset
303 : gimple_opt_pass (pass_data_tree_no_loop, ctxt)
kono
parents: 67
diff changeset
304 {}
kono
parents: 67
diff changeset
305
kono
parents: 67
diff changeset
306 /* opt_pass methods: */
kono
parents: 67
diff changeset
307 virtual bool gate (function *fn) { return !gate_loop (fn); }
kono
parents: 67
diff changeset
308
kono
parents: 67
diff changeset
309 }; // class pass_tree_no_loop
kono
parents: 67
diff changeset
310
kono
parents: 67
diff changeset
311 } // anon namespace
kono
parents: 67
diff changeset
312
kono
parents: 67
diff changeset
313 gimple_opt_pass *
kono
parents: 67
diff changeset
314 make_pass_tree_no_loop (gcc::context *ctxt)
kono
parents: 67
diff changeset
315 {
kono
parents: 67
diff changeset
316 return new pass_tree_no_loop (ctxt);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
317 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
318
111
kono
parents: 67
diff changeset
319
kono
parents: 67
diff changeset
320 /* Loop optimizer initialization. */
kono
parents: 67
diff changeset
321
kono
parents: 67
diff changeset
322 namespace {
kono
parents: 67
diff changeset
323
kono
parents: 67
diff changeset
324 const pass_data pass_data_tree_loop_init =
kono
parents: 67
diff changeset
325 {
kono
parents: 67
diff changeset
326 GIMPLE_PASS, /* type */
kono
parents: 67
diff changeset
327 "loopinit", /* name */
kono
parents: 67
diff changeset
328 OPTGROUP_LOOP, /* optinfo_flags */
kono
parents: 67
diff changeset
329 TV_NONE, /* tv_id */
kono
parents: 67
diff changeset
330 PROP_cfg, /* properties_required */
kono
parents: 67
diff changeset
331 0, /* properties_provided */
kono
parents: 67
diff changeset
332 0, /* properties_destroyed */
kono
parents: 67
diff changeset
333 0, /* todo_flags_start */
kono
parents: 67
diff changeset
334 0, /* todo_flags_finish */
kono
parents: 67
diff changeset
335 };
kono
parents: 67
diff changeset
336
kono
parents: 67
diff changeset
337 class pass_tree_loop_init : public gimple_opt_pass
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
338 {
111
kono
parents: 67
diff changeset
339 public:
kono
parents: 67
diff changeset
340 pass_tree_loop_init (gcc::context *ctxt)
kono
parents: 67
diff changeset
341 : gimple_opt_pass (pass_data_tree_loop_init, ctxt)
kono
parents: 67
diff changeset
342 {}
kono
parents: 67
diff changeset
343
kono
parents: 67
diff changeset
344 /* opt_pass methods: */
kono
parents: 67
diff changeset
345 virtual unsigned int execute (function *);
kono
parents: 67
diff changeset
346
kono
parents: 67
diff changeset
347 }; // class pass_tree_loop_init
kono
parents: 67
diff changeset
348
kono
parents: 67
diff changeset
349 unsigned int
kono
parents: 67
diff changeset
350 pass_tree_loop_init::execute (function *fun ATTRIBUTE_UNUSED)
kono
parents: 67
diff changeset
351 {
kono
parents: 67
diff changeset
352 /* When processing a loop in the loop pipeline, we should be able to assert
kono
parents: 67
diff changeset
353 that:
kono
parents: 67
diff changeset
354 (loops_state_satisfies_p (LOOPS_NORMAL | LOOPS_HAVE_RECORDED_EXITS
kono
parents: 67
diff changeset
355 | LOOP_CLOSED_SSA)
kono
parents: 67
diff changeset
356 && scev_initialized_p ())
kono
parents: 67
diff changeset
357 */
kono
parents: 67
diff changeset
358 loop_optimizer_init (LOOPS_NORMAL
kono
parents: 67
diff changeset
359 | LOOPS_HAVE_RECORDED_EXITS);
kono
parents: 67
diff changeset
360 rewrite_into_loop_closed_ssa (NULL, TODO_update_ssa);
kono
parents: 67
diff changeset
361 scev_initialize ();
kono
parents: 67
diff changeset
362
kono
parents: 67
diff changeset
363 return 0;
kono
parents: 67
diff changeset
364 }
kono
parents: 67
diff changeset
365
kono
parents: 67
diff changeset
366 } // anon namespace
kono
parents: 67
diff changeset
367
kono
parents: 67
diff changeset
368 gimple_opt_pass *
kono
parents: 67
diff changeset
369 make_pass_tree_loop_init (gcc::context *ctxt)
kono
parents: 67
diff changeset
370 {
kono
parents: 67
diff changeset
371 return new pass_tree_loop_init (ctxt);
kono
parents: 67
diff changeset
372 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
373
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
374 /* Loop autovectorization. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
375
111
kono
parents: 67
diff changeset
376 namespace {
kono
parents: 67
diff changeset
377
kono
parents: 67
diff changeset
378 const pass_data pass_data_vectorize =
kono
parents: 67
diff changeset
379 {
kono
parents: 67
diff changeset
380 GIMPLE_PASS, /* type */
kono
parents: 67
diff changeset
381 "vect", /* name */
kono
parents: 67
diff changeset
382 OPTGROUP_LOOP | OPTGROUP_VEC, /* optinfo_flags */
kono
parents: 67
diff changeset
383 TV_TREE_VECTORIZATION, /* tv_id */
kono
parents: 67
diff changeset
384 ( PROP_cfg | PROP_ssa ), /* properties_required */
kono
parents: 67
diff changeset
385 0, /* properties_provided */
kono
parents: 67
diff changeset
386 0, /* properties_destroyed */
kono
parents: 67
diff changeset
387 0, /* todo_flags_start */
kono
parents: 67
diff changeset
388 0, /* todo_flags_finish */
kono
parents: 67
diff changeset
389 };
kono
parents: 67
diff changeset
390
kono
parents: 67
diff changeset
391 class pass_vectorize : public gimple_opt_pass
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
392 {
111
kono
parents: 67
diff changeset
393 public:
kono
parents: 67
diff changeset
394 pass_vectorize (gcc::context *ctxt)
kono
parents: 67
diff changeset
395 : gimple_opt_pass (pass_data_vectorize, ctxt)
kono
parents: 67
diff changeset
396 {}
kono
parents: 67
diff changeset
397
kono
parents: 67
diff changeset
398 /* opt_pass methods: */
kono
parents: 67
diff changeset
399 virtual bool gate (function *fun)
kono
parents: 67
diff changeset
400 {
kono
parents: 67
diff changeset
401 return flag_tree_loop_vectorize || fun->has_force_vectorize_loops;
kono
parents: 67
diff changeset
402 }
kono
parents: 67
diff changeset
403
kono
parents: 67
diff changeset
404 virtual unsigned int execute (function *);
kono
parents: 67
diff changeset
405
kono
parents: 67
diff changeset
406 }; // class pass_vectorize
kono
parents: 67
diff changeset
407
kono
parents: 67
diff changeset
408 unsigned int
kono
parents: 67
diff changeset
409 pass_vectorize::execute (function *fun)
kono
parents: 67
diff changeset
410 {
kono
parents: 67
diff changeset
411 if (number_of_loops (fun) <= 1)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
412 return 0;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
413
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
414 return vectorize_loops ();
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
415 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
416
111
kono
parents: 67
diff changeset
417 } // anon namespace
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
418
111
kono
parents: 67
diff changeset
419 gimple_opt_pass *
kono
parents: 67
diff changeset
420 make_pass_vectorize (gcc::context *ctxt)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
421 {
111
kono
parents: 67
diff changeset
422 return new pass_vectorize (ctxt);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
423 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
424
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
425 /* Propagation of constants using scev. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
426
111
kono
parents: 67
diff changeset
427 namespace {
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
428
111
kono
parents: 67
diff changeset
429 const pass_data pass_data_scev_cprop =
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
430 {
111
kono
parents: 67
diff changeset
431 GIMPLE_PASS, /* type */
kono
parents: 67
diff changeset
432 "sccp", /* name */
kono
parents: 67
diff changeset
433 OPTGROUP_LOOP, /* optinfo_flags */
kono
parents: 67
diff changeset
434 TV_SCEV_CONST, /* tv_id */
kono
parents: 67
diff changeset
435 ( PROP_cfg | PROP_ssa ), /* properties_required */
kono
parents: 67
diff changeset
436 0, /* properties_provided */
kono
parents: 67
diff changeset
437 0, /* properties_destroyed */
kono
parents: 67
diff changeset
438 0, /* todo_flags_start */
kono
parents: 67
diff changeset
439 ( TODO_cleanup_cfg
kono
parents: 67
diff changeset
440 | TODO_update_ssa_only_virtuals ), /* todo_flags_finish */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
441 };
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
442
111
kono
parents: 67
diff changeset
443 class pass_scev_cprop : public gimple_opt_pass
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
444 {
111
kono
parents: 67
diff changeset
445 public:
kono
parents: 67
diff changeset
446 pass_scev_cprop (gcc::context *ctxt)
kono
parents: 67
diff changeset
447 : gimple_opt_pass (pass_data_scev_cprop, ctxt)
kono
parents: 67
diff changeset
448 {}
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
449
111
kono
parents: 67
diff changeset
450 /* opt_pass methods: */
kono
parents: 67
diff changeset
451 virtual bool gate (function *) { return flag_tree_scev_cprop; }
kono
parents: 67
diff changeset
452 virtual unsigned int execute (function *) { return scev_const_prop (); }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
453
111
kono
parents: 67
diff changeset
454 }; // class pass_scev_cprop
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
455
111
kono
parents: 67
diff changeset
456 } // anon namespace
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
457
111
kono
parents: 67
diff changeset
458 gimple_opt_pass *
kono
parents: 67
diff changeset
459 make_pass_scev_cprop (gcc::context *ctxt)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
460 {
111
kono
parents: 67
diff changeset
461 return new pass_scev_cprop (ctxt);
kono
parents: 67
diff changeset
462 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
463
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
464 /* Induction variable optimizations. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
465
111
kono
parents: 67
diff changeset
466 namespace {
kono
parents: 67
diff changeset
467
kono
parents: 67
diff changeset
468 const pass_data pass_data_iv_optimize =
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
469 {
111
kono
parents: 67
diff changeset
470 GIMPLE_PASS, /* type */
kono
parents: 67
diff changeset
471 "ivopts", /* name */
kono
parents: 67
diff changeset
472 OPTGROUP_LOOP, /* optinfo_flags */
kono
parents: 67
diff changeset
473 TV_TREE_LOOP_IVOPTS, /* tv_id */
kono
parents: 67
diff changeset
474 ( PROP_cfg | PROP_ssa ), /* properties_required */
kono
parents: 67
diff changeset
475 0, /* properties_provided */
kono
parents: 67
diff changeset
476 0, /* properties_destroyed */
kono
parents: 67
diff changeset
477 0, /* todo_flags_start */
kono
parents: 67
diff changeset
478 TODO_update_ssa, /* todo_flags_finish */
kono
parents: 67
diff changeset
479 };
kono
parents: 67
diff changeset
480
kono
parents: 67
diff changeset
481 class pass_iv_optimize : public gimple_opt_pass
kono
parents: 67
diff changeset
482 {
kono
parents: 67
diff changeset
483 public:
kono
parents: 67
diff changeset
484 pass_iv_optimize (gcc::context *ctxt)
kono
parents: 67
diff changeset
485 : gimple_opt_pass (pass_data_iv_optimize, ctxt)
kono
parents: 67
diff changeset
486 {}
kono
parents: 67
diff changeset
487
kono
parents: 67
diff changeset
488 /* opt_pass methods: */
kono
parents: 67
diff changeset
489 virtual bool gate (function *) { return flag_ivopts != 0; }
kono
parents: 67
diff changeset
490 virtual unsigned int execute (function *);
kono
parents: 67
diff changeset
491
kono
parents: 67
diff changeset
492 }; // class pass_iv_optimize
kono
parents: 67
diff changeset
493
kono
parents: 67
diff changeset
494 unsigned int
kono
parents: 67
diff changeset
495 pass_iv_optimize::execute (function *fun)
kono
parents: 67
diff changeset
496 {
kono
parents: 67
diff changeset
497 if (number_of_loops (fun) <= 1)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
498 return 0;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
499
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
500 tree_ssa_iv_optimize ();
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
501 return 0;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
502 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
503
111
kono
parents: 67
diff changeset
504 } // anon namespace
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
505
111
kono
parents: 67
diff changeset
506 gimple_opt_pass *
kono
parents: 67
diff changeset
507 make_pass_iv_optimize (gcc::context *ctxt)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
508 {
111
kono
parents: 67
diff changeset
509 return new pass_iv_optimize (ctxt);
kono
parents: 67
diff changeset
510 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
511
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
512 /* Loop optimizer finalization. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
513
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
514 static unsigned int
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
515 tree_ssa_loop_done (void)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
516 {
111
kono
parents: 67
diff changeset
517 free_numbers_of_iterations_estimates (cfun);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
518 scev_finalize ();
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
519 loop_optimizer_finalize ();
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
520 return 0;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
521 }
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
522
111
kono
parents: 67
diff changeset
523 namespace {
kono
parents: 67
diff changeset
524
kono
parents: 67
diff changeset
525 const pass_data pass_data_tree_loop_done =
kono
parents: 67
diff changeset
526 {
kono
parents: 67
diff changeset
527 GIMPLE_PASS, /* type */
kono
parents: 67
diff changeset
528 "loopdone", /* name */
kono
parents: 67
diff changeset
529 OPTGROUP_LOOP, /* optinfo_flags */
kono
parents: 67
diff changeset
530 TV_NONE, /* tv_id */
kono
parents: 67
diff changeset
531 PROP_cfg, /* properties_required */
kono
parents: 67
diff changeset
532 0, /* properties_provided */
kono
parents: 67
diff changeset
533 0, /* properties_destroyed */
kono
parents: 67
diff changeset
534 0, /* todo_flags_start */
kono
parents: 67
diff changeset
535 TODO_cleanup_cfg, /* todo_flags_finish */
kono
parents: 67
diff changeset
536 };
kono
parents: 67
diff changeset
537
kono
parents: 67
diff changeset
538 class pass_tree_loop_done : public gimple_opt_pass
kono
parents: 67
diff changeset
539 {
kono
parents: 67
diff changeset
540 public:
kono
parents: 67
diff changeset
541 pass_tree_loop_done (gcc::context *ctxt)
kono
parents: 67
diff changeset
542 : gimple_opt_pass (pass_data_tree_loop_done, ctxt)
kono
parents: 67
diff changeset
543 {}
kono
parents: 67
diff changeset
544
kono
parents: 67
diff changeset
545 /* opt_pass methods: */
kono
parents: 67
diff changeset
546 virtual unsigned int execute (function *) { return tree_ssa_loop_done (); }
kono
parents: 67
diff changeset
547
kono
parents: 67
diff changeset
548 }; // class pass_tree_loop_done
kono
parents: 67
diff changeset
549
kono
parents: 67
diff changeset
550 } // anon namespace
kono
parents: 67
diff changeset
551
kono
parents: 67
diff changeset
552 gimple_opt_pass *
kono
parents: 67
diff changeset
553 make_pass_tree_loop_done (gcc::context *ctxt)
kono
parents: 67
diff changeset
554 {
kono
parents: 67
diff changeset
555 return new pass_tree_loop_done (ctxt);
kono
parents: 67
diff changeset
556 }
kono
parents: 67
diff changeset
557
kono
parents: 67
diff changeset
558 /* Calls CBCK for each index in memory reference ADDR_P. There are two
kono
parents: 67
diff changeset
559 kinds situations handled; in each of these cases, the memory reference
kono
parents: 67
diff changeset
560 and DATA are passed to the callback:
kono
parents: 67
diff changeset
561
kono
parents: 67
diff changeset
562 Access to an array: ARRAY_{RANGE_}REF (base, index). In this case we also
kono
parents: 67
diff changeset
563 pass the pointer to the index to the callback.
kono
parents: 67
diff changeset
564
kono
parents: 67
diff changeset
565 Pointer dereference: INDIRECT_REF (addr). In this case we also pass the
kono
parents: 67
diff changeset
566 pointer to addr to the callback.
kono
parents: 67
diff changeset
567
kono
parents: 67
diff changeset
568 If the callback returns false, the whole search stops and false is returned.
kono
parents: 67
diff changeset
569 Otherwise the function returns true after traversing through the whole
kono
parents: 67
diff changeset
570 reference *ADDR_P. */
kono
parents: 67
diff changeset
571
kono
parents: 67
diff changeset
572 bool
kono
parents: 67
diff changeset
573 for_each_index (tree *addr_p, bool (*cbck) (tree, tree *, void *), void *data)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
574 {
111
kono
parents: 67
diff changeset
575 tree *nxt, *idx;
kono
parents: 67
diff changeset
576
kono
parents: 67
diff changeset
577 for (; ; addr_p = nxt)
kono
parents: 67
diff changeset
578 {
kono
parents: 67
diff changeset
579 switch (TREE_CODE (*addr_p))
kono
parents: 67
diff changeset
580 {
kono
parents: 67
diff changeset
581 case SSA_NAME:
kono
parents: 67
diff changeset
582 return cbck (*addr_p, addr_p, data);
kono
parents: 67
diff changeset
583
kono
parents: 67
diff changeset
584 case MEM_REF:
kono
parents: 67
diff changeset
585 nxt = &TREE_OPERAND (*addr_p, 0);
kono
parents: 67
diff changeset
586 return cbck (*addr_p, nxt, data);
kono
parents: 67
diff changeset
587
kono
parents: 67
diff changeset
588 case BIT_FIELD_REF:
kono
parents: 67
diff changeset
589 case VIEW_CONVERT_EXPR:
kono
parents: 67
diff changeset
590 case REALPART_EXPR:
kono
parents: 67
diff changeset
591 case IMAGPART_EXPR:
kono
parents: 67
diff changeset
592 nxt = &TREE_OPERAND (*addr_p, 0);
kono
parents: 67
diff changeset
593 break;
kono
parents: 67
diff changeset
594
kono
parents: 67
diff changeset
595 case COMPONENT_REF:
kono
parents: 67
diff changeset
596 /* If the component has varying offset, it behaves like index
kono
parents: 67
diff changeset
597 as well. */
kono
parents: 67
diff changeset
598 idx = &TREE_OPERAND (*addr_p, 2);
kono
parents: 67
diff changeset
599 if (*idx
kono
parents: 67
diff changeset
600 && !cbck (*addr_p, idx, data))
kono
parents: 67
diff changeset
601 return false;
kono
parents: 67
diff changeset
602
kono
parents: 67
diff changeset
603 nxt = &TREE_OPERAND (*addr_p, 0);
kono
parents: 67
diff changeset
604 break;
kono
parents: 67
diff changeset
605
kono
parents: 67
diff changeset
606 case ARRAY_REF:
kono
parents: 67
diff changeset
607 case ARRAY_RANGE_REF:
kono
parents: 67
diff changeset
608 nxt = &TREE_OPERAND (*addr_p, 0);
kono
parents: 67
diff changeset
609 if (!cbck (*addr_p, &TREE_OPERAND (*addr_p, 1), data))
kono
parents: 67
diff changeset
610 return false;
kono
parents: 67
diff changeset
611 break;
kono
parents: 67
diff changeset
612
kono
parents: 67
diff changeset
613 case CONSTRUCTOR:
kono
parents: 67
diff changeset
614 return true;
kono
parents: 67
diff changeset
615
kono
parents: 67
diff changeset
616 case ADDR_EXPR:
kono
parents: 67
diff changeset
617 gcc_assert (is_gimple_min_invariant (*addr_p));
kono
parents: 67
diff changeset
618 return true;
kono
parents: 67
diff changeset
619
kono
parents: 67
diff changeset
620 case TARGET_MEM_REF:
kono
parents: 67
diff changeset
621 idx = &TMR_BASE (*addr_p);
kono
parents: 67
diff changeset
622 if (*idx
kono
parents: 67
diff changeset
623 && !cbck (*addr_p, idx, data))
kono
parents: 67
diff changeset
624 return false;
kono
parents: 67
diff changeset
625 idx = &TMR_INDEX (*addr_p);
kono
parents: 67
diff changeset
626 if (*idx
kono
parents: 67
diff changeset
627 && !cbck (*addr_p, idx, data))
kono
parents: 67
diff changeset
628 return false;
kono
parents: 67
diff changeset
629 idx = &TMR_INDEX2 (*addr_p);
kono
parents: 67
diff changeset
630 if (*idx
kono
parents: 67
diff changeset
631 && !cbck (*addr_p, idx, data))
kono
parents: 67
diff changeset
632 return false;
kono
parents: 67
diff changeset
633 return true;
kono
parents: 67
diff changeset
634
kono
parents: 67
diff changeset
635 default:
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
636 if (DECL_P (*addr_p)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
637 || CONSTANT_CLASS_P (*addr_p))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
638 return true;
111
kono
parents: 67
diff changeset
639 gcc_unreachable ();
kono
parents: 67
diff changeset
640 }
kono
parents: 67
diff changeset
641 }
kono
parents: 67
diff changeset
642 }
kono
parents: 67
diff changeset
643
kono
parents: 67
diff changeset
644
kono
parents: 67
diff changeset
645 /* The name and the length of the currently generated variable
kono
parents: 67
diff changeset
646 for lsm. */
kono
parents: 67
diff changeset
647 #define MAX_LSM_NAME_LENGTH 40
kono
parents: 67
diff changeset
648 static char lsm_tmp_name[MAX_LSM_NAME_LENGTH + 1];
kono
parents: 67
diff changeset
649 static int lsm_tmp_name_length;
kono
parents: 67
diff changeset
650
kono
parents: 67
diff changeset
651 /* Adds S to lsm_tmp_name. */
kono
parents: 67
diff changeset
652
kono
parents: 67
diff changeset
653 static void
kono
parents: 67
diff changeset
654 lsm_tmp_name_add (const char *s)
kono
parents: 67
diff changeset
655 {
kono
parents: 67
diff changeset
656 int l = strlen (s) + lsm_tmp_name_length;
kono
parents: 67
diff changeset
657 if (l > MAX_LSM_NAME_LENGTH)
kono
parents: 67
diff changeset
658 return;
kono
parents: 67
diff changeset
659
kono
parents: 67
diff changeset
660 strcpy (lsm_tmp_name + lsm_tmp_name_length, s);
kono
parents: 67
diff changeset
661 lsm_tmp_name_length = l;
kono
parents: 67
diff changeset
662 }
kono
parents: 67
diff changeset
663
kono
parents: 67
diff changeset
664 /* Stores the name for temporary variable that replaces REF to
kono
parents: 67
diff changeset
665 lsm_tmp_name. */
kono
parents: 67
diff changeset
666
kono
parents: 67
diff changeset
667 static void
kono
parents: 67
diff changeset
668 gen_lsm_tmp_name (tree ref)
kono
parents: 67
diff changeset
669 {
kono
parents: 67
diff changeset
670 const char *name;
kono
parents: 67
diff changeset
671
kono
parents: 67
diff changeset
672 switch (TREE_CODE (ref))
kono
parents: 67
diff changeset
673 {
kono
parents: 67
diff changeset
674 case MEM_REF:
kono
parents: 67
diff changeset
675 case TARGET_MEM_REF:
kono
parents: 67
diff changeset
676 gen_lsm_tmp_name (TREE_OPERAND (ref, 0));
kono
parents: 67
diff changeset
677 lsm_tmp_name_add ("_");
kono
parents: 67
diff changeset
678 break;
kono
parents: 67
diff changeset
679
kono
parents: 67
diff changeset
680 case ADDR_EXPR:
kono
parents: 67
diff changeset
681 gen_lsm_tmp_name (TREE_OPERAND (ref, 0));
kono
parents: 67
diff changeset
682 break;
kono
parents: 67
diff changeset
683
kono
parents: 67
diff changeset
684 case BIT_FIELD_REF:
kono
parents: 67
diff changeset
685 case VIEW_CONVERT_EXPR:
kono
parents: 67
diff changeset
686 case ARRAY_RANGE_REF:
kono
parents: 67
diff changeset
687 gen_lsm_tmp_name (TREE_OPERAND (ref, 0));
kono
parents: 67
diff changeset
688 break;
kono
parents: 67
diff changeset
689
kono
parents: 67
diff changeset
690 case REALPART_EXPR:
kono
parents: 67
diff changeset
691 gen_lsm_tmp_name (TREE_OPERAND (ref, 0));
kono
parents: 67
diff changeset
692 lsm_tmp_name_add ("_RE");
kono
parents: 67
diff changeset
693 break;
kono
parents: 67
diff changeset
694
kono
parents: 67
diff changeset
695 case IMAGPART_EXPR:
kono
parents: 67
diff changeset
696 gen_lsm_tmp_name (TREE_OPERAND (ref, 0));
kono
parents: 67
diff changeset
697 lsm_tmp_name_add ("_IM");
kono
parents: 67
diff changeset
698 break;
kono
parents: 67
diff changeset
699
kono
parents: 67
diff changeset
700 case COMPONENT_REF:
kono
parents: 67
diff changeset
701 gen_lsm_tmp_name (TREE_OPERAND (ref, 0));
kono
parents: 67
diff changeset
702 lsm_tmp_name_add ("_");
kono
parents: 67
diff changeset
703 name = get_name (TREE_OPERAND (ref, 1));
kono
parents: 67
diff changeset
704 if (!name)
kono
parents: 67
diff changeset
705 name = "F";
kono
parents: 67
diff changeset
706 lsm_tmp_name_add (name);
kono
parents: 67
diff changeset
707 break;
kono
parents: 67
diff changeset
708
kono
parents: 67
diff changeset
709 case ARRAY_REF:
kono
parents: 67
diff changeset
710 gen_lsm_tmp_name (TREE_OPERAND (ref, 0));
kono
parents: 67
diff changeset
711 lsm_tmp_name_add ("_I");
kono
parents: 67
diff changeset
712 break;
kono
parents: 67
diff changeset
713
kono
parents: 67
diff changeset
714 case SSA_NAME:
kono
parents: 67
diff changeset
715 case VAR_DECL:
kono
parents: 67
diff changeset
716 case PARM_DECL:
kono
parents: 67
diff changeset
717 case FUNCTION_DECL:
kono
parents: 67
diff changeset
718 case LABEL_DECL:
kono
parents: 67
diff changeset
719 name = get_name (ref);
kono
parents: 67
diff changeset
720 if (!name)
kono
parents: 67
diff changeset
721 name = "D";
kono
parents: 67
diff changeset
722 lsm_tmp_name_add (name);
kono
parents: 67
diff changeset
723 break;
kono
parents: 67
diff changeset
724
kono
parents: 67
diff changeset
725 case STRING_CST:
kono
parents: 67
diff changeset
726 lsm_tmp_name_add ("S");
kono
parents: 67
diff changeset
727 break;
kono
parents: 67
diff changeset
728
kono
parents: 67
diff changeset
729 case RESULT_DECL:
kono
parents: 67
diff changeset
730 lsm_tmp_name_add ("R");
kono
parents: 67
diff changeset
731 break;
kono
parents: 67
diff changeset
732
kono
parents: 67
diff changeset
733 case INTEGER_CST:
kono
parents: 67
diff changeset
734 default:
kono
parents: 67
diff changeset
735 /* Nothing. */
kono
parents: 67
diff changeset
736 break;
kono
parents: 67
diff changeset
737 }
kono
parents: 67
diff changeset
738 }
kono
parents: 67
diff changeset
739
kono
parents: 67
diff changeset
740 /* Determines name for temporary variable that replaces REF.
kono
parents: 67
diff changeset
741 The name is accumulated into the lsm_tmp_name variable.
kono
parents: 67
diff changeset
742 N is added to the name of the temporary. */
kono
parents: 67
diff changeset
743
kono
parents: 67
diff changeset
744 char *
kono
parents: 67
diff changeset
745 get_lsm_tmp_name (tree ref, unsigned n, const char *suffix)
kono
parents: 67
diff changeset
746 {
kono
parents: 67
diff changeset
747 char ns[2];
kono
parents: 67
diff changeset
748
kono
parents: 67
diff changeset
749 lsm_tmp_name_length = 0;
kono
parents: 67
diff changeset
750 gen_lsm_tmp_name (ref);
kono
parents: 67
diff changeset
751 lsm_tmp_name_add ("_lsm");
kono
parents: 67
diff changeset
752 if (n < 10)
kono
parents: 67
diff changeset
753 {
kono
parents: 67
diff changeset
754 ns[0] = '0' + n;
kono
parents: 67
diff changeset
755 ns[1] = 0;
kono
parents: 67
diff changeset
756 lsm_tmp_name_add (ns);
kono
parents: 67
diff changeset
757 }
kono
parents: 67
diff changeset
758 return lsm_tmp_name;
kono
parents: 67
diff changeset
759 if (suffix != NULL)
kono
parents: 67
diff changeset
760 lsm_tmp_name_add (suffix);
kono
parents: 67
diff changeset
761 }
kono
parents: 67
diff changeset
762
kono
parents: 67
diff changeset
763 /* Computes an estimated number of insns in LOOP, weighted by WEIGHTS. */
kono
parents: 67
diff changeset
764
kono
parents: 67
diff changeset
765 unsigned
kono
parents: 67
diff changeset
766 tree_num_loop_insns (struct loop *loop, eni_weights *weights)
kono
parents: 67
diff changeset
767 {
kono
parents: 67
diff changeset
768 basic_block *body = get_loop_body (loop);
kono
parents: 67
diff changeset
769 gimple_stmt_iterator gsi;
kono
parents: 67
diff changeset
770 unsigned size = 0, i;
kono
parents: 67
diff changeset
771
kono
parents: 67
diff changeset
772 for (i = 0; i < loop->num_nodes; i++)
kono
parents: 67
diff changeset
773 for (gsi = gsi_start_bb (body[i]); !gsi_end_p (gsi); gsi_next (&gsi))
kono
parents: 67
diff changeset
774 size += estimate_num_insns (gsi_stmt (gsi), weights);
kono
parents: 67
diff changeset
775 free (body);
kono
parents: 67
diff changeset
776
kono
parents: 67
diff changeset
777 return size;
kono
parents: 67
diff changeset
778 }
kono
parents: 67
diff changeset
779
kono
parents: 67
diff changeset
780
kono
parents: 67
diff changeset
781