annotate gcc/tree-ssa-tail-merge.c @ 128:fe568345ddd5

fix CbC-example
author mir3636
date Wed, 11 Apr 2018 19:32:28 +0900
parents 04ced10e8804
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Tail merging for gimple.
kono
parents:
diff changeset
2 Copyright (C) 2011-2017 Free Software Foundation, Inc.
kono
parents:
diff changeset
3 Contributed by Tom de Vries (tom@codesourcery.com)
kono
parents:
diff changeset
4
kono
parents:
diff changeset
5 This file is part of GCC.
kono
parents:
diff changeset
6
kono
parents:
diff changeset
7 GCC is free software; you can redistribute it and/or modify
kono
parents:
diff changeset
8 it under the terms of the GNU General Public License as published by
kono
parents:
diff changeset
9 the Free Software Foundation; either version 3, or (at your option)
kono
parents:
diff changeset
10 any later version.
kono
parents:
diff changeset
11
kono
parents:
diff changeset
12 GCC is distributed in the hope that it will be useful,
kono
parents:
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
kono
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
kono
parents:
diff changeset
15 GNU General Public License for more details.
kono
parents:
diff changeset
16
kono
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
kono
parents:
diff changeset
18 along with GCC; see the file COPYING3. If not see
kono
parents:
diff changeset
19 <http://www.gnu.org/licenses/>. */
kono
parents:
diff changeset
20
kono
parents:
diff changeset
21 /* Pass overview.
kono
parents:
diff changeset
22
kono
parents:
diff changeset
23
kono
parents:
diff changeset
24 MOTIVATIONAL EXAMPLE
kono
parents:
diff changeset
25
kono
parents:
diff changeset
26 gimple representation of gcc/testsuite/gcc.dg/pr43864.c at
kono
parents:
diff changeset
27
kono
parents:
diff changeset
28 hprofStartupp (charD.1 * outputFileNameD.2600, charD.1 * ctxD.2601)
kono
parents:
diff changeset
29 {
kono
parents:
diff changeset
30 struct FILED.1638 * fpD.2605;
kono
parents:
diff changeset
31 charD.1 fileNameD.2604[1000];
kono
parents:
diff changeset
32 intD.0 D.3915;
kono
parents:
diff changeset
33 const charD.1 * restrict outputFileName.0D.3914;
kono
parents:
diff changeset
34
kono
parents:
diff changeset
35 # BLOCK 2 freq:10000
kono
parents:
diff changeset
36 # PRED: ENTRY [100.0%] (fallthru,exec)
kono
parents:
diff changeset
37 # PT = nonlocal { D.3926 } (restr)
kono
parents:
diff changeset
38 outputFileName.0D.3914_3
kono
parents:
diff changeset
39 = (const charD.1 * restrict) outputFileNameD.2600_2(D);
kono
parents:
diff changeset
40 # .MEMD.3923_13 = VDEF <.MEMD.3923_12(D)>
kono
parents:
diff changeset
41 # USE = nonlocal null { fileNameD.2604 D.3926 } (restr)
kono
parents:
diff changeset
42 # CLB = nonlocal null { fileNameD.2604 D.3926 } (restr)
kono
parents:
diff changeset
43 sprintfD.759 (&fileNameD.2604, outputFileName.0D.3914_3);
kono
parents:
diff changeset
44 # .MEMD.3923_14 = VDEF <.MEMD.3923_13>
kono
parents:
diff changeset
45 # USE = nonlocal null { fileNameD.2604 D.3926 } (restr)
kono
parents:
diff changeset
46 # CLB = nonlocal null { fileNameD.2604 D.3926 } (restr)
kono
parents:
diff changeset
47 D.3915_4 = accessD.2606 (&fileNameD.2604, 1);
kono
parents:
diff changeset
48 if (D.3915_4 == 0)
kono
parents:
diff changeset
49 goto <bb 3>;
kono
parents:
diff changeset
50 else
kono
parents:
diff changeset
51 goto <bb 4>;
kono
parents:
diff changeset
52 # SUCC: 3 [10.0%] (true,exec) 4 [90.0%] (false,exec)
kono
parents:
diff changeset
53
kono
parents:
diff changeset
54 # BLOCK 3 freq:1000
kono
parents:
diff changeset
55 # PRED: 2 [10.0%] (true,exec)
kono
parents:
diff changeset
56 # .MEMD.3923_15 = VDEF <.MEMD.3923_14>
kono
parents:
diff changeset
57 # USE = nonlocal null { fileNameD.2604 D.3926 } (restr)
kono
parents:
diff changeset
58 # CLB = nonlocal null { fileNameD.2604 D.3926 } (restr)
kono
parents:
diff changeset
59 freeD.898 (ctxD.2601_5(D));
kono
parents:
diff changeset
60 goto <bb 7>;
kono
parents:
diff changeset
61 # SUCC: 7 [100.0%] (fallthru,exec)
kono
parents:
diff changeset
62
kono
parents:
diff changeset
63 # BLOCK 4 freq:9000
kono
parents:
diff changeset
64 # PRED: 2 [90.0%] (false,exec)
kono
parents:
diff changeset
65 # .MEMD.3923_16 = VDEF <.MEMD.3923_14>
kono
parents:
diff changeset
66 # PT = nonlocal escaped
kono
parents:
diff changeset
67 # USE = nonlocal null { fileNameD.2604 D.3926 } (restr)
kono
parents:
diff changeset
68 # CLB = nonlocal null { fileNameD.2604 D.3926 } (restr)
kono
parents:
diff changeset
69 fpD.2605_8 = fopenD.1805 (&fileNameD.2604[0], 0B);
kono
parents:
diff changeset
70 if (fpD.2605_8 == 0B)
kono
parents:
diff changeset
71 goto <bb 5>;
kono
parents:
diff changeset
72 else
kono
parents:
diff changeset
73 goto <bb 6>;
kono
parents:
diff changeset
74 # SUCC: 5 [1.9%] (true,exec) 6 [98.1%] (false,exec)
kono
parents:
diff changeset
75
kono
parents:
diff changeset
76 # BLOCK 5 freq:173
kono
parents:
diff changeset
77 # PRED: 4 [1.9%] (true,exec)
kono
parents:
diff changeset
78 # .MEMD.3923_17 = VDEF <.MEMD.3923_16>
kono
parents:
diff changeset
79 # USE = nonlocal null { fileNameD.2604 D.3926 } (restr)
kono
parents:
diff changeset
80 # CLB = nonlocal null { fileNameD.2604 D.3926 } (restr)
kono
parents:
diff changeset
81 freeD.898 (ctxD.2601_5(D));
kono
parents:
diff changeset
82 goto <bb 7>;
kono
parents:
diff changeset
83 # SUCC: 7 [100.0%] (fallthru,exec)
kono
parents:
diff changeset
84
kono
parents:
diff changeset
85 # BLOCK 6 freq:8827
kono
parents:
diff changeset
86 # PRED: 4 [98.1%] (false,exec)
kono
parents:
diff changeset
87 # .MEMD.3923_18 = VDEF <.MEMD.3923_16>
kono
parents:
diff changeset
88 # USE = nonlocal null { fileNameD.2604 D.3926 } (restr)
kono
parents:
diff changeset
89 # CLB = nonlocal null { fileNameD.2604 D.3926 } (restr)
kono
parents:
diff changeset
90 fooD.2599 (outputFileNameD.2600_2(D), fpD.2605_8);
kono
parents:
diff changeset
91 # SUCC: 7 [100.0%] (fallthru,exec)
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93 # BLOCK 7 freq:10000
kono
parents:
diff changeset
94 # PRED: 3 [100.0%] (fallthru,exec) 5 [100.0%] (fallthru,exec)
kono
parents:
diff changeset
95 6 [100.0%] (fallthru,exec)
kono
parents:
diff changeset
96 # PT = nonlocal null
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 # ctxD.2601_1 = PHI <0B(3), 0B(5), ctxD.2601_5(D)(6)>
kono
parents:
diff changeset
99 # .MEMD.3923_11 = PHI <.MEMD.3923_15(3), .MEMD.3923_17(5),
kono
parents:
diff changeset
100 .MEMD.3923_18(6)>
kono
parents:
diff changeset
101 # VUSE <.MEMD.3923_11>
kono
parents:
diff changeset
102 return ctxD.2601_1;
kono
parents:
diff changeset
103 # SUCC: EXIT [100.0%]
kono
parents:
diff changeset
104 }
kono
parents:
diff changeset
105
kono
parents:
diff changeset
106 bb 3 and bb 5 can be merged. The blocks have different predecessors, but the
kono
parents:
diff changeset
107 same successors, and the same operations.
kono
parents:
diff changeset
108
kono
parents:
diff changeset
109
kono
parents:
diff changeset
110 CONTEXT
kono
parents:
diff changeset
111
kono
parents:
diff changeset
112 A technique called tail merging (or cross jumping) can fix the example
kono
parents:
diff changeset
113 above. For a block, we look for common code at the end (the tail) of the
kono
parents:
diff changeset
114 predecessor blocks, and insert jumps from one block to the other.
kono
parents:
diff changeset
115 The example is a special case for tail merging, in that 2 whole blocks
kono
parents:
diff changeset
116 can be merged, rather than just the end parts of it.
kono
parents:
diff changeset
117 We currently only focus on whole block merging, so in that sense
kono
parents:
diff changeset
118 calling this pass tail merge is a bit of a misnomer.
kono
parents:
diff changeset
119
kono
parents:
diff changeset
120 We distinguish 2 kinds of situations in which blocks can be merged:
kono
parents:
diff changeset
121 - same operations, same predecessors. The successor edges coming from one
kono
parents:
diff changeset
122 block are redirected to come from the other block.
kono
parents:
diff changeset
123 - same operations, same successors. The predecessor edges entering one block
kono
parents:
diff changeset
124 are redirected to enter the other block. Note that this operation might
kono
parents:
diff changeset
125 involve introducing phi operations.
kono
parents:
diff changeset
126
kono
parents:
diff changeset
127 For efficient implementation, we would like to value numbers the blocks, and
kono
parents:
diff changeset
128 have a comparison operator that tells us whether the blocks are equal.
kono
parents:
diff changeset
129 Besides being runtime efficient, block value numbering should also abstract
kono
parents:
diff changeset
130 from irrelevant differences in order of operations, much like normal value
kono
parents:
diff changeset
131 numbering abstracts from irrelevant order of operations.
kono
parents:
diff changeset
132
kono
parents:
diff changeset
133 For the first situation (same_operations, same predecessors), normal value
kono
parents:
diff changeset
134 numbering fits well. We can calculate a block value number based on the
kono
parents:
diff changeset
135 value numbers of the defs and vdefs.
kono
parents:
diff changeset
136
kono
parents:
diff changeset
137 For the second situation (same operations, same successors), this approach
kono
parents:
diff changeset
138 doesn't work so well. We can illustrate this using the example. The calls
kono
parents:
diff changeset
139 to free use different vdefs: MEMD.3923_16 and MEMD.3923_14, and these will
kono
parents:
diff changeset
140 remain different in value numbering, since they represent different memory
kono
parents:
diff changeset
141 states. So the resulting vdefs of the frees will be different in value
kono
parents:
diff changeset
142 numbering, so the block value numbers will be different.
kono
parents:
diff changeset
143
kono
parents:
diff changeset
144 The reason why we call the blocks equal is not because they define the same
kono
parents:
diff changeset
145 values, but because uses in the blocks use (possibly different) defs in the
kono
parents:
diff changeset
146 same way. To be able to detect this efficiently, we need to do some kind of
kono
parents:
diff changeset
147 reverse value numbering, meaning number the uses rather than the defs, and
kono
parents:
diff changeset
148 calculate a block value number based on the value number of the uses.
kono
parents:
diff changeset
149 Ideally, a block comparison operator will also indicate which phis are needed
kono
parents:
diff changeset
150 to merge the blocks.
kono
parents:
diff changeset
151
kono
parents:
diff changeset
152 For the moment, we don't do block value numbering, but we do insn-by-insn
kono
parents:
diff changeset
153 matching, using scc value numbers to match operations with results, and
kono
parents:
diff changeset
154 structural comparison otherwise, while ignoring vop mismatches.
kono
parents:
diff changeset
155
kono
parents:
diff changeset
156
kono
parents:
diff changeset
157 IMPLEMENTATION
kono
parents:
diff changeset
158
kono
parents:
diff changeset
159 1. The pass first determines all groups of blocks with the same successor
kono
parents:
diff changeset
160 blocks.
kono
parents:
diff changeset
161 2. Within each group, it tries to determine clusters of equal basic blocks.
kono
parents:
diff changeset
162 3. The clusters are applied.
kono
parents:
diff changeset
163 4. The same successor groups are updated.
kono
parents:
diff changeset
164 5. This process is repeated from 2 onwards, until no more changes.
kono
parents:
diff changeset
165
kono
parents:
diff changeset
166
kono
parents:
diff changeset
167 LIMITATIONS/TODO
kono
parents:
diff changeset
168
kono
parents:
diff changeset
169 - block only
kono
parents:
diff changeset
170 - handles only 'same operations, same successors'.
kono
parents:
diff changeset
171 It handles same predecessors as a special subcase though.
kono
parents:
diff changeset
172 - does not implement the reverse value numbering and block value numbering.
kono
parents:
diff changeset
173 - improve memory allocation: use garbage collected memory, obstacks,
kono
parents:
diff changeset
174 allocpools where appropriate.
kono
parents:
diff changeset
175 - no insertion of gimple_reg phis, We only introduce vop-phis.
kono
parents:
diff changeset
176 - handle blocks with gimple_reg phi_nodes.
kono
parents:
diff changeset
177
kono
parents:
diff changeset
178
kono
parents:
diff changeset
179 PASS PLACEMENT
kono
parents:
diff changeset
180 This 'pass' is not a stand-alone gimple pass, but runs as part of
kono
parents:
diff changeset
181 pass_pre, in order to share the value numbering.
kono
parents:
diff changeset
182
kono
parents:
diff changeset
183
kono
parents:
diff changeset
184 SWITCHES
kono
parents:
diff changeset
185
kono
parents:
diff changeset
186 - ftree-tail-merge. On at -O2. We may have to enable it only at -Os. */
kono
parents:
diff changeset
187
kono
parents:
diff changeset
188 #include "config.h"
kono
parents:
diff changeset
189 #include "system.h"
kono
parents:
diff changeset
190 #include "coretypes.h"
kono
parents:
diff changeset
191 #include "backend.h"
kono
parents:
diff changeset
192 #include "tree.h"
kono
parents:
diff changeset
193 #include "gimple.h"
kono
parents:
diff changeset
194 #include "cfghooks.h"
kono
parents:
diff changeset
195 #include "tree-pass.h"
kono
parents:
diff changeset
196 #include "ssa.h"
kono
parents:
diff changeset
197 #include "fold-const.h"
kono
parents:
diff changeset
198 #include "trans-mem.h"
kono
parents:
diff changeset
199 #include "cfganal.h"
kono
parents:
diff changeset
200 #include "cfgcleanup.h"
kono
parents:
diff changeset
201 #include "gimple-iterator.h"
kono
parents:
diff changeset
202 #include "tree-cfg.h"
kono
parents:
diff changeset
203 #include "tree-into-ssa.h"
kono
parents:
diff changeset
204 #include "params.h"
kono
parents:
diff changeset
205 #include "tree-ssa-sccvn.h"
kono
parents:
diff changeset
206 #include "cfgloop.h"
kono
parents:
diff changeset
207 #include "tree-eh.h"
kono
parents:
diff changeset
208 #include "tree-cfgcleanup.h"
kono
parents:
diff changeset
209
kono
parents:
diff changeset
210 const int ignore_edge_flags = EDGE_DFS_BACK | EDGE_EXECUTABLE;
kono
parents:
diff changeset
211
kono
parents:
diff changeset
212 /* Describes a group of bbs with the same successors. The successor bbs are
kono
parents:
diff changeset
213 cached in succs, and the successor edge flags are cached in succ_flags.
kono
parents:
diff changeset
214 If a bb has the EDGE_TRUE/FALSE_VALUE flags swapped compared to succ_flags,
kono
parents:
diff changeset
215 it's marked in inverse.
kono
parents:
diff changeset
216 Additionally, the hash value for the struct is cached in hashval, and
kono
parents:
diff changeset
217 in_worklist indicates whether it's currently part of worklist. */
kono
parents:
diff changeset
218
kono
parents:
diff changeset
219 struct same_succ : pointer_hash <same_succ>
kono
parents:
diff changeset
220 {
kono
parents:
diff changeset
221 /* The bbs that have the same successor bbs. */
kono
parents:
diff changeset
222 bitmap bbs;
kono
parents:
diff changeset
223 /* The successor bbs. */
kono
parents:
diff changeset
224 bitmap succs;
kono
parents:
diff changeset
225 /* Indicates whether the EDGE_TRUE/FALSE_VALUEs of succ_flags are swapped for
kono
parents:
diff changeset
226 bb. */
kono
parents:
diff changeset
227 bitmap inverse;
kono
parents:
diff changeset
228 /* The edge flags for each of the successor bbs. */
kono
parents:
diff changeset
229 vec<int> succ_flags;
kono
parents:
diff changeset
230 /* Indicates whether the struct is currently in the worklist. */
kono
parents:
diff changeset
231 bool in_worklist;
kono
parents:
diff changeset
232 /* The hash value of the struct. */
kono
parents:
diff changeset
233 hashval_t hashval;
kono
parents:
diff changeset
234
kono
parents:
diff changeset
235 /* hash_table support. */
kono
parents:
diff changeset
236 static inline hashval_t hash (const same_succ *);
kono
parents:
diff changeset
237 static int equal (const same_succ *, const same_succ *);
kono
parents:
diff changeset
238 static void remove (same_succ *);
kono
parents:
diff changeset
239 };
kono
parents:
diff changeset
240
kono
parents:
diff changeset
241 /* hash routine for hash_table support, returns hashval of E. */
kono
parents:
diff changeset
242
kono
parents:
diff changeset
243 inline hashval_t
kono
parents:
diff changeset
244 same_succ::hash (const same_succ *e)
kono
parents:
diff changeset
245 {
kono
parents:
diff changeset
246 return e->hashval;
kono
parents:
diff changeset
247 }
kono
parents:
diff changeset
248
kono
parents:
diff changeset
249 /* A group of bbs where 1 bb from bbs can replace the other bbs. */
kono
parents:
diff changeset
250
kono
parents:
diff changeset
251 struct bb_cluster
kono
parents:
diff changeset
252 {
kono
parents:
diff changeset
253 /* The bbs in the cluster. */
kono
parents:
diff changeset
254 bitmap bbs;
kono
parents:
diff changeset
255 /* The preds of the bbs in the cluster. */
kono
parents:
diff changeset
256 bitmap preds;
kono
parents:
diff changeset
257 /* Index in all_clusters vector. */
kono
parents:
diff changeset
258 int index;
kono
parents:
diff changeset
259 /* The bb to replace the cluster with. */
kono
parents:
diff changeset
260 basic_block rep_bb;
kono
parents:
diff changeset
261 };
kono
parents:
diff changeset
262
kono
parents:
diff changeset
263 /* Per bb-info. */
kono
parents:
diff changeset
264
kono
parents:
diff changeset
265 struct aux_bb_info
kono
parents:
diff changeset
266 {
kono
parents:
diff changeset
267 /* The number of non-debug statements in the bb. */
kono
parents:
diff changeset
268 int size;
kono
parents:
diff changeset
269 /* The same_succ that this bb is a member of. */
kono
parents:
diff changeset
270 same_succ *bb_same_succ;
kono
parents:
diff changeset
271 /* The cluster that this bb is a member of. */
kono
parents:
diff changeset
272 bb_cluster *cluster;
kono
parents:
diff changeset
273 /* The vop state at the exit of a bb. This is shortlived data, used to
kono
parents:
diff changeset
274 communicate data between update_block_by and update_vuses. */
kono
parents:
diff changeset
275 tree vop_at_exit;
kono
parents:
diff changeset
276 /* The bb that either contains or is dominated by the dependencies of the
kono
parents:
diff changeset
277 bb. */
kono
parents:
diff changeset
278 basic_block dep_bb;
kono
parents:
diff changeset
279 };
kono
parents:
diff changeset
280
kono
parents:
diff changeset
281 /* Macros to access the fields of struct aux_bb_info. */
kono
parents:
diff changeset
282
kono
parents:
diff changeset
283 #define BB_SIZE(bb) (((struct aux_bb_info *)bb->aux)->size)
kono
parents:
diff changeset
284 #define BB_SAME_SUCC(bb) (((struct aux_bb_info *)bb->aux)->bb_same_succ)
kono
parents:
diff changeset
285 #define BB_CLUSTER(bb) (((struct aux_bb_info *)bb->aux)->cluster)
kono
parents:
diff changeset
286 #define BB_VOP_AT_EXIT(bb) (((struct aux_bb_info *)bb->aux)->vop_at_exit)
kono
parents:
diff changeset
287 #define BB_DEP_BB(bb) (((struct aux_bb_info *)bb->aux)->dep_bb)
kono
parents:
diff changeset
288
kono
parents:
diff changeset
289 /* Returns true if the only effect a statement STMT has, is to define locally
kono
parents:
diff changeset
290 used SSA_NAMEs. */
kono
parents:
diff changeset
291
kono
parents:
diff changeset
292 static bool
kono
parents:
diff changeset
293 stmt_local_def (gimple *stmt)
kono
parents:
diff changeset
294 {
kono
parents:
diff changeset
295 basic_block bb, def_bb;
kono
parents:
diff changeset
296 imm_use_iterator iter;
kono
parents:
diff changeset
297 use_operand_p use_p;
kono
parents:
diff changeset
298 tree val;
kono
parents:
diff changeset
299 def_operand_p def_p;
kono
parents:
diff changeset
300
kono
parents:
diff changeset
301 if (gimple_vdef (stmt) != NULL_TREE
kono
parents:
diff changeset
302 || gimple_has_side_effects (stmt)
kono
parents:
diff changeset
303 || gimple_could_trap_p_1 (stmt, false, false)
kono
parents:
diff changeset
304 || gimple_vuse (stmt) != NULL_TREE)
kono
parents:
diff changeset
305 return false;
kono
parents:
diff changeset
306
kono
parents:
diff changeset
307 def_p = SINGLE_SSA_DEF_OPERAND (stmt, SSA_OP_DEF);
kono
parents:
diff changeset
308 if (def_p == NULL)
kono
parents:
diff changeset
309 return false;
kono
parents:
diff changeset
310
kono
parents:
diff changeset
311 val = DEF_FROM_PTR (def_p);
kono
parents:
diff changeset
312 if (val == NULL_TREE || TREE_CODE (val) != SSA_NAME)
kono
parents:
diff changeset
313 return false;
kono
parents:
diff changeset
314
kono
parents:
diff changeset
315 def_bb = gimple_bb (stmt);
kono
parents:
diff changeset
316
kono
parents:
diff changeset
317 FOR_EACH_IMM_USE_FAST (use_p, iter, val)
kono
parents:
diff changeset
318 {
kono
parents:
diff changeset
319 if (is_gimple_debug (USE_STMT (use_p)))
kono
parents:
diff changeset
320 continue;
kono
parents:
diff changeset
321 bb = gimple_bb (USE_STMT (use_p));
kono
parents:
diff changeset
322 if (bb == def_bb)
kono
parents:
diff changeset
323 continue;
kono
parents:
diff changeset
324
kono
parents:
diff changeset
325 if (gimple_code (USE_STMT (use_p)) == GIMPLE_PHI
kono
parents:
diff changeset
326 && EDGE_PRED (bb, PHI_ARG_INDEX_FROM_USE (use_p))->src == def_bb)
kono
parents:
diff changeset
327 continue;
kono
parents:
diff changeset
328
kono
parents:
diff changeset
329 return false;
kono
parents:
diff changeset
330 }
kono
parents:
diff changeset
331
kono
parents:
diff changeset
332 return true;
kono
parents:
diff changeset
333 }
kono
parents:
diff changeset
334
kono
parents:
diff changeset
335 /* Let GSI skip forwards over local defs. */
kono
parents:
diff changeset
336
kono
parents:
diff changeset
337 static void
kono
parents:
diff changeset
338 gsi_advance_fw_nondebug_nonlocal (gimple_stmt_iterator *gsi)
kono
parents:
diff changeset
339 {
kono
parents:
diff changeset
340 gimple *stmt;
kono
parents:
diff changeset
341
kono
parents:
diff changeset
342 while (true)
kono
parents:
diff changeset
343 {
kono
parents:
diff changeset
344 if (gsi_end_p (*gsi))
kono
parents:
diff changeset
345 return;
kono
parents:
diff changeset
346 stmt = gsi_stmt (*gsi);
kono
parents:
diff changeset
347 if (!stmt_local_def (stmt))
kono
parents:
diff changeset
348 return;
kono
parents:
diff changeset
349 gsi_next_nondebug (gsi);
kono
parents:
diff changeset
350 }
kono
parents:
diff changeset
351 }
kono
parents:
diff changeset
352
kono
parents:
diff changeset
353 /* VAL1 and VAL2 are either:
kono
parents:
diff changeset
354 - uses in BB1 and BB2, or
kono
parents:
diff changeset
355 - phi alternatives for BB1 and BB2.
kono
parents:
diff changeset
356 Return true if the uses have the same gvn value. */
kono
parents:
diff changeset
357
kono
parents:
diff changeset
358 static bool
kono
parents:
diff changeset
359 gvn_uses_equal (tree val1, tree val2)
kono
parents:
diff changeset
360 {
kono
parents:
diff changeset
361 gcc_checking_assert (val1 != NULL_TREE && val2 != NULL_TREE);
kono
parents:
diff changeset
362
kono
parents:
diff changeset
363 if (val1 == val2)
kono
parents:
diff changeset
364 return true;
kono
parents:
diff changeset
365
kono
parents:
diff changeset
366 if (vn_valueize (val1) != vn_valueize (val2))
kono
parents:
diff changeset
367 return false;
kono
parents:
diff changeset
368
kono
parents:
diff changeset
369 return ((TREE_CODE (val1) == SSA_NAME || CONSTANT_CLASS_P (val1))
kono
parents:
diff changeset
370 && (TREE_CODE (val2) == SSA_NAME || CONSTANT_CLASS_P (val2)));
kono
parents:
diff changeset
371 }
kono
parents:
diff changeset
372
kono
parents:
diff changeset
373 /* Prints E to FILE. */
kono
parents:
diff changeset
374
kono
parents:
diff changeset
375 static void
kono
parents:
diff changeset
376 same_succ_print (FILE *file, const same_succ *e)
kono
parents:
diff changeset
377 {
kono
parents:
diff changeset
378 unsigned int i;
kono
parents:
diff changeset
379 bitmap_print (file, e->bbs, "bbs:", "\n");
kono
parents:
diff changeset
380 bitmap_print (file, e->succs, "succs:", "\n");
kono
parents:
diff changeset
381 bitmap_print (file, e->inverse, "inverse:", "\n");
kono
parents:
diff changeset
382 fprintf (file, "flags:");
kono
parents:
diff changeset
383 for (i = 0; i < e->succ_flags.length (); ++i)
kono
parents:
diff changeset
384 fprintf (file, " %x", e->succ_flags[i]);
kono
parents:
diff changeset
385 fprintf (file, "\n");
kono
parents:
diff changeset
386 }
kono
parents:
diff changeset
387
kono
parents:
diff changeset
388 /* Prints same_succ VE to VFILE. */
kono
parents:
diff changeset
389
kono
parents:
diff changeset
390 inline int
kono
parents:
diff changeset
391 ssa_same_succ_print_traverse (same_succ **pe, FILE *file)
kono
parents:
diff changeset
392 {
kono
parents:
diff changeset
393 const same_succ *e = *pe;
kono
parents:
diff changeset
394 same_succ_print (file, e);
kono
parents:
diff changeset
395 return 1;
kono
parents:
diff changeset
396 }
kono
parents:
diff changeset
397
kono
parents:
diff changeset
398 /* Update BB_DEP_BB (USE_BB), given a use of VAL in USE_BB. */
kono
parents:
diff changeset
399
kono
parents:
diff changeset
400 static void
kono
parents:
diff changeset
401 update_dep_bb (basic_block use_bb, tree val)
kono
parents:
diff changeset
402 {
kono
parents:
diff changeset
403 basic_block dep_bb;
kono
parents:
diff changeset
404
kono
parents:
diff changeset
405 /* Not a dep. */
kono
parents:
diff changeset
406 if (TREE_CODE (val) != SSA_NAME)
kono
parents:
diff changeset
407 return;
kono
parents:
diff changeset
408
kono
parents:
diff changeset
409 /* Skip use of global def. */
kono
parents:
diff changeset
410 if (SSA_NAME_IS_DEFAULT_DEF (val))
kono
parents:
diff changeset
411 return;
kono
parents:
diff changeset
412
kono
parents:
diff changeset
413 /* Skip use of local def. */
kono
parents:
diff changeset
414 dep_bb = gimple_bb (SSA_NAME_DEF_STMT (val));
kono
parents:
diff changeset
415 if (dep_bb == use_bb)
kono
parents:
diff changeset
416 return;
kono
parents:
diff changeset
417
kono
parents:
diff changeset
418 if (BB_DEP_BB (use_bb) == NULL
kono
parents:
diff changeset
419 || dominated_by_p (CDI_DOMINATORS, dep_bb, BB_DEP_BB (use_bb)))
kono
parents:
diff changeset
420 BB_DEP_BB (use_bb) = dep_bb;
kono
parents:
diff changeset
421 }
kono
parents:
diff changeset
422
kono
parents:
diff changeset
423 /* Update BB_DEP_BB, given the dependencies in STMT. */
kono
parents:
diff changeset
424
kono
parents:
diff changeset
425 static void
kono
parents:
diff changeset
426 stmt_update_dep_bb (gimple *stmt)
kono
parents:
diff changeset
427 {
kono
parents:
diff changeset
428 ssa_op_iter iter;
kono
parents:
diff changeset
429 use_operand_p use;
kono
parents:
diff changeset
430
kono
parents:
diff changeset
431 FOR_EACH_SSA_USE_OPERAND (use, stmt, iter, SSA_OP_USE)
kono
parents:
diff changeset
432 update_dep_bb (gimple_bb (stmt), USE_FROM_PTR (use));
kono
parents:
diff changeset
433 }
kono
parents:
diff changeset
434
kono
parents:
diff changeset
435 /* Calculates hash value for same_succ VE. */
kono
parents:
diff changeset
436
kono
parents:
diff changeset
437 static hashval_t
kono
parents:
diff changeset
438 same_succ_hash (const same_succ *e)
kono
parents:
diff changeset
439 {
kono
parents:
diff changeset
440 inchash::hash hstate (bitmap_hash (e->succs));
kono
parents:
diff changeset
441 int flags;
kono
parents:
diff changeset
442 unsigned int i;
kono
parents:
diff changeset
443 unsigned int first = bitmap_first_set_bit (e->bbs);
kono
parents:
diff changeset
444 basic_block bb = BASIC_BLOCK_FOR_FN (cfun, first);
kono
parents:
diff changeset
445 int size = 0;
kono
parents:
diff changeset
446 gimple *stmt;
kono
parents:
diff changeset
447 tree arg;
kono
parents:
diff changeset
448 unsigned int s;
kono
parents:
diff changeset
449 bitmap_iterator bs;
kono
parents:
diff changeset
450
kono
parents:
diff changeset
451 for (gimple_stmt_iterator gsi = gsi_start_nondebug_bb (bb);
kono
parents:
diff changeset
452 !gsi_end_p (gsi); gsi_next_nondebug (&gsi))
kono
parents:
diff changeset
453 {
kono
parents:
diff changeset
454 stmt = gsi_stmt (gsi);
kono
parents:
diff changeset
455 stmt_update_dep_bb (stmt);
kono
parents:
diff changeset
456 if (stmt_local_def (stmt))
kono
parents:
diff changeset
457 continue;
kono
parents:
diff changeset
458 size++;
kono
parents:
diff changeset
459
kono
parents:
diff changeset
460 hstate.add_int (gimple_code (stmt));
kono
parents:
diff changeset
461 if (is_gimple_assign (stmt))
kono
parents:
diff changeset
462 hstate.add_int (gimple_assign_rhs_code (stmt));
kono
parents:
diff changeset
463 if (!is_gimple_call (stmt))
kono
parents:
diff changeset
464 continue;
kono
parents:
diff changeset
465 if (gimple_call_internal_p (stmt))
kono
parents:
diff changeset
466 hstate.add_int (gimple_call_internal_fn (stmt));
kono
parents:
diff changeset
467 else
kono
parents:
diff changeset
468 {
kono
parents:
diff changeset
469 inchash::add_expr (gimple_call_fn (stmt), hstate);
kono
parents:
diff changeset
470 if (gimple_call_chain (stmt))
kono
parents:
diff changeset
471 inchash::add_expr (gimple_call_chain (stmt), hstate);
kono
parents:
diff changeset
472 }
kono
parents:
diff changeset
473 for (i = 0; i < gimple_call_num_args (stmt); i++)
kono
parents:
diff changeset
474 {
kono
parents:
diff changeset
475 arg = gimple_call_arg (stmt, i);
kono
parents:
diff changeset
476 arg = vn_valueize (arg);
kono
parents:
diff changeset
477 inchash::add_expr (arg, hstate);
kono
parents:
diff changeset
478 }
kono
parents:
diff changeset
479 }
kono
parents:
diff changeset
480
kono
parents:
diff changeset
481 hstate.add_int (size);
kono
parents:
diff changeset
482 BB_SIZE (bb) = size;
kono
parents:
diff changeset
483
kono
parents:
diff changeset
484 hstate.add_int (bb->loop_father->num);
kono
parents:
diff changeset
485
kono
parents:
diff changeset
486 for (i = 0; i < e->succ_flags.length (); ++i)
kono
parents:
diff changeset
487 {
kono
parents:
diff changeset
488 flags = e->succ_flags[i];
kono
parents:
diff changeset
489 flags = flags & ~(EDGE_TRUE_VALUE | EDGE_FALSE_VALUE);
kono
parents:
diff changeset
490 hstate.add_int (flags);
kono
parents:
diff changeset
491 }
kono
parents:
diff changeset
492
kono
parents:
diff changeset
493 EXECUTE_IF_SET_IN_BITMAP (e->succs, 0, s, bs)
kono
parents:
diff changeset
494 {
kono
parents:
diff changeset
495 int n = find_edge (bb, BASIC_BLOCK_FOR_FN (cfun, s))->dest_idx;
kono
parents:
diff changeset
496 for (gphi_iterator gsi = gsi_start_phis (BASIC_BLOCK_FOR_FN (cfun, s));
kono
parents:
diff changeset
497 !gsi_end_p (gsi);
kono
parents:
diff changeset
498 gsi_next (&gsi))
kono
parents:
diff changeset
499 {
kono
parents:
diff changeset
500 gphi *phi = gsi.phi ();
kono
parents:
diff changeset
501 tree lhs = gimple_phi_result (phi);
kono
parents:
diff changeset
502 tree val = gimple_phi_arg_def (phi, n);
kono
parents:
diff changeset
503
kono
parents:
diff changeset
504 if (virtual_operand_p (lhs))
kono
parents:
diff changeset
505 continue;
kono
parents:
diff changeset
506 update_dep_bb (bb, val);
kono
parents:
diff changeset
507 }
kono
parents:
diff changeset
508 }
kono
parents:
diff changeset
509
kono
parents:
diff changeset
510 return hstate.end ();
kono
parents:
diff changeset
511 }
kono
parents:
diff changeset
512
kono
parents:
diff changeset
513 /* Returns true if E1 and E2 have 2 successors, and if the successor flags
kono
parents:
diff changeset
514 are inverse for the EDGE_TRUE_VALUE and EDGE_FALSE_VALUE flags, and equal for
kono
parents:
diff changeset
515 the other edge flags. */
kono
parents:
diff changeset
516
kono
parents:
diff changeset
517 static bool
kono
parents:
diff changeset
518 inverse_flags (const same_succ *e1, const same_succ *e2)
kono
parents:
diff changeset
519 {
kono
parents:
diff changeset
520 int f1a, f1b, f2a, f2b;
kono
parents:
diff changeset
521 int mask = ~(EDGE_TRUE_VALUE | EDGE_FALSE_VALUE);
kono
parents:
diff changeset
522
kono
parents:
diff changeset
523 if (e1->succ_flags.length () != 2)
kono
parents:
diff changeset
524 return false;
kono
parents:
diff changeset
525
kono
parents:
diff changeset
526 f1a = e1->succ_flags[0];
kono
parents:
diff changeset
527 f1b = e1->succ_flags[1];
kono
parents:
diff changeset
528 f2a = e2->succ_flags[0];
kono
parents:
diff changeset
529 f2b = e2->succ_flags[1];
kono
parents:
diff changeset
530
kono
parents:
diff changeset
531 if (f1a == f2a && f1b == f2b)
kono
parents:
diff changeset
532 return false;
kono
parents:
diff changeset
533
kono
parents:
diff changeset
534 return (f1a & mask) == (f2a & mask) && (f1b & mask) == (f2b & mask);
kono
parents:
diff changeset
535 }
kono
parents:
diff changeset
536
kono
parents:
diff changeset
537 /* Compares SAME_SUCCs E1 and E2. */
kono
parents:
diff changeset
538
kono
parents:
diff changeset
539 int
kono
parents:
diff changeset
540 same_succ::equal (const same_succ *e1, const same_succ *e2)
kono
parents:
diff changeset
541 {
kono
parents:
diff changeset
542 unsigned int i, first1, first2;
kono
parents:
diff changeset
543 gimple_stmt_iterator gsi1, gsi2;
kono
parents:
diff changeset
544 gimple *s1, *s2;
kono
parents:
diff changeset
545 basic_block bb1, bb2;
kono
parents:
diff changeset
546
kono
parents:
diff changeset
547 if (e1 == e2)
kono
parents:
diff changeset
548 return 1;
kono
parents:
diff changeset
549
kono
parents:
diff changeset
550 if (e1->hashval != e2->hashval)
kono
parents:
diff changeset
551 return 0;
kono
parents:
diff changeset
552
kono
parents:
diff changeset
553 if (e1->succ_flags.length () != e2->succ_flags.length ())
kono
parents:
diff changeset
554 return 0;
kono
parents:
diff changeset
555
kono
parents:
diff changeset
556 if (!bitmap_equal_p (e1->succs, e2->succs))
kono
parents:
diff changeset
557 return 0;
kono
parents:
diff changeset
558
kono
parents:
diff changeset
559 if (!inverse_flags (e1, e2))
kono
parents:
diff changeset
560 {
kono
parents:
diff changeset
561 for (i = 0; i < e1->succ_flags.length (); ++i)
kono
parents:
diff changeset
562 if (e1->succ_flags[i] != e2->succ_flags[i])
kono
parents:
diff changeset
563 return 0;
kono
parents:
diff changeset
564 }
kono
parents:
diff changeset
565
kono
parents:
diff changeset
566 first1 = bitmap_first_set_bit (e1->bbs);
kono
parents:
diff changeset
567 first2 = bitmap_first_set_bit (e2->bbs);
kono
parents:
diff changeset
568
kono
parents:
diff changeset
569 bb1 = BASIC_BLOCK_FOR_FN (cfun, first1);
kono
parents:
diff changeset
570 bb2 = BASIC_BLOCK_FOR_FN (cfun, first2);
kono
parents:
diff changeset
571
kono
parents:
diff changeset
572 if (BB_SIZE (bb1) != BB_SIZE (bb2))
kono
parents:
diff changeset
573 return 0;
kono
parents:
diff changeset
574
kono
parents:
diff changeset
575 if (bb1->loop_father != bb2->loop_father)
kono
parents:
diff changeset
576 return 0;
kono
parents:
diff changeset
577
kono
parents:
diff changeset
578 gsi1 = gsi_start_nondebug_bb (bb1);
kono
parents:
diff changeset
579 gsi2 = gsi_start_nondebug_bb (bb2);
kono
parents:
diff changeset
580 gsi_advance_fw_nondebug_nonlocal (&gsi1);
kono
parents:
diff changeset
581 gsi_advance_fw_nondebug_nonlocal (&gsi2);
kono
parents:
diff changeset
582 while (!(gsi_end_p (gsi1) || gsi_end_p (gsi2)))
kono
parents:
diff changeset
583 {
kono
parents:
diff changeset
584 s1 = gsi_stmt (gsi1);
kono
parents:
diff changeset
585 s2 = gsi_stmt (gsi2);
kono
parents:
diff changeset
586 if (gimple_code (s1) != gimple_code (s2))
kono
parents:
diff changeset
587 return 0;
kono
parents:
diff changeset
588 if (is_gimple_call (s1) && !gimple_call_same_target_p (s1, s2))
kono
parents:
diff changeset
589 return 0;
kono
parents:
diff changeset
590 gsi_next_nondebug (&gsi1);
kono
parents:
diff changeset
591 gsi_next_nondebug (&gsi2);
kono
parents:
diff changeset
592 gsi_advance_fw_nondebug_nonlocal (&gsi1);
kono
parents:
diff changeset
593 gsi_advance_fw_nondebug_nonlocal (&gsi2);
kono
parents:
diff changeset
594 }
kono
parents:
diff changeset
595
kono
parents:
diff changeset
596 return 1;
kono
parents:
diff changeset
597 }
kono
parents:
diff changeset
598
kono
parents:
diff changeset
599 /* Alloc and init a new SAME_SUCC. */
kono
parents:
diff changeset
600
kono
parents:
diff changeset
601 static same_succ *
kono
parents:
diff changeset
602 same_succ_alloc (void)
kono
parents:
diff changeset
603 {
kono
parents:
diff changeset
604 same_succ *same = XNEW (struct same_succ);
kono
parents:
diff changeset
605
kono
parents:
diff changeset
606 same->bbs = BITMAP_ALLOC (NULL);
kono
parents:
diff changeset
607 same->succs = BITMAP_ALLOC (NULL);
kono
parents:
diff changeset
608 same->inverse = BITMAP_ALLOC (NULL);
kono
parents:
diff changeset
609 same->succ_flags.create (10);
kono
parents:
diff changeset
610 same->in_worklist = false;
kono
parents:
diff changeset
611
kono
parents:
diff changeset
612 return same;
kono
parents:
diff changeset
613 }
kono
parents:
diff changeset
614
kono
parents:
diff changeset
615 /* Delete same_succ E. */
kono
parents:
diff changeset
616
kono
parents:
diff changeset
617 void
kono
parents:
diff changeset
618 same_succ::remove (same_succ *e)
kono
parents:
diff changeset
619 {
kono
parents:
diff changeset
620 BITMAP_FREE (e->bbs);
kono
parents:
diff changeset
621 BITMAP_FREE (e->succs);
kono
parents:
diff changeset
622 BITMAP_FREE (e->inverse);
kono
parents:
diff changeset
623 e->succ_flags.release ();
kono
parents:
diff changeset
624
kono
parents:
diff changeset
625 XDELETE (e);
kono
parents:
diff changeset
626 }
kono
parents:
diff changeset
627
kono
parents:
diff changeset
628 /* Reset same_succ SAME. */
kono
parents:
diff changeset
629
kono
parents:
diff changeset
630 static void
kono
parents:
diff changeset
631 same_succ_reset (same_succ *same)
kono
parents:
diff changeset
632 {
kono
parents:
diff changeset
633 bitmap_clear (same->bbs);
kono
parents:
diff changeset
634 bitmap_clear (same->succs);
kono
parents:
diff changeset
635 bitmap_clear (same->inverse);
kono
parents:
diff changeset
636 same->succ_flags.truncate (0);
kono
parents:
diff changeset
637 }
kono
parents:
diff changeset
638
kono
parents:
diff changeset
639 static hash_table<same_succ> *same_succ_htab;
kono
parents:
diff changeset
640
kono
parents:
diff changeset
641 /* Array that is used to store the edge flags for a successor. */
kono
parents:
diff changeset
642
kono
parents:
diff changeset
643 static int *same_succ_edge_flags;
kono
parents:
diff changeset
644
kono
parents:
diff changeset
645 /* Bitmap that is used to mark bbs that are recently deleted. */
kono
parents:
diff changeset
646
kono
parents:
diff changeset
647 static bitmap deleted_bbs;
kono
parents:
diff changeset
648
kono
parents:
diff changeset
649 /* Bitmap that is used to mark predecessors of bbs that are
kono
parents:
diff changeset
650 deleted. */
kono
parents:
diff changeset
651
kono
parents:
diff changeset
652 static bitmap deleted_bb_preds;
kono
parents:
diff changeset
653
kono
parents:
diff changeset
654 /* Prints same_succ_htab to stderr. */
kono
parents:
diff changeset
655
kono
parents:
diff changeset
656 extern void debug_same_succ (void);
kono
parents:
diff changeset
657 DEBUG_FUNCTION void
kono
parents:
diff changeset
658 debug_same_succ ( void)
kono
parents:
diff changeset
659 {
kono
parents:
diff changeset
660 same_succ_htab->traverse <FILE *, ssa_same_succ_print_traverse> (stderr);
kono
parents:
diff changeset
661 }
kono
parents:
diff changeset
662
kono
parents:
diff changeset
663
kono
parents:
diff changeset
664 /* Vector of bbs to process. */
kono
parents:
diff changeset
665
kono
parents:
diff changeset
666 static vec<same_succ *> worklist;
kono
parents:
diff changeset
667
kono
parents:
diff changeset
668 /* Prints worklist to FILE. */
kono
parents:
diff changeset
669
kono
parents:
diff changeset
670 static void
kono
parents:
diff changeset
671 print_worklist (FILE *file)
kono
parents:
diff changeset
672 {
kono
parents:
diff changeset
673 unsigned int i;
kono
parents:
diff changeset
674 for (i = 0; i < worklist.length (); ++i)
kono
parents:
diff changeset
675 same_succ_print (file, worklist[i]);
kono
parents:
diff changeset
676 }
kono
parents:
diff changeset
677
kono
parents:
diff changeset
678 /* Adds SAME to worklist. */
kono
parents:
diff changeset
679
kono
parents:
diff changeset
680 static void
kono
parents:
diff changeset
681 add_to_worklist (same_succ *same)
kono
parents:
diff changeset
682 {
kono
parents:
diff changeset
683 if (same->in_worklist)
kono
parents:
diff changeset
684 return;
kono
parents:
diff changeset
685
kono
parents:
diff changeset
686 if (bitmap_count_bits (same->bbs) < 2)
kono
parents:
diff changeset
687 return;
kono
parents:
diff changeset
688
kono
parents:
diff changeset
689 same->in_worklist = true;
kono
parents:
diff changeset
690 worklist.safe_push (same);
kono
parents:
diff changeset
691 }
kono
parents:
diff changeset
692
kono
parents:
diff changeset
693 /* Add BB to same_succ_htab. */
kono
parents:
diff changeset
694
kono
parents:
diff changeset
695 static void
kono
parents:
diff changeset
696 find_same_succ_bb (basic_block bb, same_succ **same_p)
kono
parents:
diff changeset
697 {
kono
parents:
diff changeset
698 unsigned int j;
kono
parents:
diff changeset
699 bitmap_iterator bj;
kono
parents:
diff changeset
700 same_succ *same = *same_p;
kono
parents:
diff changeset
701 same_succ **slot;
kono
parents:
diff changeset
702 edge_iterator ei;
kono
parents:
diff changeset
703 edge e;
kono
parents:
diff changeset
704
kono
parents:
diff changeset
705 if (bb == NULL)
kono
parents:
diff changeset
706 return;
kono
parents:
diff changeset
707 bitmap_set_bit (same->bbs, bb->index);
kono
parents:
diff changeset
708 FOR_EACH_EDGE (e, ei, bb->succs)
kono
parents:
diff changeset
709 {
kono
parents:
diff changeset
710 int index = e->dest->index;
kono
parents:
diff changeset
711 bitmap_set_bit (same->succs, index);
kono
parents:
diff changeset
712 same_succ_edge_flags[index] = (e->flags & ~ignore_edge_flags);
kono
parents:
diff changeset
713 }
kono
parents:
diff changeset
714 EXECUTE_IF_SET_IN_BITMAP (same->succs, 0, j, bj)
kono
parents:
diff changeset
715 same->succ_flags.safe_push (same_succ_edge_flags[j]);
kono
parents:
diff changeset
716
kono
parents:
diff changeset
717 same->hashval = same_succ_hash (same);
kono
parents:
diff changeset
718
kono
parents:
diff changeset
719 slot = same_succ_htab->find_slot_with_hash (same, same->hashval, INSERT);
kono
parents:
diff changeset
720 if (*slot == NULL)
kono
parents:
diff changeset
721 {
kono
parents:
diff changeset
722 *slot = same;
kono
parents:
diff changeset
723 BB_SAME_SUCC (bb) = same;
kono
parents:
diff changeset
724 add_to_worklist (same);
kono
parents:
diff changeset
725 *same_p = NULL;
kono
parents:
diff changeset
726 }
kono
parents:
diff changeset
727 else
kono
parents:
diff changeset
728 {
kono
parents:
diff changeset
729 bitmap_set_bit ((*slot)->bbs, bb->index);
kono
parents:
diff changeset
730 BB_SAME_SUCC (bb) = *slot;
kono
parents:
diff changeset
731 add_to_worklist (*slot);
kono
parents:
diff changeset
732 if (inverse_flags (same, *slot))
kono
parents:
diff changeset
733 bitmap_set_bit ((*slot)->inverse, bb->index);
kono
parents:
diff changeset
734 same_succ_reset (same);
kono
parents:
diff changeset
735 }
kono
parents:
diff changeset
736 }
kono
parents:
diff changeset
737
kono
parents:
diff changeset
738 /* Find bbs with same successors. */
kono
parents:
diff changeset
739
kono
parents:
diff changeset
740 static void
kono
parents:
diff changeset
741 find_same_succ (void)
kono
parents:
diff changeset
742 {
kono
parents:
diff changeset
743 same_succ *same = same_succ_alloc ();
kono
parents:
diff changeset
744 basic_block bb;
kono
parents:
diff changeset
745
kono
parents:
diff changeset
746 FOR_EACH_BB_FN (bb, cfun)
kono
parents:
diff changeset
747 {
kono
parents:
diff changeset
748 find_same_succ_bb (bb, &same);
kono
parents:
diff changeset
749 if (same == NULL)
kono
parents:
diff changeset
750 same = same_succ_alloc ();
kono
parents:
diff changeset
751 }
kono
parents:
diff changeset
752
kono
parents:
diff changeset
753 same_succ::remove (same);
kono
parents:
diff changeset
754 }
kono
parents:
diff changeset
755
kono
parents:
diff changeset
756 /* Initializes worklist administration. */
kono
parents:
diff changeset
757
kono
parents:
diff changeset
758 static void
kono
parents:
diff changeset
759 init_worklist (void)
kono
parents:
diff changeset
760 {
kono
parents:
diff changeset
761 alloc_aux_for_blocks (sizeof (struct aux_bb_info));
kono
parents:
diff changeset
762 same_succ_htab = new hash_table<same_succ> (n_basic_blocks_for_fn (cfun));
kono
parents:
diff changeset
763 same_succ_edge_flags = XCNEWVEC (int, last_basic_block_for_fn (cfun));
kono
parents:
diff changeset
764 deleted_bbs = BITMAP_ALLOC (NULL);
kono
parents:
diff changeset
765 deleted_bb_preds = BITMAP_ALLOC (NULL);
kono
parents:
diff changeset
766 worklist.create (n_basic_blocks_for_fn (cfun));
kono
parents:
diff changeset
767 find_same_succ ();
kono
parents:
diff changeset
768
kono
parents:
diff changeset
769 if (dump_file && (dump_flags & TDF_DETAILS))
kono
parents:
diff changeset
770 {
kono
parents:
diff changeset
771 fprintf (dump_file, "initial worklist:\n");
kono
parents:
diff changeset
772 print_worklist (dump_file);
kono
parents:
diff changeset
773 }
kono
parents:
diff changeset
774 }
kono
parents:
diff changeset
775
kono
parents:
diff changeset
776 /* Deletes worklist administration. */
kono
parents:
diff changeset
777
kono
parents:
diff changeset
778 static void
kono
parents:
diff changeset
779 delete_worklist (void)
kono
parents:
diff changeset
780 {
kono
parents:
diff changeset
781 free_aux_for_blocks ();
kono
parents:
diff changeset
782 delete same_succ_htab;
kono
parents:
diff changeset
783 same_succ_htab = NULL;
kono
parents:
diff changeset
784 XDELETEVEC (same_succ_edge_flags);
kono
parents:
diff changeset
785 same_succ_edge_flags = NULL;
kono
parents:
diff changeset
786 BITMAP_FREE (deleted_bbs);
kono
parents:
diff changeset
787 BITMAP_FREE (deleted_bb_preds);
kono
parents:
diff changeset
788 worklist.release ();
kono
parents:
diff changeset
789 }
kono
parents:
diff changeset
790
kono
parents:
diff changeset
791 /* Mark BB as deleted, and mark its predecessors. */
kono
parents:
diff changeset
792
kono
parents:
diff changeset
793 static void
kono
parents:
diff changeset
794 mark_basic_block_deleted (basic_block bb)
kono
parents:
diff changeset
795 {
kono
parents:
diff changeset
796 edge e;
kono
parents:
diff changeset
797 edge_iterator ei;
kono
parents:
diff changeset
798
kono
parents:
diff changeset
799 bitmap_set_bit (deleted_bbs, bb->index);
kono
parents:
diff changeset
800
kono
parents:
diff changeset
801 FOR_EACH_EDGE (e, ei, bb->preds)
kono
parents:
diff changeset
802 bitmap_set_bit (deleted_bb_preds, e->src->index);
kono
parents:
diff changeset
803 }
kono
parents:
diff changeset
804
kono
parents:
diff changeset
805 /* Removes BB from its corresponding same_succ. */
kono
parents:
diff changeset
806
kono
parents:
diff changeset
807 static void
kono
parents:
diff changeset
808 same_succ_flush_bb (basic_block bb)
kono
parents:
diff changeset
809 {
kono
parents:
diff changeset
810 same_succ *same = BB_SAME_SUCC (bb);
kono
parents:
diff changeset
811 if (! same)
kono
parents:
diff changeset
812 return;
kono
parents:
diff changeset
813
kono
parents:
diff changeset
814 BB_SAME_SUCC (bb) = NULL;
kono
parents:
diff changeset
815 if (bitmap_single_bit_set_p (same->bbs))
kono
parents:
diff changeset
816 same_succ_htab->remove_elt_with_hash (same, same->hashval);
kono
parents:
diff changeset
817 else
kono
parents:
diff changeset
818 bitmap_clear_bit (same->bbs, bb->index);
kono
parents:
diff changeset
819 }
kono
parents:
diff changeset
820
kono
parents:
diff changeset
821 /* Removes all bbs in BBS from their corresponding same_succ. */
kono
parents:
diff changeset
822
kono
parents:
diff changeset
823 static void
kono
parents:
diff changeset
824 same_succ_flush_bbs (bitmap bbs)
kono
parents:
diff changeset
825 {
kono
parents:
diff changeset
826 unsigned int i;
kono
parents:
diff changeset
827 bitmap_iterator bi;
kono
parents:
diff changeset
828
kono
parents:
diff changeset
829 EXECUTE_IF_SET_IN_BITMAP (bbs, 0, i, bi)
kono
parents:
diff changeset
830 same_succ_flush_bb (BASIC_BLOCK_FOR_FN (cfun, i));
kono
parents:
diff changeset
831 }
kono
parents:
diff changeset
832
kono
parents:
diff changeset
833 /* Release the last vdef in BB, either normal or phi result. */
kono
parents:
diff changeset
834
kono
parents:
diff changeset
835 static void
kono
parents:
diff changeset
836 release_last_vdef (basic_block bb)
kono
parents:
diff changeset
837 {
kono
parents:
diff changeset
838 for (gimple_stmt_iterator i = gsi_last_bb (bb); !gsi_end_p (i);
kono
parents:
diff changeset
839 gsi_prev_nondebug (&i))
kono
parents:
diff changeset
840 {
kono
parents:
diff changeset
841 gimple *stmt = gsi_stmt (i);
kono
parents:
diff changeset
842 if (gimple_vdef (stmt) == NULL_TREE)
kono
parents:
diff changeset
843 continue;
kono
parents:
diff changeset
844
kono
parents:
diff changeset
845 mark_virtual_operand_for_renaming (gimple_vdef (stmt));
kono
parents:
diff changeset
846 return;
kono
parents:
diff changeset
847 }
kono
parents:
diff changeset
848
kono
parents:
diff changeset
849 for (gphi_iterator i = gsi_start_phis (bb); !gsi_end_p (i);
kono
parents:
diff changeset
850 gsi_next (&i))
kono
parents:
diff changeset
851 {
kono
parents:
diff changeset
852 gphi *phi = i.phi ();
kono
parents:
diff changeset
853 tree res = gimple_phi_result (phi);
kono
parents:
diff changeset
854
kono
parents:
diff changeset
855 if (!virtual_operand_p (res))
kono
parents:
diff changeset
856 continue;
kono
parents:
diff changeset
857
kono
parents:
diff changeset
858 mark_virtual_phi_result_for_renaming (phi);
kono
parents:
diff changeset
859 return;
kono
parents:
diff changeset
860 }
kono
parents:
diff changeset
861 }
kono
parents:
diff changeset
862
kono
parents:
diff changeset
863 /* For deleted_bb_preds, find bbs with same successors. */
kono
parents:
diff changeset
864
kono
parents:
diff changeset
865 static void
kono
parents:
diff changeset
866 update_worklist (void)
kono
parents:
diff changeset
867 {
kono
parents:
diff changeset
868 unsigned int i;
kono
parents:
diff changeset
869 bitmap_iterator bi;
kono
parents:
diff changeset
870 basic_block bb;
kono
parents:
diff changeset
871 same_succ *same;
kono
parents:
diff changeset
872
kono
parents:
diff changeset
873 bitmap_and_compl_into (deleted_bb_preds, deleted_bbs);
kono
parents:
diff changeset
874 bitmap_clear (deleted_bbs);
kono
parents:
diff changeset
875
kono
parents:
diff changeset
876 bitmap_clear_bit (deleted_bb_preds, ENTRY_BLOCK);
kono
parents:
diff changeset
877 same_succ_flush_bbs (deleted_bb_preds);
kono
parents:
diff changeset
878
kono
parents:
diff changeset
879 same = same_succ_alloc ();
kono
parents:
diff changeset
880 EXECUTE_IF_SET_IN_BITMAP (deleted_bb_preds, 0, i, bi)
kono
parents:
diff changeset
881 {
kono
parents:
diff changeset
882 bb = BASIC_BLOCK_FOR_FN (cfun, i);
kono
parents:
diff changeset
883 gcc_assert (bb != NULL);
kono
parents:
diff changeset
884 find_same_succ_bb (bb, &same);
kono
parents:
diff changeset
885 if (same == NULL)
kono
parents:
diff changeset
886 same = same_succ_alloc ();
kono
parents:
diff changeset
887 }
kono
parents:
diff changeset
888 same_succ::remove (same);
kono
parents:
diff changeset
889 bitmap_clear (deleted_bb_preds);
kono
parents:
diff changeset
890 }
kono
parents:
diff changeset
891
kono
parents:
diff changeset
892 /* Prints cluster C to FILE. */
kono
parents:
diff changeset
893
kono
parents:
diff changeset
894 static void
kono
parents:
diff changeset
895 print_cluster (FILE *file, bb_cluster *c)
kono
parents:
diff changeset
896 {
kono
parents:
diff changeset
897 if (c == NULL)
kono
parents:
diff changeset
898 return;
kono
parents:
diff changeset
899 bitmap_print (file, c->bbs, "bbs:", "\n");
kono
parents:
diff changeset
900 bitmap_print (file, c->preds, "preds:", "\n");
kono
parents:
diff changeset
901 }
kono
parents:
diff changeset
902
kono
parents:
diff changeset
903 /* Prints cluster C to stderr. */
kono
parents:
diff changeset
904
kono
parents:
diff changeset
905 extern void debug_cluster (bb_cluster *);
kono
parents:
diff changeset
906 DEBUG_FUNCTION void
kono
parents:
diff changeset
907 debug_cluster (bb_cluster *c)
kono
parents:
diff changeset
908 {
kono
parents:
diff changeset
909 print_cluster (stderr, c);
kono
parents:
diff changeset
910 }
kono
parents:
diff changeset
911
kono
parents:
diff changeset
912 /* Update C->rep_bb, given that BB is added to the cluster. */
kono
parents:
diff changeset
913
kono
parents:
diff changeset
914 static void
kono
parents:
diff changeset
915 update_rep_bb (bb_cluster *c, basic_block bb)
kono
parents:
diff changeset
916 {
kono
parents:
diff changeset
917 /* Initial. */
kono
parents:
diff changeset
918 if (c->rep_bb == NULL)
kono
parents:
diff changeset
919 {
kono
parents:
diff changeset
920 c->rep_bb = bb;
kono
parents:
diff changeset
921 return;
kono
parents:
diff changeset
922 }
kono
parents:
diff changeset
923
kono
parents:
diff changeset
924 /* Current needs no deps, keep it. */
kono
parents:
diff changeset
925 if (BB_DEP_BB (c->rep_bb) == NULL)
kono
parents:
diff changeset
926 return;
kono
parents:
diff changeset
927
kono
parents:
diff changeset
928 /* Bb needs no deps, change rep_bb. */
kono
parents:
diff changeset
929 if (BB_DEP_BB (bb) == NULL)
kono
parents:
diff changeset
930 {
kono
parents:
diff changeset
931 c->rep_bb = bb;
kono
parents:
diff changeset
932 return;
kono
parents:
diff changeset
933 }
kono
parents:
diff changeset
934
kono
parents:
diff changeset
935 /* Bb needs last deps earlier than current, change rep_bb. A potential
kono
parents:
diff changeset
936 problem with this, is that the first deps might also be earlier, which
kono
parents:
diff changeset
937 would mean we prefer longer lifetimes for the deps. To be able to check
kono
parents:
diff changeset
938 for this, we would have to trace BB_FIRST_DEP_BB as well, besides
kono
parents:
diff changeset
939 BB_DEP_BB, which is really BB_LAST_DEP_BB.
kono
parents:
diff changeset
940 The benefit of choosing the bb with last deps earlier, is that it can
kono
parents:
diff changeset
941 potentially be used as replacement for more bbs. */
kono
parents:
diff changeset
942 if (dominated_by_p (CDI_DOMINATORS, BB_DEP_BB (c->rep_bb), BB_DEP_BB (bb)))
kono
parents:
diff changeset
943 c->rep_bb = bb;
kono
parents:
diff changeset
944 }
kono
parents:
diff changeset
945
kono
parents:
diff changeset
946 /* Add BB to cluster C. Sets BB in C->bbs, and preds of BB in C->preds. */
kono
parents:
diff changeset
947
kono
parents:
diff changeset
948 static void
kono
parents:
diff changeset
949 add_bb_to_cluster (bb_cluster *c, basic_block bb)
kono
parents:
diff changeset
950 {
kono
parents:
diff changeset
951 edge e;
kono
parents:
diff changeset
952 edge_iterator ei;
kono
parents:
diff changeset
953
kono
parents:
diff changeset
954 bitmap_set_bit (c->bbs, bb->index);
kono
parents:
diff changeset
955
kono
parents:
diff changeset
956 FOR_EACH_EDGE (e, ei, bb->preds)
kono
parents:
diff changeset
957 bitmap_set_bit (c->preds, e->src->index);
kono
parents:
diff changeset
958
kono
parents:
diff changeset
959 update_rep_bb (c, bb);
kono
parents:
diff changeset
960 }
kono
parents:
diff changeset
961
kono
parents:
diff changeset
962 /* Allocate and init new cluster. */
kono
parents:
diff changeset
963
kono
parents:
diff changeset
964 static bb_cluster *
kono
parents:
diff changeset
965 new_cluster (void)
kono
parents:
diff changeset
966 {
kono
parents:
diff changeset
967 bb_cluster *c;
kono
parents:
diff changeset
968 c = XCNEW (bb_cluster);
kono
parents:
diff changeset
969 c->bbs = BITMAP_ALLOC (NULL);
kono
parents:
diff changeset
970 c->preds = BITMAP_ALLOC (NULL);
kono
parents:
diff changeset
971 c->rep_bb = NULL;
kono
parents:
diff changeset
972 return c;
kono
parents:
diff changeset
973 }
kono
parents:
diff changeset
974
kono
parents:
diff changeset
975 /* Delete clusters. */
kono
parents:
diff changeset
976
kono
parents:
diff changeset
977 static void
kono
parents:
diff changeset
978 delete_cluster (bb_cluster *c)
kono
parents:
diff changeset
979 {
kono
parents:
diff changeset
980 if (c == NULL)
kono
parents:
diff changeset
981 return;
kono
parents:
diff changeset
982 BITMAP_FREE (c->bbs);
kono
parents:
diff changeset
983 BITMAP_FREE (c->preds);
kono
parents:
diff changeset
984 XDELETE (c);
kono
parents:
diff changeset
985 }
kono
parents:
diff changeset
986
kono
parents:
diff changeset
987
kono
parents:
diff changeset
988 /* Array that contains all clusters. */
kono
parents:
diff changeset
989
kono
parents:
diff changeset
990 static vec<bb_cluster *> all_clusters;
kono
parents:
diff changeset
991
kono
parents:
diff changeset
992 /* Allocate all cluster vectors. */
kono
parents:
diff changeset
993
kono
parents:
diff changeset
994 static void
kono
parents:
diff changeset
995 alloc_cluster_vectors (void)
kono
parents:
diff changeset
996 {
kono
parents:
diff changeset
997 all_clusters.create (n_basic_blocks_for_fn (cfun));
kono
parents:
diff changeset
998 }
kono
parents:
diff changeset
999
kono
parents:
diff changeset
1000 /* Reset all cluster vectors. */
kono
parents:
diff changeset
1001
kono
parents:
diff changeset
1002 static void
kono
parents:
diff changeset
1003 reset_cluster_vectors (void)
kono
parents:
diff changeset
1004 {
kono
parents:
diff changeset
1005 unsigned int i;
kono
parents:
diff changeset
1006 basic_block bb;
kono
parents:
diff changeset
1007 for (i = 0; i < all_clusters.length (); ++i)
kono
parents:
diff changeset
1008 delete_cluster (all_clusters[i]);
kono
parents:
diff changeset
1009 all_clusters.truncate (0);
kono
parents:
diff changeset
1010 FOR_EACH_BB_FN (bb, cfun)
kono
parents:
diff changeset
1011 BB_CLUSTER (bb) = NULL;
kono
parents:
diff changeset
1012 }
kono
parents:
diff changeset
1013
kono
parents:
diff changeset
1014 /* Delete all cluster vectors. */
kono
parents:
diff changeset
1015
kono
parents:
diff changeset
1016 static void
kono
parents:
diff changeset
1017 delete_cluster_vectors (void)
kono
parents:
diff changeset
1018 {
kono
parents:
diff changeset
1019 unsigned int i;
kono
parents:
diff changeset
1020 for (i = 0; i < all_clusters.length (); ++i)
kono
parents:
diff changeset
1021 delete_cluster (all_clusters[i]);
kono
parents:
diff changeset
1022 all_clusters.release ();
kono
parents:
diff changeset
1023 }
kono
parents:
diff changeset
1024
kono
parents:
diff changeset
1025 /* Merge cluster C2 into C1. */
kono
parents:
diff changeset
1026
kono
parents:
diff changeset
1027 static void
kono
parents:
diff changeset
1028 merge_clusters (bb_cluster *c1, bb_cluster *c2)
kono
parents:
diff changeset
1029 {
kono
parents:
diff changeset
1030 bitmap_ior_into (c1->bbs, c2->bbs);
kono
parents:
diff changeset
1031 bitmap_ior_into (c1->preds, c2->preds);
kono
parents:
diff changeset
1032 }
kono
parents:
diff changeset
1033
kono
parents:
diff changeset
1034 /* Register equivalence of BB1 and BB2 (members of cluster C). Store c in
kono
parents:
diff changeset
1035 all_clusters, or merge c with existing cluster. */
kono
parents:
diff changeset
1036
kono
parents:
diff changeset
1037 static void
kono
parents:
diff changeset
1038 set_cluster (basic_block bb1, basic_block bb2)
kono
parents:
diff changeset
1039 {
kono
parents:
diff changeset
1040 basic_block merge_bb, other_bb;
kono
parents:
diff changeset
1041 bb_cluster *merge, *old, *c;
kono
parents:
diff changeset
1042
kono
parents:
diff changeset
1043 if (BB_CLUSTER (bb1) == NULL && BB_CLUSTER (bb2) == NULL)
kono
parents:
diff changeset
1044 {
kono
parents:
diff changeset
1045 c = new_cluster ();
kono
parents:
diff changeset
1046 add_bb_to_cluster (c, bb1);
kono
parents:
diff changeset
1047 add_bb_to_cluster (c, bb2);
kono
parents:
diff changeset
1048 BB_CLUSTER (bb1) = c;
kono
parents:
diff changeset
1049 BB_CLUSTER (bb2) = c;
kono
parents:
diff changeset
1050 c->index = all_clusters.length ();
kono
parents:
diff changeset
1051 all_clusters.safe_push (c);
kono
parents:
diff changeset
1052 }
kono
parents:
diff changeset
1053 else if (BB_CLUSTER (bb1) == NULL || BB_CLUSTER (bb2) == NULL)
kono
parents:
diff changeset
1054 {
kono
parents:
diff changeset
1055 merge_bb = BB_CLUSTER (bb1) == NULL ? bb2 : bb1;
kono
parents:
diff changeset
1056 other_bb = BB_CLUSTER (bb1) == NULL ? bb1 : bb2;
kono
parents:
diff changeset
1057 merge = BB_CLUSTER (merge_bb);
kono
parents:
diff changeset
1058 add_bb_to_cluster (merge, other_bb);
kono
parents:
diff changeset
1059 BB_CLUSTER (other_bb) = merge;
kono
parents:
diff changeset
1060 }
kono
parents:
diff changeset
1061 else if (BB_CLUSTER (bb1) != BB_CLUSTER (bb2))
kono
parents:
diff changeset
1062 {
kono
parents:
diff changeset
1063 unsigned int i;
kono
parents:
diff changeset
1064 bitmap_iterator bi;
kono
parents:
diff changeset
1065
kono
parents:
diff changeset
1066 old = BB_CLUSTER (bb2);
kono
parents:
diff changeset
1067 merge = BB_CLUSTER (bb1);
kono
parents:
diff changeset
1068 merge_clusters (merge, old);
kono
parents:
diff changeset
1069 EXECUTE_IF_SET_IN_BITMAP (old->bbs, 0, i, bi)
kono
parents:
diff changeset
1070 BB_CLUSTER (BASIC_BLOCK_FOR_FN (cfun, i)) = merge;
kono
parents:
diff changeset
1071 all_clusters[old->index] = NULL;
kono
parents:
diff changeset
1072 update_rep_bb (merge, old->rep_bb);
kono
parents:
diff changeset
1073 delete_cluster (old);
kono
parents:
diff changeset
1074 }
kono
parents:
diff changeset
1075 else
kono
parents:
diff changeset
1076 gcc_unreachable ();
kono
parents:
diff changeset
1077 }
kono
parents:
diff changeset
1078
kono
parents:
diff changeset
1079 /* Return true if gimple operands T1 and T2 have the same value. */
kono
parents:
diff changeset
1080
kono
parents:
diff changeset
1081 static bool
kono
parents:
diff changeset
1082 gimple_operand_equal_value_p (tree t1, tree t2)
kono
parents:
diff changeset
1083 {
kono
parents:
diff changeset
1084 if (t1 == t2)
kono
parents:
diff changeset
1085 return true;
kono
parents:
diff changeset
1086
kono
parents:
diff changeset
1087 if (t1 == NULL_TREE
kono
parents:
diff changeset
1088 || t2 == NULL_TREE)
kono
parents:
diff changeset
1089 return false;
kono
parents:
diff changeset
1090
kono
parents:
diff changeset
1091 if (operand_equal_p (t1, t2, OEP_MATCH_SIDE_EFFECTS))
kono
parents:
diff changeset
1092 return true;
kono
parents:
diff changeset
1093
kono
parents:
diff changeset
1094 return gvn_uses_equal (t1, t2);
kono
parents:
diff changeset
1095 }
kono
parents:
diff changeset
1096
kono
parents:
diff changeset
1097 /* Return true if gimple statements S1 and S2 are equal. Gimple_bb (s1) and
kono
parents:
diff changeset
1098 gimple_bb (s2) are members of SAME_SUCC. */
kono
parents:
diff changeset
1099
kono
parents:
diff changeset
1100 static bool
kono
parents:
diff changeset
1101 gimple_equal_p (same_succ *same_succ, gimple *s1, gimple *s2)
kono
parents:
diff changeset
1102 {
kono
parents:
diff changeset
1103 unsigned int i;
kono
parents:
diff changeset
1104 tree lhs1, lhs2;
kono
parents:
diff changeset
1105 basic_block bb1 = gimple_bb (s1), bb2 = gimple_bb (s2);
kono
parents:
diff changeset
1106 tree t1, t2;
kono
parents:
diff changeset
1107 bool inv_cond;
kono
parents:
diff changeset
1108 enum tree_code code1, code2;
kono
parents:
diff changeset
1109
kono
parents:
diff changeset
1110 if (gimple_code (s1) != gimple_code (s2))
kono
parents:
diff changeset
1111 return false;
kono
parents:
diff changeset
1112
kono
parents:
diff changeset
1113 switch (gimple_code (s1))
kono
parents:
diff changeset
1114 {
kono
parents:
diff changeset
1115 case GIMPLE_CALL:
kono
parents:
diff changeset
1116 if (!gimple_call_same_target_p (s1, s2))
kono
parents:
diff changeset
1117 return false;
kono
parents:
diff changeset
1118
kono
parents:
diff changeset
1119 t1 = gimple_call_chain (s1);
kono
parents:
diff changeset
1120 t2 = gimple_call_chain (s2);
kono
parents:
diff changeset
1121 if (!gimple_operand_equal_value_p (t1, t2))
kono
parents:
diff changeset
1122 return false;
kono
parents:
diff changeset
1123
kono
parents:
diff changeset
1124 if (gimple_call_num_args (s1) != gimple_call_num_args (s2))
kono
parents:
diff changeset
1125 return false;
kono
parents:
diff changeset
1126
kono
parents:
diff changeset
1127 for (i = 0; i < gimple_call_num_args (s1); ++i)
kono
parents:
diff changeset
1128 {
kono
parents:
diff changeset
1129 t1 = gimple_call_arg (s1, i);
kono
parents:
diff changeset
1130 t2 = gimple_call_arg (s2, i);
kono
parents:
diff changeset
1131 if (!gimple_operand_equal_value_p (t1, t2))
kono
parents:
diff changeset
1132 return false;
kono
parents:
diff changeset
1133 }
kono
parents:
diff changeset
1134
kono
parents:
diff changeset
1135 lhs1 = gimple_get_lhs (s1);
kono
parents:
diff changeset
1136 lhs2 = gimple_get_lhs (s2);
kono
parents:
diff changeset
1137 if (lhs1 == NULL_TREE && lhs2 == NULL_TREE)
kono
parents:
diff changeset
1138 return true;
kono
parents:
diff changeset
1139 if (lhs1 == NULL_TREE || lhs2 == NULL_TREE)
kono
parents:
diff changeset
1140 return false;
kono
parents:
diff changeset
1141 if (TREE_CODE (lhs1) == SSA_NAME && TREE_CODE (lhs2) == SSA_NAME)
kono
parents:
diff changeset
1142 return vn_valueize (lhs1) == vn_valueize (lhs2);
kono
parents:
diff changeset
1143 return operand_equal_p (lhs1, lhs2, 0);
kono
parents:
diff changeset
1144
kono
parents:
diff changeset
1145 case GIMPLE_ASSIGN:
kono
parents:
diff changeset
1146 lhs1 = gimple_get_lhs (s1);
kono
parents:
diff changeset
1147 lhs2 = gimple_get_lhs (s2);
kono
parents:
diff changeset
1148 if (TREE_CODE (lhs1) != SSA_NAME
kono
parents:
diff changeset
1149 && TREE_CODE (lhs2) != SSA_NAME)
kono
parents:
diff changeset
1150 return (operand_equal_p (lhs1, lhs2, 0)
kono
parents:
diff changeset
1151 && gimple_operand_equal_value_p (gimple_assign_rhs1 (s1),
kono
parents:
diff changeset
1152 gimple_assign_rhs1 (s2)));
kono
parents:
diff changeset
1153 else if (TREE_CODE (lhs1) == SSA_NAME
kono
parents:
diff changeset
1154 && TREE_CODE (lhs2) == SSA_NAME)
kono
parents:
diff changeset
1155 return operand_equal_p (gimple_assign_rhs1 (s1),
kono
parents:
diff changeset
1156 gimple_assign_rhs1 (s2), 0);
kono
parents:
diff changeset
1157 return false;
kono
parents:
diff changeset
1158
kono
parents:
diff changeset
1159 case GIMPLE_COND:
kono
parents:
diff changeset
1160 t1 = gimple_cond_lhs (s1);
kono
parents:
diff changeset
1161 t2 = gimple_cond_lhs (s2);
kono
parents:
diff changeset
1162 if (!gimple_operand_equal_value_p (t1, t2))
kono
parents:
diff changeset
1163 return false;
kono
parents:
diff changeset
1164
kono
parents:
diff changeset
1165 t1 = gimple_cond_rhs (s1);
kono
parents:
diff changeset
1166 t2 = gimple_cond_rhs (s2);
kono
parents:
diff changeset
1167 if (!gimple_operand_equal_value_p (t1, t2))
kono
parents:
diff changeset
1168 return false;
kono
parents:
diff changeset
1169
kono
parents:
diff changeset
1170 code1 = gimple_expr_code (s1);
kono
parents:
diff changeset
1171 code2 = gimple_expr_code (s2);
kono
parents:
diff changeset
1172 inv_cond = (bitmap_bit_p (same_succ->inverse, bb1->index)
kono
parents:
diff changeset
1173 != bitmap_bit_p (same_succ->inverse, bb2->index));
kono
parents:
diff changeset
1174 if (inv_cond)
kono
parents:
diff changeset
1175 {
kono
parents:
diff changeset
1176 bool honor_nans = HONOR_NANS (t1);
kono
parents:
diff changeset
1177 code2 = invert_tree_comparison (code2, honor_nans);
kono
parents:
diff changeset
1178 }
kono
parents:
diff changeset
1179 return code1 == code2;
kono
parents:
diff changeset
1180
kono
parents:
diff changeset
1181 default:
kono
parents:
diff changeset
1182 return false;
kono
parents:
diff changeset
1183 }
kono
parents:
diff changeset
1184 }
kono
parents:
diff changeset
1185
kono
parents:
diff changeset
1186 /* Let GSI skip backwards over local defs. Return the earliest vuse in VUSE.
kono
parents:
diff changeset
1187 Return true in VUSE_ESCAPED if the vuse influenced a SSA_OP_DEF of one of the
kono
parents:
diff changeset
1188 processed statements. */
kono
parents:
diff changeset
1189
kono
parents:
diff changeset
1190 static void
kono
parents:
diff changeset
1191 gsi_advance_bw_nondebug_nonlocal (gimple_stmt_iterator *gsi, tree *vuse,
kono
parents:
diff changeset
1192 bool *vuse_escaped)
kono
parents:
diff changeset
1193 {
kono
parents:
diff changeset
1194 gimple *stmt;
kono
parents:
diff changeset
1195 tree lvuse;
kono
parents:
diff changeset
1196
kono
parents:
diff changeset
1197 while (true)
kono
parents:
diff changeset
1198 {
kono
parents:
diff changeset
1199 if (gsi_end_p (*gsi))
kono
parents:
diff changeset
1200 return;
kono
parents:
diff changeset
1201 stmt = gsi_stmt (*gsi);
kono
parents:
diff changeset
1202
kono
parents:
diff changeset
1203 lvuse = gimple_vuse (stmt);
kono
parents:
diff changeset
1204 if (lvuse != NULL_TREE)
kono
parents:
diff changeset
1205 {
kono
parents:
diff changeset
1206 *vuse = lvuse;
kono
parents:
diff changeset
1207 if (!ZERO_SSA_OPERANDS (stmt, SSA_OP_DEF))
kono
parents:
diff changeset
1208 *vuse_escaped = true;
kono
parents:
diff changeset
1209 }
kono
parents:
diff changeset
1210
kono
parents:
diff changeset
1211 if (!stmt_local_def (stmt))
kono
parents:
diff changeset
1212 return;
kono
parents:
diff changeset
1213 gsi_prev_nondebug (gsi);
kono
parents:
diff changeset
1214 }
kono
parents:
diff changeset
1215 }
kono
parents:
diff changeset
1216
kono
parents:
diff changeset
1217 /* Return true if equal (in the sense of gimple_equal_p) statements STMT1 and
kono
parents:
diff changeset
1218 STMT2 are allowed to be merged. */
kono
parents:
diff changeset
1219
kono
parents:
diff changeset
1220 static bool
kono
parents:
diff changeset
1221 merge_stmts_p (gimple *stmt1, gimple *stmt2)
kono
parents:
diff changeset
1222 {
kono
parents:
diff changeset
1223 /* What could be better than this here is to blacklist the bb
kono
parents:
diff changeset
1224 containing the stmt, when encountering the stmt f.i. in
kono
parents:
diff changeset
1225 same_succ_hash. */
kono
parents:
diff changeset
1226 if (is_tm_ending (stmt1))
kono
parents:
diff changeset
1227 return false;
kono
parents:
diff changeset
1228
kono
parents:
diff changeset
1229 /* Verify EH landing pads. */
kono
parents:
diff changeset
1230 if (lookup_stmt_eh_lp_fn (cfun, stmt1) != lookup_stmt_eh_lp_fn (cfun, stmt2))
kono
parents:
diff changeset
1231 return false;
kono
parents:
diff changeset
1232
kono
parents:
diff changeset
1233 if (is_gimple_call (stmt1)
kono
parents:
diff changeset
1234 && gimple_call_internal_p (stmt1))
kono
parents:
diff changeset
1235 switch (gimple_call_internal_fn (stmt1))
kono
parents:
diff changeset
1236 {
kono
parents:
diff changeset
1237 case IFN_UBSAN_NULL:
kono
parents:
diff changeset
1238 case IFN_UBSAN_BOUNDS:
kono
parents:
diff changeset
1239 case IFN_UBSAN_VPTR:
kono
parents:
diff changeset
1240 case IFN_UBSAN_CHECK_ADD:
kono
parents:
diff changeset
1241 case IFN_UBSAN_CHECK_SUB:
kono
parents:
diff changeset
1242 case IFN_UBSAN_CHECK_MUL:
kono
parents:
diff changeset
1243 case IFN_UBSAN_OBJECT_SIZE:
kono
parents:
diff changeset
1244 case IFN_UBSAN_PTR:
kono
parents:
diff changeset
1245 case IFN_ASAN_CHECK:
kono
parents:
diff changeset
1246 /* For these internal functions, gimple_location is an implicit
kono
parents:
diff changeset
1247 parameter, which will be used explicitly after expansion.
kono
parents:
diff changeset
1248 Merging these statements may cause confusing line numbers in
kono
parents:
diff changeset
1249 sanitizer messages. */
kono
parents:
diff changeset
1250 return gimple_location (stmt1) == gimple_location (stmt2);
kono
parents:
diff changeset
1251 default:
kono
parents:
diff changeset
1252 break;
kono
parents:
diff changeset
1253 }
kono
parents:
diff changeset
1254
kono
parents:
diff changeset
1255 return true;
kono
parents:
diff changeset
1256 }
kono
parents:
diff changeset
1257
kono
parents:
diff changeset
1258 /* Determines whether BB1 and BB2 (members of same_succ) are duplicates. If so,
kono
parents:
diff changeset
1259 clusters them. */
kono
parents:
diff changeset
1260
kono
parents:
diff changeset
1261 static void
kono
parents:
diff changeset
1262 find_duplicate (same_succ *same_succ, basic_block bb1, basic_block bb2)
kono
parents:
diff changeset
1263 {
kono
parents:
diff changeset
1264 gimple_stmt_iterator gsi1 = gsi_last_nondebug_bb (bb1);
kono
parents:
diff changeset
1265 gimple_stmt_iterator gsi2 = gsi_last_nondebug_bb (bb2);
kono
parents:
diff changeset
1266 tree vuse1 = NULL_TREE, vuse2 = NULL_TREE;
kono
parents:
diff changeset
1267 bool vuse_escaped = false;
kono
parents:
diff changeset
1268
kono
parents:
diff changeset
1269 gsi_advance_bw_nondebug_nonlocal (&gsi1, &vuse1, &vuse_escaped);
kono
parents:
diff changeset
1270 gsi_advance_bw_nondebug_nonlocal (&gsi2, &vuse2, &vuse_escaped);
kono
parents:
diff changeset
1271
kono
parents:
diff changeset
1272 while (!gsi_end_p (gsi1) && !gsi_end_p (gsi2))
kono
parents:
diff changeset
1273 {
kono
parents:
diff changeset
1274 gimple *stmt1 = gsi_stmt (gsi1);
kono
parents:
diff changeset
1275 gimple *stmt2 = gsi_stmt (gsi2);
kono
parents:
diff changeset
1276
kono
parents:
diff changeset
1277 if (gimple_code (stmt1) == GIMPLE_LABEL
kono
parents:
diff changeset
1278 && gimple_code (stmt2) == GIMPLE_LABEL)
kono
parents:
diff changeset
1279 break;
kono
parents:
diff changeset
1280
kono
parents:
diff changeset
1281 if (!gimple_equal_p (same_succ, stmt1, stmt2))
kono
parents:
diff changeset
1282 return;
kono
parents:
diff changeset
1283
kono
parents:
diff changeset
1284 if (!merge_stmts_p (stmt1, stmt2))
kono
parents:
diff changeset
1285 return;
kono
parents:
diff changeset
1286
kono
parents:
diff changeset
1287 gsi_prev_nondebug (&gsi1);
kono
parents:
diff changeset
1288 gsi_prev_nondebug (&gsi2);
kono
parents:
diff changeset
1289 gsi_advance_bw_nondebug_nonlocal (&gsi1, &vuse1, &vuse_escaped);
kono
parents:
diff changeset
1290 gsi_advance_bw_nondebug_nonlocal (&gsi2, &vuse2, &vuse_escaped);
kono
parents:
diff changeset
1291 }
kono
parents:
diff changeset
1292
kono
parents:
diff changeset
1293 while (!gsi_end_p (gsi1) && gimple_code (gsi_stmt (gsi1)) == GIMPLE_LABEL)
kono
parents:
diff changeset
1294 {
kono
parents:
diff changeset
1295 tree label = gimple_label_label (as_a <glabel *> (gsi_stmt (gsi1)));
kono
parents:
diff changeset
1296 if (DECL_NONLOCAL (label) || FORCED_LABEL (label))
kono
parents:
diff changeset
1297 return;
kono
parents:
diff changeset
1298 gsi_prev (&gsi1);
kono
parents:
diff changeset
1299 }
kono
parents:
diff changeset
1300 while (!gsi_end_p (gsi2) && gimple_code (gsi_stmt (gsi2)) == GIMPLE_LABEL)
kono
parents:
diff changeset
1301 {
kono
parents:
diff changeset
1302 tree label = gimple_label_label (as_a <glabel *> (gsi_stmt (gsi2)));
kono
parents:
diff changeset
1303 if (DECL_NONLOCAL (label) || FORCED_LABEL (label))
kono
parents:
diff changeset
1304 return;
kono
parents:
diff changeset
1305 gsi_prev (&gsi2);
kono
parents:
diff changeset
1306 }
kono
parents:
diff changeset
1307 if (!(gsi_end_p (gsi1) && gsi_end_p (gsi2)))
kono
parents:
diff changeset
1308 return;
kono
parents:
diff changeset
1309
kono
parents:
diff changeset
1310 /* If the incoming vuses are not the same, and the vuse escaped into an
kono
parents:
diff changeset
1311 SSA_OP_DEF, then merging the 2 blocks will change the value of the def,
kono
parents:
diff changeset
1312 which potentially means the semantics of one of the blocks will be changed.
kono
parents:
diff changeset
1313 TODO: make this check more precise. */
kono
parents:
diff changeset
1314 if (vuse_escaped && vuse1 != vuse2)
kono
parents:
diff changeset
1315 return;
kono
parents:
diff changeset
1316
kono
parents:
diff changeset
1317 if (dump_file)
kono
parents:
diff changeset
1318 fprintf (dump_file, "find_duplicates: <bb %d> duplicate of <bb %d>\n",
kono
parents:
diff changeset
1319 bb1->index, bb2->index);
kono
parents:
diff changeset
1320
kono
parents:
diff changeset
1321 set_cluster (bb1, bb2);
kono
parents:
diff changeset
1322 }
kono
parents:
diff changeset
1323
kono
parents:
diff changeset
1324 /* Returns whether for all phis in DEST the phi alternatives for E1 and
kono
parents:
diff changeset
1325 E2 are equal. */
kono
parents:
diff changeset
1326
kono
parents:
diff changeset
1327 static bool
kono
parents:
diff changeset
1328 same_phi_alternatives_1 (basic_block dest, edge e1, edge e2)
kono
parents:
diff changeset
1329 {
kono
parents:
diff changeset
1330 int n1 = e1->dest_idx, n2 = e2->dest_idx;
kono
parents:
diff changeset
1331 gphi_iterator gsi;
kono
parents:
diff changeset
1332
kono
parents:
diff changeset
1333 for (gsi = gsi_start_phis (dest); !gsi_end_p (gsi); gsi_next (&gsi))
kono
parents:
diff changeset
1334 {
kono
parents:
diff changeset
1335 gphi *phi = gsi.phi ();
kono
parents:
diff changeset
1336 tree lhs = gimple_phi_result (phi);
kono
parents:
diff changeset
1337 tree val1 = gimple_phi_arg_def (phi, n1);
kono
parents:
diff changeset
1338 tree val2 = gimple_phi_arg_def (phi, n2);
kono
parents:
diff changeset
1339
kono
parents:
diff changeset
1340 if (virtual_operand_p (lhs))
kono
parents:
diff changeset
1341 continue;
kono
parents:
diff changeset
1342
kono
parents:
diff changeset
1343 if (operand_equal_for_phi_arg_p (val1, val2))
kono
parents:
diff changeset
1344 continue;
kono
parents:
diff changeset
1345 if (gvn_uses_equal (val1, val2))
kono
parents:
diff changeset
1346 continue;
kono
parents:
diff changeset
1347
kono
parents:
diff changeset
1348 return false;
kono
parents:
diff changeset
1349 }
kono
parents:
diff changeset
1350
kono
parents:
diff changeset
1351 return true;
kono
parents:
diff changeset
1352 }
kono
parents:
diff changeset
1353
kono
parents:
diff changeset
1354 /* Returns whether for all successors of BB1 and BB2 (members of SAME_SUCC), the
kono
parents:
diff changeset
1355 phi alternatives for BB1 and BB2 are equal. */
kono
parents:
diff changeset
1356
kono
parents:
diff changeset
1357 static bool
kono
parents:
diff changeset
1358 same_phi_alternatives (same_succ *same_succ, basic_block bb1, basic_block bb2)
kono
parents:
diff changeset
1359 {
kono
parents:
diff changeset
1360 unsigned int s;
kono
parents:
diff changeset
1361 bitmap_iterator bs;
kono
parents:
diff changeset
1362 edge e1, e2;
kono
parents:
diff changeset
1363 basic_block succ;
kono
parents:
diff changeset
1364
kono
parents:
diff changeset
1365 EXECUTE_IF_SET_IN_BITMAP (same_succ->succs, 0, s, bs)
kono
parents:
diff changeset
1366 {
kono
parents:
diff changeset
1367 succ = BASIC_BLOCK_FOR_FN (cfun, s);
kono
parents:
diff changeset
1368 e1 = find_edge (bb1, succ);
kono
parents:
diff changeset
1369 e2 = find_edge (bb2, succ);
kono
parents:
diff changeset
1370 if (e1->flags & EDGE_COMPLEX
kono
parents:
diff changeset
1371 || e2->flags & EDGE_COMPLEX)
kono
parents:
diff changeset
1372 return false;
kono
parents:
diff changeset
1373
kono
parents:
diff changeset
1374 /* For all phis in bb, the phi alternatives for e1 and e2 need to have
kono
parents:
diff changeset
1375 the same value. */
kono
parents:
diff changeset
1376 if (!same_phi_alternatives_1 (succ, e1, e2))
kono
parents:
diff changeset
1377 return false;
kono
parents:
diff changeset
1378 }
kono
parents:
diff changeset
1379
kono
parents:
diff changeset
1380 return true;
kono
parents:
diff changeset
1381 }
kono
parents:
diff changeset
1382
kono
parents:
diff changeset
1383 /* Return true if BB has non-vop phis. */
kono
parents:
diff changeset
1384
kono
parents:
diff changeset
1385 static bool
kono
parents:
diff changeset
1386 bb_has_non_vop_phi (basic_block bb)
kono
parents:
diff changeset
1387 {
kono
parents:
diff changeset
1388 gimple_seq phis = phi_nodes (bb);
kono
parents:
diff changeset
1389 gimple *phi;
kono
parents:
diff changeset
1390
kono
parents:
diff changeset
1391 if (phis == NULL)
kono
parents:
diff changeset
1392 return false;
kono
parents:
diff changeset
1393
kono
parents:
diff changeset
1394 if (!gimple_seq_singleton_p (phis))
kono
parents:
diff changeset
1395 return true;
kono
parents:
diff changeset
1396
kono
parents:
diff changeset
1397 phi = gimple_seq_first_stmt (phis);
kono
parents:
diff changeset
1398 return !virtual_operand_p (gimple_phi_result (phi));
kono
parents:
diff changeset
1399 }
kono
parents:
diff changeset
1400
kono
parents:
diff changeset
1401 /* Returns true if redirecting the incoming edges of FROM to TO maintains the
kono
parents:
diff changeset
1402 invariant that uses in FROM are dominates by their defs. */
kono
parents:
diff changeset
1403
kono
parents:
diff changeset
1404 static bool
kono
parents:
diff changeset
1405 deps_ok_for_redirect_from_bb_to_bb (basic_block from, basic_block to)
kono
parents:
diff changeset
1406 {
kono
parents:
diff changeset
1407 basic_block cd, dep_bb = BB_DEP_BB (to);
kono
parents:
diff changeset
1408 edge_iterator ei;
kono
parents:
diff changeset
1409 edge e;
kono
parents:
diff changeset
1410
kono
parents:
diff changeset
1411 if (dep_bb == NULL)
kono
parents:
diff changeset
1412 return true;
kono
parents:
diff changeset
1413
kono
parents:
diff changeset
1414 bitmap from_preds = BITMAP_ALLOC (NULL);
kono
parents:
diff changeset
1415 FOR_EACH_EDGE (e, ei, from->preds)
kono
parents:
diff changeset
1416 bitmap_set_bit (from_preds, e->src->index);
kono
parents:
diff changeset
1417 cd = nearest_common_dominator_for_set (CDI_DOMINATORS, from_preds);
kono
parents:
diff changeset
1418 BITMAP_FREE (from_preds);
kono
parents:
diff changeset
1419
kono
parents:
diff changeset
1420 return dominated_by_p (CDI_DOMINATORS, dep_bb, cd);
kono
parents:
diff changeset
1421 }
kono
parents:
diff changeset
1422
kono
parents:
diff changeset
1423 /* Returns true if replacing BB1 (or its replacement bb) by BB2 (or its
kono
parents:
diff changeset
1424 replacement bb) and vice versa maintains the invariant that uses in the
kono
parents:
diff changeset
1425 replacement are dominates by their defs. */
kono
parents:
diff changeset
1426
kono
parents:
diff changeset
1427 static bool
kono
parents:
diff changeset
1428 deps_ok_for_redirect (basic_block bb1, basic_block bb2)
kono
parents:
diff changeset
1429 {
kono
parents:
diff changeset
1430 if (BB_CLUSTER (bb1) != NULL)
kono
parents:
diff changeset
1431 bb1 = BB_CLUSTER (bb1)->rep_bb;
kono
parents:
diff changeset
1432
kono
parents:
diff changeset
1433 if (BB_CLUSTER (bb2) != NULL)
kono
parents:
diff changeset
1434 bb2 = BB_CLUSTER (bb2)->rep_bb;
kono
parents:
diff changeset
1435
kono
parents:
diff changeset
1436 return (deps_ok_for_redirect_from_bb_to_bb (bb1, bb2)
kono
parents:
diff changeset
1437 && deps_ok_for_redirect_from_bb_to_bb (bb2, bb1));
kono
parents:
diff changeset
1438 }
kono
parents:
diff changeset
1439
kono
parents:
diff changeset
1440 /* Within SAME_SUCC->bbs, find clusters of bbs which can be merged. */
kono
parents:
diff changeset
1441
kono
parents:
diff changeset
1442 static void
kono
parents:
diff changeset
1443 find_clusters_1 (same_succ *same_succ)
kono
parents:
diff changeset
1444 {
kono
parents:
diff changeset
1445 basic_block bb1, bb2;
kono
parents:
diff changeset
1446 unsigned int i, j;
kono
parents:
diff changeset
1447 bitmap_iterator bi, bj;
kono
parents:
diff changeset
1448 int nr_comparisons;
kono
parents:
diff changeset
1449 int max_comparisons = PARAM_VALUE (PARAM_MAX_TAIL_MERGE_COMPARISONS);
kono
parents:
diff changeset
1450
kono
parents:
diff changeset
1451 EXECUTE_IF_SET_IN_BITMAP (same_succ->bbs, 0, i, bi)
kono
parents:
diff changeset
1452 {
kono
parents:
diff changeset
1453 bb1 = BASIC_BLOCK_FOR_FN (cfun, i);
kono
parents:
diff changeset
1454
kono
parents:
diff changeset
1455 /* TODO: handle blocks with phi-nodes. We'll have to find corresponding
kono
parents:
diff changeset
1456 phi-nodes in bb1 and bb2, with the same alternatives for the same
kono
parents:
diff changeset
1457 preds. */
kono
parents:
diff changeset
1458 if (bb_has_non_vop_phi (bb1) || bb_has_eh_pred (bb1))
kono
parents:
diff changeset
1459 continue;
kono
parents:
diff changeset
1460
kono
parents:
diff changeset
1461 nr_comparisons = 0;
kono
parents:
diff changeset
1462 EXECUTE_IF_SET_IN_BITMAP (same_succ->bbs, i + 1, j, bj)
kono
parents:
diff changeset
1463 {
kono
parents:
diff changeset
1464 bb2 = BASIC_BLOCK_FOR_FN (cfun, j);
kono
parents:
diff changeset
1465
kono
parents:
diff changeset
1466 if (bb_has_non_vop_phi (bb2) || bb_has_eh_pred (bb2))
kono
parents:
diff changeset
1467 continue;
kono
parents:
diff changeset
1468
kono
parents:
diff changeset
1469 if (BB_CLUSTER (bb1) != NULL && BB_CLUSTER (bb1) == BB_CLUSTER (bb2))
kono
parents:
diff changeset
1470 continue;
kono
parents:
diff changeset
1471
kono
parents:
diff changeset
1472 /* Limit quadratic behavior. */
kono
parents:
diff changeset
1473 nr_comparisons++;
kono
parents:
diff changeset
1474 if (nr_comparisons > max_comparisons)
kono
parents:
diff changeset
1475 break;
kono
parents:
diff changeset
1476
kono
parents:
diff changeset
1477 /* This is a conservative dependency check. We could test more
kono
parents:
diff changeset
1478 precise for allowed replacement direction. */
kono
parents:
diff changeset
1479 if (!deps_ok_for_redirect (bb1, bb2))
kono
parents:
diff changeset
1480 continue;
kono
parents:
diff changeset
1481
kono
parents:
diff changeset
1482 if (!(same_phi_alternatives (same_succ, bb1, bb2)))
kono
parents:
diff changeset
1483 continue;
kono
parents:
diff changeset
1484
kono
parents:
diff changeset
1485 find_duplicate (same_succ, bb1, bb2);
kono
parents:
diff changeset
1486 }
kono
parents:
diff changeset
1487 }
kono
parents:
diff changeset
1488 }
kono
parents:
diff changeset
1489
kono
parents:
diff changeset
1490 /* Find clusters of bbs which can be merged. */
kono
parents:
diff changeset
1491
kono
parents:
diff changeset
1492 static void
kono
parents:
diff changeset
1493 find_clusters (void)
kono
parents:
diff changeset
1494 {
kono
parents:
diff changeset
1495 same_succ *same;
kono
parents:
diff changeset
1496
kono
parents:
diff changeset
1497 while (!worklist.is_empty ())
kono
parents:
diff changeset
1498 {
kono
parents:
diff changeset
1499 same = worklist.pop ();
kono
parents:
diff changeset
1500 same->in_worklist = false;
kono
parents:
diff changeset
1501 if (dump_file && (dump_flags & TDF_DETAILS))
kono
parents:
diff changeset
1502 {
kono
parents:
diff changeset
1503 fprintf (dump_file, "processing worklist entry\n");
kono
parents:
diff changeset
1504 same_succ_print (dump_file, same);
kono
parents:
diff changeset
1505 }
kono
parents:
diff changeset
1506 find_clusters_1 (same);
kono
parents:
diff changeset
1507 }
kono
parents:
diff changeset
1508 }
kono
parents:
diff changeset
1509
kono
parents:
diff changeset
1510 /* Returns the vop phi of BB, if any. */
kono
parents:
diff changeset
1511
kono
parents:
diff changeset
1512 static gphi *
kono
parents:
diff changeset
1513 vop_phi (basic_block bb)
kono
parents:
diff changeset
1514 {
kono
parents:
diff changeset
1515 gphi *stmt;
kono
parents:
diff changeset
1516 gphi_iterator gsi;
kono
parents:
diff changeset
1517 for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
kono
parents:
diff changeset
1518 {
kono
parents:
diff changeset
1519 stmt = gsi.phi ();
kono
parents:
diff changeset
1520 if (! virtual_operand_p (gimple_phi_result (stmt)))
kono
parents:
diff changeset
1521 continue;
kono
parents:
diff changeset
1522 return stmt;
kono
parents:
diff changeset
1523 }
kono
parents:
diff changeset
1524 return NULL;
kono
parents:
diff changeset
1525 }
kono
parents:
diff changeset
1526
kono
parents:
diff changeset
1527 /* Redirect all edges from BB1 to BB2, removes BB1 and marks it as removed. */
kono
parents:
diff changeset
1528
kono
parents:
diff changeset
1529 static void
kono
parents:
diff changeset
1530 replace_block_by (basic_block bb1, basic_block bb2)
kono
parents:
diff changeset
1531 {
kono
parents:
diff changeset
1532 edge pred_edge;
kono
parents:
diff changeset
1533 edge e1, e2;
kono
parents:
diff changeset
1534 edge_iterator ei;
kono
parents:
diff changeset
1535 unsigned int i;
kono
parents:
diff changeset
1536 gphi *bb2_phi;
kono
parents:
diff changeset
1537
kono
parents:
diff changeset
1538 bb2_phi = vop_phi (bb2);
kono
parents:
diff changeset
1539
kono
parents:
diff changeset
1540 /* Mark the basic block as deleted. */
kono
parents:
diff changeset
1541 mark_basic_block_deleted (bb1);
kono
parents:
diff changeset
1542
kono
parents:
diff changeset
1543 /* Redirect the incoming edges of bb1 to bb2. */
kono
parents:
diff changeset
1544 for (i = EDGE_COUNT (bb1->preds); i > 0 ; --i)
kono
parents:
diff changeset
1545 {
kono
parents:
diff changeset
1546 pred_edge = EDGE_PRED (bb1, i - 1);
kono
parents:
diff changeset
1547 pred_edge = redirect_edge_and_branch (pred_edge, bb2);
kono
parents:
diff changeset
1548 gcc_assert (pred_edge != NULL);
kono
parents:
diff changeset
1549
kono
parents:
diff changeset
1550 if (bb2_phi == NULL)
kono
parents:
diff changeset
1551 continue;
kono
parents:
diff changeset
1552
kono
parents:
diff changeset
1553 /* The phi might have run out of capacity when the redirect added an
kono
parents:
diff changeset
1554 argument, which means it could have been replaced. Refresh it. */
kono
parents:
diff changeset
1555 bb2_phi = vop_phi (bb2);
kono
parents:
diff changeset
1556
kono
parents:
diff changeset
1557 add_phi_arg (bb2_phi, SSA_NAME_VAR (gimple_phi_result (bb2_phi)),
kono
parents:
diff changeset
1558 pred_edge, UNKNOWN_LOCATION);
kono
parents:
diff changeset
1559 }
kono
parents:
diff changeset
1560
kono
parents:
diff changeset
1561 bb2->count += bb1->count;
kono
parents:
diff changeset
1562
kono
parents:
diff changeset
1563 /* Merge the outgoing edge counts from bb1 onto bb2. */
kono
parents:
diff changeset
1564 profile_count out_sum = profile_count::zero ();
kono
parents:
diff changeset
1565 int out_freq_sum = 0;
kono
parents:
diff changeset
1566
kono
parents:
diff changeset
1567 /* Recompute the edge probabilities from the new merged edge count.
kono
parents:
diff changeset
1568 Use the sum of the new merged edge counts computed above instead
kono
parents:
diff changeset
1569 of bb2's merged count, in case there are profile count insanities
kono
parents:
diff changeset
1570 making the bb count inconsistent with the edge weights. */
kono
parents:
diff changeset
1571 FOR_EACH_EDGE (e1, ei, bb1->succs)
kono
parents:
diff changeset
1572 {
kono
parents:
diff changeset
1573 if (e1->count ().initialized_p ())
kono
parents:
diff changeset
1574 out_sum += e1->count ();
kono
parents:
diff changeset
1575 out_freq_sum += EDGE_FREQUENCY (e1);
kono
parents:
diff changeset
1576 }
kono
parents:
diff changeset
1577 FOR_EACH_EDGE (e1, ei, bb2->succs)
kono
parents:
diff changeset
1578 {
kono
parents:
diff changeset
1579 if (e1->count ().initialized_p ())
kono
parents:
diff changeset
1580 out_sum += e1->count ();
kono
parents:
diff changeset
1581 out_freq_sum += EDGE_FREQUENCY (e1);
kono
parents:
diff changeset
1582 }
kono
parents:
diff changeset
1583
kono
parents:
diff changeset
1584 FOR_EACH_EDGE (e1, ei, bb1->succs)
kono
parents:
diff changeset
1585 {
kono
parents:
diff changeset
1586 e2 = find_edge (bb2, e1->dest);
kono
parents:
diff changeset
1587 gcc_assert (e2);
kono
parents:
diff changeset
1588 if (out_sum > 0 && e2->count ().initialized_p ())
kono
parents:
diff changeset
1589 {
kono
parents:
diff changeset
1590 e2->probability = e2->count ().probability_in (bb2->count);
kono
parents:
diff changeset
1591 }
kono
parents:
diff changeset
1592 else if (bb1->frequency && bb2->frequency)
kono
parents:
diff changeset
1593 e2->probability = e1->probability;
kono
parents:
diff changeset
1594 else if (bb2->frequency && !bb1->frequency)
kono
parents:
diff changeset
1595 ;
kono
parents:
diff changeset
1596 else if (out_freq_sum)
kono
parents:
diff changeset
1597 e2->probability = profile_probability::from_reg_br_prob_base
kono
parents:
diff changeset
1598 (GCOV_COMPUTE_SCALE (EDGE_FREQUENCY (e1)
kono
parents:
diff changeset
1599 + EDGE_FREQUENCY (e2),
kono
parents:
diff changeset
1600 out_freq_sum));
kono
parents:
diff changeset
1601 out_sum += e2->count ();
kono
parents:
diff changeset
1602 }
kono
parents:
diff changeset
1603 bb2->frequency += bb1->frequency;
kono
parents:
diff changeset
1604 if (bb2->frequency > BB_FREQ_MAX)
kono
parents:
diff changeset
1605 bb2->frequency = BB_FREQ_MAX;
kono
parents:
diff changeset
1606
kono
parents:
diff changeset
1607 /* Move over any user labels from bb1 after the bb2 labels. */
kono
parents:
diff changeset
1608 gimple_stmt_iterator gsi1 = gsi_start_bb (bb1);
kono
parents:
diff changeset
1609 if (!gsi_end_p (gsi1) && gimple_code (gsi_stmt (gsi1)) == GIMPLE_LABEL)
kono
parents:
diff changeset
1610 {
kono
parents:
diff changeset
1611 gimple_stmt_iterator gsi2 = gsi_after_labels (bb2);
kono
parents:
diff changeset
1612 while (!gsi_end_p (gsi1)
kono
parents:
diff changeset
1613 && gimple_code (gsi_stmt (gsi1)) == GIMPLE_LABEL)
kono
parents:
diff changeset
1614 {
kono
parents:
diff changeset
1615 tree label = gimple_label_label (as_a <glabel *> (gsi_stmt (gsi1)));
kono
parents:
diff changeset
1616 gcc_assert (!DECL_NONLOCAL (label) && !FORCED_LABEL (label));
kono
parents:
diff changeset
1617 if (DECL_ARTIFICIAL (label))
kono
parents:
diff changeset
1618 gsi_next (&gsi1);
kono
parents:
diff changeset
1619 else
kono
parents:
diff changeset
1620 gsi_move_before (&gsi1, &gsi2);
kono
parents:
diff changeset
1621 }
kono
parents:
diff changeset
1622 }
kono
parents:
diff changeset
1623
kono
parents:
diff changeset
1624 /* Clear range info from all stmts in BB2 -- this transformation
kono
parents:
diff changeset
1625 could make them out of date. */
kono
parents:
diff changeset
1626 reset_flow_sensitive_info_in_bb (bb2);
kono
parents:
diff changeset
1627
kono
parents:
diff changeset
1628 /* Do updates that use bb1, before deleting bb1. */
kono
parents:
diff changeset
1629 release_last_vdef (bb1);
kono
parents:
diff changeset
1630 same_succ_flush_bb (bb1);
kono
parents:
diff changeset
1631
kono
parents:
diff changeset
1632 delete_basic_block (bb1);
kono
parents:
diff changeset
1633 }
kono
parents:
diff changeset
1634
kono
parents:
diff changeset
1635 /* Bbs for which update_debug_stmt need to be called. */
kono
parents:
diff changeset
1636
kono
parents:
diff changeset
1637 static bitmap update_bbs;
kono
parents:
diff changeset
1638
kono
parents:
diff changeset
1639 /* For each cluster in all_clusters, merge all cluster->bbs. Returns
kono
parents:
diff changeset
1640 number of bbs removed. */
kono
parents:
diff changeset
1641
kono
parents:
diff changeset
1642 static int
kono
parents:
diff changeset
1643 apply_clusters (void)
kono
parents:
diff changeset
1644 {
kono
parents:
diff changeset
1645 basic_block bb1, bb2;
kono
parents:
diff changeset
1646 bb_cluster *c;
kono
parents:
diff changeset
1647 unsigned int i, j;
kono
parents:
diff changeset
1648 bitmap_iterator bj;
kono
parents:
diff changeset
1649 int nr_bbs_removed = 0;
kono
parents:
diff changeset
1650
kono
parents:
diff changeset
1651 for (i = 0; i < all_clusters.length (); ++i)
kono
parents:
diff changeset
1652 {
kono
parents:
diff changeset
1653 c = all_clusters[i];
kono
parents:
diff changeset
1654 if (c == NULL)
kono
parents:
diff changeset
1655 continue;
kono
parents:
diff changeset
1656
kono
parents:
diff changeset
1657 bb2 = c->rep_bb;
kono
parents:
diff changeset
1658 bitmap_set_bit (update_bbs, bb2->index);
kono
parents:
diff changeset
1659
kono
parents:
diff changeset
1660 bitmap_clear_bit (c->bbs, bb2->index);
kono
parents:
diff changeset
1661 EXECUTE_IF_SET_IN_BITMAP (c->bbs, 0, j, bj)
kono
parents:
diff changeset
1662 {
kono
parents:
diff changeset
1663 bb1 = BASIC_BLOCK_FOR_FN (cfun, j);
kono
parents:
diff changeset
1664 bitmap_clear_bit (update_bbs, bb1->index);
kono
parents:
diff changeset
1665
kono
parents:
diff changeset
1666 replace_block_by (bb1, bb2);
kono
parents:
diff changeset
1667 nr_bbs_removed++;
kono
parents:
diff changeset
1668 }
kono
parents:
diff changeset
1669 }
kono
parents:
diff changeset
1670
kono
parents:
diff changeset
1671 return nr_bbs_removed;
kono
parents:
diff changeset
1672 }
kono
parents:
diff changeset
1673
kono
parents:
diff changeset
1674 /* Resets debug statement STMT if it has uses that are not dominated by their
kono
parents:
diff changeset
1675 defs. */
kono
parents:
diff changeset
1676
kono
parents:
diff changeset
1677 static void
kono
parents:
diff changeset
1678 update_debug_stmt (gimple *stmt)
kono
parents:
diff changeset
1679 {
kono
parents:
diff changeset
1680 use_operand_p use_p;
kono
parents:
diff changeset
1681 ssa_op_iter oi;
kono
parents:
diff changeset
1682 basic_block bbuse;
kono
parents:
diff changeset
1683
kono
parents:
diff changeset
1684 if (!gimple_debug_bind_p (stmt))
kono
parents:
diff changeset
1685 return;
kono
parents:
diff changeset
1686
kono
parents:
diff changeset
1687 bbuse = gimple_bb (stmt);
kono
parents:
diff changeset
1688 FOR_EACH_PHI_OR_STMT_USE (use_p, stmt, oi, SSA_OP_USE)
kono
parents:
diff changeset
1689 {
kono
parents:
diff changeset
1690 tree name = USE_FROM_PTR (use_p);
kono
parents:
diff changeset
1691 gimple *def_stmt = SSA_NAME_DEF_STMT (name);
kono
parents:
diff changeset
1692 basic_block bbdef = gimple_bb (def_stmt);
kono
parents:
diff changeset
1693 if (bbdef == NULL || bbuse == bbdef
kono
parents:
diff changeset
1694 || dominated_by_p (CDI_DOMINATORS, bbuse, bbdef))
kono
parents:
diff changeset
1695 continue;
kono
parents:
diff changeset
1696
kono
parents:
diff changeset
1697 gimple_debug_bind_reset_value (stmt);
kono
parents:
diff changeset
1698 update_stmt (stmt);
kono
parents:
diff changeset
1699 break;
kono
parents:
diff changeset
1700 }
kono
parents:
diff changeset
1701 }
kono
parents:
diff changeset
1702
kono
parents:
diff changeset
1703 /* Resets all debug statements that have uses that are not
kono
parents:
diff changeset
1704 dominated by their defs. */
kono
parents:
diff changeset
1705
kono
parents:
diff changeset
1706 static void
kono
parents:
diff changeset
1707 update_debug_stmts (void)
kono
parents:
diff changeset
1708 {
kono
parents:
diff changeset
1709 basic_block bb;
kono
parents:
diff changeset
1710 bitmap_iterator bi;
kono
parents:
diff changeset
1711 unsigned int i;
kono
parents:
diff changeset
1712
kono
parents:
diff changeset
1713 EXECUTE_IF_SET_IN_BITMAP (update_bbs, 0, i, bi)
kono
parents:
diff changeset
1714 {
kono
parents:
diff changeset
1715 gimple *stmt;
kono
parents:
diff changeset
1716 gimple_stmt_iterator gsi;
kono
parents:
diff changeset
1717
kono
parents:
diff changeset
1718 bb = BASIC_BLOCK_FOR_FN (cfun, i);
kono
parents:
diff changeset
1719 for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
kono
parents:
diff changeset
1720 {
kono
parents:
diff changeset
1721 stmt = gsi_stmt (gsi);
kono
parents:
diff changeset
1722 if (!is_gimple_debug (stmt))
kono
parents:
diff changeset
1723 continue;
kono
parents:
diff changeset
1724 update_debug_stmt (stmt);
kono
parents:
diff changeset
1725 }
kono
parents:
diff changeset
1726 }
kono
parents:
diff changeset
1727 }
kono
parents:
diff changeset
1728
kono
parents:
diff changeset
1729 /* Runs tail merge optimization. */
kono
parents:
diff changeset
1730
kono
parents:
diff changeset
1731 unsigned int
kono
parents:
diff changeset
1732 tail_merge_optimize (unsigned int todo)
kono
parents:
diff changeset
1733 {
kono
parents:
diff changeset
1734 int nr_bbs_removed_total = 0;
kono
parents:
diff changeset
1735 int nr_bbs_removed;
kono
parents:
diff changeset
1736 bool loop_entered = false;
kono
parents:
diff changeset
1737 int iteration_nr = 0;
kono
parents:
diff changeset
1738 int max_iterations = PARAM_VALUE (PARAM_MAX_TAIL_MERGE_ITERATIONS);
kono
parents:
diff changeset
1739
kono
parents:
diff changeset
1740 if (!flag_tree_tail_merge
kono
parents:
diff changeset
1741 || max_iterations == 0)
kono
parents:
diff changeset
1742 return 0;
kono
parents:
diff changeset
1743
kono
parents:
diff changeset
1744 timevar_push (TV_TREE_TAIL_MERGE);
kono
parents:
diff changeset
1745
kono
parents:
diff changeset
1746 /* We enter from PRE which has critical edges split. Elimination
kono
parents:
diff changeset
1747 does not process trivially dead code so cleanup the CFG if we
kono
parents:
diff changeset
1748 are told so. And re-split critical edges then. */
kono
parents:
diff changeset
1749 if (todo & TODO_cleanup_cfg)
kono
parents:
diff changeset
1750 {
kono
parents:
diff changeset
1751 cleanup_tree_cfg ();
kono
parents:
diff changeset
1752 todo &= ~TODO_cleanup_cfg;
kono
parents:
diff changeset
1753 split_critical_edges ();
kono
parents:
diff changeset
1754 }
kono
parents:
diff changeset
1755
kono
parents:
diff changeset
1756 if (!dom_info_available_p (CDI_DOMINATORS))
kono
parents:
diff changeset
1757 {
kono
parents:
diff changeset
1758 /* PRE can leave us with unreachable blocks, remove them now. */
kono
parents:
diff changeset
1759 delete_unreachable_blocks ();
kono
parents:
diff changeset
1760 calculate_dominance_info (CDI_DOMINATORS);
kono
parents:
diff changeset
1761 }
kono
parents:
diff changeset
1762 init_worklist ();
kono
parents:
diff changeset
1763
kono
parents:
diff changeset
1764 while (!worklist.is_empty ())
kono
parents:
diff changeset
1765 {
kono
parents:
diff changeset
1766 if (!loop_entered)
kono
parents:
diff changeset
1767 {
kono
parents:
diff changeset
1768 loop_entered = true;
kono
parents:
diff changeset
1769 alloc_cluster_vectors ();
kono
parents:
diff changeset
1770 update_bbs = BITMAP_ALLOC (NULL);
kono
parents:
diff changeset
1771 }
kono
parents:
diff changeset
1772 else
kono
parents:
diff changeset
1773 reset_cluster_vectors ();
kono
parents:
diff changeset
1774
kono
parents:
diff changeset
1775 iteration_nr++;
kono
parents:
diff changeset
1776 if (dump_file && (dump_flags & TDF_DETAILS))
kono
parents:
diff changeset
1777 fprintf (dump_file, "worklist iteration #%d\n", iteration_nr);
kono
parents:
diff changeset
1778
kono
parents:
diff changeset
1779 find_clusters ();
kono
parents:
diff changeset
1780 gcc_assert (worklist.is_empty ());
kono
parents:
diff changeset
1781 if (all_clusters.is_empty ())
kono
parents:
diff changeset
1782 break;
kono
parents:
diff changeset
1783
kono
parents:
diff changeset
1784 nr_bbs_removed = apply_clusters ();
kono
parents:
diff changeset
1785 nr_bbs_removed_total += nr_bbs_removed;
kono
parents:
diff changeset
1786 if (nr_bbs_removed == 0)
kono
parents:
diff changeset
1787 break;
kono
parents:
diff changeset
1788
kono
parents:
diff changeset
1789 free_dominance_info (CDI_DOMINATORS);
kono
parents:
diff changeset
1790
kono
parents:
diff changeset
1791 if (iteration_nr == max_iterations)
kono
parents:
diff changeset
1792 break;
kono
parents:
diff changeset
1793
kono
parents:
diff changeset
1794 calculate_dominance_info (CDI_DOMINATORS);
kono
parents:
diff changeset
1795 update_worklist ();
kono
parents:
diff changeset
1796 }
kono
parents:
diff changeset
1797
kono
parents:
diff changeset
1798 if (dump_file && (dump_flags & TDF_DETAILS))
kono
parents:
diff changeset
1799 fprintf (dump_file, "htab collision / search: %f\n",
kono
parents:
diff changeset
1800 same_succ_htab->collisions ());
kono
parents:
diff changeset
1801
kono
parents:
diff changeset
1802 if (nr_bbs_removed_total > 0)
kono
parents:
diff changeset
1803 {
kono
parents:
diff changeset
1804 if (MAY_HAVE_DEBUG_STMTS)
kono
parents:
diff changeset
1805 {
kono
parents:
diff changeset
1806 calculate_dominance_info (CDI_DOMINATORS);
kono
parents:
diff changeset
1807 update_debug_stmts ();
kono
parents:
diff changeset
1808 }
kono
parents:
diff changeset
1809
kono
parents:
diff changeset
1810 if (dump_file && (dump_flags & TDF_DETAILS))
kono
parents:
diff changeset
1811 {
kono
parents:
diff changeset
1812 fprintf (dump_file, "Before TODOs.\n");
kono
parents:
diff changeset
1813 dump_function_to_file (current_function_decl, dump_file, dump_flags);
kono
parents:
diff changeset
1814 }
kono
parents:
diff changeset
1815
kono
parents:
diff changeset
1816 mark_virtual_operands_for_renaming (cfun);
kono
parents:
diff changeset
1817 }
kono
parents:
diff changeset
1818
kono
parents:
diff changeset
1819 delete_worklist ();
kono
parents:
diff changeset
1820 if (loop_entered)
kono
parents:
diff changeset
1821 {
kono
parents:
diff changeset
1822 delete_cluster_vectors ();
kono
parents:
diff changeset
1823 BITMAP_FREE (update_bbs);
kono
parents:
diff changeset
1824 }
kono
parents:
diff changeset
1825
kono
parents:
diff changeset
1826 timevar_pop (TV_TREE_TAIL_MERGE);
kono
parents:
diff changeset
1827
kono
parents:
diff changeset
1828 return todo;
kono
parents:
diff changeset
1829 }