Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Side by Side Diff: lib/compiler/implementation/ssa/codegen_helpers.dart

Issue 10917012: Fix bad code-generation for nested-ifs in for loops. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/language/nested_if_test.dart » ('j') | tests/language/nested_if_test.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * Instead of emitting each SSA instruction with a temporary variable 6 * Instead of emitting each SSA instruction with a temporary variable
7 * mark instructions that can be emitted at their use-site. 7 * mark instructions that can be emitted at their use-site.
8 * For example, in: 8 * For example, in:
9 * t0 = 4; 9 * t0 = 4;
10 * t1 = 3; 10 * t1 = 3;
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 } 298 }
299 299
300 // If the [thenBlock] is already a control flow operation, and does not 300 // If the [thenBlock] is already a control flow operation, and does not
301 // have any statement and its join block is [end], we can emit a 301 // have any statement and its join block is [end], we can emit a
302 // sequence of control flow operation. 302 // sequence of control flow operation.
303 if (controlFlowOperators.contains(thenBlock.last)) { 303 if (controlFlowOperators.contains(thenBlock.last)) {
304 HIf otherIf = thenBlock.last; 304 HIf otherIf = thenBlock.last;
305 if (otherIf.joinBlock !== end) { 305 if (otherIf.joinBlock !== end) {
306 // This could be a join block that just feeds into our join block. 306 // This could be a join block that just feeds into our join block.
307 HBasicBlock otherJoin = otherIf.joinBlock; 307 HBasicBlock otherJoin = otherIf.joinBlock;
308 if (otherJoin.first != otherJoin.last) return;
308 if (otherJoin.successors.length != 1) return; 309 if (otherJoin.successors.length != 1) return;
309 if (otherJoin.successors[0] != end) return; 310 if (otherJoin.successors[0] != end) return;
310 if (otherJoin.phis.isEmpty()) return; 311 if (otherJoin.phis.isEmpty()) return;
311 if (otherJoin.phis.first !== otherJoin.phis.last) return; 312 if (otherJoin.phis.first !== otherJoin.phis.last) return;
312 HPhi otherPhi = otherJoin.phis.first; 313 HPhi otherPhi = otherJoin.phis.first;
313 if (thenInput != otherPhi) return; 314 if (thenInput != otherPhi) return;
314 if (elseInput != otherPhi.inputs[1]) return; 315 if (elseInput != otherPhi.inputs[1]) return;
315 } 316 }
316 if (hasAnyStatement(thenBlock, otherIf)) return; 317 if (hasAnyStatement(thenBlock, otherIf)) return;
317 } else { 318 } else {
(...skipping 21 matching lines...) Expand all
339 } 340 }
340 341
341 // If [thenInput] is defined in the first predecessor, then it is only used 342 // If [thenInput] is defined in the first predecessor, then it is only used
342 // by [phi] and can be generated at use site. 343 // by [phi] and can be generated at use site.
343 if (thenInput.block === end.predecessors[0]) { 344 if (thenInput.block === end.predecessors[0]) {
344 assert(thenInput.usedBy.length == 1); 345 assert(thenInput.usedBy.length == 1);
345 markAsGenerateAtUseSite(thenInput); 346 markAsGenerateAtUseSite(thenInput);
346 } 347 }
347 } 348 }
348 } 349 }
OLDNEW
« no previous file with comments | « no previous file | tests/language/nested_if_test.dart » ('j') | tests/language/nested_if_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698