Bug 1209132 - Check for SSE3 in MacroAssemblerX86::convertUInt64ToDouble. r=sstangl, r=jandem, a=lizzard
authorTooru Fujisawa <arai_a@mac.com>
Tue, 29 Sep 2015 07:33:43 +0900
changeset 297894 b6390a198cbb6d64a0aafb5305e3bc70bda2df08
parent 297893 856ea7b5527be0254df2d3d8762698c87faf0b53
child 297895 e8c15469d5936cd61a606f3f0ad464e97202e6b5
push id962
push userjlund@mozilla.com
push dateFri, 04 Dec 2015 23:28:54 +0000
treeherdermozilla-release@23a2d286e80f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssstangl, jandem, lizzard
bugs1209132
milestone43.0a2
Bug 1209132 - Check for SSE3 in MacroAssemblerX86::convertUInt64ToDouble. r=sstangl, r=jandem, a=lizzard
js/src/jit/x86/Assembler-x86.h
js/src/jit/x86/MacroAssembler-x86.cpp
--- a/js/src/jit/x86/Assembler-x86.h
+++ b/js/src/jit/x86/Assembler-x86.h
@@ -387,17 +387,17 @@ class Assembler : public AssemblerX86Sha
     void shldl(const Imm32 imm, Register src, Register dest) {
         masm.shldl_irr(imm.value, src.encoding(), dest.encoding());
     }
     void shrdl(const Imm32 imm, Register src, Register dest) {
         masm.shrdl_irr(imm.value, src.encoding(), dest.encoding());
     }
 
     void vhaddpd(FloatRegister src, FloatRegister dest) {
-        MOZ_ASSERT(HasSSE2());
+        MOZ_ASSERT(HasSSE3());
         MOZ_ASSERT(src.size() == 16);
         MOZ_ASSERT(dest.size() == 16);
         masm.vhaddpd_rr(src.encoding(), dest.encoding());
     }
     void vsubpd(const Operand& src1, FloatRegister src0, FloatRegister dest) {
         MOZ_ASSERT(HasSSE2());
         MOZ_ASSERT(src0.size() == 16);
         MOZ_ASSERT(dest.size() == 16);
--- a/js/src/jit/x86/MacroAssembler-x86.cpp
+++ b/js/src/jit/x86/MacroAssembler-x86.cpp
@@ -25,19 +25,32 @@ using namespace js::jit;
 // See convertUInt64ToDouble for the details.
 MOZ_ALIGNED_DECL(static const uint64_t, 16) TO_DOUBLE[4] = {
     0x4530000043300000LL,
     0x0LL,
     0x4330000000000000LL,
     0x4530000000000000LL
 };
 
+static const double TO_DOUBLE_HIGH_SCALE = 0x100000000;
+
 void
 MacroAssemblerX86::convertUInt64ToDouble(Register64 src, Register temp, FloatRegister dest)
 {
+    // SUBPD needs SSE2, HADDPD needs SSE3.
+    if (!HasSSE3()) {
+        convertUInt32ToDouble(src.high, dest);
+        movePtr(ImmPtr(&TO_DOUBLE_HIGH_SCALE), temp);
+        loadDouble(Address(temp, 0), ScratchDoubleReg);
+        mulDouble(ScratchDoubleReg, dest);
+        convertUInt32ToDouble(src.low, ScratchDoubleReg);
+        addDouble(ScratchDoubleReg, dest);
+        return;
+    }
+
     // Following operation uses entire 128-bit of dest XMM register.
     // Currently higher 64-bit is free when we have access to lower 64-bit.
     MOZ_ASSERT(dest.size() == 8);
     FloatRegister dest128 = FloatRegister(dest.encoding(), FloatRegisters::Int32x4);
 
     // Assume that src is represented as following:
     //   src      = 0x HHHHHHHH LLLLLLLL