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

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents f6334be47118
children 84e7813d76e9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 /* Code sinking for trees
16
kono
parents: 14
diff changeset
2 Copyright (C) 2001-2017 Free Software Foundation, Inc.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 Contributed by Daniel Berlin <dan@dberlin.org>
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 This file is part of GCC.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 GCC is free software; you can redistribute it and/or modify
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 it under the terms of the GNU General Public License as published by
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 the Free Software Foundation; either version 3, or (at your option)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 any later version.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 GCC is distributed in the hope that it will be useful,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 GNU General Public License for more details.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 along with GCC; see the file COPYING3. If not see
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 <http://www.gnu.org/licenses/>. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 #include "config.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 #include "system.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 #include "coretypes.h"
16
kono
parents: 14
diff changeset
24 #include "backend.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 #include "tree.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 #include "gimple.h"
16
kono
parents: 14
diff changeset
27 #include "cfghooks.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 #include "tree-pass.h"
16
kono
parents: 14
diff changeset
29 #include "ssa.h"
kono
parents: 14
diff changeset
30 #include "gimple-pretty-print.h"
kono
parents: 14
diff changeset
31 #include "fold-const.h"
kono
parents: 14
diff changeset
32 #include "stor-layout.h"
kono
parents: 14
diff changeset
33 #include "cfganal.h"
kono
parents: 14
diff changeset
34 #include "gimple-iterator.h"
kono
parents: 14
diff changeset
35 #include "tree-cfg.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 #include "cfgloop.h"
16
kono
parents: 14
diff changeset
37 #include "params.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
38
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 /* TODO:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 1. Sinking store only using scalar promotion (IE without moving the RHS):
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
41
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 *q = p;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 p = p + 1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 if (something)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 *q = <not p>;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 y = *q;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
48
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
49
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 should become
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 sinktemp = p;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 p = p + 1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 if (something)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 *q = <not p>;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 *q = sinktemp;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 y = *q
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 Store copy propagation will take care of the store elimination above.
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
61
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
62
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 2. Sinking using Partial Dead Code Elimination. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
64
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
65
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 static struct
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
67 {
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 /* The number of statements sunk down the flowgraph by code sinking. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 int sunk;
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
70
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 } sink_stats;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
72
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
73
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 /* Given a PHI, and one of its arguments (DEF), find the edge for
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
75 that argument and return it. If the argument occurs twice in the PHI node,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 we return NULL. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
77
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 static basic_block
16
kono
parents: 14
diff changeset
79 find_bb_for_arg (gphi *phi, tree def)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 size_t i;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 bool foundone = false;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 basic_block result = NULL;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
84 for (i = 0; i < gimple_phi_num_args (phi); i++)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
85 if (PHI_ARG_DEF (phi, i) == def)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
86 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
87 if (foundone)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
88 return NULL;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 foundone = true;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
90 result = gimple_phi_arg_edge (phi, i)->src;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
91 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
92 return result;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
93 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
94
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
95 /* When the first immediate use is in a statement, then return true if all
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
96 immediate uses in IMM are in the same statement.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
97 We could also do the case where the first immediate use is in a phi node,
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
98 and all the other uses are in phis in the same basic block, but this
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
99 requires some expensive checking later (you have to make sure no def/vdef
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
100 in the statement occurs for multiple edges in the various phi nodes it's
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
101 used in, so that you only have one place you can sink it to. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
102
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
103 static bool
16
kono
parents: 14
diff changeset
104 all_immediate_uses_same_place (def_operand_p def_p)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
105 {
16
kono
parents: 14
diff changeset
106 tree var = DEF_FROM_PTR (def_p);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
107 imm_use_iterator imm_iter;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
108 use_operand_p use_p;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
109
16
kono
parents: 14
diff changeset
110 gimple *firstuse = NULL;
kono
parents: 14
diff changeset
111 FOR_EACH_IMM_USE_FAST (use_p, imm_iter, var)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
112 {
16
kono
parents: 14
diff changeset
113 if (is_gimple_debug (USE_STMT (use_p)))
kono
parents: 14
diff changeset
114 continue;
kono
parents: 14
diff changeset
115 if (firstuse == NULL)
kono
parents: 14
diff changeset
116 firstuse = USE_STMT (use_p);
kono
parents: 14
diff changeset
117 else
kono
parents: 14
diff changeset
118 if (firstuse != USE_STMT (use_p))
kono
parents: 14
diff changeset
119 return false;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
120 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
121
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
122 return true;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
123 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
124
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
125 /* Find the nearest common dominator of all of the immediate uses in IMM. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
126
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
127 static basic_block
16
kono
parents: 14
diff changeset
128 nearest_common_dominator_of_uses (def_operand_p def_p, bool *debug_stmts)
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
129 {
16
kono
parents: 14
diff changeset
130 tree var = DEF_FROM_PTR (def_p);
kono
parents: 14
diff changeset
131 auto_bitmap blocks;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
132 basic_block commondom;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
133 unsigned int j;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
134 bitmap_iterator bi;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
135 imm_use_iterator imm_iter;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
136 use_operand_p use_p;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
137
16
kono
parents: 14
diff changeset
138 FOR_EACH_IMM_USE_FAST (use_p, imm_iter, var)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
139 {
16
kono
parents: 14
diff changeset
140 gimple *usestmt = USE_STMT (use_p);
kono
parents: 14
diff changeset
141 basic_block useblock;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
142
16
kono
parents: 14
diff changeset
143 if (gphi *phi = dyn_cast <gphi *> (usestmt))
kono
parents: 14
diff changeset
144 {
kono
parents: 14
diff changeset
145 int idx = PHI_ARG_INDEX_FROM_USE (use_p);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
146
16
kono
parents: 14
diff changeset
147 useblock = gimple_phi_arg_edge (phi, idx)->src;
kono
parents: 14
diff changeset
148 }
kono
parents: 14
diff changeset
149 else if (is_gimple_debug (usestmt))
kono
parents: 14
diff changeset
150 {
kono
parents: 14
diff changeset
151 *debug_stmts = true;
kono
parents: 14
diff changeset
152 continue;
kono
parents: 14
diff changeset
153 }
kono
parents: 14
diff changeset
154 else
kono
parents: 14
diff changeset
155 {
kono
parents: 14
diff changeset
156 useblock = gimple_bb (usestmt);
kono
parents: 14
diff changeset
157 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
158
16
kono
parents: 14
diff changeset
159 /* Short circuit. Nothing dominates the entry block. */
kono
parents: 14
diff changeset
160 if (useblock == ENTRY_BLOCK_PTR_FOR_FN (cfun))
kono
parents: 14
diff changeset
161 return NULL;
kono
parents: 14
diff changeset
162
kono
parents: 14
diff changeset
163 bitmap_set_bit (blocks, useblock->index);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
164 }
16
kono
parents: 14
diff changeset
165 commondom = BASIC_BLOCK_FOR_FN (cfun, bitmap_first_set_bit (blocks));
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
166 EXECUTE_IF_SET_IN_BITMAP (blocks, 0, j, bi)
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
167 commondom = nearest_common_dominator (CDI_DOMINATORS, commondom,
16
kono
parents: 14
diff changeset
168 BASIC_BLOCK_FOR_FN (cfun, j));
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
169 return commondom;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
170 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
171
16
kono
parents: 14
diff changeset
172 /* Given EARLY_BB and LATE_BB, two blocks in a path through the dominator
kono
parents: 14
diff changeset
173 tree, return the best basic block between them (inclusive) to place
kono
parents: 14
diff changeset
174 statements.
kono
parents: 14
diff changeset
175
kono
parents: 14
diff changeset
176 We want the most control dependent block in the shallowest loop nest.
kono
parents: 14
diff changeset
177
kono
parents: 14
diff changeset
178 If the resulting block is in a shallower loop nest, then use it. Else
kono
parents: 14
diff changeset
179 only use the resulting block if it has significantly lower execution
kono
parents: 14
diff changeset
180 frequency than EARLY_BB to avoid gratutious statement movement. We
kono
parents: 14
diff changeset
181 consider statements with VOPS more desirable to move.
kono
parents: 14
diff changeset
182
kono
parents: 14
diff changeset
183 This pass would obviously benefit from PDO as it utilizes block
kono
parents: 14
diff changeset
184 frequencies. It would also benefit from recomputing frequencies
kono
parents: 14
diff changeset
185 if profile data is not available since frequencies often get out
kono
parents: 14
diff changeset
186 of sync with reality. */
kono
parents: 14
diff changeset
187
kono
parents: 14
diff changeset
188 static basic_block
kono
parents: 14
diff changeset
189 select_best_block (basic_block early_bb,
kono
parents: 14
diff changeset
190 basic_block late_bb,
kono
parents: 14
diff changeset
191 gimple *stmt)
kono
parents: 14
diff changeset
192 {
kono
parents: 14
diff changeset
193 basic_block best_bb = late_bb;
kono
parents: 14
diff changeset
194 basic_block temp_bb = late_bb;
kono
parents: 14
diff changeset
195 int threshold;
kono
parents: 14
diff changeset
196
kono
parents: 14
diff changeset
197 while (temp_bb != early_bb)
kono
parents: 14
diff changeset
198 {
kono
parents: 14
diff changeset
199 /* If we've moved into a lower loop nest, then that becomes
kono
parents: 14
diff changeset
200 our best block. */
kono
parents: 14
diff changeset
201 if (bb_loop_depth (temp_bb) < bb_loop_depth (best_bb))
kono
parents: 14
diff changeset
202 best_bb = temp_bb;
kono
parents: 14
diff changeset
203
kono
parents: 14
diff changeset
204 /* Walk up the dominator tree, hopefully we'll find a shallower
kono
parents: 14
diff changeset
205 loop nest. */
kono
parents: 14
diff changeset
206 temp_bb = get_immediate_dominator (CDI_DOMINATORS, temp_bb);
kono
parents: 14
diff changeset
207 }
kono
parents: 14
diff changeset
208
kono
parents: 14
diff changeset
209 /* If we found a shallower loop nest, then we always consider that
kono
parents: 14
diff changeset
210 a win. This will always give us the most control dependent block
kono
parents: 14
diff changeset
211 within that loop nest. */
kono
parents: 14
diff changeset
212 if (bb_loop_depth (best_bb) < bb_loop_depth (early_bb))
kono
parents: 14
diff changeset
213 return best_bb;
kono
parents: 14
diff changeset
214
kono
parents: 14
diff changeset
215 /* Get the sinking threshold. If the statement to be moved has memory
kono
parents: 14
diff changeset
216 operands, then increase the threshold by 7% as those are even more
kono
parents: 14
diff changeset
217 profitable to avoid, clamping at 100%. */
kono
parents: 14
diff changeset
218 threshold = PARAM_VALUE (PARAM_SINK_FREQUENCY_THRESHOLD);
kono
parents: 14
diff changeset
219 if (gimple_vuse (stmt) || gimple_vdef (stmt))
kono
parents: 14
diff changeset
220 {
kono
parents: 14
diff changeset
221 threshold += 7;
kono
parents: 14
diff changeset
222 if (threshold > 100)
kono
parents: 14
diff changeset
223 threshold = 100;
kono
parents: 14
diff changeset
224 }
kono
parents: 14
diff changeset
225
kono
parents: 14
diff changeset
226 /* If BEST_BB is at the same nesting level, then require it to have
kono
parents: 14
diff changeset
227 significantly lower execution frequency to avoid gratutious movement. */
kono
parents: 14
diff changeset
228 if (bb_loop_depth (best_bb) == bb_loop_depth (early_bb)
kono
parents: 14
diff changeset
229 && best_bb->frequency < (early_bb->frequency * threshold / 100.0))
kono
parents: 14
diff changeset
230 return best_bb;
kono
parents: 14
diff changeset
231
kono
parents: 14
diff changeset
232 /* No better block found, so return EARLY_BB, which happens to be the
kono
parents: 14
diff changeset
233 statement's original block. */
kono
parents: 14
diff changeset
234 return early_bb;
kono
parents: 14
diff changeset
235 }
kono
parents: 14
diff changeset
236
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
237 /* Given a statement (STMT) and the basic block it is currently in (FROMBB),
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
238 determine the location to sink the statement to, if any.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
239 Returns true if there is such location; in that case, TOGSI points to the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
240 statement before that STMT should be moved. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
241
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
242 static bool
16
kono
parents: 14
diff changeset
243 statement_sink_location (gimple *stmt, basic_block frombb,
kono
parents: 14
diff changeset
244 gimple_stmt_iterator *togsi, bool *zero_uses_p)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
245 {
16
kono
parents: 14
diff changeset
246 gimple *use;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
247 use_operand_p one_use = NULL_USE_OPERAND_P;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
248 basic_block sinkbb;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
249 use_operand_p use_p;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
250 def_operand_p def_p;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
251 ssa_op_iter iter;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
252 imm_use_iterator imm_iter;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
253
16
kono
parents: 14
diff changeset
254 *zero_uses_p = false;
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
255
16
kono
parents: 14
diff changeset
256 /* We only can sink assignments and non-looping const/pure calls. */
kono
parents: 14
diff changeset
257 int cf;
kono
parents: 14
diff changeset
258 if (!is_gimple_assign (stmt)
kono
parents: 14
diff changeset
259 && (!is_gimple_call (stmt)
kono
parents: 14
diff changeset
260 || !((cf = gimple_call_flags (stmt)) & (ECF_CONST|ECF_PURE))
kono
parents: 14
diff changeset
261 || (cf & ECF_LOOPING_CONST_OR_PURE)))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
262 return false;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
263
16
kono
parents: 14
diff changeset
264 /* We only can sink stmts with a single definition. */
kono
parents: 14
diff changeset
265 def_p = single_ssa_def_operand (stmt, SSA_OP_ALL_DEFS);
kono
parents: 14
diff changeset
266 if (def_p == NULL_DEF_OPERAND_P)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
267 return false;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
268
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
269 /* There are a few classes of things we can't or don't move, some because we
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
270 don't have code to handle it, some because it's not profitable and some
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
271 because it's not legal.
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
272
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
273 We can't sink things that may be global stores, at least not without
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
274 calculating a lot more information, because we may cause it to no longer
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
275 be seen by an external routine that needs it depending on where it gets
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
276 moved to.
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
277
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
278 We can't sink statements that end basic blocks without splitting the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
279 incoming edge for the sink location to place it there.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
280
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
281 We can't sink statements that have volatile operands.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
282
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
283 We don't want to sink dead code, so anything with 0 immediate uses is not
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
284 sunk.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
285
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
286 Don't sink BLKmode assignments if current function has any local explicit
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
287 register variables, as BLKmode assignments may involve memcpy or memset
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
288 calls or, on some targets, inline expansion thereof that sometimes need
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
289 to use specific hard registers.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
290
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
291 */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
292 if (stmt_ends_bb_p (stmt)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
293 || gimple_has_side_effects (stmt)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
294 || (cfun->has_local_explicit_reg_vars
16
kono
parents: 14
diff changeset
295 && TYPE_MODE (TREE_TYPE (gimple_get_lhs (stmt))) == BLKmode))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
296 return false;
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
297
16
kono
parents: 14
diff changeset
298 /* Return if there are no immediate uses of this stmt. */
kono
parents: 14
diff changeset
299 if (has_zero_uses (DEF_FROM_PTR (def_p)))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
300 {
16
kono
parents: 14
diff changeset
301 *zero_uses_p = true;
kono
parents: 14
diff changeset
302 return false;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
303 }
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
304
16
kono
parents: 14
diff changeset
305 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (DEF_FROM_PTR (def_p)))
kono
parents: 14
diff changeset
306 return false;
kono
parents: 14
diff changeset
307
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
308 FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter, SSA_OP_ALL_USES)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
309 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
310 tree use = USE_FROM_PTR (use_p);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
311 if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (use))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
312 return false;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
313 }
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
314
16
kono
parents: 14
diff changeset
315 use = NULL;
kono
parents: 14
diff changeset
316
kono
parents: 14
diff changeset
317 /* If stmt is a store the one and only use needs to be the VOP
kono
parents: 14
diff changeset
318 merging PHI node. */
kono
parents: 14
diff changeset
319 if (virtual_operand_p (DEF_FROM_PTR (def_p)))
kono
parents: 14
diff changeset
320 {
kono
parents: 14
diff changeset
321 FOR_EACH_IMM_USE_FAST (use_p, imm_iter, DEF_FROM_PTR (def_p))
kono
parents: 14
diff changeset
322 {
kono
parents: 14
diff changeset
323 gimple *use_stmt = USE_STMT (use_p);
kono
parents: 14
diff changeset
324
kono
parents: 14
diff changeset
325 /* A killing definition is not a use. */
kono
parents: 14
diff changeset
326 if ((gimple_has_lhs (use_stmt)
kono
parents: 14
diff changeset
327 && operand_equal_p (gimple_get_lhs (stmt),
kono
parents: 14
diff changeset
328 gimple_get_lhs (use_stmt), 0))
kono
parents: 14
diff changeset
329 || stmt_kills_ref_p (use_stmt, gimple_get_lhs (stmt)))
kono
parents: 14
diff changeset
330 {
kono
parents: 14
diff changeset
331 /* If use_stmt is or might be a nop assignment then USE_STMT
kono
parents: 14
diff changeset
332 acts as a use as well as definition. */
kono
parents: 14
diff changeset
333 if (stmt != use_stmt
kono
parents: 14
diff changeset
334 && ref_maybe_used_by_stmt_p (use_stmt,
kono
parents: 14
diff changeset
335 gimple_get_lhs (stmt)))
kono
parents: 14
diff changeset
336 return false;
kono
parents: 14
diff changeset
337 continue;
kono
parents: 14
diff changeset
338 }
kono
parents: 14
diff changeset
339
kono
parents: 14
diff changeset
340 if (gimple_code (use_stmt) != GIMPLE_PHI)
kono
parents: 14
diff changeset
341 return false;
kono
parents: 14
diff changeset
342
kono
parents: 14
diff changeset
343 if (use
kono
parents: 14
diff changeset
344 && use != use_stmt)
kono
parents: 14
diff changeset
345 return false;
kono
parents: 14
diff changeset
346
kono
parents: 14
diff changeset
347 use = use_stmt;
kono
parents: 14
diff changeset
348 }
kono
parents: 14
diff changeset
349 if (!use)
kono
parents: 14
diff changeset
350 return false;
kono
parents: 14
diff changeset
351 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
352 /* If all the immediate uses are not in the same place, find the nearest
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
353 common dominator of all the immediate uses. For PHI nodes, we have to
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
354 find the nearest common dominator of all of the predecessor blocks, since
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
355 that is where insertion would have to take place. */
16
kono
parents: 14
diff changeset
356 else if (gimple_vuse (stmt)
kono
parents: 14
diff changeset
357 || !all_immediate_uses_same_place (def_p))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
358 {
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
359 bool debug_stmts = false;
16
kono
parents: 14
diff changeset
360 basic_block commondom = nearest_common_dominator_of_uses (def_p,
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
361 &debug_stmts);
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
362
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
363 if (commondom == frombb)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
364 return false;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
365
16
kono
parents: 14
diff changeset
366 /* If this is a load then do not sink past any stores.
kono
parents: 14
diff changeset
367 ??? This is overly simple but cheap. We basically look
kono
parents: 14
diff changeset
368 for an existing load with the same VUSE in the path to one
kono
parents: 14
diff changeset
369 of the sink candidate blocks and we adjust commondom to the
kono
parents: 14
diff changeset
370 nearest to commondom. */
kono
parents: 14
diff changeset
371 if (gimple_vuse (stmt))
kono
parents: 14
diff changeset
372 {
kono
parents: 14
diff changeset
373 /* Do not sink loads from hard registers. */
kono
parents: 14
diff changeset
374 if (gimple_assign_single_p (stmt)
kono
parents: 14
diff changeset
375 && TREE_CODE (gimple_assign_rhs1 (stmt)) == VAR_DECL
kono
parents: 14
diff changeset
376 && DECL_HARD_REGISTER (gimple_assign_rhs1 (stmt)))
kono
parents: 14
diff changeset
377 return false;
kono
parents: 14
diff changeset
378
kono
parents: 14
diff changeset
379 imm_use_iterator imm_iter;
kono
parents: 14
diff changeset
380 use_operand_p use_p;
kono
parents: 14
diff changeset
381 basic_block found = NULL;
kono
parents: 14
diff changeset
382 FOR_EACH_IMM_USE_FAST (use_p, imm_iter, gimple_vuse (stmt))
kono
parents: 14
diff changeset
383 {
kono
parents: 14
diff changeset
384 gimple *use_stmt = USE_STMT (use_p);
kono
parents: 14
diff changeset
385 basic_block bb = gimple_bb (use_stmt);
kono
parents: 14
diff changeset
386 /* For PHI nodes the block we know sth about
kono
parents: 14
diff changeset
387 is the incoming block with the use. */
kono
parents: 14
diff changeset
388 if (gimple_code (use_stmt) == GIMPLE_PHI)
kono
parents: 14
diff changeset
389 bb = EDGE_PRED (bb, PHI_ARG_INDEX_FROM_USE (use_p))->src;
kono
parents: 14
diff changeset
390 /* Any dominator of commondom would be ok with
kono
parents: 14
diff changeset
391 adjusting commondom to that block. */
kono
parents: 14
diff changeset
392 bb = nearest_common_dominator (CDI_DOMINATORS, bb, commondom);
kono
parents: 14
diff changeset
393 if (!found)
kono
parents: 14
diff changeset
394 found = bb;
kono
parents: 14
diff changeset
395 else if (dominated_by_p (CDI_DOMINATORS, bb, found))
kono
parents: 14
diff changeset
396 found = bb;
kono
parents: 14
diff changeset
397 /* If we can't improve, stop. */
kono
parents: 14
diff changeset
398 if (found == commondom)
kono
parents: 14
diff changeset
399 break;
kono
parents: 14
diff changeset
400 }
kono
parents: 14
diff changeset
401 commondom = found;
kono
parents: 14
diff changeset
402 if (commondom == frombb)
kono
parents: 14
diff changeset
403 return false;
kono
parents: 14
diff changeset
404 }
kono
parents: 14
diff changeset
405
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
406 /* Our common dominator has to be dominated by frombb in order to be a
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
407 trivially safe place to put this statement, since it has multiple
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
408 uses. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
409 if (!dominated_by_p (CDI_DOMINATORS, commondom, frombb))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
410 return false;
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
411
16
kono
parents: 14
diff changeset
412 commondom = select_best_block (frombb, commondom, stmt);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
413
16
kono
parents: 14
diff changeset
414 if (commondom == frombb)
kono
parents: 14
diff changeset
415 return false;
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
416
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
417 *togsi = gsi_after_labels (commondom);
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
418
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
419 return true;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
420 }
16
kono
parents: 14
diff changeset
421 else
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
422 {
16
kono
parents: 14
diff changeset
423 FOR_EACH_IMM_USE_FAST (one_use, imm_iter, DEF_FROM_PTR (def_p))
kono
parents: 14
diff changeset
424 {
kono
parents: 14
diff changeset
425 if (is_gimple_debug (USE_STMT (one_use)))
kono
parents: 14
diff changeset
426 continue;
kono
parents: 14
diff changeset
427 break;
kono
parents: 14
diff changeset
428 }
kono
parents: 14
diff changeset
429 use = USE_STMT (one_use);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
430
16
kono
parents: 14
diff changeset
431 if (gimple_code (use) != GIMPLE_PHI)
kono
parents: 14
diff changeset
432 {
kono
parents: 14
diff changeset
433 sinkbb = gimple_bb (use);
kono
parents: 14
diff changeset
434 sinkbb = select_best_block (frombb, gimple_bb (use), stmt);
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
435
16
kono
parents: 14
diff changeset
436 if (sinkbb == frombb)
kono
parents: 14
diff changeset
437 return false;
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
438
16
kono
parents: 14
diff changeset
439 *togsi = gsi_for_stmt (use);
kono
parents: 14
diff changeset
440
kono
parents: 14
diff changeset
441 return true;
kono
parents: 14
diff changeset
442 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
443 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
444
16
kono
parents: 14
diff changeset
445 sinkbb = find_bb_for_arg (as_a <gphi *> (use), DEF_FROM_PTR (def_p));
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
446
16
kono
parents: 14
diff changeset
447 /* This can happen if there are multiple uses in a PHI. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
448 if (!sinkbb)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
449 return false;
16
kono
parents: 14
diff changeset
450
kono
parents: 14
diff changeset
451 sinkbb = select_best_block (frombb, sinkbb, stmt);
kono
parents: 14
diff changeset
452 if (!sinkbb || sinkbb == frombb)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
453 return false;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
454
14
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
455 /* If the latch block is empty, don't make it non-empty by sinking
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
456 something into it. */
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
457 if (sinkbb == frombb->loop_father->latch
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
458 && empty_block_p (sinkbb))
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
459 return false;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 11
diff changeset
460
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
461 *togsi = gsi_after_labels (sinkbb);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
462
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
463 return true;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
464 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
465
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
466 /* Perform code sinking on BB */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
467
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
468 static void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
469 sink_code_in_bb (basic_block bb)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
470 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
471 basic_block son;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
472 gimple_stmt_iterator gsi;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
473 edge_iterator ei;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
474 edge e;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
475 bool last = true;
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
476
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
477 /* If this block doesn't dominate anything, there can't be any place to sink
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
478 the statements to. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
479 if (first_dom_son (CDI_DOMINATORS, bb) == NULL)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
480 goto earlyout;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
481
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
482 /* We can't move things across abnormal edges, so don't try. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
483 FOR_EACH_EDGE (e, ei, bb->succs)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
484 if (e->flags & EDGE_ABNORMAL)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
485 goto earlyout;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
486
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
487 for (gsi = gsi_last_bb (bb); !gsi_end_p (gsi);)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
488 {
16
kono
parents: 14
diff changeset
489 gimple *stmt = gsi_stmt (gsi);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
490 gimple_stmt_iterator togsi;
16
kono
parents: 14
diff changeset
491 bool zero_uses_p;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
492
16
kono
parents: 14
diff changeset
493 if (!statement_sink_location (stmt, bb, &togsi, &zero_uses_p))
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
494 {
16
kono
parents: 14
diff changeset
495 gimple_stmt_iterator saved = gsi;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
496 if (!gsi_end_p (gsi))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
497 gsi_prev (&gsi);
16
kono
parents: 14
diff changeset
498 /* If we face a dead stmt remove it as it possibly blocks
kono
parents: 14
diff changeset
499 sinking of uses. */
kono
parents: 14
diff changeset
500 if (zero_uses_p
kono
parents: 14
diff changeset
501 && ! gimple_vdef (stmt))
kono
parents: 14
diff changeset
502 {
kono
parents: 14
diff changeset
503 gsi_remove (&saved, true);
kono
parents: 14
diff changeset
504 release_defs (stmt);
kono
parents: 14
diff changeset
505 }
kono
parents: 14
diff changeset
506 else
kono
parents: 14
diff changeset
507 last = false;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
508 continue;
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
509 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
510 if (dump_file)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
511 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
512 fprintf (dump_file, "Sinking ");
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
513 print_gimple_stmt (dump_file, stmt, 0, TDF_VOPS);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
514 fprintf (dump_file, " from bb %d to bb %d\n",
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
515 bb->index, (gsi_bb (togsi))->index);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
516 }
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
517
16
kono
parents: 14
diff changeset
518 /* Update virtual operands of statements in the path we
kono
parents: 14
diff changeset
519 do not sink to. */
kono
parents: 14
diff changeset
520 if (gimple_vdef (stmt))
kono
parents: 14
diff changeset
521 {
kono
parents: 14
diff changeset
522 imm_use_iterator iter;
kono
parents: 14
diff changeset
523 use_operand_p use_p;
kono
parents: 14
diff changeset
524 gimple *vuse_stmt;
kono
parents: 14
diff changeset
525
kono
parents: 14
diff changeset
526 FOR_EACH_IMM_USE_STMT (vuse_stmt, iter, gimple_vdef (stmt))
kono
parents: 14
diff changeset
527 if (gimple_code (vuse_stmt) != GIMPLE_PHI)
kono
parents: 14
diff changeset
528 FOR_EACH_IMM_USE_ON_STMT (use_p, iter)
kono
parents: 14
diff changeset
529 SET_USE (use_p, gimple_vuse (stmt));
kono
parents: 14
diff changeset
530 }
kono
parents: 14
diff changeset
531
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
532 /* If this is the end of the basic block, we need to insert at the end
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
533 of the basic block. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
534 if (gsi_end_p (togsi))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
535 gsi_move_to_bb_end (&gsi, gsi_bb (togsi));
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
536 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
537 gsi_move_before (&gsi, &togsi);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
538
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
539 sink_stats.sunk++;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
540
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
541 /* If we've just removed the last statement of the BB, the
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
542 gsi_end_p() test below would fail, but gsi_prev() would have
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
543 succeeded, and we want it to succeed. So we keep track of
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
544 whether we're at the last statement and pick up the new last
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
545 statement. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
546 if (last)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
547 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
548 gsi = gsi_last_bb (bb);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
549 continue;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
550 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
551
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
552 last = false;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
553 if (!gsi_end_p (gsi))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
554 gsi_prev (&gsi);
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
555
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
556 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
557 earlyout:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
558 for (son = first_dom_son (CDI_POST_DOMINATORS, bb);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
559 son;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
560 son = next_dom_son (CDI_POST_DOMINATORS, son))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
561 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
562 sink_code_in_bb (son);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
563 }
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
564 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
565
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
566 /* Perform code sinking.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
567 This moves code down the flowgraph when we know it would be
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
568 profitable to do so, or it wouldn't increase the number of
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
569 executions of the statement.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
570
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
571 IE given
9
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
572
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
573 a_1 = b + c;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
574 if (<something>)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
575 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
576 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
577 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
578 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
579 foo (&b, &c);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
580 a_5 = b + c;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
581 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
582 a_6 = PHI (a_5, a_1);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
583 USE a_6.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
584
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
585 we'll transform this into:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
586
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
587 if (<something>)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
588 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
589 a_1 = b + c;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
590 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
591 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
592 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
593 foo (&b, &c);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
594 a_5 = b + c;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
595 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
596 a_6 = PHI (a_5, a_1);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
597 USE a_6.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
598
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
599 Note that this reduces the number of computations of a = b + c to 1
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
600 when we take the else edge, instead of 2.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
601 */
16
kono
parents: 14
diff changeset
602 namespace {
kono
parents: 14
diff changeset
603
kono
parents: 14
diff changeset
604 const pass_data pass_data_sink_code =
kono
parents: 14
diff changeset
605 {
kono
parents: 14
diff changeset
606 GIMPLE_PASS, /* type */
kono
parents: 14
diff changeset
607 "sink", /* name */
kono
parents: 14
diff changeset
608 OPTGROUP_NONE, /* optinfo_flags */
kono
parents: 14
diff changeset
609 TV_TREE_SINK, /* tv_id */
kono
parents: 14
diff changeset
610 /* PROP_no_crit_edges is ensured by running split_critical_edges in
kono
parents: 14
diff changeset
611 pass_data_sink_code::execute (). */
kono
parents: 14
diff changeset
612 ( PROP_cfg | PROP_ssa ), /* properties_required */
kono
parents: 14
diff changeset
613 0, /* properties_provided */
kono
parents: 14
diff changeset
614 0, /* properties_destroyed */
kono
parents: 14
diff changeset
615 0, /* todo_flags_start */
kono
parents: 14
diff changeset
616 TODO_update_ssa, /* todo_flags_finish */
kono
parents: 14
diff changeset
617 };
kono
parents: 14
diff changeset
618
kono
parents: 14
diff changeset
619 class pass_sink_code : public gimple_opt_pass
kono
parents: 14
diff changeset
620 {
kono
parents: 14
diff changeset
621 public:
kono
parents: 14
diff changeset
622 pass_sink_code (gcc::context *ctxt)
kono
parents: 14
diff changeset
623 : gimple_opt_pass (pass_data_sink_code, ctxt)
kono
parents: 14
diff changeset
624 {}
kono
parents: 14
diff changeset
625
kono
parents: 14
diff changeset
626 /* opt_pass methods: */
kono
parents: 14
diff changeset
627 virtual bool gate (function *) { return flag_tree_sink != 0; }
kono
parents: 14
diff changeset
628 virtual unsigned int execute (function *);
kono
parents: 14
diff changeset
629
kono
parents: 14
diff changeset
630 }; // class pass_sink_code
kono
parents: 14
diff changeset
631
kono
parents: 14
diff changeset
632 unsigned int
kono
parents: 14
diff changeset
633 pass_sink_code::execute (function *fun)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
634 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
635 loop_optimizer_init (LOOPS_NORMAL);
16
kono
parents: 14
diff changeset
636 split_critical_edges ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
637 connect_infinite_loops_to_exit ();
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
638 memset (&sink_stats, 0, sizeof (sink_stats));
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
639 calculate_dominance_info (CDI_DOMINATORS);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
640 calculate_dominance_info (CDI_POST_DOMINATORS);
16
kono
parents: 14
diff changeset
641 sink_code_in_bb (EXIT_BLOCK_PTR_FOR_FN (fun));
kono
parents: 14
diff changeset
642 statistics_counter_event (fun, "Sunk statements", sink_stats.sunk);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
643 free_dominance_info (CDI_POST_DOMINATORS);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
644 remove_fake_exit_edges ();
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
645 loop_optimizer_finalize ();
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
646
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
647 return 0;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
648 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
649
16
kono
parents: 14
diff changeset
650 } // anon namespace
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
651
16
kono
parents: 14
diff changeset
652 gimple_opt_pass *
kono
parents: 14
diff changeset
653 make_pass_sink_code (gcc::context *ctxt)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
654 {
16
kono
parents: 14
diff changeset
655 return new pass_sink_code (ctxt);
kono
parents: 14
diff changeset
656 }