| Index: pkg/compiler/lib/src/ssa/codegen.dart
|
| diff --git a/pkg/compiler/lib/src/ssa/codegen.dart b/pkg/compiler/lib/src/ssa/codegen.dart
|
| index 0ff32f29c1d3b3bbdb850f0c356cf454fb2787fd..963754991ceff88c0296859854c958b35cc0fabc 100644
|
| --- a/pkg/compiler/lib/src/ssa/codegen.dart
|
| +++ b/pkg/compiler/lib/src/ssa/codegen.dart
|
| @@ -1496,8 +1496,25 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
|
| js.Statement elsePart =
|
| unwrapStatement(generateStatementsInNewBlock(elseGraph));
|
|
|
| - pushStatement(new js.If(test, thenPart, elsePart)
|
| - .withSourceInformation(node.sourceInformation));
|
| + js.Statement code;
|
| + // Peephole rewrites:
|
| + //
|
| + // if (e); else S; --> if(!e) S;
|
| + //
|
| + // if (e); --> e;
|
| + //
|
| + // TODO(sra): This peephole optimization would be better done as an SSA
|
| + // optimization.
|
| + if (thenPart is js.EmptyStatement) {
|
| + if (elsePart is js.EmptyStatement) {
|
| + code = new js.ExpressionStatement(test);
|
| + } else {
|
| + code = new js.If.noElse(new js.Prefix('!', test), elsePart);
|
| + }
|
| + } else {
|
| + code = new js.If(test, thenPart, elsePart);
|
| + }
|
| + pushStatement(code.withSourceInformation(node.sourceInformation));
|
| }
|
|
|
| visitIf(HIf node) {
|
|
|