Jit64: subfx - Special case b == 0

Happens in Super Mario Sunshine. You could probably do something similar
for b == -1 (like we do for subfic), but I couldn't find any titles that
do this.

- Case 1: d == a

Before:
41 8B C7             mov         eax,r15d
41 BF 00 00 00 00    mov         r15d,0
44 2B F8             sub         r15d,eax

After:
41 F7 DF             neg         r15d

- Case 2: d != a

Before:
BF 00 00 00 00       mov         edi,0
41 2B FD             sub         edi,r13d

After:
41 8B FD             mov         edi,r13d
F7 DF                neg         edi
This commit is contained in:
Sintendo 2021-01-04 23:56:58 +01:00
parent 57548b456b
commit b0be20560f

View File

@ -980,6 +980,18 @@ void Jit64::subfx(UGeckoInstruction inst)
GenerateOverflow();
}
}
else if (gpr.IsImm(b) && gpr.Imm32(b) == 0)
{
RCOpArg Ra = gpr.Use(a, RCMode::Read);
RCX64Reg Rd = gpr.Bind(d, RCMode::Write);
RegCache::Realize(Ra, Rd);
if (d != a)
MOV(32, Rd, Ra);
NEG(32, Rd);
if (inst.OE)
GenerateOverflow();
}
else
{
RCOpArg Ra = gpr.Use(a, RCMode::Read);