Merge pull request #2095 from lioncash/correctness
Interpreter: Set the FPCC bits correctly for ordered/unordered compares.
This commit is contained in:
commit
8cd32e171a
|
@ -22,19 +22,7 @@ void Interpreter::Helper_FloatCompareOrdered(UGeckoInstruction _inst, double fa,
|
||||||
{
|
{
|
||||||
int compareResult;
|
int compareResult;
|
||||||
|
|
||||||
if (fa < fb)
|
if (IsNAN(fa) || IsNAN(fb))
|
||||||
{
|
|
||||||
compareResult = FPCC::FL;
|
|
||||||
}
|
|
||||||
else if (fa > fb)
|
|
||||||
{
|
|
||||||
compareResult = FPCC::FG;
|
|
||||||
}
|
|
||||||
else if (fa == fb)
|
|
||||||
{
|
|
||||||
compareResult = FPCC::FE;
|
|
||||||
}
|
|
||||||
else // NaN
|
|
||||||
{
|
{
|
||||||
FPSCR.FX = 1;
|
FPSCR.FX = 1;
|
||||||
compareResult = FPCC::FU;
|
compareResult = FPCC::FU;
|
||||||
|
@ -51,16 +39,7 @@ void Interpreter::Helper_FloatCompareOrdered(UGeckoInstruction _inst, double fa,
|
||||||
SetFPException(FPSCR_VXVC);
|
SetFPException(FPSCR_VXVC);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (fa < fb)
|
||||||
FPSCR.FPRF = compareResult;
|
|
||||||
SetCRField(_inst.CRFD, compareResult);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Interpreter::Helper_FloatCompareUnordered(UGeckoInstruction _inst, double fa, double fb)
|
|
||||||
{
|
|
||||||
int compareResult;
|
|
||||||
|
|
||||||
if (fa < fb)
|
|
||||||
{
|
{
|
||||||
compareResult = FPCC::FL;
|
compareResult = FPCC::FL;
|
||||||
}
|
}
|
||||||
|
@ -68,21 +47,47 @@ void Interpreter::Helper_FloatCompareUnordered(UGeckoInstruction _inst, double f
|
||||||
{
|
{
|
||||||
compareResult = FPCC::FG;
|
compareResult = FPCC::FG;
|
||||||
}
|
}
|
||||||
else if (fa == fb)
|
else // Equals
|
||||||
{
|
{
|
||||||
compareResult = FPCC::FE;
|
compareResult = FPCC::FE;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
// Clear and set the FPCC bits accordingly.
|
||||||
|
FPSCR.FPRF = (FPSCR.FPRF & ~0xF) | compareResult;
|
||||||
|
|
||||||
|
SetCRField(_inst.CRFD, compareResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Interpreter::Helper_FloatCompareUnordered(UGeckoInstruction _inst, double fa, double fb)
|
||||||
|
{
|
||||||
|
int compareResult;
|
||||||
|
|
||||||
|
if (IsNAN(fa) || IsNAN(fb))
|
||||||
{
|
{
|
||||||
compareResult = FPCC::FU;
|
compareResult = FPCC::FU;
|
||||||
|
|
||||||
if (IsSNAN(fa) || IsSNAN(fb))
|
if (IsSNAN(fa) || IsSNAN(fb))
|
||||||
{
|
{
|
||||||
FPSCR.FX = 1;
|
FPSCR.FX = 1;
|
||||||
SetFPException(FPSCR_VXSNAN);
|
SetFPException(FPSCR_VXSNAN);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (fa < fb)
|
||||||
|
{
|
||||||
|
compareResult = FPCC::FL;
|
||||||
|
}
|
||||||
|
else if (fa > fb)
|
||||||
|
{
|
||||||
|
compareResult = FPCC::FG;
|
||||||
|
}
|
||||||
|
else // Equals
|
||||||
|
{
|
||||||
|
compareResult = FPCC::FE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear and set the FPCC bits accordingly.
|
||||||
|
FPSCR.FPRF = (FPSCR.FPRF & ~0xF) | compareResult;
|
||||||
|
|
||||||
FPSCR.FPRF = compareResult;
|
|
||||||
SetCRField(_inst.CRFD, compareResult);
|
SetCRField(_inst.CRFD, compareResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue