FPU: not need to check NaN, slightly faster. The fcmpo opcode is used a lot, really need to be much faster than it is now.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4284 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
rice1964 2009-09-16 06:07:36 +00:00
parent f7e15ec7f2
commit ce029df144
2 changed files with 51 additions and 18 deletions

View File

@ -59,8 +59,24 @@ void fcmpo(UGeckoInstruction _inst)
double fb = rPS0(_inst.FB);
int compareResult;
if (IsNAN(fa) || IsNAN(fb))
//if (IsNAN(fa) || IsNAN(fb))
//{
// FPSCR.FX = 1;
// compareResult = 1;
// if (IsSNAN(fa) || IsSNAN(fb))
// {
// FPSCR.VXSNAN = 1;
// if (!FPSCR.FEX || IsQNAN(fa) || IsQNAN(fb))
// FPSCR.VXVC = 1;
// }
//}
//else
if (fa < fb) compareResult = 8;
else if (fa > fb) compareResult = 4;
else if (fa == fb) compareResult = 2;
else
{
// either fa or fb is NaN, or both,
FPSCR.FX = 1;
compareResult = 1;
if (IsSNAN(fa) || IsSNAN(fb))
@ -69,10 +85,8 @@ void fcmpo(UGeckoInstruction _inst)
if (!FPSCR.FEX || IsQNAN(fa) || IsQNAN(fb))
FPSCR.VXVC = 1;
}
}
else if (fa < fb) compareResult = 8;
else if (fa > fb) compareResult = 4;
else compareResult = 2;
FPSCR.FPRF = compareResult;
SetCRField(_inst.CRFD, compareResult);
@ -86,8 +100,22 @@ void fcmpu(UGeckoInstruction _inst)
double fb = rPS0(_inst.FB);
int compareResult;
if (IsNAN(fa) || IsNAN(fb))
//if (IsNAN(fa) || IsNAN(fb))
//{
// FPSCR.FX = 1;
// compareResult = 1;
// if (IsSNAN(fa) || IsSNAN(fb))
// {
// FPSCR.VXSNAN = 1;
// }
//}
//else
if (fa < fb) compareResult = 8;
else if (fa > fb) compareResult = 4;
else if (fa == fb) compareResult = 2;
else
{
// either fa or fb is NaN, or both
FPSCR.FX = 1;
compareResult = 1;
if (IsSNAN(fa) || IsSNAN(fb))
@ -95,9 +123,6 @@ void fcmpu(UGeckoInstruction _inst)
FPSCR.VXSNAN = 1;
}
}
else if (fa < fb) compareResult = 8;
else if (fa > fb) compareResult = 4;
else compareResult = 2;
FPSCR.FPRF = compareResult;
SetCRField(_inst.CRFD, compareResult);

View File

@ -29,10 +29,14 @@ namespace Interpreter
// These "binary instructions" do not alter FPSCR.
void ps_sel(UGeckoInstruction _inst)
{
rPS0(_inst.FD) = !IsNAN(rPS0(_inst.FA)) && rPS0(_inst.FA) >= -0.0 ?
rPS0(_inst.FC) : rPS0(_inst.FB);
rPS1(_inst.FD) = !IsNAN(rPS1(_inst.FA)) && rPS1(_inst.FA) >= -0.0 ?
rPS1(_inst.FC) : rPS1(_inst.FB);
//rPS0(_inst.FD) = !IsNAN(rPS0(_inst.FA)) && rPS0(_inst.FA) >= -0.0 ?
// rPS0(_inst.FC) : rPS0(_inst.FB);
//rPS1(_inst.FD) = !IsNAN(rPS1(_inst.FA)) && rPS1(_inst.FA) >= -0.0 ?
// rPS1(_inst.FC) : rPS1(_inst.FB);
// no need to check isNaN
rPS0(_inst.FD) = rPS0(_inst.FA) >= -0.0 ? rPS0(_inst.FC) : rPS0(_inst.FB);
rPS1(_inst.FD) = rPS1(_inst.FA) >= -0.0 ? rPS1(_inst.FC) : rPS1(_inst.FB);
if (_inst.Rc) Helper_UpdateCR1(rPS0(_inst.FD));
}
@ -243,10 +247,12 @@ void ps_cmpu0(UGeckoInstruction _inst)
double fa = rPS0(_inst.FA);
double fb = rPS0(_inst.FB);
int compareResult;
if (IsNAN(fa) || IsNAN(fb)) compareResult = 1;
else if (fa < fb) compareResult = 8;
//if (IsNAN(fa) || IsNAN(fb)) compareResult = 1;
//else
if (fa < fb) compareResult = 8;
else if (fa > fb) compareResult = 4;
else compareResult = 2;
else if (fa == fb) compareResult = 2;
else compareResult = 1;
SetCRField(_inst.CRFD, compareResult);
if (_inst.Rc) Helper_UpdateCR1(rPS0(_inst.FD));
}
@ -262,10 +268,12 @@ void ps_cmpu1(UGeckoInstruction _inst)
double fa = rPS1(_inst.FA);
double fb = rPS1(_inst.FB);
int compareResult;
if (IsNAN(fa) || IsNAN(fb)) compareResult = 1;
else if (fa < fb) compareResult = 8;
//if (IsNAN(fa) || IsNAN(fb)) compareResult = 1;
//else
if (fa < fb) compareResult = 8;
else if (fa > fb) compareResult = 4;
else compareResult = 2;
else if (fa == fb) compareResult = 2;
else compareResult = 1;
SetCRField(_inst.CRFD, compareResult);
if (_inst.Rc) Helper_UpdateCR1(rPS0(_inst.FD));
}