Optimize addi/addiu to just LEA when possible.

This commit is contained in:
Unknown W. Brackets 2013-02-20 21:04:05 -08:00
parent 2db368c29a
commit 9e479b4391

View File

@ -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;