OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler/common-operator.h" | 5 #include "src/compiler/common-operator.h" |
6 #include "src/compiler/graph.h" | 6 #include "src/compiler/graph.h" |
7 #include "src/compiler/loop-peeling.h" | 7 #include "src/compiler/loop-peeling.h" |
8 #include "src/compiler/node.h" | 8 #include "src/compiler/node.h" |
9 #include "src/compiler/node-marker.h" | 9 #include "src/compiler/node-marker.h" |
10 #include "src/compiler/node-properties-inl.h" | 10 #include "src/compiler/node-properties.h" |
11 #include "src/zone.h" | 11 #include "src/zone.h" |
12 | 12 |
13 // Loop peeling is an optimization that copies the body of a loop, creating | 13 // Loop peeling is an optimization that copies the body of a loop, creating |
14 // a new copy of the body called the "peeled iteration" that represents the | 14 // a new copy of the body called the "peeled iteration" that represents the |
15 // first iteration. Beginning with a loop as follows: | 15 // first iteration. Beginning with a loop as follows: |
16 | 16 |
17 // E | 17 // E |
18 // | A | 18 // | A |
19 // | | (backedges) | 19 // | | (backedges) |
20 // | +---------------|---------------------------------+ | 20 // | +---------------|---------------------------------+ |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 } | 269 } |
270 // There should be a merge or a return for each exit. | 270 // There should be a merge or a return for each exit. |
271 CHECK_NE(NULL, found); | 271 CHECK_NE(NULL, found); |
272 } | 272 } |
273 // Return nodes, the end merge, and the phis associated with the end merge | 273 // Return nodes, the end merge, and the phis associated with the end merge |
274 // must be duplicated as well. | 274 // must be duplicated as well. |
275 for (Node* node : rets) exits.push_back(node); | 275 for (Node* node : rets) exits.push_back(node); |
276 if (end != NULL) { | 276 if (end != NULL) { |
277 exits.push_back(end); | 277 exits.push_back(end); |
278 for (Node* use : end->uses()) { | 278 for (Node* use : end->uses()) { |
279 if (IrOpcode::IsPhiOpcode(use->opcode())) exits.push_back(use); | 279 if (NodeProperties::IsPhi(use)) exits.push_back(use); |
280 } | 280 } |
281 } | 281 } |
282 } | 282 } |
283 | 283 |
284 //============================================================================ | 284 //============================================================================ |
285 // Duplicate the loop exit region and add a merge. | 285 // Duplicate the loop exit region and add a merge. |
286 //============================================================================ | 286 //============================================================================ |
287 NodeRange exit_range(&exits[0], &exits[0] + exits.size()); | 287 NodeRange exit_range(&exits[0], &exits[0] + exits.size()); |
288 peeling.CopyNodes(graph, tmp_zone, dead, exit_range); | 288 peeling.CopyNodes(graph, tmp_zone, dead, exit_range); |
289 | 289 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 } | 330 } |
331 } | 331 } |
332 } | 332 } |
333 | 333 |
334 return iter; | 334 return iter; |
335 } | 335 } |
336 | 336 |
337 } // namespace compiler | 337 } // namespace compiler |
338 } // namespace internal | 338 } // namespace internal |
339 } // namespace v8 | 339 } // namespace v8 |
OLD | NEW |