Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Tilka authored and degasus committed Oct 15, 2013
1 parent b451331 commit c234dc9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 39 deletions.
35 changes: 15 additions & 20 deletions Source/Core/Core/Src/PowerPC/Jit64/Jit_FloatingPoint.cpp
Expand Up @@ -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));
Expand Down Expand Up @@ -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
Expand Down
33 changes: 14 additions & 19 deletions Source/Core/Core/Src/PowerPC/Jit64/Jit_Paired.cpp
Expand Up @@ -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();
}
Expand Down

0 comments on commit c234dc9

Please sign in to comment.