From ddc90ee550567302c85fa3ee13a7c776f6cc9dbc Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 8 Nov 2014 09:39:55 -0800 Subject: [PATCH 1/7] x86jit: Implement vfad and vavg. --- Core/MIPS/x86/CompVFPU.cpp | 39 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/Core/MIPS/x86/CompVFPU.cpp b/Core/MIPS/x86/CompVFPU.cpp index e8044eeac4..bd1f4f664a 100644 --- a/Core/MIPS/x86/CompVFPU.cpp +++ b/Core/MIPS/x86/CompVFPU.cpp @@ -2226,16 +2226,51 @@ void Jit::Comp_Vi2x(MIPSOpcode op) { DISABLE; } +static const float MEMORY_ALIGNED16( vavg_table[4] ) = {1.0f, 1.0f / 2.0f, 1.0f / 3.0f, 1.0f / 4.0f}; + void Jit::Comp_Vhoriz(MIPSOpcode op) { - DISABLE; + CONDITIONAL_DISABLE; + + if (js.HasUnknownPrefix()) + DISABLE; + + VectorSize sz = GetVecSize(op); + int n = GetNumVectorElements(sz); + + u8 sregs[4], dregs[1]; + GetVectorRegsPrefixS(sregs, sz, _VS); + GetVectorRegsPrefixD(dregs, V_Single, _VD); + + X64Reg reg = XMM0; + if (IsOverlapSafeAllowS(dregs[0], 0, n, sregs)) { + fpr.MapRegV(dregs[0], (dregs[0] == sregs[0] ? 0 : MAP_NOINIT) | MAP_DIRTY); + fpr.SpillLockV(dregs[0]); + reg = fpr.VX(dregs[0]); + } + + // We use a temp reg in case of overlap. + if (!fpr.V(sregs[0]).IsSimpleReg(reg)) { + MOVSS(reg, fpr.V(sregs[0])); + } + for (int i = 1; i < n; ++i) { + ADDSS(reg, fpr.V(sregs[i])); + } - // Do any games use these a noticable amount? switch ((op >> 16) & 31) { case 6: // vfad break; case 7: // vavg + MOVSS(XMM1, M(&vavg_table[n])); + MULSS(reg, R(XMM1)); break; } + + if (reg == XMM0) { + MOVSS(fpr.V(dregs[0]), XMM0); + } + + ApplyPrefixD(dregs, V_Single); + fpr.ReleaseSpillLocks(); } void Jit::Comp_Viim(MIPSOpcode op) { From 0e646f748a0cb5b4b501c5461b1b9da6c9466398 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 8 Nov 2014 11:31:54 -0800 Subject: [PATCH 2/7] x86jit: Implement vi2x instructions. Also, my opcodes were wrong in the test (shifted the pair bit the wrong way, oops.) AFAICT, there's no reason PSRAD/etc. were not encoding REX... --- Common/x64Emitter.cpp | 18 ++----- Common/x64Emitter.h | 1 + Core/MIPS/x86/CompVFPU.cpp | 106 ++++++++++++++++++++++++++++++++++++- unittest/JitHarness.cpp | 14 ++--- 4 files changed, 116 insertions(+), 23 deletions(-) diff --git a/Common/x64Emitter.cpp b/Common/x64Emitter.cpp index ff477bae08..f646133c65 100644 --- a/Common/x64Emitter.cpp +++ b/Common/x64Emitter.cpp @@ -1659,6 +1659,7 @@ void XEmitter::PACKUSWB(X64Reg dest, OpArg arg) {WriteSSEOp(0x66, 0x67, dest, ar void XEmitter::PUNPCKLBW(X64Reg dest, const OpArg &arg) {WriteSSEOp(0x66, 0x60, dest, arg);} void XEmitter::PUNPCKLWD(X64Reg dest, const OpArg &arg) {WriteSSEOp(0x66, 0x61, dest, arg);} void XEmitter::PUNPCKLDQ(X64Reg dest, const OpArg &arg) {WriteSSEOp(0x66, 0x62, dest, arg);} +void XEmitter::PUNPCKLQDQ(X64Reg dest, const OpArg &arg) {WriteSSEOp(0x66, 0x6C, dest, arg);} void XEmitter::PSRLW(X64Reg reg, int shift) { @@ -1711,28 +1712,15 @@ void XEmitter::PSLLDQ(X64Reg reg, int shift) { Write8(shift); } - -// WARNING not REX compatible void XEmitter::PSRAW(X64Reg reg, int shift) { - if (reg > 7) - PanicAlert("The PSRAW-emitter does not support regs above 7"); - Write8(0x66); - Write8(0x0f); - Write8(0x71); - Write8(0xE0 | reg); + WriteSSEOp(0x66, 0x71, (X64Reg)4, R(reg)); Write8(shift); } -// WARNING not REX compatible void XEmitter::PSRAD(X64Reg reg, int shift) { - if (reg > 7) - PanicAlert("The PSRAD-emitter does not support regs above 7"); - Write8(0x66); - Write8(0x0f); - Write8(0x72); - Write8(0xE0 | reg); + WriteSSEOp(0x66, 0x72, (X64Reg)4, R(reg)); Write8(shift); } diff --git a/Common/x64Emitter.h b/Common/x64Emitter.h index 4f1c46fed5..5992887099 100644 --- a/Common/x64Emitter.h +++ b/Common/x64Emitter.h @@ -714,6 +714,7 @@ public: void PUNPCKLBW(X64Reg dest, const OpArg &arg); void PUNPCKLWD(X64Reg dest, const OpArg &arg); void PUNPCKLDQ(X64Reg dest, const OpArg &arg); + void PUNPCKLQDQ(X64Reg dest, const OpArg &arg); void PTEST(X64Reg dest, OpArg arg); void PAND(X64Reg dest, OpArg arg); diff --git a/Core/MIPS/x86/CompVFPU.cpp b/Core/MIPS/x86/CompVFPU.cpp index bd1f4f664a..cd712bc79a 100644 --- a/Core/MIPS/x86/CompVFPU.cpp +++ b/Core/MIPS/x86/CompVFPU.cpp @@ -2223,7 +2223,111 @@ void Jit::Comp_VDet(MIPSOpcode op) { } void Jit::Comp_Vi2x(MIPSOpcode op) { - DISABLE; + CONDITIONAL_DISABLE; + if (js.HasUnknownPrefix()) + DISABLE; + + int bits = ((op >> 16) & 2) == 0 ? 8 : 16; // vi2uc/vi2c (0/1), vi2us/vi2s (2/3) + bool unsignedOp = ((op >> 16) & 1) == 0; // vi2uc (0), vi2us (2) + + // These instructions pack pairs or quads of integers into 32 bits. + // The unsigned (u) versions skip the sign bit when packing. + + VectorSize sz = GetVecSize(op); + VectorSize outsize; + if (bits == 8) { + outsize = V_Single; + if (sz != V_Quad) { + DISABLE; + } + } else { + switch (sz) { + case V_Pair: + outsize = V_Single; + break; + case V_Quad: + outsize = V_Pair; + break; + default: + DISABLE; + } + } + + u8 sregs[4], dregs[4]; + GetVectorRegsPrefixS(sregs, sz, _VS); + GetVectorRegsPrefixD(dregs, outsize, _VD); + + // First, let's assemble the sregs into lanes of a single xmm reg. + // For quad inputs, we need somewhere for the bottom regs. Ideally dregs[0]. + X64Reg dst0 = XMM0; + if (sz == V_Quad) { + int vreg = dregs[0]; + if (!IsOverlapSafeAllowS(dregs[0], 0, 4, sregs)) { + // Will be discarded on release. + vreg = fpr.GetTempV(); + } + fpr.MapRegV(vreg, (vreg == sregs[0] ? 0 : MAP_NOINIT) | MAP_DIRTY); + fpr.SpillLockV(vreg); + dst0 = fpr.VX(vreg); + } else { + // Pair, let's check if we should use dregs[0] directly. No temp needed. + int vreg = dregs[0]; + if (IsOverlapSafeAllowS(dregs[0], 0, 2, sregs)) { + fpr.MapRegV(vreg, (vreg == sregs[0] ? 0 : MAP_NOINIT) | MAP_DIRTY); + fpr.SpillLockV(vreg); + dst0 = fpr.VX(vreg); + } + } + + if (!fpr.V(sregs[0]).IsSimpleReg(dst0)) { + MOVSS(dst0, fpr.V(sregs[0])); + } + MOVSS(XMM1, fpr.V(sregs[1])); + // With this, we have the lower half in dst0. + PUNPCKLDQ(dst0, R(XMM1)); + if (sz == V_Quad) { + MOVSS(XMM0, fpr.V(sregs[2])); + MOVSS(XMM1, fpr.V(sregs[3])); + PUNPCKLDQ(XMM0, R(XMM1)); + // Now we need to combine XMM0 into dst0. + PUNPCKLQDQ(dst0, R(XMM0)); + } else { + // Otherwise, we need to zero out the top 2. + // TODO: Maybe PAND would be better? + PXOR(XMM1, R(XMM1)); + PUNPCKLQDQ(dst0, R(XMM1)); + } + + // For "u" type ops, we clamp to zero and shift off the sign bit first. + if (unsignedOp) { + // Get a mask of the sign bit in dst0, then and in the values. This clamps to 0. + MOVDQA(XMM1, R(dst0)); + PSRAD(dst0, 31); + PSLLD(XMM1, 1); + PANDN(dst0, R(XMM1)); + } + + // At this point, everything is aligned in the high bits of our lanes. + // Let's *arithmetically* shift in the sign so we can use saturating packs. + PSRAD(dst0, 32 - bits); + // XMM1 used for the high part just so there's no dependency. It contains garbage or 0. + PACKSSDW(dst0, R(XMM1)); + if (bits == 8) { + PACKSSWB(dst0, R(XMM1)); + } + + if (!fpr.V(dregs[0]).IsSimpleReg(dst0)) { + MOVSS(fpr.V(dregs[0]), dst0); + } + if (outsize == V_Pair) { + fpr.MapRegV(dregs[1], MAP_NOINIT | MAP_DIRTY); + MOVDQA(fpr.V(dregs[1]), dst0); + // Shift out the lower result to get the result we want. + PSRLDQ(fpr.VX(dregs[1]), 4); + } + + ApplyPrefixD(dregs, outsize); + fpr.ReleaseSpillLocks(); } static const float MEMORY_ALIGNED16( vavg_table[4] ) = {1.0f, 1.0f / 2.0f, 1.0f / 3.0f, 1.0f / 4.0f}; diff --git a/unittest/JitHarness.cpp b/unittest/JitHarness.cpp index 430b4b6ebd..32f198e038 100644 --- a/unittest/JitHarness.cpp +++ b/unittest/JitHarness.cpp @@ -101,13 +101,13 @@ bool TestJit() { // TODO: Smarter way of seeding in the code sequence. for (int i = 0; i < 100; ++i) { - *p++ = 0xD03B0000 | (1 >> 7) | (7 << 8); - *p++ = 0xD03B0000 | (1 >> 7); - *p++ = 0xD03B0000 | (7 << 8); - *p++ = 0xD03B0000 | (1 >> 7) | (7 << 8); - *p++ = 0xD03B0000 | (1 >> 7) | (7 << 8); - *p++ = 0xD03B0000 | (1 >> 7) | (7 << 8); - *p++ = 0xD03B0000 | (1 >> 7) | (7 << 8); + *p++ = 0xD03C0000 | (1 << 7) | (1 << 15) | (7 << 8); + *p++ = 0xD03C0000 | (1 << 7) | (1 << 15); + *p++ = 0xD03C0000 | (1 << 7) | (1 << 15) | (7 << 8); + *p++ = 0xD03C0000 | (1 << 7) | (1 << 15) | (7 << 8); + *p++ = 0xD03C0000 | (1 << 7) | (1 << 15) | (7 << 8); + *p++ = 0xD03C0000 | (1 << 7) | (1 << 15) | (7 << 8); + *p++ = 0xD03C0000 | (1 << 7) | (1 << 15) | (7 << 8); } *p++ = MIPS_MAKE_SYSCALL("UnitTestFakeSyscalls", "UnitTestTerminator"); From bc7497857af47e32fcb6702051f868a5a3887b4e Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 8 Nov 2014 11:58:59 -0800 Subject: [PATCH 3/7] x86jit: Micro optimize vi2x a bit with ssse3/sse4. Both are small wins. --- Common/x64Emitter.cpp | 9 ++++++++ Common/x64Emitter.h | 10 ++++++++- Core/MIPS/x86/CompVFPU.cpp | 43 +++++++++++++++++++++++++++----------- 3 files changed, 49 insertions(+), 13 deletions(-) diff --git a/Common/x64Emitter.cpp b/Common/x64Emitter.cpp index f646133c65..049f6216fe 100644 --- a/Common/x64Emitter.cpp +++ b/Common/x64Emitter.cpp @@ -1742,6 +1742,15 @@ void XEmitter::PSHUFB(X64Reg dest, OpArg arg) {WriteSSSE3Op(0x66, 0x3800, dest void XEmitter::PTEST(X64Reg dest, OpArg arg) {WriteSSE41Op(0x66, 0x3817, dest, arg);} void XEmitter::PACKUSDW(X64Reg dest, OpArg arg) {WriteSSE41Op(0x66, 0x382b, dest, arg);} +void XEmitter::PMINSB(X64Reg dest, OpArg arg) {WriteSSE41Op(0x66, 0x3838, dest, arg);} +void XEmitter::PMINSD(X64Reg dest, OpArg arg) {WriteSSE41Op(0x66, 0x3839, dest, arg);} +void XEmitter::PMINUW(X64Reg dest, OpArg arg) {WriteSSE41Op(0x66, 0x383a, dest, arg);} +void XEmitter::PMINUD(X64Reg dest, OpArg arg) {WriteSSE41Op(0x66, 0x383b, dest, arg);} +void XEmitter::PMAXSB(X64Reg dest, OpArg arg) {WriteSSE41Op(0x66, 0x383c, dest, arg);} +void XEmitter::PMAXSD(X64Reg dest, OpArg arg) {WriteSSE41Op(0x66, 0x383d, dest, arg);} +void XEmitter::PMAXUW(X64Reg dest, OpArg arg) {WriteSSE41Op(0x66, 0x383e, dest, arg);} +void XEmitter::PMAXUD(X64Reg dest, OpArg arg) {WriteSSE41Op(0x66, 0x383f, dest, arg);} + void XEmitter::PMOVSXBW(X64Reg dest, OpArg arg) {WriteSSE41Op(0x66, 0x3820, dest, arg);} void XEmitter::PMOVSXBD(X64Reg dest, OpArg arg) {WriteSSE41Op(0x66, 0x3821, dest, arg);} void XEmitter::PMOVSXBQ(X64Reg dest, OpArg arg) {WriteSSE41Op(0x66, 0x3822, dest, arg);} diff --git a/Common/x64Emitter.h b/Common/x64Emitter.h index 5992887099..8b60cc34b4 100644 --- a/Common/x64Emitter.h +++ b/Common/x64Emitter.h @@ -763,7 +763,15 @@ public: void PMAXUB(X64Reg dest, OpArg arg); void PMINSW(X64Reg dest, OpArg arg); void PMINUB(X64Reg dest, OpArg arg); - // SSE4 has PMAXSB and PMINSB and PMAXUW and PMINUW too if we need them. + // SSE4: More MAX/MIN instructions. + void PMINSB(X64Reg dest, OpArg arg); + void PMINSD(X64Reg dest, OpArg arg); + void PMINUW(X64Reg dest, OpArg arg); + void PMINUD(X64Reg dest, OpArg arg); + void PMAXSB(X64Reg dest, OpArg arg); + void PMAXSD(X64Reg dest, OpArg arg); + void PMAXUW(X64Reg dest, OpArg arg); + void PMAXUD(X64Reg dest, OpArg arg); void PMOVMSKB(X64Reg dest, OpArg arg); void PSHUFD(X64Reg dest, OpArg arg, u8 shuffle); diff --git a/Core/MIPS/x86/CompVFPU.cpp b/Core/MIPS/x86/CompVFPU.cpp index cd712bc79a..f841470678 100644 --- a/Core/MIPS/x86/CompVFPU.cpp +++ b/Core/MIPS/x86/CompVFPU.cpp @@ -2222,6 +2222,12 @@ void Jit::Comp_VDet(MIPSOpcode op) { DISABLE; } +// The goal is to map (reversed byte order for clarity): +// 000000AA 000000BB 000000CC 000000DD -> AABBCCDD +static s8 MEMORY_ALIGNED16( vi2xc_shuffle[16] ) = { 3, 7, 11, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; +// 0000AAAA 0000BBBB 0000CCCC 0000DDDD -> AAAABBBB CCCCDDDD +static s8 MEMORY_ALIGNED16( vi2xs_shuffle[16] ) = { 2, 3, 6, 7, 10, 11, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1 }; + void Jit::Comp_Vi2x(MIPSOpcode op) { CONDITIONAL_DISABLE; if (js.HasUnknownPrefix()) @@ -2293,27 +2299,40 @@ void Jit::Comp_Vi2x(MIPSOpcode op) { PUNPCKLQDQ(dst0, R(XMM0)); } else { // Otherwise, we need to zero out the top 2. - // TODO: Maybe PAND would be better? + // We expect XMM1 to be zero below. PXOR(XMM1, R(XMM1)); PUNPCKLQDQ(dst0, R(XMM1)); } // For "u" type ops, we clamp to zero and shift off the sign bit first. if (unsignedOp) { - // Get a mask of the sign bit in dst0, then and in the values. This clamps to 0. - MOVDQA(XMM1, R(dst0)); - PSRAD(dst0, 31); - PSLLD(XMM1, 1); - PANDN(dst0, R(XMM1)); + if (cpu_info.bSSE4_1) { + if (sz == V_Quad) { + // Zeroed in the other case above. + PXOR(XMM1, R(XMM1)); + } + PMAXSD(dst0, R(XMM1)); + PSLLD(dst0, 1); + } else { + // Get a mask of the sign bit in dst0, then and in the values. This clamps to 0. + MOVDQA(XMM1, R(dst0)); + PSRAD(dst0, 31); + PSLLD(XMM1, 1); + PANDN(dst0, R(XMM1)); + } } // At this point, everything is aligned in the high bits of our lanes. - // Let's *arithmetically* shift in the sign so we can use saturating packs. - PSRAD(dst0, 32 - bits); - // XMM1 used for the high part just so there's no dependency. It contains garbage or 0. - PACKSSDW(dst0, R(XMM1)); - if (bits == 8) { - PACKSSWB(dst0, R(XMM1)); + if (cpu_info.bSSSE3) { + PSHUFB(dst0, bits == 8 ? M(vi2xc_shuffle) : M(vi2xs_shuffle)); + } else { + // Let's *arithmetically* shift in the sign so we can use saturating packs. + PSRAD(dst0, 32 - bits); + // XMM1 used for the high part just so there's no dependency. It contains garbage or 0. + PACKSSDW(dst0, R(XMM1)); + if (bits == 8) { + PACKSSWB(dst0, R(XMM1)); + } } if (!fpr.V(dregs[0]).IsSimpleReg(dst0)) { From 761e269e5fbeaae6bd74fe82cde167a0a17d4c8a Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 8 Nov 2014 12:38:08 -0800 Subject: [PATCH 4/7] x86jit: Avoid some regcache pollution. --- Core/MIPS/x86/CompVFPU.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Core/MIPS/x86/CompVFPU.cpp b/Core/MIPS/x86/CompVFPU.cpp index f841470678..036e883daf 100644 --- a/Core/MIPS/x86/CompVFPU.cpp +++ b/Core/MIPS/x86/CompVFPU.cpp @@ -1805,9 +1805,15 @@ void Jit::Comp_Mftv(MIPSOpcode op) { // rt = 0, imm = 255 appears to be used as a CPU interlock by some games. if (rt != MIPS_REG_ZERO) { if (imm < 128) { //R(rt) = VI(imm); - fpr.MapRegV(imm, 0); // TODO: Seems the V register becomes dirty here? It shouldn't. - gpr.MapReg(rt, false, true); - MOVD_xmm(gpr.R(rt), fpr.VX(imm)); + if (fpr.V(imm).IsSimpleReg()) { + fpr.MapRegV(imm, 0); + gpr.MapReg(rt, false, true); + MOVD_xmm(gpr.R(rt), fpr.VX(imm)); + } else { + // Let's not bother mapping the vreg. + gpr.MapReg(rt, false, true); + MOV(32, gpr.R(rt), fpr.V(imm)); + } } else if (imm < 128 + VFPU_CTRL_MAX) { //mfvc if (imm - 128 == VFPU_CTRL_CC) { if (gpr.IsImm(MIPS_REG_VFPUCC)) { @@ -1834,8 +1840,8 @@ void Jit::Comp_Mftv(MIPSOpcode op) { case 7: //mtv if (imm < 128) { // VI(imm) = R(rt); - fpr.MapRegV(imm, MAP_DIRTY | MAP_NOINIT); // TODO: Seems the V register becomes dirty here? It shouldn't. - gpr.MapReg(rt, true, false); + fpr.MapRegV(imm, MAP_DIRTY | MAP_NOINIT); + // Let's not bother mapping rt if we don't have to. MOVD_xmm(fpr.VX(imm), gpr.R(rt)); } else if (imm < 128 + VFPU_CTRL_MAX) { //mtvc //currentMIPS->vfpuCtrl[imm - 128] = R(rt); if (imm - 128 == VFPU_CTRL_CC) { From c0be19edb6688bb3dceb163ece08da603d71512b Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 8 Nov 2014 12:40:04 -0800 Subject: [PATCH 5/7] x86jit: Simplify vavg a bit. --- Core/MIPS/x86/CompVFPU.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Core/MIPS/x86/CompVFPU.cpp b/Core/MIPS/x86/CompVFPU.cpp index 036e883daf..5db6b879b7 100644 --- a/Core/MIPS/x86/CompVFPU.cpp +++ b/Core/MIPS/x86/CompVFPU.cpp @@ -2389,8 +2389,7 @@ void Jit::Comp_Vhoriz(MIPSOpcode op) { case 6: // vfad break; case 7: // vavg - MOVSS(XMM1, M(&vavg_table[n])); - MULSS(reg, R(XMM1)); + MULSS(reg, M(&vavg_table[n])); break; } From c29b126357ab7501ae68a93dab46b7058e483d43 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 8 Nov 2014 12:41:48 -0800 Subject: [PATCH 6/7] x86jit: Oops, can't have an imm here. --- Core/MIPS/x86/CompVFPU.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Core/MIPS/x86/CompVFPU.cpp b/Core/MIPS/x86/CompVFPU.cpp index 5db6b879b7..22b2caaea5 100644 --- a/Core/MIPS/x86/CompVFPU.cpp +++ b/Core/MIPS/x86/CompVFPU.cpp @@ -1842,6 +1842,7 @@ void Jit::Comp_Mftv(MIPSOpcode op) { if (imm < 128) { // VI(imm) = R(rt); fpr.MapRegV(imm, MAP_DIRTY | MAP_NOINIT); // Let's not bother mapping rt if we don't have to. + gpr.KillImmediate(rt, true, false); MOVD_xmm(fpr.VX(imm), gpr.R(rt)); } else if (imm < 128 + VFPU_CTRL_MAX) { //mtvc //currentMIPS->vfpuCtrl[imm - 128] = R(rt); if (imm - 128 == VFPU_CTRL_CC) { From 671dee85c7ce5b969c6b21b7846007fbe42fec6a Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 8 Nov 2014 13:07:01 -0800 Subject: [PATCH 7/7] x86jit: Micro optimize vi2f a little bit. This didn't help overall perf much but micro benchmarks are better. --- Core/MIPS/x86/CompVFPU.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Core/MIPS/x86/CompVFPU.cpp b/Core/MIPS/x86/CompVFPU.cpp index 22b2caaea5..7d7123f344 100644 --- a/Core/MIPS/x86/CompVFPU.cpp +++ b/Core/MIPS/x86/CompVFPU.cpp @@ -1122,15 +1122,15 @@ void Jit::Comp_Vi2f(MIPSOpcode op) { if (*mult != 1.0f) MOVSS(XMM1, M(mult)); for (int i = 0; i < n; i++) { - if (fpr.V(sregs[i]).IsSimpleReg()) - MOVD_xmm(R(EAX), fpr.VX(sregs[i])); - else - MOV(32, R(EAX), fpr.V(sregs[i])); - CVTSI2SS(XMM0, R(EAX)); + fpr.MapRegV(tempregs[i], (sregs[i] == dregs[i] ? 0 : MAP_NOINIT) | MAP_DIRTY); + if (fpr.V(sregs[i]).IsSimpleReg()) { + CVTDQ2PS(fpr.VX(tempregs[i]), fpr.V(sregs[i])); + } else { + MOVSS(fpr.VX(tempregs[i]), fpr.V(sregs[i])); + CVTDQ2PS(fpr.VX(tempregs[i]), R(fpr.VX(tempregs[i]))); + } if (*mult != 1.0f) - MULSS(XMM0, R(XMM1)); - fpr.MapRegV(tempregs[i], MAP_DIRTY); - MOVSS(fpr.V(tempregs[i]), XMM0); + MULSS(fpr.VX(tempregs[i]), R(XMM1)); } for (int i = 0; i < n; ++i) {