Bug 1029830 - IonMonkey: GVN: Now that there are foldsTo functions using dependency information, clear it when it becomes invalid r=nbp
authorDan Gohman <sunfish@mozilla.com>
Wed, 17 Sep 2014 10:27:24 -0700
changeset 205740 b0f729f0e0d38840fcdda9296b62a3d598cc62d0
parent 205739 f7f1732c82097f169fc862bb6979527c9ae0ad36
child 205741 d123ad5677f6be76ba98550876451b743a086de1
push id49264
push userdgohman@mozilla.com
push dateWed, 17 Sep 2014 17:27:46 +0000
treeherdermozilla-inbound@ce0a75f9481b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnbp
bugs1029830
milestone35.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 1029830 - IonMonkey: GVN: Now that there are foldsTo functions using dependency information, clear it when it becomes invalid r=nbp
js/src/jit/ValueNumbering.cpp
--- a/js/src/jit/ValueNumbering.cpp
+++ b/js/src/jit/ValueNumbering.cpp
@@ -463,16 +463,31 @@ ValueNumberer::loopHasOptimizablePhi(MBa
     }
     return false;
 }
 
 // Visit |def|.
 bool
 ValueNumberer::visitDefinition(MDefinition *def)
 {
+    // If this instruction has a dependency() into an unreachable block, we'll
+    // need to update AliasAnalysis.
+    const MDefinition *dep = def->dependency();
+    if (dep != nullptr && dep->block()->isDead()) {
+        JitSpew(JitSpew_GVN, "    AliasAnalysis invalidated");
+        if (updateAliasAnalysis_ && !dependenciesBroken_) {
+            // TODO: Recomputing alias-analysis could theoretically expose more
+            // GVN opportunities.
+            JitSpew(JitSpew_GVN, "      Will recompute!");
+            dependenciesBroken_ = true;
+        }
+        // Clear its dependency for now, to protect foldsTo.
+        def->setDependency(def->toInstruction());
+    }
+
     // Look for a simplified form of |def|.
     MDefinition *sim = simplified(def);
     if (sim != def) {
         if (sim == nullptr)
             return false;
 
         // If |sim| doesn't belong to a block, insert it next to |def|.
         if (sim->block() == nullptr)
@@ -518,26 +533,16 @@ ValueNumberer::visitDefinition(MDefiniti
                               "so it shouldn't have failed");
                 MOZ_ASSERT(deadDefs_.empty(),
                            "discardDef shouldn't have added anything to the worklist");
             }
             def = rep;
         }
     }
 
-    // If this instruction has a dependency() into an unreachable block, we'll
-    // need to update AliasAnalysis.
-    if (updateAliasAnalysis_ && !dependenciesBroken_) {
-        const MDefinition *dep = def->dependency();
-        if (dep != nullptr && dep->block()->isDead()) {
-            JitSpew(JitSpew_GVN, "    AliasAnalysis invalidated; will recompute!");
-            dependenciesBroken_ = true;
-        }
-    }
-
     return true;
 }
 
 // Visit the control instruction at the end of |block|.
 bool
 ValueNumberer::visitControlInstruction(MBasicBlock *block, const MBasicBlock *dominatorRoot)
 {
     // Look for a simplified form of the control instruction.