Jit64: subfic - Handle constants

Occurs surprisingly often. Prevents generating silly code like this:

BE 03 00 00 00       mov         esi,3
83 EE 08             sub         esi,8
0F 93 45 58          setae       byte ptr [rbp+58h]
This commit is contained in:
Sintendo 2020-11-15 13:04:57 +01:00
parent 6ddf69d094
commit 2e4e2ad1ff

View File

@ -862,13 +862,20 @@ void Jit64::subfic(UGeckoInstruction inst)
{
INSTRUCTION_START
JITDISABLE(bJITIntegerOff);
int a = inst.RA, d = inst.RD;
int a = inst.RA, d = inst.RD, imm = inst.SIMM_16;
if (gpr.IsImm(a))
{
u32 i = imm, j = gpr.Imm32(a);
gpr.SetImmediate32(d, i - j);
FinalizeCarry(j == 0 || (i > j - 1));
return;
}
RCOpArg Ra = gpr.Use(a, RCMode::Read);
RCX64Reg Rd = gpr.Bind(d, RCMode::Write);
RegCache::Realize(Ra, Rd);
int imm = inst.SIMM_16;
if (d == a)
{
if (imm == 0)