From cbceae917663d0387deae0280b1e196eb7520cb2 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Fri, 25 Nov 2022 22:36:06 +0100 Subject: [PATCH] Jit64: Correctly handle NaNs for ps_mulsX --- Source/Core/Core/PowerPC/Jit64/Jit_Paired.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Source/Core/Core/PowerPC/Jit64/Jit_Paired.cpp b/Source/Core/Core/PowerPC/Jit64/Jit_Paired.cpp index fe42929ce1..160cd77497 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit_Paired.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit_Paired.cpp @@ -98,23 +98,26 @@ void Jit64::ps_muls(UGeckoInstruction inst) RCOpArg Ra = fpr.Use(a, RCMode::Read); RCOpArg Rc = fpr.Use(c, RCMode::Read); RCX64Reg Rd = fpr.Bind(d, RCMode::Write); - RegCache::Realize(Ra, Rc, Rd); + RCX64Reg Rc_duplicated = m_accurate_nans ? fpr.Scratch() : fpr.Scratch(XMM1); + RegCache::Realize(Ra, Rc, Rd, Rc_duplicated); switch (inst.SUBOP5) { case 12: // ps_muls0 - MOVDDUP(XMM1, Rc); + MOVDDUP(Rc_duplicated, Rc); break; case 13: // ps_muls1 - avx_op(&XEmitter::VSHUFPD, &XEmitter::SHUFPD, XMM1, Rc, Rc, 3); + avx_op(&XEmitter::VSHUFPD, &XEmitter::SHUFPD, Rc_duplicated, Rc, Rc, 3); break; default: PanicAlertFmt("ps_muls WTF!!!"); } if (round_input) - Force25BitPrecision(XMM1, R(XMM1), XMM0); + Force25BitPrecision(XMM1, R(Rc_duplicated), XMM0); + else if (XMM1 != Rc_duplicated) + MOVAPD(XMM1, Rc_duplicated); MULPD(XMM1, Ra); - HandleNaNs(inst, XMM1, XMM0, Ra, std::nullopt, Rc); + HandleNaNs(inst, XMM1, XMM0, Ra, std::nullopt, Rc_duplicated); FinalizeSingleResult(Rd, R(XMM1)); }