Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(594)

Unified Diff: lib/compiler/implementation/ssa/codegen.dart

Issue 11065007: Use the correct inputs when checking if inverse operator can be used. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: !isDouble is not enough, because we could infer num for a NaN. Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/compiler/dart2js/inverse_operator_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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()));
« no previous file with comments | « no previous file | tests/compiler/dart2js/inverse_operator_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698