Title: [197446] trunk/Source/_javascript_Core
Revision
197446
Author
[email protected]
Date
2016-03-02 02:22:27 -0800 (Wed, 02 Mar 2016)

Log Message

[JSC] Use a Move without REX byte when possible
https://bugs.webkit.org/show_bug.cgi?id=154801

Patch by Benjamin Poulain <[email protected]> on 2016-03-02
Reviewed by Alex Christensen.

Filip wrote an optimization in the register allocator
to use 32bit "Move" when we don't care about the top bytes.

When I moved the commutative ops to the fake 3 operands instruction
I largely destroyed this since all the "Moves" became full register.

In this patch, I switch back to 32bit "Moves" for 32bit operations.

* assembler/MacroAssemblerX86Common.h:
(JSC::MacroAssemblerX86Common::and32):
(JSC::MacroAssemblerX86Common::lshift32):
(JSC::MacroAssemblerX86Common::mul32):
(JSC::MacroAssemblerX86Common::or32):
(JSC::MacroAssemblerX86Common::rshift32):
(JSC::MacroAssemblerX86Common::urshift32):
(JSC::MacroAssemblerX86Common::xor32):
(JSC::MacroAssemblerX86Common::branchAdd32):
(JSC::MacroAssemblerX86Common::branchMul32):
(JSC::MacroAssemblerX86Common::branchSub32):
(JSC::MacroAssemblerX86Common::move32IfNeeded):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (197445 => 197446)


--- trunk/Source/_javascript_Core/ChangeLog	2016-03-02 07:53:20 UTC (rev 197445)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-03-02 10:22:27 UTC (rev 197446)
@@ -1,3 +1,31 @@
+2016-03-02  Benjamin Poulain  <[email protected]>
+
+        [JSC] Use a Move without REX byte when possible
+        https://bugs.webkit.org/show_bug.cgi?id=154801
+
+        Reviewed by Alex Christensen.
+
+        Filip wrote an optimization in the register allocator
+        to use 32bit "Move" when we don't care about the top bytes.
+
+        When I moved the commutative ops to the fake 3 operands instruction
+        I largely destroyed this since all the "Moves" became full register.
+
+        In this patch, I switch back to 32bit "Moves" for 32bit operations.
+
+        * assembler/MacroAssemblerX86Common.h:
+        (JSC::MacroAssemblerX86Common::and32):
+        (JSC::MacroAssemblerX86Common::lshift32):
+        (JSC::MacroAssemblerX86Common::mul32):
+        (JSC::MacroAssemblerX86Common::or32):
+        (JSC::MacroAssemblerX86Common::rshift32):
+        (JSC::MacroAssemblerX86Common::urshift32):
+        (JSC::MacroAssemblerX86Common::xor32):
+        (JSC::MacroAssemblerX86Common::branchAdd32):
+        (JSC::MacroAssemblerX86Common::branchMul32):
+        (JSC::MacroAssemblerX86Common::branchSub32):
+        (JSC::MacroAssemblerX86Common::move32IfNeeded):
+
 2016-03-01  Benjamin Poulain  <[email protected]>
 
         [JSC] Simplify ArithMod(ArithMod(x, const1), const2) if const2 >= const1

Modified: trunk/Source/_javascript_Core/assembler/MacroAssemblerX86Common.h (197445 => 197446)


--- trunk/Source/_javascript_Core/assembler/MacroAssemblerX86Common.h	2016-03-02 07:53:20 UTC (rev 197445)
+++ trunk/Source/_javascript_Core/assembler/MacroAssemblerX86Common.h	2016-03-02 10:22:27 UTC (rev 197446)
@@ -262,26 +262,26 @@
         else if (op1 == dest)
             and32(op2, dest);
         else {
-            move(op2, dest);
+            move32IfNeeded(op2, dest);
             and32(op1, dest);
         }
     }
 
     void and32(Address op1, RegisterID op2, RegisterID dest)
     {
-        move(op2, dest);
+        move32IfNeeded(op2, dest);
         and32(op1, dest);
     }
 
     void and32(RegisterID op1, Address op2, RegisterID dest)
     {
-        move(op1, dest);
+        move32IfNeeded(op1, dest);
         and32(op2, dest);
     }
 
     void and32(TrustedImm32 imm, RegisterID src, RegisterID dest)
     {
-        move(src, dest);
+        move32IfNeeded(src, dest);
         and32(imm, dest);
     }
 
@@ -324,8 +324,7 @@
     {
         ASSERT(shift_amount != dest);
 
-        if (src != dest)
-            move(src, dest);
+        move32IfNeeded(src, dest);
         lshift32(shift_amount, dest);
     }
 
@@ -336,8 +335,7 @@
     
     void lshift32(RegisterID src, TrustedImm32 imm, RegisterID dest)
     {
-        if (src != dest)
-            move(src, dest);
+        move32IfNeeded(src, dest);
         lshift32(imm, dest);
     }
     
@@ -352,7 +350,7 @@
             m_assembler.imull_rr(src1, dest);
             return;
         }
-        move(src1, dest);
+        move32IfNeeded(src1, dest);
         m_assembler.imull_rr(src2, dest);
     }
 
@@ -363,13 +361,13 @@
 
     void mul32(Address src1, RegisterID src2, RegisterID dest)
     {
-        move(src2, dest);
+        move32IfNeeded(src2, dest);
         mul32(src1, dest);
     }
 
     void mul32(RegisterID src1, Address src2, RegisterID dest)
     {
-        move(src1, dest);
+        move32IfNeeded(src1, dest);
         mul32(src2, dest);
     }
     
