summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2015-02-21 22:23:48 -0500
committerLioncash <mathew1800@gmail.com>2015-02-21 22:26:23 -0500
commit09319a1e118c3885372c4e7ea07f4526630a111e (patch)
tree7c7c25cfe9a6905f4f7fc2653dfb8f25a5ee59c3 /Source
parent860c889454635c0f4f7cf601f8ec77c7b81c19cd (diff)
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.
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/Core/PowerPC/Interpreter/Interpreter_FloatingPoint.cpp49
1 files changed, 25 insertions, 24 deletions
diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter_FloatingPoint.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter_FloatingPoint.cpp
index 31850a1c25..a469e3ccbb 100644
--- a/Source/Core/Core/PowerPC/Interpreter/Interpreter_FloatingPoint.cpp
+++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter_FloatingPoint.cpp
@@ -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);