Jit64: addx - Prefer ADD over LEA when possible

The old logic would always emit LEA when both sources are in a register
and OE is disabled. However, ADD is still preferable when one of the
sources matches the destination.

Before:
45 8D 6C 35 00       lea         r13d,[r13+rsi]

After:
44 03 EE             add         r13d,esi
This commit is contained in:
Sintendo 2020-01-05 23:01:48 +01:00
parent 7a6a4510f6
commit 8e7b6f4178
1 changed files with 7 additions and 4 deletions

View File

@ -1330,18 +1330,21 @@ void Jit64::addx(UGeckoInstruction inst)
RCX64Reg Rd = gpr.Bind(d, RCMode::Write);
RegCache::Realize(Ra, Rb, Rd);
if (Ra.IsSimpleReg() && Rb.IsSimpleReg() && !inst.OE)
if (d == a)
{
LEA(32, Rd, MRegSum(Ra.GetSimpleReg(), Rb.GetSimpleReg()));
ADD(32, Rd, Rb);
}
else if (d == b)
{
ADD(32, Rd, Ra);
}
else if (Ra.IsSimpleReg() && Rb.IsSimpleReg() && !inst.OE)
{
LEA(32, Rd, MRegSum(Ra.GetSimpleReg(), Rb.GetSimpleReg()));
}
else
{
if (d != a)
MOV(32, Rd, Ra);
MOV(32, Rd, Ra);
ADD(32, Rd, Rb);
}
if (inst.OE)