[X86_64] Smaller code for test_ir when register is accumulator.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Mar 2014 09:48:57 +0000 (09:48 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 10 Mar 2014 09:48:57 +0000 (09:48 +0000)
<https://webkit.org/b/130006>

Generate the shorthand version of "test eax, imm" when possible.

Reviewed by Benjamin Poulain.

* assembler/X86Assembler.h:
(JSC::X86Assembler::testl_i32r):
(JSC::X86Assembler::testq_i32r):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@165368 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/assembler/X86Assembler.h

index 4bc1921b8cf88a036366e1f74cf6d7ecd37594a5..e996fa0a890afeeb72ba7916c9aa416e9144266a 100644 (file)
@@ -1,3 +1,16 @@
+2014-03-10  Andreas Kling  <akling@apple.com>
+
+        [X86_64] Smaller code for test_ir when register is accumulator.
+        <https://webkit.org/b/130006>
+
+        Generate the shorthand version of "test eax, imm" when possible.
+
+        Reviewed by Benjamin Poulain.
+
+        * assembler/X86Assembler.h:
+        (JSC::X86Assembler::testl_i32r):
+        (JSC::X86Assembler::testq_i32r):
+
 2014-03-10  Andreas Kling  <akling@apple.com>
 
         [X86_64] Smaller code for cmp_ir when register is accumulator.
index 215e462d844242776f0810f5d073aa15b16b08d3..f7ec41be3af55f7d043531cc7a4449c77903d094 100644 (file)
@@ -229,6 +229,7 @@ private:
         OP_CDQ                          = 0x99,
         OP_MOV_EAXOv                    = 0xA1,
         OP_MOV_OvEAX                    = 0xA3,
+        OP_TEST_EAXIv                   = 0xA9,
         OP_MOV_EAXIv                    = 0xB8,
         OP_GROUP2_EvIb                  = 0xC1,
         OP_RET                          = 0xC3,
@@ -1099,7 +1100,10 @@ public:
     
     void testl_i32r(int imm, RegisterID dst)
     {
-        m_formatter.oneByteOp(OP_GROUP3_EvIz, GROUP3_OP_TEST, dst);
+        if (dst == X86Registers::eax)
+            m_formatter.oneByteOp(OP_TEST_EAXIv);
+        else
+            m_formatter.oneByteOp(OP_GROUP3_EvIz, GROUP3_OP_TEST, dst);
         m_formatter.immediate32(imm);
     }
 
@@ -1153,7 +1157,10 @@ public:
 
     void testq_i32r(int imm, RegisterID dst)
     {
-        m_formatter.oneByteOp64(OP_GROUP3_EvIz, GROUP3_OP_TEST, dst);
+        if (dst == X86Registers::eax)
+            m_formatter.oneByteOp64(OP_TEST_EAXIv);
+        else
+            m_formatter.oneByteOp64(OP_GROUP3_EvIz, GROUP3_OP_TEST, dst);
         m_formatter.immediate32(imm);
     }