Bug 1039836 - IonMonkey: GVN: Switch to including dependency() in the value hash. r=nbp
authorDan Gohman <sunfish@mozilla.com>
Thu, 17 Jul 2014 06:28:40 -0700
changeset 194644 291b0b70cabb
parent 194643 52f0f39c8889
child 194645 a3a5fccdbccf
push id46409
push userdgohman@mozilla.com
push dateThu, 17 Jul 2014 13:28:40 +0000
treeherdermozilla-inbound@291b0b70cabb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnbp
bugs1039836
milestone33.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1039836 - IonMonkey: GVN: Switch to including dependency() in the value hash. r=nbp
js/src/jit/MIR.cpp
js/src/jit/ValueNumbering.cpp
--- a/js/src/jit/MIR.cpp
+++ b/js/src/jit/MIR.cpp
@@ -181,16 +181,18 @@ MDefinition::addU32ToHash(HashNumber has
 }
 
 HashNumber
 MDefinition::valueHash() const
 {
     HashNumber out = op();
     for (size_t i = 0, e = numOperands(); i < e; i++)
         out = addU32ToHash(out, getOperand(i)->id());
+    if (MDefinition *dep = dependency())
+        out = addU32ToHash(out, dep->id());
     return out;
 }
 
 bool
 MDefinition::congruentIfOperandsEqual(const MDefinition *ins) const
 {
     if (op() != ins->op())
         return false;
--- a/js/src/jit/ValueNumbering.cpp
+++ b/js/src/jit/ValueNumbering.cpp
@@ -45,16 +45,21 @@ ValueNumberer::VisibleValues::ValueHashe
 {
     return ins->valueHash();
 }
 
 // Test whether two MDefinitions are congruent.
 bool
 ValueNumberer::VisibleValues::ValueHasher::match(Key k, Lookup l)
 {
+    // If one of the instructions depends on a store, and the other instruction
+    // does not depend on the same store, the instructions are not congruent.
+    if (k->dependency() != l->dependency())
+        return false;
+
     return k->congruentTo(l); // Ask the values themselves what they think.
 }
 
 void
 ValueNumberer::VisibleValues::ValueHasher::rekey(Key &k, Key newKey)
 {
     k = newKey;
 }
@@ -401,29 +406,25 @@ ValueNumberer::leader(MDefinition *def)
     // If the value isn't suitable for eliminating, don't bother hashing it. The
     // convention is that congruentTo returns false for node kinds that wish to
     // opt out of redundance elimination.
     // TODO: It'd be nice to clean up that convention (bug 1031406).
     if (!def->isEffectful() && def->congruentTo(def)) {
         // Look for a match.
         VisibleValues::AddPtr p = values_.findLeaderForAdd(def);
         if (p) {
-            // We found a congruent value.
             MDefinition *rep = *p;
-            if (rep->block()->dominates(def->block()) &&
-                rep->dependency() == def->dependency())
-            {
-                // It dominates and has the same dependency. Use it!
+            if (rep->block()->dominates(def->block())) {
+                // We found a dominating congruent value.
                 MOZ_ASSERT(!rep->isInWorklist(), "Dead value in set");
                 return rep;
             }
 
-            // The congruent value doesn't dominate or it has a different
-            // dependency. It won't be suitable for replacing anything else
-            // we'll see in this dominator tree walk, so overwrite it.
+            // The congruent value doesn't dominate. It never will again in this
+            // dominator tree, so overwrite it.
             values_.overwrite(p, def);
         } else {
             // No match. Add a new entry.
             if (!values_.insert(p, def))
                 return nullptr;
         }
     }