Bug 1176240: IonMonkey: Try to fold phis containing MFilterTypeSet, r=nbp
authorHannes Verschore <hv1989@gmail.com>
Fri, 11 Sep 2015 15:59:48 +0200
changeset 294625 480c60fad3524f1a84967ea0862f0158a1f1ce97
parent 294624 f0fbe3de27cb6812269c67eac9a917f2a95d1b25
child 294626 c8549221c366b0bab175841af01af1edaeb55f94
push id5245
push userraliiev@mozilla.com
push dateThu, 29 Oct 2015 11:30:51 +0000
treeherdermozilla-beta@dac831dc1bd0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnbp
bugs1176240
milestone43.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 1176240: IonMonkey: Try to fold phis containing MFilterTypeSet, r=nbp
js/src/jit/MIR.cpp
js/src/jit/MIR.h
--- a/js/src/jit/MIR.cpp
+++ b/js/src/jit/MIR.cpp
@@ -1734,24 +1734,67 @@ MPhi::operandIfRedundant()
         MDefinition* op = getOperand(i);
         if (op != first && op != this)
             return nullptr;
     }
     return first;
 }
 
 MDefinition*
+MPhi::foldsFilterTypeSet()
+{
+    // Fold phi with as operands a combination of 'subject' and
+    // MFilterTypeSet(subject) to 'subject'.
+
+    if (inputs_.length() == 0)
+        return nullptr;
+
+    MDefinition* subject = getOperand(0);
+    if (subject->isFilterTypeSet())
+        subject = subject->toFilterTypeSet()->input();
+
+    // Not same type, don't fold.
+    if (subject->type() != type())
+        return nullptr;
+
+    // Phi is better typed (has typeset). Don't fold.
+    if (resultTypeSet() && !subject->resultTypeSet())
+        return nullptr;
+
+    // Phi is better typed (according to typeset). Don't fold.
+    if (subject->resultTypeSet() && resultTypeSet()) {
+        if (!subject->resultTypeSet()->isSubset(resultTypeSet()))
+            return nullptr;
+    }
+
+    for (size_t i = 1, e = numOperands(); i < e; i++) {
+        MDefinition* op = getOperand(i);
+        if (op == subject)
+            continue;
+        if (op->isFilterTypeSet() && op->toFilterTypeSet()->input() == subject)
+            continue;
+
+        return nullptr;
+    }
+
+    return subject;
+}
+
+MDefinition*
 MPhi::foldsTo(TempAllocator& alloc)
 {
     if (MDefinition* def = operandIfRedundant())
         return def;
 
     if (MDefinition* def = foldsTernary())
         return def;
 
+    if (MDefinition* def = foldsFilterTypeSet())
+        return def;
+
     return this;
 }
 
 bool
 MPhi::congruentTo(const MDefinition* ins) const
 {
     if (!ins->isPhi())
         return false;
--- a/js/src/jit/MIR.h
+++ b/js/src/jit/MIR.h
@@ -6897,16 +6897,17 @@ class MPhi final
     }
 
     // Update the type of this phi after adding |ins| as an input. Set
     // |*ptypeChange| to true if the type changed.
     bool checkForTypeChange(MDefinition* ins, bool* ptypeChange);
 
     MDefinition* foldsTo(TempAllocator& alloc) override;
     MDefinition* foldsTernary();
+    MDefinition* foldsFilterTypeSet();
 
     bool congruentTo(const MDefinition* ins) const override;
 
     bool isIterator() const {
         return isIterator_;
     }
     void setIterator() {
         isIterator_ = true;