annotate gcc/tree-ssa-loop-ch.c @ 16:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents f6334be47118
children 84e7813d76e9
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 header copying on trees.
16
kono
parents: 14
diff changeset
2 Copyright (C) 2004-2017 Free Software Foundation, Inc.
9
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.
9
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.
9
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.
9
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"
16
kono
parents: 14
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"
16
kono
parents: 14
diff changeset
25 #include "gimple.h"
kono
parents: 14
diff changeset
26 #include "cfghooks.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 #include "tree-pass.h"
16
kono
parents: 14
diff changeset
28 #include "gimple-ssa.h"
kono
parents: 14
diff changeset
29 #include "gimple-iterator.h"
kono
parents: 14
diff changeset
30 #include "tree-cfg.h"
kono
parents: 14
diff changeset
31 #include "tree-into-ssa.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 #include "cfgloop.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 #include "tree-inline.h"
16
kono
parents: 14
diff changeset
34 #include "tree-ssa-scopedtables.h"
kono
parents: 14
diff changeset
35 #include "tree-ssa-threadedge.h"
kono
parents: 14
diff changeset
36 #include "params.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 /* Duplicates headers of loops if they are small enough, so that the statements
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 in the loop body are always executed when the loop is entered. This
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 increases effectiveness of code motion optimizations, and reduces the need
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 for loop preconditioning. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
42
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 /* Check whether we should duplicate HEADER of LOOP. At most *LIMIT
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 instructions should be duplicated, limit is decreased by the actual
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 amount. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
46
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 static bool
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 should_duplicate_loop_header_p (basic_block header, struct loop *loop,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 int *limit)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 gimple_stmt_iterator bsi;
16
kono
parents: 14
diff changeset
52 gimple *last;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
53
16
kono
parents: 14
diff changeset
54 gcc_assert (!header->aux);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
55
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 /* Loop header copying usually increases size of the code. This used not to
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 be true, since quite often it is possible to verify that the condition is
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 satisfied in the first iteration and therefore to eliminate it. Jump
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 threading handles these cases now. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 if (optimize_loop_for_size_p (loop))
16
kono
parents: 14
diff changeset
61 {
kono
parents: 14
diff changeset
62 if (dump_file && (dump_flags & TDF_DETAILS))
kono
parents: 14
diff changeset
63 fprintf (dump_file,
kono
parents: 14
diff changeset
64 " Not duplicating bb %i: optimizing for size.\n",
kono
parents: 14
diff changeset
65 header->index);
kono
parents: 14
diff changeset
66 return false;
kono
parents: 14
diff changeset
67 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
68
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 gcc_assert (EDGE_COUNT (header->succs) > 0);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 if (single_succ_p (header))
16
kono
parents: 14
diff changeset
71 {
kono
parents: 14
diff changeset
72 if (dump_file && (dump_flags & TDF_DETAILS))
kono
parents: 14
diff changeset
73 fprintf (dump_file,
kono
parents: 14
diff changeset
74 " Not duplicating bb %i: it is single succ.\n",
kono
parents: 14
diff changeset
75 header->index);
kono
parents: 14
diff changeset
76 return false;
kono
parents: 14
diff changeset
77 }
kono
parents: 14
diff changeset
78
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 if (flow_bb_inside_loop_p (loop, EDGE_SUCC (header, 0)->dest)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 && flow_bb_inside_loop_p (loop, EDGE_SUCC (header, 1)->dest))
16
kono
parents: 14
diff changeset
81 {
kono
parents: 14
diff changeset
82 if (dump_file && (dump_flags & TDF_DETAILS))
kono
parents: 14
diff changeset
83 fprintf (dump_file,
kono
parents: 14
diff changeset
84 " Not duplicating bb %i: both sucessors are in loop.\n",
kono
parents: 14
diff changeset
85 loop->num);
kono
parents: 14
diff changeset
86 return false;
kono
parents: 14
diff changeset
87 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
88
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 /* If this is not the original loop header, we want it to have just
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
90 one predecessor in order to match the && pattern. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
91 if (header != loop->header && !single_pred_p (header))
16
kono
parents: 14
diff changeset
92 {
kono
parents: 14
diff changeset
93 if (dump_file && (dump_flags & TDF_DETAILS))
kono
parents: 14
diff changeset
94 fprintf (dump_file,
kono
parents: 14
diff changeset
95 " Not duplicating bb %i: it has mutiple predecestors.\n",
kono
parents: 14
diff changeset
96 header->index);
kono
parents: 14
diff changeset
97 return false;
kono
parents: 14
diff changeset
98 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
99
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
100 last = last_stmt (header);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
101 if (gimple_code (last) != GIMPLE_COND)
16
kono
parents: 14
diff changeset
102 {
kono
parents: 14
diff changeset
103 if (dump_file && (dump_flags & TDF_DETAILS))
kono
parents: 14
diff changeset
104 fprintf (dump_file,
kono
parents: 14
diff changeset
105 " Not duplicating bb %i: it does not end by conditional.\n",
kono
parents: 14
diff changeset
106 header->index);
kono
parents: 14
diff changeset
107 return false;
kono
parents: 14
diff changeset
108 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
109
16
kono
parents: 14
diff changeset
110 /* Count number of instructions and punt on calls. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
111 for (bsi = gsi_start_bb (header); !gsi_end_p (bsi); gsi_next (&bsi))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
112 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
113 last = gsi_stmt (bsi);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
114
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
115 if (gimple_code (last) == GIMPLE_LABEL)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
116 continue;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
117
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
118 if (is_gimple_debug (last))
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
119 continue;
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
120
16
kono
parents: 14
diff changeset
121 if (gimple_code (last) == GIMPLE_CALL
kono
parents: 14
diff changeset
122 && (!gimple_inexpensive_call_p (as_a <gcall *> (last))
kono
parents: 14
diff changeset
123 /* IFN_LOOP_DIST_ALIAS means that inner loop is distributed
kono
parents: 14
diff changeset
124 at current loop's header. Don't copy in this case. */
kono
parents: 14
diff changeset
125 || gimple_call_internal_p (last, IFN_LOOP_DIST_ALIAS)))
kono
parents: 14
diff changeset
126 {
kono
parents: 14
diff changeset
127 if (dump_file && (dump_flags & TDF_DETAILS))
kono
parents: 14
diff changeset
128 fprintf (dump_file,
kono
parents: 14
diff changeset
129 " Not duplicating bb %i: it contains call.\n",
kono
parents: 14
diff changeset
130 header->index);
kono
parents: 14
diff changeset
131 return false;
kono
parents: 14
diff changeset
132 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
133
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
134 *limit -= estimate_num_insns (last, &eni_size_weights);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
135 if (*limit < 0)
16
kono
parents: 14
diff changeset
136 {
kono
parents: 14
diff changeset
137 if (dump_file && (dump_flags & TDF_DETAILS))
kono
parents: 14
diff changeset
138 fprintf (dump_file,
kono
parents: 14
diff changeset
139 " Not duplicating bb %i contains too many insns.\n",
kono
parents: 14
diff changeset
140 header->index);
kono
parents: 14
diff changeset
141 return false;
kono
parents: 14
diff changeset
142 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
143 }
16
kono
parents: 14
diff changeset
144 if (dump_file && (dump_flags & TDF_DETAILS))
kono
parents: 14
diff changeset
145 fprintf (dump_file, " Will duplicate bb %i\n", header->index);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
146 return true;
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
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
149 /* Checks whether LOOP is a do-while style loop. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
150
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
151 static bool
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
152 do_while_loop_p (struct loop *loop)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
153 {
16
kono
parents: 14
diff changeset
154 gimple *stmt = last_stmt (loop->latch);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
155
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
156 /* If the latch of the loop is not empty, it is not a do-while loop. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
157 if (stmt
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
158 && gimple_code (stmt) != GIMPLE_LABEL)
16
kono
parents: 14
diff changeset
159 {
kono
parents: 14
diff changeset
160 if (dump_file && (dump_flags & TDF_DETAILS))
kono
parents: 14
diff changeset
161 fprintf (dump_file,
kono
parents: 14
diff changeset
162 "Loop %i is not do-while loop: latch is not empty.\n",
kono
parents: 14
diff changeset
163 loop->num);
kono
parents: 14
diff changeset
164 return false;
kono
parents: 14
diff changeset
165 }
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 /* If the header contains just a condition, it is not a do-while loop. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
168 stmt = last_and_only_stmt (loop->header);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
169 if (stmt
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
170 && gimple_code (stmt) == GIMPLE_COND)
16
kono
parents: 14
diff changeset
171 {
kono
parents: 14
diff changeset
172 if (dump_file && (dump_flags & TDF_DETAILS))
kono
parents: 14
diff changeset
173 fprintf (dump_file,
kono
parents: 14
diff changeset
174 "Loop %i is not do-while loop: "
kono
parents: 14
diff changeset
175 "header contains just condition.\n", loop->num);
kono
parents: 14
diff changeset
176 return false;
kono
parents: 14
diff changeset
177 }
kono
parents: 14
diff changeset
178 if (dump_file && (dump_flags & TDF_DETAILS))
kono
parents: 14
diff changeset
179 fprintf (dump_file, "Loop %i is do-while loop\n", loop->num);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
180
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
181 return true;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
182 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
183
16
kono
parents: 14
diff changeset
184 namespace {
kono
parents: 14
diff changeset
185
kono
parents: 14
diff changeset
186 /* Common superclass for both header-copying phases. */
kono
parents: 14
diff changeset
187 class ch_base : public gimple_opt_pass
kono
parents: 14
diff changeset
188 {
kono
parents: 14
diff changeset
189 protected:
kono
parents: 14
diff changeset
190 ch_base (pass_data data, gcc::context *ctxt)
kono
parents: 14
diff changeset
191 : gimple_opt_pass (data, ctxt)
kono
parents: 14
diff changeset
192 {}
kono
parents: 14
diff changeset
193
kono
parents: 14
diff changeset
194 /* Copies headers of all loops in FUN for which process_loop_p is true. */
kono
parents: 14
diff changeset
195 unsigned int copy_headers (function *fun);
kono
parents: 14
diff changeset
196
kono
parents: 14
diff changeset
197 /* Return true to copy headers of LOOP or false to skip. */
kono
parents: 14
diff changeset
198 virtual bool process_loop_p (struct loop *loop) = 0;
kono
parents: 14
diff changeset
199 };
kono
parents: 14
diff changeset
200
kono
parents: 14
diff changeset
201 const pass_data pass_data_ch =
kono
parents: 14
diff changeset
202 {
kono
parents: 14
diff changeset
203 GIMPLE_PASS, /* type */
kono
parents: 14
diff changeset
204 "ch", /* name */
kono
parents: 14
diff changeset
205 OPTGROUP_LOOP, /* optinfo_flags */
kono
parents: 14
diff changeset
206 TV_TREE_CH, /* tv_id */
kono
parents: 14
diff changeset
207 ( PROP_cfg | PROP_ssa ), /* properties_required */
kono
parents: 14
diff changeset
208 0, /* properties_provided */
kono
parents: 14
diff changeset
209 0, /* properties_destroyed */
kono
parents: 14
diff changeset
210 0, /* todo_flags_start */
kono
parents: 14
diff changeset
211 0, /* todo_flags_finish */
kono
parents: 14
diff changeset
212 };
kono
parents: 14
diff changeset
213
kono
parents: 14
diff changeset
214 class pass_ch : public ch_base
kono
parents: 14
diff changeset
215 {
kono
parents: 14
diff changeset
216 public:
kono
parents: 14
diff changeset
217 pass_ch (gcc::context *ctxt)
kono
parents: 14
diff changeset
218 : ch_base (pass_data_ch, ctxt)
kono
parents: 14
diff changeset
219 {}
kono
parents: 14
diff changeset
220
kono
parents: 14
diff changeset
221 /* opt_pass methods: */
kono
parents: 14
diff changeset
222 virtual bool gate (function *) { return flag_tree_ch != 0; }
kono
parents: 14
diff changeset
223
kono
parents: 14
diff changeset
224 /* Initialize and finalize loop structures, copying headers inbetween. */
kono
parents: 14
diff changeset
225 virtual unsigned int execute (function *);
kono
parents: 14
diff changeset
226
kono
parents: 14
diff changeset
227 opt_pass * clone () { return new pass_ch (m_ctxt); }
kono
parents: 14
diff changeset
228
kono
parents: 14
diff changeset
229 protected:
kono
parents: 14
diff changeset
230 /* ch_base method: */
kono
parents: 14
diff changeset
231 virtual bool process_loop_p (struct loop *loop);
kono
parents: 14
diff changeset
232 }; // class pass_ch
kono
parents: 14
diff changeset
233
kono
parents: 14
diff changeset
234 const pass_data pass_data_ch_vect =
kono
parents: 14
diff changeset
235 {
kono
parents: 14
diff changeset
236 GIMPLE_PASS, /* type */
kono
parents: 14
diff changeset
237 "ch_vect", /* name */
kono
parents: 14
diff changeset
238 OPTGROUP_LOOP, /* optinfo_flags */
kono
parents: 14
diff changeset
239 TV_TREE_CH, /* tv_id */
kono
parents: 14
diff changeset
240 ( PROP_cfg | PROP_ssa ), /* properties_required */
kono
parents: 14
diff changeset
241 0, /* properties_provided */
kono
parents: 14
diff changeset
242 0, /* properties_destroyed */
kono
parents: 14
diff changeset
243 0, /* todo_flags_start */
kono
parents: 14
diff changeset
244 0, /* todo_flags_finish */
kono
parents: 14
diff changeset
245 };
kono
parents: 14
diff changeset
246
kono
parents: 14
diff changeset
247 /* This is a more aggressive version of the same pass, designed to run just
kono
parents: 14
diff changeset
248 before if-conversion and vectorization, to put more loops into the form
kono
parents: 14
diff changeset
249 required for those phases. */
kono
parents: 14
diff changeset
250 class pass_ch_vect : public ch_base
kono
parents: 14
diff changeset
251 {
kono
parents: 14
diff changeset
252 public:
kono
parents: 14
diff changeset
253 pass_ch_vect (gcc::context *ctxt)
kono
parents: 14
diff changeset
254 : ch_base (pass_data_ch_vect, ctxt)
kono
parents: 14
diff changeset
255 {}
kono
parents: 14
diff changeset
256
kono
parents: 14
diff changeset
257 /* opt_pass methods: */
kono
parents: 14
diff changeset
258 virtual bool gate (function *fun)
kono
parents: 14
diff changeset
259 {
kono
parents: 14
diff changeset
260 return flag_tree_ch != 0
kono
parents: 14
diff changeset
261 && (flag_tree_loop_vectorize != 0 || fun->has_force_vectorize_loops);
kono
parents: 14
diff changeset
262 }
kono
parents: 14
diff changeset
263
kono
parents: 14
diff changeset
264 /* Just copy headers, no initialization/finalization of loop structures. */
kono
parents: 14
diff changeset
265 virtual unsigned int execute (function *);
kono
parents: 14
diff changeset
266
kono
parents: 14
diff changeset
267 protected:
kono
parents: 14
diff changeset
268 /* ch_base method: */
kono
parents: 14
diff changeset
269 virtual bool process_loop_p (struct loop *loop);
kono
parents: 14
diff changeset
270 }; // class pass_ch_vect
kono
parents: 14
diff changeset
271
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
272 /* For all loops, copy the condition at the end of the loop body in front
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
273 of the loop. This is beneficial since it increases efficiency of
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
274 code motion optimizations. It also saves one jump on entry to the loop. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
275
16
kono
parents: 14
diff changeset
276 unsigned int
kono
parents: 14
diff changeset
277 ch_base::copy_headers (function *fun)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
278 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
279 struct loop *loop;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
280 basic_block header;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
281 edge exit, entry;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
282 basic_block *bbs, *copied_bbs;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
283 unsigned n_bbs;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
284 unsigned bbs_size;
16
kono
parents: 14
diff changeset
285 bool changed = false;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
286
16
kono
parents: 14
diff changeset
287 if (number_of_loops (fun) <= 1)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
288 return 0;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
289
16
kono
parents: 14
diff changeset
290 bbs = XNEWVEC (basic_block, n_basic_blocks_for_fn (fun));
kono
parents: 14
diff changeset
291 copied_bbs = XNEWVEC (basic_block, n_basic_blocks_for_fn (fun));
kono
parents: 14
diff changeset
292 bbs_size = n_basic_blocks_for_fn (fun);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
293
16
kono
parents: 14
diff changeset
294 FOR_EACH_LOOP (loop, 0)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
295 {
16
kono
parents: 14
diff changeset
296 int initial_limit = PARAM_VALUE (PARAM_MAX_LOOP_HEADER_INSNS);
kono
parents: 14
diff changeset
297 int remaining_limit = initial_limit;
kono
parents: 14
diff changeset
298 if (dump_file && (dump_flags & TDF_DETAILS))
kono
parents: 14
diff changeset
299 fprintf (dump_file,
kono
parents: 14
diff changeset
300 "Analyzing loop %i\n", loop->num);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
301
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
302 header = loop->header;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
303
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
304 /* If the loop is already a do-while style one (either because it was
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
305 written as such, or because jump threading transformed it into one),
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
306 we might be in fact peeling the first iteration of the loop. This
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
307 in general is not a good idea. */
16
kono
parents: 14
diff changeset
308 if (!process_loop_p (loop))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
309 continue;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
310
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
311 /* Iterate the header copying up to limit; this takes care of the cases
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
312 like while (a && b) {...}, where we want to have both of the conditions
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
313 copied. TODO -- handle while (a || b) - like cases, by not requiring
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
314 the header to have just a single successor and copying up to
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
315 postdominator. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
316
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
317 exit = NULL;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
318 n_bbs = 0;
16
kono
parents: 14
diff changeset
319 while (should_duplicate_loop_header_p (header, loop, &remaining_limit))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
320 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
321 /* Find a successor of header that is inside a loop; i.e. the new
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
322 header after the condition is copied. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
323 if (flow_bb_inside_loop_p (loop, EDGE_SUCC (header, 0)->dest))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
324 exit = EDGE_SUCC (header, 0);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
325 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
326 exit = EDGE_SUCC (header, 1);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
327 bbs[n_bbs++] = header;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
328 gcc_assert (bbs_size > n_bbs);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
329 header = exit->dest;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
330 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
331
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
332 if (!exit)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
333 continue;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
334
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
335 if (dump_file && (dump_flags & TDF_DETAILS))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
336 fprintf (dump_file,
16
kono
parents: 14
diff changeset
337 "Duplicating header of the loop %d up to edge %d->%d,"
kono
parents: 14
diff changeset
338 " %i insns.\n",
kono
parents: 14
diff changeset
339 loop->num, exit->src->index, exit->dest->index,
kono
parents: 14
diff changeset
340 initial_limit - remaining_limit);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
341
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
342 /* Ensure that the header will have just the latch as a predecessor
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
343 inside the loop. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
344 if (!single_pred_p (exit->dest))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
345 exit = single_pred_edge (split_edge (exit));
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
346
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
347 entry = loop_preheader_edge (loop);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
348
16
kono
parents: 14
diff changeset
349 propagate_threaded_block_debug_into (exit->dest, entry->dest);
kono
parents: 14
diff changeset
350 if (!gimple_duplicate_sese_region (entry, exit, bbs, n_bbs, copied_bbs,
kono
parents: 14
diff changeset
351 true))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
352 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
353 fprintf (dump_file, "Duplication failed.\n");
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
354 continue;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
355 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
356
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
357 /* If the loop has the form "for (i = j; i < j + 10; i++)" then
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
358 this copying can introduce a case where we rely on undefined
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
359 signed overflow to eliminate the preheader condition, because
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
360 we assume that "j < j + 10" is true. We don't want to warn
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
361 about that case for -Wstrict-overflow, because in general we
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
362 don't warn about overflow involving loops. Prevent the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
363 warning by setting the no_warning flag in the condition. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
364 if (warn_strict_overflow > 0)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
365 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
366 unsigned int i;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
367
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
368 for (i = 0; i < n_bbs; ++i)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
369 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
370 gimple_stmt_iterator bsi;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
371
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
372 for (bsi = gsi_start_bb (copied_bbs[i]);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
373 !gsi_end_p (bsi);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
374 gsi_next (&bsi))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
375 {
16
kono
parents: 14
diff changeset
376 gimple *stmt = gsi_stmt (bsi);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
377 if (gimple_code (stmt) == GIMPLE_COND)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
378 gimple_set_no_warning (stmt, true);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
379 else if (is_gimple_assign (stmt))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
380 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
381 enum tree_code rhs_code = gimple_assign_rhs_code (stmt);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
382 if (TREE_CODE_CLASS (rhs_code) == tcc_comparison)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
383 gimple_set_no_warning (stmt, true);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
384 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
385 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
386 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
387 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
388
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
389 /* Ensure that the latch and the preheader is simple (we know that they
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
390 are not now, since there was the loop exit condition. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
391 split_edge (loop_preheader_edge (loop));
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
392 split_edge (loop_latch_edge (loop));
16
kono
parents: 14
diff changeset
393
kono
parents: 14
diff changeset
394 changed = true;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
395 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
396
16
kono
parents: 14
diff changeset
397 if (changed)
kono
parents: 14
diff changeset
398 update_ssa (TODO_update_ssa);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
399 free (bbs);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
400 free (copied_bbs);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
401
16
kono
parents: 14
diff changeset
402 return changed ? TODO_cleanup_cfg : 0;
kono
parents: 14
diff changeset
403 }
kono
parents: 14
diff changeset
404
kono
parents: 14
diff changeset
405 /* Initialize the loop structures we need, and finalize after. */
kono
parents: 14
diff changeset
406
kono
parents: 14
diff changeset
407 unsigned int
kono
parents: 14
diff changeset
408 pass_ch::execute (function *fun)
kono
parents: 14
diff changeset
409 {
kono
parents: 14
diff changeset
410 loop_optimizer_init (LOOPS_HAVE_PREHEADERS
kono
parents: 14
diff changeset
411 | LOOPS_HAVE_SIMPLE_LATCHES);
kono
parents: 14
diff changeset
412
kono
parents: 14
diff changeset
413 unsigned int res = copy_headers (fun);
kono
parents: 14
diff changeset
414
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
415 loop_optimizer_finalize ();
16
kono
parents: 14
diff changeset
416 return res;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
417 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
418
16
kono
parents: 14
diff changeset
419 /* Assume an earlier phase has already initialized all the loop structures that
kono
parents: 14
diff changeset
420 we need here (and perhaps others too), and that these will be finalized by
kono
parents: 14
diff changeset
421 a later phase. */
kono
parents: 14
diff changeset
422
kono
parents: 14
diff changeset
423 unsigned int
kono
parents: 14
diff changeset
424 pass_ch_vect::execute (function *fun)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
425 {
16
kono
parents: 14
diff changeset
426 return copy_headers (fun);
kono
parents: 14
diff changeset
427 }
kono
parents: 14
diff changeset
428
kono
parents: 14
diff changeset
429 /* Apply header copying according to a very simple test of do-while shape. */
kono
parents: 14
diff changeset
430
kono
parents: 14
diff changeset
431 bool
kono
parents: 14
diff changeset
432 pass_ch::process_loop_p (struct loop *loop)
kono
parents: 14
diff changeset
433 {
kono
parents: 14
diff changeset
434 return !do_while_loop_p (loop);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
435 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
436
16
kono
parents: 14
diff changeset
437 /* Apply header-copying to loops where we might enable vectorization. */
kono
parents: 14
diff changeset
438
kono
parents: 14
diff changeset
439 bool
kono
parents: 14
diff changeset
440 pass_ch_vect::process_loop_p (struct loop *loop)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
441 {
16
kono
parents: 14
diff changeset
442 if (!flag_tree_loop_vectorize && !loop->force_vectorize)
kono
parents: 14
diff changeset
443 return false;
kono
parents: 14
diff changeset
444
kono
parents: 14
diff changeset
445 if (loop->dont_vectorize)
kono
parents: 14
diff changeset
446 return false;
kono
parents: 14
diff changeset
447
kono
parents: 14
diff changeset
448 if (!do_while_loop_p (loop))
kono
parents: 14
diff changeset
449 return true;
kono
parents: 14
diff changeset
450
kono
parents: 14
diff changeset
451 /* The vectorizer won't handle anything with multiple exits, so skip. */
kono
parents: 14
diff changeset
452 edge exit = single_exit (loop);
kono
parents: 14
diff changeset
453 if (!exit)
kono
parents: 14
diff changeset
454 return false;
kono
parents: 14
diff changeset
455
kono
parents: 14
diff changeset
456 /* Copy headers iff there looks to be code in the loop after the exit block,
kono
parents: 14
diff changeset
457 i.e. the exit block has an edge to another block (besides the latch,
kono
parents: 14
diff changeset
458 which should be empty). */
kono
parents: 14
diff changeset
459 edge_iterator ei;
kono
parents: 14
diff changeset
460 edge e;
kono
parents: 14
diff changeset
461 FOR_EACH_EDGE (e, ei, exit->src->succs)
kono
parents: 14
diff changeset
462 if (!loop_exit_edge_p (loop, e)
kono
parents: 14
diff changeset
463 && e->dest != loop->header
kono
parents: 14
diff changeset
464 && e->dest != loop->latch)
kono
parents: 14
diff changeset
465 return true;
kono
parents: 14
diff changeset
466
kono
parents: 14
diff changeset
467 return false;
kono
parents: 14
diff changeset
468 }
kono
parents: 14
diff changeset
469
kono
parents: 14
diff changeset
470 } // anon namespace
kono
parents: 14
diff changeset
471
kono
parents: 14
diff changeset
472 gimple_opt_pass *
kono
parents: 14
diff changeset
473 make_pass_ch_vect (gcc::context *ctxt)
kono
parents: 14
diff changeset
474 {
kono
parents: 14
diff changeset
475 return new pass_ch_vect (ctxt);
kono
parents: 14
diff changeset
476 }
kono
parents: 14
diff changeset
477
kono
parents: 14
diff changeset
478 gimple_opt_pass *
kono
parents: 14
diff changeset
479 make_pass_ch (gcc::context *ctxt)
kono
parents: 14
diff changeset
480 {
kono
parents: 14
diff changeset
481 return new pass_ch (ctxt);
kono
parents: 14
diff changeset
482 }