Merge pull request #9425 from Sintendo/jit64subfx

Jit64: subfx optimizations
This commit is contained in:
LC 2021-01-14 21:40:05 -05:00 committed by GitHub
commit 0c2bc3582d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 58 additions and 6 deletions

View File

@ -933,13 +933,63 @@ void Jit64::subfx(UGeckoInstruction inst)
JITDISABLE(bJITIntegerOff); JITDISABLE(bJITIntegerOff);
int a = inst.RA, b = inst.RB, d = inst.RD; int a = inst.RA, b = inst.RB, d = inst.RD;
if (gpr.IsImm(a) && gpr.IsImm(b)) if (a == b)
{
gpr.SetImmediate32(d, 0);
if (inst.OE)
GenerateConstantOverflow(false);
}
else if (gpr.IsImm(a, b))
{ {
s32 i = gpr.SImm32(b), j = gpr.SImm32(a); s32 i = gpr.SImm32(b), j = gpr.SImm32(a);
gpr.SetImmediate32(d, i - j); gpr.SetImmediate32(d, i - j);
if (inst.OE) if (inst.OE)
GenerateConstantOverflow((s64)i - (s64)j); GenerateConstantOverflow((s64)i - (s64)j);
} }
else if (gpr.IsImm(a))
{
s32 j = gpr.SImm32(a);
RCOpArg Rb = gpr.Use(b, RCMode::Read);
RCX64Reg Rd = gpr.Bind(d, RCMode::Write);
RegCache::Realize(Rb, Rd);
if (j == 0)
{
if (d != b)
MOV(32, Rd, Rb);
if (inst.OE)
GenerateConstantOverflow(false);
}
else if (d == b)
{
SUB(32, Rd, Imm32(j));
if (inst.OE)
GenerateOverflow();
}
else if (Rb.IsSimpleReg() && !inst.OE)
{
LEA(32, Rd, MDisp(Rb.GetSimpleReg(), -j));
}
else
{
MOV(32, Rd, Rb);
SUB(32, Rd, Imm32(j));
if (inst.OE)
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 else
{ {
RCOpArg Ra = gpr.Use(a, RCMode::Read); RCOpArg Ra = gpr.Use(a, RCMode::Read);
@ -957,10 +1007,6 @@ void Jit64::subfx(UGeckoInstruction inst)
MOV(32, Rd, Rb); MOV(32, Rd, Rb);
SUB(32, Rd, R(RSCRATCH)); SUB(32, Rd, R(RSCRATCH));
} }
else if (Rb.IsSimpleReg() && Ra.IsImm() && !inst.OE)
{
LEA(32, Rd, MDisp(Rb.GetSimpleReg(), -Ra.SImm32()));
}
else else
{ {
MOV(32, Rd, Rb); MOV(32, Rd, Rb);

View File

@ -856,7 +856,13 @@ void JitArm64::subfx(UGeckoInstruction inst)
int a = inst.RA, b = inst.RB, d = inst.RD; int a = inst.RA, b = inst.RB, d = inst.RD;
if (gpr.IsImm(a) && gpr.IsImm(b)) if (a == b)
{
gpr.SetImmediate(d, 0);
if (inst.Rc)
ComputeRC0(gpr.GetImm(d));
}
else if (gpr.IsImm(a) && gpr.IsImm(b))
{ {
u32 i = gpr.GetImm(a), j = gpr.GetImm(b); u32 i = gpr.GetImm(a), j = gpr.GetImm(b);
gpr.SetImmediate(d, j - i); gpr.SetImmediate(d, j - i);