Interpreter: Rearrange ordered/unordered compares

Comparing floating point numbers with == can trigger warnings (and have static analysis tools complain). So we make it the else case.
This also more closely resembles the Gekko manual.
This commit is contained in:
Lioncash 2015-02-21 22:23:48 -05:00
parent 860c889454
commit 09319a1e11

View file

@ -22,19 +22,7 @@ void Interpreter::Helper_FloatCompareOrdered(UGeckoInstruction _inst, double fa,
{
int compareResult;
if (fa < fb)
{
compareResult = FPCC::FL;
}
else if (fa > fb)
{
compareResult = FPCC::FG;
}
else if (fa == fb)
{
compareResult = FPCC::FE;
}
else // NaN
if (IsNAN(fa) || IsNAN(fb))
{
FPSCR.FX = 1;
compareResult = FPCC::FU;
@ -51,6 +39,18 @@ void Interpreter::Helper_FloatCompareOrdered(UGeckoInstruction _inst, double fa,
SetFPException(FPSCR_VXVC);
}
}
else if (fa < fb)
{
compareResult = FPCC::FL;
}
else if (fa > fb)
{
compareResult = FPCC::FG;
}
else // Equals
{
compareResult = FPCC::FE;
}
FPSCR.FPRF = compareResult;
SetCRField(_inst.CRFD, compareResult);
@ -60,7 +60,17 @@ void Interpreter::Helper_FloatCompareUnordered(UGeckoInstruction _inst, double f
{
int compareResult;
if (fa < fb)
if (IsNAN(fa) || IsNAN(fb))
{
compareResult = FPCC::FU;
if (IsSNAN(fa) || IsSNAN(fb))
{
FPSCR.FX = 1;
SetFPException(FPSCR_VXSNAN);
}
}
else if (fa < fb)
{
compareResult = FPCC::FL;
}
@ -68,19 +78,10 @@ void Interpreter::Helper_FloatCompareUnordered(UGeckoInstruction _inst, double f
{
compareResult = FPCC::FG;
}
else if (fa == fb)
else // Equals
{
compareResult = FPCC::FE;
}
else
{
compareResult = FPCC::FU;
if (IsSNAN(fa) || IsSNAN(fb))
{
FPSCR.FX = 1;
SetFPException(FPSCR_VXSNAN);
}
}
FPSCR.FPRF = compareResult;
SetCRField(_inst.CRFD, compareResult);