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

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

Issue 10375048: Don't allow phi equivalences along back-edges. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Added test. Updated other tests. Simplified isPhiBefore. Created 8 years, 7 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 | « frog/tests/leg_only/regression_2913_test.dart ('k') | no next file » | no next file with comments »
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 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 // All binary operators (excluding assignment) are left associative. 433 // All binary operators (excluding assignment) are left associative.
434 int get precedence() => left; 434 int get precedence() => left;
435 } 435 }
436 436
437 class PhiEquivalator { 437 class PhiEquivalator {
438 final Equivalence<HPhi> equivalence; 438 final Equivalence<HPhi> equivalence;
439 final Map<HPhi, String> logicalOperations; 439 final Map<HPhi, String> logicalOperations;
440 PhiEquivalator(this.equivalence, this.logicalOperations); 440 PhiEquivalator(this.equivalence, this.logicalOperations);
441 441
442 void analyzeGraph(HGraph graph) { 442 void analyzeGraph(HGraph graph) {
443 graph.blocks.forEach((HBasicBlock block) => analyzeBlock(block)); 443 graph.blocks.forEach(analyzeBlock);
444 }
445
446 static bool isPhiBeforeUse(HPhi phi1) {
447 assert(phi1.usedBy.length == 1);
448 HPhi phi2 = phi1.usedBy[0];
449 // A phi can never be used in another phi in the same block.
ngeoffray 2012/05/08 09:13:01 That you could assert here.
Lasse Reichstein Nielsen 2012/05/08 09:17:14 I'll just inline it all in the test that already t
450 return phi1.block.id < phi2.block.id;
ngeoffray 2012/05/08 09:13:01 If that is true, maybe also assert that phi2 is a
Lasse Reichstein Nielsen 2012/05/08 09:17:14 Not sure it's necessary. If it's an invariant, it'
444 } 451 }
445 452
446 void analyzeBlock(HBasicBlock block) { 453 void analyzeBlock(HBasicBlock block) {
447 for (HPhi phi = block.phis.first; phi !== null; phi = phi.next) { 454 for (HPhi phi = block.phis.first; phi !== null; phi = phi.next) {
448 if (!logicalOperations.containsKey(phi) && 455 if (!logicalOperations.containsKey(phi) &&
449 phi.usedBy.length == 1 && 456 phi.usedBy.length == 1 &&
450 phi.usedBy[0] is HPhi) { 457 phi.usedBy[0] is HPhi &&
458 isPhiBeforeUse(phi)) {
451 equivalence.makeEquivalent(phi, phi.usedBy[0]); 459 equivalence.makeEquivalent(phi, phi.usedBy[0]);
452 } 460 }
453 } 461 }
454 } 462 }
455 } 463 }
456 464
457 465
458 /** 466 /**
459 * Try to figure out which phis can be represented by the same temporary 467 * Try to figure out which phis can be represented by the same temporary
460 * variable, to avoid creating a new variable for each phi. 468 * variable, to avoid creating a new variable for each phi.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 // improving the performance of future lookups. 500 // improving the performance of future lookups.
493 T root = getRepresentative(parent); 501 T root = getRepresentative(parent);
494 if (root !== parent) representative[element] = root; 502 if (root !== parent) representative[element] = root;
495 return root; 503 return root;
496 } 504 }
497 505
498 bool areEquivalent(T a, T b) { 506 bool areEquivalent(T a, T b) {
499 return getRepresentative(a) === getRepresentative(b); 507 return getRepresentative(a) === getRepresentative(b);
500 } 508 }
501 } 509 }
OLDNEW
« no previous file with comments | « frog/tests/leg_only/regression_2913_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698