Jit_Integer: mulhwXx

This commit is contained in:
MerryMage 2018-10-15 21:01:01 +01:00
parent 24aadd933e
commit 2652d4dfdb
1 changed files with 25 additions and 21 deletions

View File

@ -1112,41 +1112,45 @@ void Jit64::mulhwXx(UGeckoInstruction inst)
int a = inst.RA, b = inst.RB, d = inst.RD; int a = inst.RA, b = inst.RB, d = inst.RD;
bool sign = inst.SUBOP10 == 75; bool sign = inst.SUBOP10 == 75;
if (gpr.R(a).IsImm() && gpr.R(b).IsImm()) if (gpr.IsImm(a, b))
{ {
if (sign) if (sign)
gpr.SetImmediate32(d, (u32)((u64)(((s64)gpr.R(a).SImm32() * (s64)gpr.R(b).SImm32())) >> 32)); gpr.SetImmediate32(d, (u32)((u64)(((s64)gpr.SImm32(a) * (s64)gpr.SImm32(b))) >> 32));
else else
gpr.SetImmediate32(d, (u32)(((u64)gpr.R(a).Imm32() * (u64)gpr.R(b).Imm32()) >> 32)); gpr.SetImmediate32(d, (u32)(((u64)gpr.Imm32(a) * (u64)gpr.Imm32(b)) >> 32));
} }
else if (sign) else if (sign)
{ {
gpr.Lock(a, b, d); RCOpArg Ra = gpr.Use(a, RCMode::Read);
// no register choice RCOpArg Rb = gpr.UseNoImm(b, RCMode::Read);
gpr.FlushLockX(EDX, EAX); RCX64Reg Rd = gpr.Bind(d, RCMode::Write);
gpr.BindToRegister(d, d == a || d == b, true); RCX64Reg eax = gpr.Scratch(EAX);
MOV(32, R(EAX), gpr.R(a)); RCX64Reg edx = gpr.Scratch(EDX);
gpr.KillImmediate(b, true, false); RegCache::Realize(Ra, Rb, Rd, eax, edx);
IMUL(32, gpr.R(b));
MOV(32, gpr.R(d), R(EDX)); MOV(32, eax, Ra);
IMUL(32, Rb);
MOV(32, Rd, edx);
} }
else else
{ {
// Not faster for signed because we'd need two movsx. // Not faster for signed because we'd need two movsx.
gpr.Lock(a, b, d);
// We need to bind everything to registers since the top 32 bits need to be zero. // We need to bind everything to registers since the top 32 bits need to be zero.
int src = d == b ? a : b; int src = d == b ? a : b;
gpr.BindToRegister(d, d == a || d == b, true); int other = src == b ? a : b;
gpr.BindToRegister(src, true, false);
if (d != a && d != b) RCX64Reg Rd = gpr.Bind(d, RCMode::Write);
MOV(32, gpr.R(d), gpr.R(a)); RCX64Reg Rsrc = gpr.Bind(src, RCMode::Read);
IMUL(64, gpr.RX(d), gpr.R(src)); RCOpArg Rother = gpr.Use(other, RCMode::Read);
SHR(64, gpr.R(d), Imm8(32)); RegCache::Realize(Rd, Rsrc, Rother);
if (other != d)
MOV(32, Rd, Rother);
IMUL(64, Rd, Rsrc);
SHR(64, Rd, Imm8(32));
} }
if (inst.Rc) if (inst.Rc)
ComputeRC(gpr.R(d)); ComputeRC(d);
gpr.UnlockAll();
gpr.UnlockAllX();
} }
void Jit64::divwux(UGeckoInstruction inst) void Jit64::divwux(UGeckoInstruction inst)