diff --git a/Core/MIPS/JitCommon/JitState.cpp b/Core/MIPS/JitCommon/JitState.cpp index 3e7108443a..801359c2e5 100644 --- a/Core/MIPS/JitCommon/JitState.cpp +++ b/Core/MIPS/JitCommon/JitState.cpp @@ -48,7 +48,6 @@ namespace MIPSComp { enableBlocklink = !Disabled(JitDisable::BLOCKLINK); #endif immBranches = false; - continueBranches = false; continueJumps = false; continueMaxInstructions = 300; diff --git a/Core/MIPS/JitCommon/JitState.h b/Core/MIPS/JitCommon/JitState.h index 4e26d7add1..4dd2e226c1 100644 --- a/Core/MIPS/JitCommon/JitState.h +++ b/Core/MIPS/JitCommon/JitState.h @@ -239,7 +239,6 @@ namespace MIPSComp { // Common bool enableBlocklink; bool immBranches; - bool continueBranches; bool continueJumps; int continueMaxInstructions; }; diff --git a/Core/MIPS/x86/CompBranch.cpp b/Core/MIPS/x86/CompBranch.cpp index d3487c811b..a1172fbf9f 100644 --- a/Core/MIPS/x86/CompBranch.cpp +++ b/Core/MIPS/x86/CompBranch.cpp @@ -202,112 +202,41 @@ void Jit::CompBranchExits(CCFlags cc, u32 targetAddr, u32 notTakenAddr, const Br // We may want to try to continue along this branch a little while, to reduce reg flushing. bool predictTakeBranch = PredictTakeBranch(targetAddr, branchInfo.likely); - if (!branchInfo.delaySlotIsBranch && CanContinueBranch(predictTakeBranch ? targetAddr : notTakenAddr)) - { - if (predictTakeBranch) - cc = FlipCCFlag(cc); - Gen::FixupBranch ptr; - RegCacheState state; - if (!branchInfo.likely) - { - if (!branchInfo.delaySlotIsNice) - CompileDelaySlot(DELAYSLOT_SAFE); - ptr = J_CC(cc, true); - GetStateAndFlushAll(state); - } + Gen::FixupBranch ptr; + if (!branchInfo.likely) { + if (!branchInfo.delaySlotIsNice && !branchInfo.delaySlotIsBranch) + CompileDelaySlot(DELAYSLOT_SAFE_FLUSH); else - { - ptr = J_CC(cc, true); - if (predictTakeBranch) - GetStateAndFlushAll(state); - else - { - // We need to get the state BEFORE the delay slot is compiled. - gpr.GetState(state.gpr); - fpr.GetState(state.fpr); - CompileDelaySlot(DELAYSLOT_FLUSH); - } - } - - if (predictTakeBranch) - { - // We flipped the cc, the not taken case is first. - CONDITIONAL_LOG_EXIT(notTakenAddr); - WriteExit(notTakenAddr, js.nextExit++); - - // Now our taken path. Bring the regs back, we didn't flush 'em after all. - SetJumpTarget(ptr); - RestoreState(state); - CONDITIONAL_LOG_EXIT(targetAddr); - - // Don't forget to run the delay slot if likely. - if (branchInfo.likely) - CompileDelaySlot(DELAYSLOT_NICE); - - AddContinuedBlock(targetAddr); - // Account for the increment in the loop. - js.compilerPC = targetAddr - 4; - // In case the delay slot was a break or something. - js.compiling = true; - } - else - { - // Take the branch - CONDITIONAL_LOG_EXIT(targetAddr); - WriteExit(targetAddr, js.nextExit++); - - // Not taken - SetJumpTarget(ptr); - RestoreState(state); - CONDITIONAL_LOG_EXIT(notTakenAddr); - - // Account for the delay slot. - js.compilerPC += 4; - // In case the delay slot was a break or something. - js.compiling = true; - } - } - else - { - Gen::FixupBranch ptr; - if (!branchInfo.likely) - { - if (!branchInfo.delaySlotIsNice && !branchInfo.delaySlotIsBranch) - CompileDelaySlot(DELAYSLOT_SAFE_FLUSH); - else - FlushAll(); - ptr = J_CC(cc, true); - } - else - { FlushAll(); - ptr = J_CC(cc, true); - if (!branchInfo.delaySlotIsBranch) - CompileDelaySlot(DELAYSLOT_FLUSH); - } - - // Handle the linkage of a delay slot, even when we're taking the branch. - if (branchInfo.delaySlotIsBranch) { - // We still link when the branch is taken (targetAddr case.) - // Remember, it's from the perspective of the delay slot, so +12. - if ((branchInfo.delaySlotInfo & OUT_RA) != 0) - gpr.SetImm(MIPS_REG_RA, GetCompilerPC() + 12); - if ((branchInfo.delaySlotInfo & OUT_RD) != 0) - gpr.SetImm(MIPS_GET_RD(branchInfo.delaySlotOp), GetCompilerPC() + 12); - FlushAll(); - } - - // Take the branch - CONDITIONAL_LOG_EXIT(targetAddr); - WriteExit(targetAddr, js.nextExit++); - - // Not taken - SetJumpTarget(ptr); - CONDITIONAL_LOG_EXIT(notTakenAddr); - WriteExit(notTakenAddr, js.nextExit++); - js.compiling = false; + ptr = J_CC(cc, true); + } else { + FlushAll(); + ptr = J_CC(cc, true); + if (!branchInfo.delaySlotIsBranch) + CompileDelaySlot(DELAYSLOT_FLUSH); } + + // Handle the linkage of a delay slot, even when we're taking the branch. + if (branchInfo.delaySlotIsBranch) { + // We still link when the branch is taken (targetAddr case.) + // Remember, it's from the perspective of the delay slot, so +12. + if ((branchInfo.delaySlotInfo & OUT_RA) != 0) + gpr.SetImm(MIPS_REG_RA, GetCompilerPC() + 12); + if ((branchInfo.delaySlotInfo & OUT_RD) != 0) + gpr.SetImm(MIPS_GET_RD(branchInfo.delaySlotOp), GetCompilerPC() + 12); + FlushAll(); + } + + // Take the branch + CONDITIONAL_LOG_EXIT(targetAddr); + WriteExit(targetAddr, js.nextExit++); + + // Not taken + SetJumpTarget(ptr); + CONDITIONAL_LOG_EXIT(notTakenAddr); + WriteExit(notTakenAddr, js.nextExit++); + js.compiling = false; } void Jit::CompBranchExit(bool taken, u32 targetAddr, u32 notTakenAddr, const BranchInfo &branchInfo) { diff --git a/Core/MIPS/x86/Jit.h b/Core/MIPS/x86/Jit.h index 4236785006..e359f7c715 100644 --- a/Core/MIPS/x86/Jit.h +++ b/Core/MIPS/x86/Jit.h @@ -268,20 +268,6 @@ private: } bool PredictTakeBranch(u32 targetAddr, bool likely); - bool CanContinueBranch(u32 targetAddr) { - if (!jo.continueBranches || js.numInstructions >= jo.continueMaxInstructions) { - return false; - } - // Need at least 2 exits left over. - if (js.nextExit >= MAX_JIT_BLOCK_EXITS - 2) { - return false; - } - // Sometimes we predict wrong and get into impossible conditions where games have jumps to 0. - if (!targetAddr) { - return false; - } - return true; - } bool CanContinueJump(u32 targetAddr) { if (!jo.continueJumps || js.numInstructions >= jo.continueMaxInstructions) { return false;