From c234dc97c00cf5d47313478ef3896a52b461fef1 Mon Sep 17 00:00:00 2001 From: Tillmann Karras Date: Tue, 15 Oct 2013 23:47:35 +0200 Subject: [PATCH] Jit64: optimize floating-point/paired-single arith The "else if (b != d)" branch was dead code and only works if b == d. Now the last else block with two temporary XMM registers is not needed anymore. --- .../Src/PowerPC/Jit64/Jit_FloatingPoint.cpp | 35 ++++++++----------- .../Core/Src/PowerPC/Jit64/Jit_Paired.cpp | 33 ++++++++--------- 2 files changed, 29 insertions(+), 39 deletions(-) diff --git a/Source/Core/Core/Src/PowerPC/Jit64/Jit_FloatingPoint.cpp b/Source/Core/Core/Src/PowerPC/Jit64/Jit_FloatingPoint.cpp index a04114d110..c157903726 100644 --- a/Source/Core/Core/Src/PowerPC/Jit64/Jit_FloatingPoint.cpp +++ b/Source/Core/Core/Src/PowerPC/Jit64/Jit_FloatingPoint.cpp @@ -25,33 +25,28 @@ void Jit64::fp_tri_op(int d, int a, int b, bool reversible, bool dupe, void (XEm fpr.BindToRegister(d, true); (this->*op)(fpr.RX(d), fpr.R(b)); } - else if (d == b && reversible) + else if (d == b) { - fpr.BindToRegister(d, true); - (this->*op)(fpr.RX(d), fpr.R(a)); + if (reversible) + { + fpr.BindToRegister(d, true); + (this->*op)(fpr.RX(d), fpr.R(a)); + } + else + { + MOVSD(XMM0, fpr.R(b)); + fpr.BindToRegister(d, !dupe); + MOVSD(fpr.RX(d), fpr.R(a)); + (this->*op)(fpr.RX(d), Gen::R(XMM0)); + } } - else if (a != d && b != d) + else { // Sources different from d, can use rather quick solution fpr.BindToRegister(d, !dupe); MOVSD(fpr.RX(d), fpr.R(a)); (this->*op)(fpr.RX(d), fpr.R(b)); } - else if (b != d) - { - fpr.BindToRegister(d, !dupe); - MOVSD(XMM0, fpr.R(b)); - MOVSD(fpr.RX(d), fpr.R(a)); - (this->*op)(fpr.RX(d), Gen::R(XMM0)); - } - else // Other combo, must use two temps :( - { - MOVSD(XMM0, fpr.R(a)); - MOVSD(XMM1, fpr.R(b)); - fpr.BindToRegister(d, !dupe); - (this->*op)(XMM0, Gen::R(XMM1)); - MOVSD(fpr.RX(d), Gen::R(XMM0)); - } if (dupe) { ForceSinglePrecisionS(fpr.RX(d)); @@ -83,7 +78,7 @@ void Jit64::fp_arith_s(UGeckoInstruction inst) // Causing problems for GC - Starfox Assault (invisible boss at the end of level 1) if (inst.SUBOP5 == 21) { Default(inst); return; - } + } if (inst.SUBOP5 == 26) { // frsqrtex diff --git a/Source/Core/Core/Src/PowerPC/Jit64/Jit_Paired.cpp b/Source/Core/Core/Src/PowerPC/Jit64/Jit_Paired.cpp index b58a140497..074a79740d 100644 --- a/Source/Core/Core/Src/PowerPC/Jit64/Jit_Paired.cpp +++ b/Source/Core/Core/Src/PowerPC/Jit64/Jit_Paired.cpp @@ -152,33 +152,28 @@ void Jit64::tri_op(int d, int a, int b, bool reversible, void (XEmitter::*op)(X6 fpr.BindToRegister(d, true); (this->*op)(fpr.RX(d), fpr.R(b)); } - else if (d == b && reversible) + else if (d == b) { - fpr.BindToRegister(d, true); - (this->*op)(fpr.RX(d), fpr.R(a)); + if (reversible) + { + fpr.BindToRegister(d, true); + (this->*op)(fpr.RX(d), fpr.R(a)); + } + else + { + MOVAPD(XMM0, fpr.R(b)); + fpr.BindToRegister(d, false); + MOVAPD(fpr.RX(d), fpr.R(a)); + (this->*op)(fpr.RX(d), Gen::R(XMM0)); + } } - else if (a != d && b != d) + else { //sources different from d, can use rather quick solution fpr.BindToRegister(d, false); MOVAPD(fpr.RX(d), fpr.R(a)); (this->*op)(fpr.RX(d), fpr.R(b)); } - else if (b != d) - { - fpr.BindToRegister(d, false); - MOVAPD(XMM0, fpr.R(b)); - MOVAPD(fpr.RX(d), fpr.R(a)); - (this->*op)(fpr.RX(d), Gen::R(XMM0)); - } - else //Other combo, must use two temps :( - { - MOVAPD(XMM0, fpr.R(a)); - MOVAPD(XMM1, fpr.R(b)); - fpr.BindToRegister(d, false); - (this->*op)(XMM0, Gen::R(XMM1)); - MOVAPD(fpr.RX(d), Gen::R(XMM0)); - } ForceSinglePrecisionP(fpr.RX(d)); fpr.UnlockAll(); }