Title: [195744] trunk/Source/_javascript_Core
Revision
195744
Author
[email protected]
Date
2016-01-28 09:30:00 -0800 (Thu, 28 Jan 2016)

Log Message

LowerToAir::preferRightForResult() should resolve use count ties by selecting the child that is closest in an idom walk
https://bugs.webkit.org/show_bug.cgi?id=153583

Reviewed by Benjamin Poulain.

This undoes the AsmBench/n-body regression in r195654 while preserving that revision's
Kraken progression.

* b3/B3LowerToAir.cpp:
(JSC::B3::Air::LowerToAir::LowerToAir):
(JSC::B3::Air::LowerToAir::preferRightForResult):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (195743 => 195744)


--- trunk/Source/_javascript_Core/ChangeLog	2016-01-28 17:26:41 UTC (rev 195743)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-01-28 17:30:00 UTC (rev 195744)
@@ -1,3 +1,17 @@
+2016-01-28  Filip Pizlo  <[email protected]>
+
+        LowerToAir::preferRightForResult() should resolve use count ties by selecting the child that is closest in an idom walk
+        https://bugs.webkit.org/show_bug.cgi?id=153583
+
+        Reviewed by Benjamin Poulain.
+
+        This undoes the AsmBench/n-body regression in r195654 while preserving that revision's
+        Kraken progression.
+
+        * b3/B3LowerToAir.cpp:
+        (JSC::B3::Air::LowerToAir::LowerToAir):
+        (JSC::B3::Air::LowerToAir::preferRightForResult):
+
 2016-01-28  Benjamin Poulain  <[email protected]>
 
         [JSC] B3 Tail Call with Varargs do not restore callee saved registers

Modified: trunk/Source/_javascript_Core/b3/B3LowerToAir.cpp (195743 => 195744)


--- trunk/Source/_javascript_Core/b3/B3LowerToAir.cpp	2016-01-28 17:26:41 UTC (rev 195743)
+++ trunk/Source/_javascript_Core/b3/B3LowerToAir.cpp	2016-01-28 17:30:00 UTC (rev 195744)
@@ -39,6 +39,7 @@
 #include "B3CCallValue.h"
 #include "B3CheckSpecial.h"
 #include "B3Commutativity.h"
+#include "B3Dominators.h"
 #include "B3IndexMap.h"
 #include "B3IndexSet.h"
 #include "B3MemoryValue.h"
@@ -75,6 +76,7 @@
         , m_blockToBlock(procedure.size())
         , m_useCounts(procedure)
         , m_phiChildren(procedure)
+        , m_dominators(procedure.dominators())
         , m_procedure(procedure)
         , m_code(procedure.code())
     {
@@ -592,18 +594,22 @@
         if (leftIsPhiWithThis != rightIsPhiWithThis)
             return rightIsPhiWithThis;
 
-        bool leftResult = m_useCounts.numUsingInstructions(left) == 1;
-        bool rightResult = m_useCounts.numUsingInstructions(right) == 1;
-        if (leftResult && rightResult) {
-            // If one operand is not in the block, it could be in a block dominating a loop
-            // containing m_value.
-            if (left->owner == m_value->owner)
-                return false;
-            if (right->owner == m_value->owner)
-                return true;
-        }
+        if (m_useCounts.numUsingInstructions(right) != 1)
+            return false;
+        
+        if (m_useCounts.numUsingInstructions(left) != 1)
+            return true;
 
-        return rightResult;
+        // The use count might be 1 if the variable is live around a loop. We can guarantee that we
+        // pick the the variable that is least likely to suffer this problem if we pick the one that
+        // is closest to us in an idom walk. By convention, we slightly bias this in favor of
+        // returning true.
+
+        // We cannot prefer right if right is further away in an idom walk.
+        if (m_dominators.strictlyDominates(right->owner, left->owner))
+            return false;
+
+        return true;
     }
 
     template<Air::Opcode opcode32, Air::Opcode opcode64, Air::Opcode opcodeDouble, Air::Opcode opcodeFloat, Commutativity commutativity = NotCommutative>
@@ -2297,6 +2303,7 @@
     UseCounts m_useCounts;
     PhiChildren m_phiChildren;
     BlockWorklist m_fastWorklist;
+    Dominators& m_dominators;
 
     Vector<Vector<Inst, 4>> m_insts;
     Vector<Inst> m_prologue;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to