@@ -444,26 +442,26 @@
         else if (op1 == dest)
             or32(op2, dest);
         else {
-            move(op2, dest);
+            move32IfNeeded(op2, dest);
             or32(op1, dest);
         }
     }
 
     void or32(Address op1, RegisterID op2, RegisterID dest)
     {
-        move(op2, dest);
+        move32IfNeeded(op2, dest);
         or32(op1, dest);
     }
 
     void or32(RegisterID op1, Address op2, RegisterID dest)
     {
-        move(op1, dest);
+        move32IfNeeded(op1, dest);
         or32(op2, dest);
     }
 
     void or32(TrustedImm32 imm, RegisterID src, RegisterID dest)
     {
-        move(src, dest);
+        move32IfNeeded(src, dest);
         or32(imm, dest);
     }
 
@@ -487,8 +485,7 @@
     {
         ASSERT(shift_amount != dest);
 
-        if (src != dest)
-            move(src, dest);
+        move32IfNeeded(src, dest);
         rshift32(shift_amount, dest);
     }
 
@@ -499,8 +496,7 @@
     
     void rshift32(RegisterID src, TrustedImm32 imm, RegisterID dest)
     {
-        if (src != dest)
-            move(src, dest);
+        move32IfNeeded(src, dest);
         rshift32(imm, dest);
     }
     
@@ -524,8 +520,7 @@
     {
         ASSERT(shift_amount != dest);
 
-        if (src != dest)
-            move(src, dest);
+        move32IfNeeded(src, dest);
         urshift32(shift_amount, dest);
     }
 
@@ -536,8 +531,7 @@
     
     void urshift32(RegisterID src, TrustedImm32 imm, RegisterID dest)
     {
-        if (src != dest)
-            move(src, dest);
+        move32IfNeeded(src, dest);
         urshift32(imm, dest);
     }
     
@@ -607,26 +601,26 @@
         else if (op1 == dest)
             xor32(op2, dest);
         else {
-            move(op2, dest);
+            move32IfNeeded(op2, dest);
             xor32(op1, dest);
         }
     }
 
     void xor32(Address op1, RegisterID op2, RegisterID dest)
     {
-        move(op2, dest);
+        move32IfNeeded(op2, dest);
         xor32(op1, dest);
     }
 
     void xor32(RegisterID op1, Address op2, RegisterID dest)
     {
-        move(op1, dest);
+        move32IfNeeded(op1, dest);
         xor32(op2, dest);
     }
 
     void xor32(TrustedImm32 imm, RegisterID src, RegisterID dest)
     {
-        move(src, dest);
+        move32IfNeeded(src, dest);
         xor32(imm, dest);
     }
 
@@ -2036,25 +2030,25 @@
     {
         if (src1 == dest)
             return branchAdd32(cond, src2, dest);
-        move(src2, dest);
+        move32IfNeeded(src2, dest);
         return branchAdd32(cond, src1, dest);
     }
 
     Jump branchAdd32(ResultCondition cond, Address src1, RegisterID src2, RegisterID dest)
     {
-        move(src2, dest);
+        move32IfNeeded(src2, dest);
         return branchAdd32(cond, src1, dest);
     }
 
     Jump branchAdd32(ResultCondition cond, RegisterID src1, Address src2, RegisterID dest)
     {
-        move(src1, dest);
+        move32IfNeeded(src1, dest);
         return branchAdd32(cond, src2, dest);
     }
 
     Jump branchAdd32(ResultCondition cond, RegisterID src, TrustedImm32 imm, RegisterID dest)
     {
-        move(src, dest);
+        move32IfNeeded(src, dest);
         return branchAdd32(cond, imm, dest);
     }
 
@@ -2086,7 +2080,7 @@
     {
         if (src1 == dest)
             return branchMul32(cond, src2, dest);
-        move(src2, dest);
+        move32IfNeeded(src2, dest);
         return branchMul32(cond, src1, dest);
     }
 
@@ -2125,13 +2119,13 @@
         // B := A - B is invalid.
         ASSERT(src1 == dest || src2 != dest);
 
-        move(src1, dest);
+        move32IfNeeded(src1, dest);
         return branchSub32(cond, src2, dest);
     }
 
     Jump branchSub32(ResultCondition cond, RegisterID src1, TrustedImm32 src2, RegisterID dest)
     {
-        move(src1, dest);
+        move32IfNeeded(src1, dest);
         return branchSub32(cond, src2, dest);
     }
 
@@ -2492,6 +2486,15 @@
         return Jump(m_assembler.jCC(static_cast<X86Assembler::Condition>(cond & ~DoubleConditionBits)));
     }
 
+    // The 32bit Move does not need the REX byte for low registers, making it shorter.
+    // Use this if the top bits are irrelevant because they will be reset by the next instruction.
+    void move32IfNeeded(RegisterID src, RegisterID dest)
+    {
+        if (src == dest)
+            return;
+        m_assembler.movl_rr(src, dest);
+    }
+
 #if CPU(X86_64)
     void moveConditionallyAfterFloatingPointCompare(DoubleCondition cond, FPRegisterID left, FPRegisterID right, RegisterID src, RegisterID dest)
     {
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to