| Index: lib/compiler/implementation/ssa/optimize.dart
|
| diff --git a/lib/compiler/implementation/ssa/optimize.dart b/lib/compiler/implementation/ssa/optimize.dart
|
| index af319b4b597f770c952586141180811c68b5f503..79deacf0a2e6a60de79240522fd98b00cfc158dd 100644
|
| --- a/lib/compiler/implementation/ssa/optimize.dart
|
| +++ b/lib/compiler/implementation/ssa/optimize.dart
|
| @@ -1,4 +1,4 @@
|
| -// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
|
| +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
| // for details. All rights reserved. Use of this source code is governed by a
|
| // BSD-style license that can be found in the LICENSE file.
|
|
|
| @@ -711,12 +711,11 @@ class SsaDeadCodeEliminator extends HGraphVisitor implements OptimizationPhase {
|
| final String name = "SsaDeadCodeEliminator";
|
|
|
| static bool isDeadCode(HInstruction instruction) {
|
| - // TODO(ngeoffray): the way we handle side effects is not right
|
| - // (e.g. branching instructions have side effects).
|
| return !instruction.hasSideEffects()
|
| && instruction.usedBy.isEmpty()
|
| && instruction is !HCheck
|
| - && instruction is !HTypeGuard;
|
| + && instruction is !HTypeGuard
|
| + && !instruction.isControlFlow();
|
| }
|
|
|
| void visitGraph(HGraph graph) {
|
| @@ -904,13 +903,16 @@ class SsaGlobalValueNumberer implements OptimizationPhase {
|
|
|
| void visitBasicBlock(HBasicBlock block, ValueSet values) {
|
| HInstruction instruction = block.first;
|
| + if (block.isLoopHeader()) {
|
| + int flags = loopChangesFlags[block.id];
|
| + values.kill(flags);
|
| + }
|
| while (instruction !== null) {
|
| HInstruction next = instruction.next;
|
| int flags = instruction.getChangesFlags();
|
| - if (flags != 0) {
|
| - assert(!instruction.useGvn());
|
| - values.kill(flags);
|
| - } else if (instruction.useGvn()) {
|
| + assert(flags == 0 || !instruction.useGvn());
|
| + values.kill(flags);
|
| + if (instruction.useGvn()) {
|
| HInstruction other = values.lookup(instruction);
|
| if (other !== null) {
|
| assert(other.gvnEquals(instruction) && instruction.gvnEquals(other));
|
|
|