Jit_Integer: arithcx

This commit is contained in:
MerryMage 2018-10-15 21:01:07 +01:00
parent 6ce718b920
commit bde5df03a3
1 changed files with 24 additions and 20 deletions

View File

@ -1466,37 +1466,41 @@ void Jit64::arithcx(UGeckoInstruction inst)
JITDISABLE(bJITIntegerOff); JITDISABLE(bJITIntegerOff);
bool add = !!(inst.SUBOP10 & 2); // add or sub bool add = !!(inst.SUBOP10 & 2); // add or sub
int a = inst.RA, b = inst.RB, d = inst.RD; int a = inst.RA, b = inst.RB, d = inst.RD;
gpr.Lock(a, b, d);
gpr.BindToRegister(d, d == a || d == b, true);
if (d == a && d != b)
{ {
if (add) RCOpArg Ra = gpr.Use(a, RCMode::Read);
RCOpArg Rb = gpr.Use(b, RCMode::Read);
RCX64Reg Rd = gpr.Bind(d, RCMode::Write);
RegCache::Realize(Ra, Rb, Rd);
if (d == a && d != b)
{ {
ADD(32, gpr.R(d), gpr.R(b)); if (add)
{
ADD(32, Rd, Rb);
}
else
{
// special case, because sub isn't reversible
MOV(32, R(RSCRATCH), Ra);
MOV(32, Rd, Rb);
SUB(32, Rd, R(RSCRATCH));
}
} }
else else
{ {
// special case, because sub isn't reversible if (d != b)
MOV(32, R(RSCRATCH), gpr.R(a)); MOV(32, Rd, Rb);
MOV(32, gpr.R(d), gpr.R(b)); if (add)
SUB(32, gpr.R(d), R(RSCRATCH)); ADD(32, Rd, Ra);
else
SUB(32, Rd, Ra);
} }
} }
else
{
if (d != b)
MOV(32, gpr.R(d), gpr.R(b));
if (add)
ADD(32, gpr.R(d), gpr.R(a));
else
SUB(32, gpr.R(d), gpr.R(a));
}
FinalizeCarryOverflow(inst.OE, !add); FinalizeCarryOverflow(inst.OE, !add);
if (inst.Rc) if (inst.Rc)
ComputeRC(gpr.R(d)); ComputeRC(d);
gpr.UnlockAll();
} }
void Jit64::rlwinmx(UGeckoInstruction inst) void Jit64::rlwinmx(UGeckoInstruction inst)