From a3c777ed8447ff5085fba0c6190fbd8378dea464 Mon Sep 17 00:00:00 2001 From: zilmar Date: Thu, 28 Nov 2024 15:14:26 +1030 Subject: [PATCH] Core: Have CX86RecompilerOps::SPECIAL_AND unmap the register on const write --- .../Recompiler/x86/x86RecompilerOps.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp b/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp index 5dfd4fe97..8e00096a5 100644 --- a/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp +++ b/Source/Project64-core/N64System/Recompiler/x86/x86RecompilerOps.cpp @@ -5519,9 +5519,12 @@ void CX86RecompilerOps::SPECIAL_AND() { if (m_RegWorkingSet.Is64Bit(m_Opcode.rt) || m_RegWorkingSet.Is64Bit(m_Opcode.rs)) { - m_RegWorkingSet.SetMipsReg(m_Opcode.rd, - (m_RegWorkingSet.Is64Bit(m_Opcode.rt) ? m_RegWorkingSet.GetMipsReg(m_Opcode.rt) : (int64_t)m_RegWorkingSet.GetMipsRegLo_S(m_Opcode.rt)) & - (m_RegWorkingSet.Is64Bit(m_Opcode.rs) ? m_RegWorkingSet.GetMipsReg(m_Opcode.rs) : (int64_t)m_RegWorkingSet.GetMipsRegLo_S(m_Opcode.rs))); + uint64_t Value = (m_RegWorkingSet.Is64Bit(m_Opcode.rt) ? m_RegWorkingSet.GetMipsReg(m_Opcode.rt) : (int64_t)m_RegWorkingSet.GetMipsRegLo_S(m_Opcode.rt)) & (m_RegWorkingSet.Is64Bit(m_Opcode.rs) ? m_RegWorkingSet.GetMipsReg(m_Opcode.rs) : (int64_t)m_RegWorkingSet.GetMipsRegLo_S(m_Opcode.rs)); + if (m_RegWorkingSet.IsMapped(m_Opcode.rd)) + { + m_RegWorkingSet.UnMap_GPR(m_Opcode.rd, false); + } + m_RegWorkingSet.SetMipsReg(m_Opcode.rd, Value); if (m_RegWorkingSet.GetMipsRegLo_S(m_Opcode.rd) < 0 && m_RegWorkingSet.GetMipsRegHi_S(m_Opcode.rd) == -1) { @@ -5538,7 +5541,12 @@ void CX86RecompilerOps::SPECIAL_AND() } else { - m_RegWorkingSet.SetMipsReg(m_Opcode.rd, m_RegWorkingSet.GetMipsRegLo(m_Opcode.rt) & m_RegWorkingSet.GetMipsReg(m_Opcode.rs)); + uint32_t Value = m_RegWorkingSet.GetMipsRegLo(m_Opcode.rt) & m_RegWorkingSet.GetMipsReg(m_Opcode.rs); + if (m_RegWorkingSet.IsMapped(m_Opcode.rd)) + { + m_RegWorkingSet.UnMap_GPR(m_Opcode.rd, false); + } + m_RegWorkingSet.SetMipsReg(m_Opcode.rd, Value); m_RegWorkingSet.SetMipsRegState(m_Opcode.rd, CRegInfo::STATE_CONST_32_SIGN); } }