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

Unified Diff: runtime/vm/intermediate_language.cc

Issue 12852007: Improve code for !identical(a, b): (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 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 | « runtime/vm/intermediate_language.h ('k') | runtime/vm/token.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/intermediate_language.cc
===================================================================
--- runtime/vm/intermediate_language.cc (revision 20548)
+++ runtime/vm/intermediate_language.cc (working copy)
@@ -1243,9 +1243,13 @@
// Only handle strict-compares.
if (comparison()->IsStrictCompare()) {
Definition* replacement = comparison()->Canonicalize(optimizer);
- if (replacement == comparison() || replacement == NULL) return this;
+ if ((replacement == comparison()) || (replacement == NULL)) {
+ return this;
+ }
ComparisonInstr* comp = replacement->AsComparison();
- if ((comp == NULL) || comp->CanDeoptimize()) return this;
+ if ((comp == NULL) || comp->CanDeoptimize()) {
+ return this;
+ }
// Check that comparison is not serving as a pending deoptimization target
// for conversions.
@@ -1278,7 +1282,9 @@
Definition* StrictCompareInstr::Canonicalize(FlowGraphOptimizer* optimizer) {
- if (!right()->BindsToConstant()) return this;
+ if (!right()->BindsToConstant()) {
+ return this;
+ }
const Object& right_constant = right()->BoundConstant();
Definition* left_defn = left()->definition();
// TODO(fschneider): Handle other cases: e === false and e !== true/false.
@@ -1289,6 +1295,18 @@
// Return left subexpression as the replacement for this instruction.
return left_defn;
}
+ // x = (a === b); y = x !== true; -> y = a !== b.
+ // In order to merge two strict comares, 'left_strict' must have only one use.
+ // Do not check left's cid as it is required to be a strict compare.
+ StrictCompareInstr* left_strict = left_defn->AsStrictCompare();
+ if ((kind() == Token::kNE_STRICT) &&
+ (right_constant.raw() == Bool::True().raw()) &&
+ (left_strict != NULL) &&
+ (left_strict->HasOnlyUse(left()))) {
+ left_strict->set_kind(Token::NegateComparison(left_strict->kind()));
+ return left_strict;
+ }
+
return this;
}
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | runtime/vm/token.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698