From 13e9d5c889cea23228c57676bd964e788824c547 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sat, 8 Oct 2022 22:36:14 +0200 Subject: [PATCH] Jit64: Improve register handling in fp_arith This lets us avoid the "ugly" case. --- .../Core/PowerPC/Jit64/Jit_FloatingPoint.cpp | 37 ++++--------------- 1 file changed, 8 insertions(+), 29 deletions(-) diff --git a/Source/Core/Core/PowerPC/Jit64/Jit_FloatingPoint.cpp b/Source/Core/Core/PowerPC/Jit64/Jit_FloatingPoint.cpp index 8deabd3b00..4723c1c2cf 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit_FloatingPoint.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit_FloatingPoint.cpp @@ -282,7 +282,9 @@ void Jit64::fp_arith(UGeckoInstruction inst) RCOpArg Rarg2 = fpr.Use(arg2, RCMode::Read); RegCache::Realize(Rd, Ra, Rarg2); - X64Reg dest = preserve_inputs ? XMM1 : static_cast(Rd); + X64Reg dest = X64Reg(Rd); + if (preserve_inputs && (a == d || arg2 == d)) + dest = XMM1; if (round_rhs) { if (a == d && !preserve_inputs) @@ -314,39 +316,16 @@ void Jit64::fp_arith(UGeckoInstruction inst) { (this->*avxOp)(dest, Rarg2.GetSimpleReg(), Ra); } - else if (!Rarg2.IsSimpleReg(dest)) + else { + if (Rarg2.IsSimpleReg(dest)) + dest = XMM1; + if (packed) MOVAPD(dest, Ra); else MOVSD(dest, Ra); - (this->*sseOp)(dest, OpArg(Ra) == OpArg(Rarg2) ? R(dest) : Rarg2); - } - else if (reversible && !Ra.IsSimpleReg(dest)) - { - if (packed) - MOVAPD(dest, Rarg2); - else - MOVSD(dest, Rarg2); - (this->*sseOp)(dest, OpArg(Ra) == OpArg(Rarg2) ? R(dest) : Ra); - } - else - { - // The ugly case: Not reversible, and we have dest == Rarg2 without AVX or with Ra == memory - if (!Ra.IsSimpleReg(XMM0)) - MOVAPD(XMM0, Ra); - if (cpu_info.bAVX) - { - (this->*avxOp)(dest, XMM0, Rarg2); - } - else - { - (this->*sseOp)(XMM0, Rarg2); - if (packed) - MOVAPD(dest, R(XMM0)); - else - MOVSD(dest, R(XMM0)); - } + (this->*sseOp)(dest, a == arg2 ? R(dest) : Rarg2); } }