From 9e479b4391d034a80d10f15d02606bd4437564a1 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Wed, 20 Feb 2013 21:04:05 -0800 Subject: [PATCH] Optimize addi/addiu to just LEA when possible. --- Core/MIPS/x86/CompALU.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Core/MIPS/x86/CompALU.cpp b/Core/MIPS/x86/CompALU.cpp index a3e8c955a2..5935af9be7 100644 --- a/Core/MIPS/x86/CompALU.cpp +++ b/Core/MIPS/x86/CompALU.cpp @@ -78,11 +78,14 @@ namespace MIPSComp gpr.Lock(rt, rs); gpr.BindToRegister(rt, rt == rs, true); - if (rt != rs) + if (rt == rs || gpr.R(rs).IsSimpleReg()) + LEA(32, gpr.RX(rt), MDisp(gpr.RX(rs), simm)); + else + { MOV(32, gpr.R(rt), gpr.R(rs)); - if (simm != 0) - ADD(32, gpr.R(rt), Imm32((u32)(s32)simm)); - // TODO: Can also do LEA if both operands happen to be in registers. + if (simm != 0) + ADD(32, gpr.R(rt), Imm32((u32)(s32)simm)); + } gpr.UnlockAll(); } break;