summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorMarkus Wick <degasus@users.noreply.github.com>2018-05-17 10:43:14 +0200
committerGitHub <noreply@github.com>2018-05-17 10:43:14 +0200
commit6ed3f8b474be5555b196e1b7f240cbfa778d0d8d (patch)
treed03bfa2a932e63658a955273d3f01df11c78046e /Source
parent3e6a70685891d18d9b69b180f06b273058058dc2 (diff)
parenta36bf438cde503f98964af16a958891ad9cd8ff9 (diff)
Merge pull request #6634 from lioncash/frsp
Interpreter_FloatingPoint: Handle SNaNs and QNaNs properly in frsp
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/Core/PowerPC/Interpreter/Interpreter_FloatingPoint.cpp34
1 files changed, 28 insertions, 6 deletions
diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter_FloatingPoint.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter_FloatingPoint.cpp
index 5ef3ff035a..b2df0f9b71 100644
--- a/Source/Core/Core/PowerPC/Interpreter/Interpreter_FloatingPoint.cpp
+++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter_FloatingPoint.cpp
@@ -276,12 +276,34 @@ void Interpreter::fselx(UGeckoInstruction inst)
// PS1 is said to be undefined
void Interpreter::frspx(UGeckoInstruction inst) // round to single
{
- double b = rPS0(inst.FB);
- double rounded = ForceSingle(b);
- SetFI(b != rounded);
- FPSCR.FR = fabs(rounded) > fabs(b);
- PowerPC::UpdateFPRF(rounded);
- rPS0(inst.FD) = rPS1(inst.FD) = rounded;
+ const double b = rPS0(inst.FB);
+ const double rounded = ForceSingle(b);
+
+ if (std::isnan(b))
+ {
+ const bool is_snan = MathUtil::IsSNAN(b);
+
+ if (is_snan)
+ SetFPException(FPSCR_VXSNAN);
+
+ if (!is_snan || FPSCR.VE == 0)
+ {
+ rPS0(inst.FD) = rounded;
+ rPS1(inst.FD) = rounded;
+ PowerPC::UpdateFPRF(b);
+ }
+
+ SetFI(0);
+ FPSCR.FR = 0;
+ }
+ else
+ {
+ SetFI(b != rounded);
+ FPSCR.FR = fabs(rounded) > fabs(b);
+ PowerPC::UpdateFPRF(rounded);
+ rPS0(inst.FD) = rounded;
+ rPS1(inst.FD) = rounded;
+ }
if (inst.Rc)
Helper_UpdateCR1();