diff --git a/Core/MIPS/ARM/ArmCompBranch.cpp b/Core/MIPS/ARM/ArmCompBranch.cpp index e6d2d76088..49d8cb55b8 100644 --- a/Core/MIPS/ARM/ArmCompBranch.cpp +++ b/Core/MIPS/ARM/ArmCompBranch.cpp @@ -323,18 +323,27 @@ void Jit::Comp_Jump(u32 op) } u32 off = ((op & 0x03FFFFFF) << 2); u32 targetAddr = (js.compilerPC & 0xF0000000) | off; - CompileDelaySlot(DELAYSLOT_NICE); + + u32 delaySlotOp = Memory::ReadUnchecked_U32(js.compilerPC + 4); + bool delaySlotIsNice = (op >> 26) == 2 || IsDelaySlotNiceReg(op, delaySlotOp, MIPS_REG_RA); + CONDITIONAL_NICE_DELAYSLOT; + if (!likely && delaySlotIsNice) + CompileDelaySlot(DELAYSLOT_NICE); FlushAll(); switch (op >> 26) { case 2: //j + if (!delaySlotIsNice) + CompileDelaySlot(DELAYSLOT_SAFE_FLUSH); WriteExit(targetAddr, 0); break; case 3: //jal MOVI2R(R0, js.compilerPC + 8); STR(R0, CTXREG, MIPS_REG_RA * 4); + if (!delaySlotIsNice) + CompileDelaySlot(DELAYSLOT_SAFE_FLUSH); WriteExit(targetAddr, 0); break; diff --git a/Core/MIPS/x86/CompBranch.cpp b/Core/MIPS/x86/CompBranch.cpp index d5c76463aa..a12411f971 100644 --- a/Core/MIPS/x86/CompBranch.cpp +++ b/Core/MIPS/x86/CompBranch.cpp @@ -409,18 +409,27 @@ void Jit::Comp_Jump(u32 op) } u32 off = ((op & 0x3FFFFFF) << 2); u32 targetAddr = (js.compilerPC & 0xF0000000) | off; - CompileDelaySlot(DELAYSLOT_NICE); + + u32 delaySlotOp = Memory::Read_Instruction(js.compilerPC + 4); + bool delaySlotIsNice = (op >> 26) == 2 || IsDelaySlotNiceReg(op, delaySlotOp, MIPS_REG_RA); + CONDITIONAL_NICE_DELAYSLOT; + if (delaySlotIsNice) + CompileDelaySlot(DELAYSLOT_NICE); FlushAll(); switch (op >> 26) { case 2: //j + if (!delaySlotIsNice) + CompileDelaySlot(DELAYSLOT_SAFE_FLUSH); CONDITIONAL_LOG_EXIT(targetAddr); WriteExit(targetAddr, 0); - break; + break; case 3: //jal MOV(32, M(&mips_->r[MIPS_REG_RA]), Imm32(js.compilerPC + 8)); // Save return address + if (!delaySlotIsNice) + CompileDelaySlot(DELAYSLOT_SAFE_FLUSH); CONDITIONAL_LOG_EXIT(targetAddr); WriteExit(targetAddr, 0); break;