| Index: lib/compiler/implementation/ssa/codegen.dart
|
| diff --git a/lib/compiler/implementation/ssa/codegen.dart b/lib/compiler/implementation/ssa/codegen.dart
|
| index db2c5005505abe97003b41478f0f41ecaa7b6768..16081b16dc27b91592582710d33730c1e5bf7cfe 100644
|
| --- a/lib/compiler/implementation/ssa/codegen.dart
|
| +++ b/lib/compiler/implementation/ssa/codegen.dart
|
| @@ -1789,23 +1789,23 @@ abstract class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
|
|
|
|
|
| void generateNot(HInstruction input) {
|
| - bool isBuiltinRelational(HInstruction instruction) {
|
| + bool canGenerateOptimizedComparison(HInstruction instruction) {
|
| if (instruction is !HRelational) return false;
|
| HRelational relational = instruction;
|
| - return relational.isBuiltin(types);
|
| + HInstruction left = relational.left;
|
| + HInstruction right = relational.right;
|
| + // This optimization doesn't work for NaN, so we only do it if the
|
| + // type is known to be an integer.
|
| + return relational.isBuiltin(types)
|
| + && types[left].isUseful() && left.isInteger(types)
|
| + && types[right].isUseful() && right.isInteger(types);
|
| }
|
|
|
| if (input is HBoolify && isGenerateAtUseSite(input)) {
|
| use(input.inputs[0]);
|
| push(new js.Binary("!==", pop(), new js.LiteralBool(true)), input);
|
| - } else if (isBuiltinRelational(input) &&
|
| - isGenerateAtUseSite(input) &&
|
| - types[input.inputs[0]].isUseful() &&
|
| - !input.inputs[0].isDouble(types) &&
|
| - types[input.inputs[1]].isUseful() &&
|
| - !input.inputs[1].isDouble(types)) {
|
| - // This optimization doesn't work for NaN, so we only do it if the
|
| - // type is known to be non-Double.
|
| + } else if (canGenerateOptimizedComparison(input) &&
|
| + isGenerateAtUseSite(input)) {
|
| Map<String, String> inverseOperator = const <String, String>{
|
| "==" : "!=",
|
| "!=" : "==",
|
| @@ -1817,9 +1817,8 @@ abstract class SsaCodeGenerator implements HVisitor, HBlockInformationVisitor {
|
| ">=" : "<"
|
| };
|
| HRelational relational = input;
|
| -
|
| - visitInvokeBinary(input,
|
| - inverseOperator[relational.operation.name.stringValue]);
|
| + BinaryOperation operation = relational.operation(backend.constantSystem);
|
| + visitInvokeBinary(input, inverseOperator[operation.name.stringValue]);
|
| } else {
|
| use(input);
|
| push(new js.Prefix("!", pop()));
|
|
|