diff --git a/Core/MIPS/ARM/ArmAsm.cpp b/Core/MIPS/ARM/ArmAsm.cpp index 7f345e231f..12cf336764 100644 --- a/Core/MIPS/ARM/ArmAsm.cpp +++ b/Core/MIPS/ARM/ArmAsm.cpp @@ -127,10 +127,7 @@ void Jit::GenerateFixedCode() LDR(R0, R10, offsetof(MIPSState, pc)); BIC(R0, R0, Operand2(0xC0, 4)); // &= 0x3FFFFFFF - ADD(R0, R0, R11); // TODO: Optimize (can merge with next instr) - LDR(R0, R0); - // This could replace the above two instructions if the emitter wasn't bugged: - // LDR(R0, R11, Operand2(R0)); + LDR(R0, R11, R0, true, true); AND(R1, R0, Operand2(0xFC, 4)); // rotation is to the right, in 2-bit increments. BIC(R0, R0, Operand2(0xFC, 4)); CMP(R1, Operand2(MIPS_EMUHACK_OPCODE >> 24, 4)); diff --git a/Core/MIPS/ARM/ArmCompLoadStore.cpp b/Core/MIPS/ARM/ArmCompLoadStore.cpp index 1fdba9d5fd..9b336550b3 100644 --- a/Core/MIPS/ARM/ArmCompLoadStore.cpp +++ b/Core/MIPS/ARM/ArmCompLoadStore.cpp @@ -59,17 +59,23 @@ namespace MIPSComp if (TryMakeOperand2(offset, op2)) { ADD(R0, gpr.R(rs), op2); } else { - ARMABI_MOVI2R(R0, (u32)offset); - ADD(R0, gpr.R(rs), R0); + // Try to avoid using MOVT + if (offset < 0) { + ARMABI_MOVI2R(R0, (u32)(-offset)); + SUB(R0, gpr.R(rs), R0); + } else { + ARMABI_MOVI2R(R0, (u32)offset); + ADD(R0, gpr.R(rs), R0); + } } BIC(R0, R0, Operand2(0xC0, 4)); // &= 0x3FFFFFFF } else { BIC(R0, gpr.R(rs), Operand2(0xC0, 4)); // &= 0x3FFFFFFF } - ADD(R0, R0, R11); // TODO: Merge with next instruction if (o == 35) { - LDR(gpr.R(rt), R0); + LDR(gpr.R(rt), R11, R0, true, true); } else if (o == 36) { + ADD(R0, R0, R11); // TODO: Merge with next instruction LDRB(gpr.R(rt), R0); } } else { @@ -91,17 +97,23 @@ namespace MIPSComp if (TryMakeOperand2(offset, op2)) { ADD(R0, gpr.R(rs), op2); } else { - ARMABI_MOVI2R(R0, (u32)offset); - ADD(R0, gpr.R(rs), R0); + // Try to avoid using MOVT + if (offset < 0) { + ARMABI_MOVI2R(R0, (u32)(-offset)); + SUB(R0, gpr.R(rs), R0); + } else { + ARMABI_MOVI2R(R0, (u32)offset); + ADD(R0, gpr.R(rs), R0); + } } BIC(R0, R0, Operand2(0xC0, 4)); // &= 0x3FFFFFFF } else { BIC(R0, gpr.R(rs), Operand2(0xC0, 4)); // &= 0x3FFFFFFF } - ADD(R0, R0, R11); if (o == 43) { - STR(R0, gpr.R(rt)); + STR(R0, gpr.R(rt), R11, true, true); } else if (o == 40) { + ADD(R0, R0, R11); STRB(R0, gpr.R(rt)); } } else {