Jit_FloatingPoint: HandleNaNs

This commit is contained in:
MerryMage 2018-10-15 21:02:05 +01:00
parent 0a96da578e
commit 96b86a9bc4
1 changed files with 15 additions and 10 deletions

View File

@ -76,7 +76,9 @@ void Jit64::HandleNaNs(UGeckoInstruction inst, X64Reg xmm_out, X64Reg xmm, X64Re
std::vector<FixupBranch> fixups; std::vector<FixupBranch> fixups;
for (u32 x : inputs) for (u32 x : inputs)
{ {
MOVDDUP(xmm, fpr.R(x)); RCOpArg Rx = fpr.Use(x, RCMode::Read);
RegCache::Realize(Rx);
MOVDDUP(xmm, Rx);
UCOMISD(xmm, R(xmm)); UCOMISD(xmm, R(xmm));
fixups.push_back(J_CC(CC_P)); fixups.push_back(J_CC(CC_P));
} }
@ -102,8 +104,10 @@ void Jit64::HandleNaNs(UGeckoInstruction inst, X64Reg xmm_out, X64Reg xmm, X64Re
BLENDVPD(xmm, MConst(psGeneratedQNaN)); BLENDVPD(xmm, MConst(psGeneratedQNaN));
for (u32 x : inputs) for (u32 x : inputs)
{ {
avx_op(&XEmitter::VCMPPD, &XEmitter::CMPPD, clobber, fpr.R(x), fpr.R(x), CMP_UNORD); RCOpArg Rx = fpr.Use(x, RCMode::Read);
BLENDVPD(xmm, fpr.R(x)); RegCache::Realize(Rx);
avx_op(&XEmitter::VCMPPD, &XEmitter::CMPPD, clobber, Rx, Rx, CMP_UNORD);
BLENDVPD(xmm, Rx);
} }
FixupBranch done = J(true); FixupBranch done = J(true);
SwitchToNearCode(); SwitchToNearCode();
@ -112,8 +116,8 @@ void Jit64::HandleNaNs(UGeckoInstruction inst, X64Reg xmm_out, X64Reg xmm, X64Re
else else
{ {
// SSE2 fallback // SSE2 fallback
X64Reg tmp = fpr.GetFreeXReg(); RCX64Reg tmp = fpr.Scratch(fpr.GetFreeXReg());
fpr.FlushLockX(tmp); RegCache::Realize(tmp);
MOVAPD(clobber, R(xmm)); MOVAPD(clobber, R(xmm));
CMPPD(clobber, R(clobber), CMP_UNORD); CMPPD(clobber, R(clobber), CMP_UNORD);
MOVMSKPD(RSCRATCH, R(clobber)); MOVMSKPD(RSCRATCH, R(clobber));
@ -125,20 +129,21 @@ void Jit64::HandleNaNs(UGeckoInstruction inst, X64Reg xmm_out, X64Reg xmm, X64Re
ANDNPD(clobber, R(xmm)); ANDNPD(clobber, R(xmm));
ANDPD(tmp, MConst(psGeneratedQNaN)); ANDPD(tmp, MConst(psGeneratedQNaN));
ORPD(tmp, R(clobber)); ORPD(tmp, R(clobber));
MOVAPD(xmm, R(tmp)); MOVAPD(xmm, tmp);
for (u32 x : inputs) for (u32 x : inputs)
{ {
MOVAPD(clobber, fpr.R(x)); RCOpArg Rx = fpr.Use(x, RCMode::Read);
RegCache::Realize(Rx);
MOVAPD(clobber, Rx);
CMPPD(clobber, R(clobber), CMP_ORD); CMPPD(clobber, R(clobber), CMP_ORD);
MOVAPD(tmp, R(clobber)); MOVAPD(tmp, R(clobber));
ANDNPD(clobber, fpr.R(x)); ANDNPD(clobber, Rx);
ANDPD(xmm, R(tmp)); ANDPD(xmm, tmp);
ORPD(xmm, R(clobber)); ORPD(xmm, R(clobber));
} }
FixupBranch done = J(true); FixupBranch done = J(true);
SwitchToNearCode(); SwitchToNearCode();
SetJumpTarget(done); SetJumpTarget(done);
fpr.UnlockX(tmp);
} }
} }
if (xmm_out != xmm) if (xmm_out != xmm)