Chromium Code Reviews| Index: lib/compiler/implementation/ssa/codegen_helpers.dart |
| diff --git a/lib/compiler/implementation/ssa/codegen_helpers.dart b/lib/compiler/implementation/ssa/codegen_helpers.dart |
| index 64453d782273bd701cbabf7e79d867a67e8296ff..44f071cb9c8f6a6d7376292f3549e4a7eb648892 100644 |
| --- a/lib/compiler/implementation/ssa/codegen_helpers.dart |
| +++ b/lib/compiler/implementation/ssa/codegen_helpers.dart |
| @@ -440,14 +440,22 @@ class PhiEquivalator { |
| PhiEquivalator(this.equivalence, this.logicalOperations); |
| void analyzeGraph(HGraph graph) { |
| - graph.blocks.forEach((HBasicBlock block) => analyzeBlock(block)); |
| + graph.blocks.forEach(analyzeBlock); |
| + } |
| + |
| + static bool isPhiBeforeUse(HPhi phi1) { |
| + assert(phi1.usedBy.length == 1); |
| + HPhi phi2 = phi1.usedBy[0]; |
| + // 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
|
| + 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'
|
| } |
| void analyzeBlock(HBasicBlock block) { |
| for (HPhi phi = block.phis.first; phi !== null; phi = phi.next) { |
| if (!logicalOperations.containsKey(phi) && |
| phi.usedBy.length == 1 && |
| - phi.usedBy[0] is HPhi) { |
| + phi.usedBy[0] is HPhi && |
| + isPhiBeforeUse(phi)) { |
| equivalence.makeEquivalent(phi, phi.usedBy[0]); |
| } |
| } |