From 68a327c246d82d8529af692abc7843858dca4cab Mon Sep 17 00:00:00 2001 From: magumagu Date: Sun, 25 May 2014 19:23:57 -0700 Subject: [PATCH 1/2] JIT: Simplify redundant if statements for memcheck. --- Source/Core/Core/PowerPC/Jit64/Jit_LoadStore.cpp | 4 ++-- Source/Core/Core/PowerPC/Jit64/Jit_LoadStoreFloating.cpp | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/Source/Core/Core/PowerPC/Jit64/Jit_LoadStore.cpp b/Source/Core/Core/PowerPC/Jit64/Jit_LoadStore.cpp index f408a5b7bd..cdc8683480 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit_LoadStore.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit_LoadStore.cpp @@ -176,14 +176,14 @@ void Jit64::lXXx(UGeckoInstruction inst) { u32 val = (u32)gpr.R(a).offset + (s32)inst.SIMM_16; opAddress = Imm32(val); - if (update && !js.memcheck) + if (update) gpr.SetImmediate32(a, val); } else if ((inst.OPCD == 31) && gpr.R(a).IsImm() && gpr.R(b).IsImm() && !js.memcheck) { u32 val = (u32)gpr.R(a).offset + (u32)gpr.R(b).offset; opAddress = Imm32(val); - if (update && !js.memcheck) + if (update) gpr.SetImmediate32(a, val); } else diff --git a/Source/Core/Core/PowerPC/Jit64/Jit_LoadStoreFloating.cpp b/Source/Core/Core/PowerPC/Jit64/Jit_LoadStoreFloating.cpp index cd0261e158..88eeacc30b 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit_LoadStoreFloating.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit_LoadStoreFloating.cpp @@ -324,12 +324,8 @@ void Jit64::lfsx(UGeckoInstruction inst) #else MOVD_xmm(XMM0, MComplex(RBX, EAX, SCALE_1, 0)); #endif - MEMCHECK_START - PSHUFB(XMM0, M((void *)bswapShuffle1x4)); ConvertSingleToDouble(s, XMM0); - - MEMCHECK_END } else { SafeLoadToReg(EAX, R(EAX), 32, 0, RegistersInUse(), false); From e5ebf22161db12b2b7f68b0c739867b3da793166 Mon Sep 17 00:00:00 2001 From: magumagu Date: Sun, 25 May 2014 19:41:46 -0700 Subject: [PATCH 2/2] JIT: unify two branches in SafeLoadToReg. Should behave the same as it did before. --- .../Core/Core/PowerPC/JitCommon/Jit_Util.cpp | 92 +++++++------------ 1 file changed, 31 insertions(+), 61 deletions(-) diff --git a/Source/Core/Core/PowerPC/JitCommon/Jit_Util.cpp b/Source/Core/Core/PowerPC/JitCommon/Jit_Util.cpp index 43c757d160..fa4b2959ab 100644 --- a/Source/Core/Core/PowerPC/JitCommon/Jit_Util.cpp +++ b/Source/Core/Core/PowerPC/JitCommon/Jit_Util.cpp @@ -358,74 +358,44 @@ void EmuCodeBlock::SafeLoadToReg(X64Reg reg_value, const Gen::OpArg & opAddress, } else { + OpArg addr_loc = opAddress; if (offset) { + addr_loc = R(EAX); MOV(32, R(EAX), opAddress); ADD(32, R(EAX), Imm32(offset)); - TEST(32, R(EAX), Imm32(mem_mask)); - FixupBranch fast = J_CC(CC_Z, true); - - ABI_PushRegistersAndAdjustStack(registersInUse, false); - switch (accessSize) - { - case 32: ABI_CallFunctionR((void *)&Memory::Read_U32, EAX); break; - case 16: ABI_CallFunctionR((void *)&Memory::Read_U16_ZX, EAX); break; - case 8: ABI_CallFunctionR((void *)&Memory::Read_U8_ZX, EAX); break; - } - ABI_PopRegistersAndAdjustStack(registersInUse, false); - - MEMCHECK_START - - if (signExtend && accessSize < 32) - { - // Need to sign extend values coming from the Read_U* functions. - MOVSX(32, accessSize, reg_value, R(EAX)); - } - else if (reg_value != EAX) - { - MOVZX(32, accessSize, reg_value, R(EAX)); - } - - MEMCHECK_END - - FixupBranch exit = J(); - SetJumpTarget(fast); - UnsafeLoadToReg(reg_value, R(EAX), accessSize, 0, signExtend); - SetJumpTarget(exit); } - else + TEST(32, addr_loc, Imm32(mem_mask)); + + FixupBranch fast = J_CC(CC_Z, true); + + ABI_PushRegistersAndAdjustStack(registersInUse, false); + switch (accessSize) { - TEST(32, opAddress, Imm32(mem_mask)); - FixupBranch fast = J_CC(CC_Z, true); - - ABI_PushRegistersAndAdjustStack(registersInUse, false); - switch (accessSize) - { - case 32: ABI_CallFunctionA((void *)&Memory::Read_U32, opAddress); break; - case 16: ABI_CallFunctionA((void *)&Memory::Read_U16_ZX, opAddress); break; - case 8: ABI_CallFunctionA((void *)&Memory::Read_U8_ZX, opAddress); break; - } - ABI_PopRegistersAndAdjustStack(registersInUse, false); - - MEMCHECK_START - - if (signExtend && accessSize < 32) - { - // Need to sign extend values coming from the Read_U* functions. - MOVSX(32, accessSize, reg_value, R(EAX)); - } - else if (reg_value != EAX) - { - MOVZX(32, accessSize, reg_value, R(EAX)); - } - - MEMCHECK_END - - FixupBranch exit = J(); - SetJumpTarget(fast); - UnsafeLoadToReg(reg_value, opAddress, accessSize, offset, signExtend); - SetJumpTarget(exit); + case 32: ABI_CallFunctionA((void *)&Memory::Read_U32, addr_loc); break; + case 16: ABI_CallFunctionA((void *)&Memory::Read_U16_ZX, addr_loc); break; + case 8: ABI_CallFunctionA((void *)&Memory::Read_U8_ZX, addr_loc); break; } + ABI_PopRegistersAndAdjustStack(registersInUse, false); + + MEMCHECK_START + + if (signExtend && accessSize < 32) + { + // Need to sign extend values coming from the Read_U* functions. + MOVSX(32, accessSize, reg_value, R(EAX)); + } + else if (reg_value != EAX) + { + MOVZX(32, accessSize, reg_value, R(EAX)); + } + + MEMCHECK_END + + FixupBranch exit = J(); + SetJumpTarget(fast); + UnsafeLoadToReg(reg_value, addr_loc, accessSize, 0, signExtend); + SetJumpTarget(exit); } } }