CPU/Recompiler: Reduce register usage of SWL/SWR

Fixes crash in Ape Escape on AArch32.
This commit is contained in:
Connor McLaughlin 2021-09-10 15:53:11 +10:00
parent 38fc5c0210
commit d2e90b0516

View file

@ -1707,11 +1707,13 @@ bool CodeGenerator::Compile_StoreLeftRight(const CodeBlockInstruction& cbi)
Value shift = ShlValues(AndValues(address, Value::FromConstantU32(3)), Value::FromConstantU32(3)); // * 8 Value shift = ShlValues(AndValues(address, Value::FromConstantU32(3)), Value::FromConstantU32(3)); // * 8
address = AndValues(address, Value::FromConstantU32(~u32(3))); address = AndValues(address, Value::FromConstantU32(~u32(3)));
Value mem = EmitLoadGuestMemory(cbi, address, address_spec, RegSize_32); Value mem;
if (cbi.instruction.op == InstructionOp::swl) if (cbi.instruction.op == InstructionOp::swl)
{ {
EmitAnd(mem.GetHostRegister(), mem.GetHostRegister(), ShlValues(Value::FromConstantU32(0xFFFFFF00), shift)); Value mask = ShlValues(Value::FromConstantU32(0xFFFFFF00), shift);
mem = EmitLoadGuestMemory(cbi, address, address_spec, RegSize_32);
EmitAnd(mem.GetHostRegister(), mem.GetHostRegister(), mask);
mask.ReleaseAndClear();
Value reg = m_register_cache.ReadGuestRegister(cbi.instruction.r.rt); Value reg = m_register_cache.ReadGuestRegister(cbi.instruction.r.rt);
Value lhs = ShrValues(reg, SubValues(Value::FromConstantU32(24), shift, false)); Value lhs = ShrValues(reg, SubValues(Value::FromConstantU32(24), shift, false));
@ -1721,8 +1723,10 @@ bool CodeGenerator::Compile_StoreLeftRight(const CodeBlockInstruction& cbi)
} }
else else
{ {
AndValueInPlace(mem, Value mask = ShrValues(Value::FromConstantU32(0x00FFFFFF), SubValues(Value::FromConstantU32(24), shift, false));
ShrValues(Value::FromConstantU32(0x00FFFFFF), SubValues(Value::FromConstantU32(24), shift, false))); mem = EmitLoadGuestMemory(cbi, address, address_spec, RegSize_32);
AndValueInPlace(mem, mask);
mask.ReleaseAndClear();
Value reg = m_register_cache.ReadGuestRegister(cbi.instruction.r.rt); Value reg = m_register_cache.ReadGuestRegister(cbi.instruction.r.rt);
Value lhs = ShlValues(reg, shift); Value lhs = ShlValues(reg, shift);