Mercurial > hg > CbC > CbC_gcc
comparison gcc/cfgloopmanip.c @ 67:f6334be47118
update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
author | nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 22 Mar 2011 17:18:12 +0900 |
parents | 77e2b8dfacca |
children | 04ced10e8804 |
comparison
equal
deleted
inserted
replaced
65:65488c3d617d | 67:f6334be47118 |
---|---|
1 /* Loop manipulation code for GNU compiler. | 1 /* Loop manipulation code for GNU compiler. |
2 Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008, 2009 Free Software | 2 Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010, 2011 |
3 Foundation, Inc. | 3 Free Software Foundation, Inc. |
4 | 4 |
5 This file is part of GCC. | 5 This file is part of GCC. |
6 | 6 |
7 GCC is free software; you can redistribute it and/or modify it under | 7 GCC is free software; you can redistribute it and/or modify it under |
8 the terms of the GNU General Public License as published by the Free | 8 the terms of the GNU General Public License as published by the Free |
128 edge e; | 128 edge e; |
129 VEC (edge, heap) *exits = get_loop_exit_edges (loop); | 129 VEC (edge, heap) *exits = get_loop_exit_edges (loop); |
130 struct loop *father = current_loops->tree_root, *act; | 130 struct loop *father = current_loops->tree_root, *act; |
131 bool ret = false; | 131 bool ret = false; |
132 | 132 |
133 for (i = 0; VEC_iterate (edge, exits, i, e); i++) | 133 FOR_EACH_VEC_ELT (edge, exits, i, e) |
134 { | 134 { |
135 act = find_common_loop (loop, e->dest->loop_father); | 135 act = find_common_loop (loop, e->dest->loop_father); |
136 if (flow_loop_nested_p (father, act)) | 136 if (flow_loop_nested_p (father, act)) |
137 father = act; | 137 father = act; |
138 } | 138 } |
144 flow_loop_tree_node_remove (loop); | 144 flow_loop_tree_node_remove (loop); |
145 flow_loop_tree_node_add (father, loop); | 145 flow_loop_tree_node_add (father, loop); |
146 | 146 |
147 /* The exit edges of LOOP no longer exits its original immediate | 147 /* The exit edges of LOOP no longer exits its original immediate |
148 superloops; remove them from the appropriate exit lists. */ | 148 superloops; remove them from the appropriate exit lists. */ |
149 for (i = 0; VEC_iterate (edge, exits, i, e); i++) | 149 FOR_EACH_VEC_ELT (edge, exits, i, e) |
150 rescan_loop_exit (e, false, false); | 150 rescan_loop_exit (e, false, false); |
151 | 151 |
152 ret = true; | 152 ret = true; |
153 } | 153 } |
154 | 154 |
172 fix_bb_placements (basic_block from, | 172 fix_bb_placements (basic_block from, |
173 bool *irred_invalidated) | 173 bool *irred_invalidated) |
174 { | 174 { |
175 sbitmap in_queue; | 175 sbitmap in_queue; |
176 basic_block *queue, *qtop, *qbeg, *qend; | 176 basic_block *queue, *qtop, *qbeg, *qend; |
177 struct loop *base_loop; | 177 struct loop *base_loop, *target_loop; |
178 edge e; | 178 edge e; |
179 | 179 |
180 /* We pass through blocks back-reachable from FROM, testing whether some | 180 /* We pass through blocks back-reachable from FROM, testing whether some |
181 of their successors moved to outer loop. It may be necessary to | 181 of their successors moved to outer loop. It may be necessary to |
182 iterate several times, but it is finite, as we stop unless we move | 182 iterate several times, but it is finite, as we stop unless we move |
183 the basic block up the loop structure. The whole story is a bit | 183 the basic block up the loop structure. The whole story is a bit |
184 more complicated due to presence of subloops, those are moved using | 184 more complicated due to presence of subloops, those are moved using |
185 fix_loop_placement. */ | 185 fix_loop_placement. */ |
186 | 186 |
187 base_loop = from->loop_father; | 187 base_loop = from->loop_father; |
188 if (base_loop == current_loops->tree_root) | 188 /* If we are already in the outermost loop, the basic blocks cannot be moved |
189 outside of it. If FROM is the header of the base loop, it cannot be moved | |
190 outside of it, either. In both cases, we can end now. */ | |
191 if (base_loop == current_loops->tree_root | |
192 || from == base_loop->header) | |
189 return; | 193 return; |
190 | 194 |
191 in_queue = sbitmap_alloc (last_basic_block); | 195 in_queue = sbitmap_alloc (last_basic_block); |
192 sbitmap_zero (in_queue); | 196 sbitmap_zero (in_queue); |
193 SET_BIT (in_queue, from->index); | 197 SET_BIT (in_queue, from->index); |
212 if (from->loop_father->header == from) | 216 if (from->loop_father->header == from) |
213 { | 217 { |
214 /* Subloop header, maybe move the loop upward. */ | 218 /* Subloop header, maybe move the loop upward. */ |
215 if (!fix_loop_placement (from->loop_father)) | 219 if (!fix_loop_placement (from->loop_father)) |
216 continue; | 220 continue; |
221 target_loop = loop_outer (from->loop_father); | |
217 } | 222 } |
218 else | 223 else |
219 { | 224 { |
220 /* Ordinary basic block. */ | 225 /* Ordinary basic block. */ |
221 if (!fix_bb_placement (from)) | 226 if (!fix_bb_placement (from)) |
222 continue; | 227 continue; |
228 target_loop = from->loop_father; | |
223 } | 229 } |
224 | 230 |
225 FOR_EACH_EDGE (e, ei, from->succs) | 231 FOR_EACH_EDGE (e, ei, from->succs) |
226 { | 232 { |
227 if (e->flags & EDGE_IRREDUCIBLE_LOOP) | 233 if (e->flags & EDGE_IRREDUCIBLE_LOOP) |
246 nca = find_common_loop (pred->loop_father, base_loop); | 252 nca = find_common_loop (pred->loop_father, base_loop); |
247 if (pred->loop_father != base_loop | 253 if (pred->loop_father != base_loop |
248 && (nca == base_loop | 254 && (nca == base_loop |
249 || nca != pred->loop_father)) | 255 || nca != pred->loop_father)) |
250 pred = pred->loop_father->header; | 256 pred = pred->loop_father->header; |
251 else if (!flow_loop_nested_p (from->loop_father, pred->loop_father)) | 257 else if (!flow_loop_nested_p (target_loop, pred->loop_father)) |
252 { | 258 { |
253 /* No point in processing it. */ | 259 /* If PRED is already higher in the loop hierarchy than the |
260 TARGET_LOOP to that we moved FROM, the change of the position | |
261 of FROM does not affect the position of PRED, so there is no | |
262 point in processing it. */ | |
254 continue; | 263 continue; |
255 } | 264 } |
256 | 265 |
257 if (TEST_BIT (in_queue, pred->index)) | 266 if (TEST_BIT (in_queue, pred->index)) |
258 continue; | 267 continue; |
1269 | 1278 |
1270 bb = bbs[i]; | 1279 bb = bbs[i]; |
1271 bb->aux = 0; | 1280 bb->aux = 0; |
1272 | 1281 |
1273 dom_bbs = get_dominated_by (CDI_DOMINATORS, bb); | 1282 dom_bbs = get_dominated_by (CDI_DOMINATORS, bb); |
1274 for (j = 0; VEC_iterate (basic_block, dom_bbs, j, dominated); j++) | 1283 FOR_EACH_VEC_ELT (basic_block, dom_bbs, j, dominated) |
1275 { | 1284 { |
1276 if (flow_bb_inside_loop_p (loop, dominated)) | 1285 if (flow_bb_inside_loop_p (loop, dominated)) |
1277 continue; | 1286 continue; |
1278 dom_bb = nearest_common_dominator ( | 1287 dom_bb = nearest_common_dominator ( |
1279 CDI_DOMINATORS, first_active[i], first_active_latch); | 1288 CDI_DOMINATORS, first_active[i], first_active_latch); |
1536 first_head = entry->dest; | 1545 first_head = entry->dest; |
1537 | 1546 |
1538 /* Duplicate loop. */ | 1547 /* Duplicate loop. */ |
1539 if (!cfg_hook_duplicate_loop_to_header_edge (loop, entry, 1, | 1548 if (!cfg_hook_duplicate_loop_to_header_edge (loop, entry, 1, |
1540 NULL, NULL, NULL, 0)) | 1549 NULL, NULL, NULL, 0)) |
1541 return NULL; | 1550 { |
1551 entry->flags |= irred_flag; | |
1552 return NULL; | |
1553 } | |
1542 | 1554 |
1543 /* After duplication entry edge now points to new loop head block. | 1555 /* After duplication entry edge now points to new loop head block. |
1544 Note down new head as second_head. */ | 1556 Note down new head as second_head. */ |
1545 second_head = entry->dest; | 1557 second_head = entry->dest; |
1546 | 1558 |