Bug 981894 - IonMonkey: Merge the code in MPhi::foldsTo with MPhi::operandIfRedundant. r=nbp
authorDan Gohman <sunfish@mozilla.com>
Thu, 20 Mar 2014 08:58:27 -0700
changeset 174612 3762c3e540cd53baebd29e414c8c41d862a6dd26
parent 174611 d35f97a5b1fe6e2804797b447215a9ea5bb9b35d
child 174613 11d170b90e988e4516a76fdb0627cab57c93f907
push id26456
push userryanvm@gmail.com
push dateThu, 20 Mar 2014 21:03:17 +0000
treeherdermozilla-central@045dd7740be7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnbp
bugs981894
milestone31.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 981894 - IonMonkey: Merge the code in MPhi::foldsTo with MPhi::operandIfRedundant. r=nbp
js/src/jit/MIR.cpp
js/src/jit/MIR.h
--- a/js/src/jit/MIR.cpp
+++ b/js/src/jit/MIR.cpp
@@ -948,30 +948,43 @@ MPhi::removeOperand(size_t index)
         MPhi::setOperand(i, next->producer());
     }
 
     // truncate the inputs_ list:
     inputs_.shrinkBy(1);
 }
 
 MDefinition *
+MPhi::operandIfRedundant()
+{
+    JS_ASSERT(inputs_.length() != 0);
+
+    // If this phi is redundant (e.g., phi(a,a) or b=phi(a,this)),
+    // returns the operand that it will always be equal to (a, in
+    // those two cases).
+    MDefinition *first = getOperand(0);
+    for (size_t i = 1, e = numOperands(); i < e; i++) {
+        // Phis need dominator information to fold based on value numbers. For
+        // simplicity, we only compare SSA names right now (bug 714727).
+        if (!EqualValues(false, getOperand(i), first) &&
+            !EqualValues(false, getOperand(i), this))
+        {
+            return nullptr;
+        }
+    }
+    return first;
+}
+
+MDefinition *
 MPhi::foldsTo(TempAllocator &alloc, bool useValueNumbers)
 {
-    JS_ASSERT(!inputs_.empty());
-
-    MDefinition *first = getOperand(0);
-
-    for (size_t i = 1; i < inputs_.length(); i++) {
-        // Phis need dominator information to fold based on value numbers. For
-        // simplicity, we only compare SSA names right now (bug 714727).
-        if (!EqualValues(false, getOperand(i), first))
-            return this;
-    }
-
-    return first;
+    if (MDefinition *def = operandIfRedundant())
+        return def;
+
+    return this;
 }
 
 bool
 MPhi::congruentTo(MDefinition *ins) const
 {
     if (!ins->isPhi())
         return false;
     // Since we do not know which predecessor we are merging from, we must
--- a/js/src/jit/MIR.h
+++ b/js/src/jit/MIR.h
@@ -4551,27 +4551,17 @@ class MPhi MOZ_FINAL : public MDefinitio
         isIterator_ = true;
     }
 
     AliasSet getAliasSet() const {
         return AliasSet::None();
     }
     void computeRange(TempAllocator &alloc);
 
-    MDefinition *operandIfRedundant() {
-        // If this phi is redundant (e.g., phi(a,a) or b=phi(a,this)),
-        // returns the operand that it will always be equal to (a, in
-        // those two cases).
-        MDefinition *first = getOperand(0);
-        for (size_t i = 1, e = numOperands(); i < e; i++) {
-            if (getOperand(i) != first && getOperand(i) != this)
-                return nullptr;
-        }
-        return first;
-    }
+    MDefinition *operandIfRedundant();
 
     bool canProduceFloat32() const {
         return canProduceFloat32_;
     }
 
     void setCanProduceFloat32(bool can) {
         canProduceFloat32_ = can;
     }