Jit_FloatingPoint: fselx

This commit is contained in:
MerryMage
2018-10-15 21:01:57 +01:00
parent d62ca40496
commit fecbf091e5

View File

@ -417,35 +417,38 @@ void Jit64::fselx(UGeckoInstruction inst)
bool packed = inst.OPCD == 4; // ps_sel bool packed = inst.OPCD == 4; // ps_sel
fpr.Lock(a, b, c, d); RCOpArg Ra = fpr.Use(a, RCMode::Read);
RCOpArg Rb = fpr.Use(b, RCMode::Read);
RCOpArg Rc = fpr.Use(c, RCMode::Read);
RCX64Reg Rd = fpr.Bind(d, packed ? RCMode::Write : RCMode::ReadWrite);
RegCache::Realize(Ra, Rb, Rc, Rd);
XORPD(XMM0, R(XMM0)); XORPD(XMM0, R(XMM0));
// This condition is very tricky; there's only one right way to handle both the case of // This condition is very tricky; there's only one right way to handle both the case of
// negative/positive zero and NaN properly. // negative/positive zero and NaN properly.
// (a >= -0.0 ? c : b) transforms into (0 > a ? b : c), hence the NLE. // (a >= -0.0 ? c : b) transforms into (0 > a ? b : c), hence the NLE.
if (packed) if (packed)
CMPPD(XMM0, fpr.R(a), CMP_NLE); CMPPD(XMM0, Ra, CMP_NLE);
else else
CMPSD(XMM0, fpr.R(a), CMP_NLE); CMPSD(XMM0, Ra, CMP_NLE);
if (cpu_info.bSSE4_1) if (cpu_info.bSSE4_1)
{ {
MOVAPD(XMM1, fpr.R(c)); MOVAPD(XMM1, Rc);
BLENDVPD(XMM1, fpr.R(b)); BLENDVPD(XMM1, Rb);
} }
else else
{ {
MOVAPD(XMM1, R(XMM0)); MOVAPD(XMM1, R(XMM0));
ANDPD(XMM0, fpr.R(b)); ANDPD(XMM0, Rb);
ANDNPD(XMM1, fpr.R(c)); ANDNPD(XMM1, Rc);
ORPD(XMM1, R(XMM0)); ORPD(XMM1, R(XMM0));
} }
fpr.BindToRegister(d, !packed);
if (packed) if (packed)
MOVAPD(fpr.RX(d), R(XMM1)); MOVAPD(Rd, R(XMM1));
else else
MOVSD(fpr.RX(d), R(XMM1)); MOVSD(Rd, R(XMM1));
fpr.UnlockAll();
} }
void Jit64::fmrx(UGeckoInstruction inst) void Jit64::fmrx(UGeckoInstruction inst)