diff --git a/lib/compiler/implementation/ssa/bailout.dart b/lib/compiler/implementation/ssa/bailout.dart index ba2423c5680..6cc69c59f89 100644 --- a/lib/compiler/implementation/ssa/bailout.dart +++ b/lib/compiler/implementation/ssa/bailout.dart @@ -454,10 +454,8 @@ class SsaBailoutPropagator extends HBaseVisitor { HIfBlockInformation info = instruction.blockInformation.body; visitStatements(info.thenGraph); preVisitedBlocks++; - if (instruction.hasElse) { - visitStatements(info.elseGraph); - preVisitedBlocks++; - } + visitStatements(info.elseGraph); + preVisitedBlocks++; HBasicBlock joinBlock = instruction.joinBlock; if (joinBlock !== null diff --git a/lib/compiler/implementation/ssa/builder.dart b/lib/compiler/implementation/ssa/builder.dart index 981f7858ea1..fc61e895948 100644 --- a/lib/compiler/implementation/ssa/builder.dart +++ b/lib/compiler/implementation/ssa/builder.dart @@ -1578,7 +1578,7 @@ class SsaBuilder extends ResolvedVisitor implements Visitor { SubExpression conditionGraph = new SubExpression(conditionStartBlock, lastOpenedBlock); HInstruction condition = popBoolified(); - HIf branch = new HIf(condition, true); + HIf branch = new HIf(condition); HBasicBlock conditionBlock = close(branch); LocalsHandler savedLocals = new LocalsHandler.from(localsHandler); diff --git a/lib/compiler/implementation/ssa/codegen.dart b/lib/compiler/implementation/ssa/codegen.dart index 145761d9419..df545511e8a 100644 --- a/lib/compiler/implementation/ssa/codegen.dart +++ b/lib/compiler/implementation/ssa/codegen.dart @@ -1703,7 +1703,7 @@ class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor { // Depending on how the then/else branches terminate // (e.g., return/throw/break) there can be any number of these. List dominated = node.block.dominatedBlocks; - for (int i = node.hasElse ? 2 : 1; i < dominated.length; i++) { + for (int i = 2; i < dominated.length; i++) { visitBasicBlock(dominated[i]); } } @@ -3048,15 +3048,15 @@ class SsaUnoptimizedCodeGenerator extends SsaCodeGenerator { HStatementInformation thenGraph = info.thenGraph; HStatementInformation elseGraph = info.elseGraph; bool thenHasGuards = thenGraph.start.hasGuards(); - bool elseHasGuards = node.hasElse && elseGraph.start.hasGuards(); + bool elseHasGuards = elseGraph.start.hasGuards(); bool hasGuards = thenHasGuards || elseHasGuards; if (!hasGuards) return super.generateIf(node, info); int elseKind = analyzeGraphForCodegen(elseGraph); - bool emptyElse = !node.hasElse || elseKind == SsaCodeGenerator.EMPTY; + bool emptyElse = elseKind == SsaCodeGenerator.EMPTY; startBailoutCase(thenGraph.start.guards, - node.hasElse ? elseGraph.start.guards : const []); + emptyElse ? const [] : elseGraph.start.guards); addIndented('if ('); int precedence = JSPrecedence.EXPRESSION_PRECEDENCE; diff --git a/lib/compiler/implementation/ssa/nodes.dart b/lib/compiler/implementation/ssa/nodes.dart index cfc8a8a32fe..49c0943a7d0 100644 --- a/lib/compiler/implementation/ssa/nodes.dart +++ b/lib/compiler/implementation/ssa/nodes.dart @@ -1748,9 +1748,8 @@ class HTry extends HControlFlow { } class HIf extends HConditionalBranch { - bool hasElse; HBlockFlow blockInformation = null; - HIf(HInstruction condition, this.hasElse) : super([condition]); + HIf(HInstruction condition) : super([condition]); toString() => 'if'; accept(HVisitor visitor) => visitor.visitIf(this); @@ -1760,12 +1759,8 @@ class HIf extends HConditionalBranch { } HBasicBlock get elseBlock() { - if (hasElse) { - assert(block.dominatedBlocks[1] === block.successors[1]); - return block.successors[1]; - } else { - return null; - } + assert(block.dominatedBlocks[1] === block.successors[1]); + return block.successors[1]; } HBasicBlock get joinBlock() => blockInformation.continuation; diff --git a/lib/compiler/implementation/ssa/optimize.dart b/lib/compiler/implementation/ssa/optimize.dart index 27e382d4f6a..2be7fa922b4 100644 --- a/lib/compiler/implementation/ssa/optimize.dart +++ b/lib/compiler/implementation/ssa/optimize.dart @@ -1168,15 +1168,7 @@ class SsaTypeConversionInserter extends HBaseVisitor } for (HIf ifUser in notIfUsers) { - if (ifUser.hasElse) { - changeUsesDominatedBy(ifUser.elseBlock, input, convertedType); - } else if (ifUser.joinBlock.predecessors.length == 1) { - // If the join block has only one predecessor, then we know - // the if block terminates. So any use of the instruction - // after the join block should be changed to the new - // instruction. - changeUsesDominatedBy(ifUser.joinBlock, input, convertedType); - } + changeUsesDominatedBy(ifUser.elseBlock, input, convertedType); // TODO(ngeoffray): Also change uses for the then block on a HType // that knows it is not of a specific Type. }