mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-05-02 14:58:03 +03:00
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:
parent
860c889454
commit
09319a1e11
1 changed files with 25 additions and 24 deletions
|
@ -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,6 +39,18 @@ void Interpreter::Helper_FloatCompareOrdered(UGeckoInstruction _inst, double fa,
|
||||||
SetFPException(FPSCR_VXVC);
|
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;
|
FPSCR.FPRF = compareResult;
|
||||||
SetCRField(_inst.CRFD, compareResult);
|
SetCRField(_inst.CRFD, compareResult);
|
||||||
|
@ -60,7 +60,17 @@ void Interpreter::Helper_FloatCompareUnordered(UGeckoInstruction _inst, double f
|
||||||
{
|
{
|
||||||
int compareResult;
|
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;
|
compareResult = FPCC::FL;
|
||||||
}
|
}
|
||||||
|
@ -68,19 +78,10 @@ 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
|
|
||||||
{
|
|
||||||
compareResult = FPCC::FU;
|
|
||||||
if (IsSNAN(fa) || IsSNAN(fb))
|
|
||||||
{
|
|
||||||
FPSCR.FX = 1;
|
|
||||||
SetFPException(FPSCR_VXSNAN);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FPSCR.FPRF = compareResult;
|
FPSCR.FPRF = compareResult;
|
||||||
SetCRField(_inst.CRFD, compareResult);
|
SetCRField(_inst.CRFD, compareResult);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue