From b18dd442f7b6790936f9e9f0287236ead0aee53f Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 27 May 2018 16:08:23 -0400 Subject: [PATCH] Interpreter_FPUtils: Set FPSCR.VXSNAN if either operand to NI_sub is a signaling NaN If either operand is a signaling NaN, we need to signify this by setting the VXSNAN bit. This fixes NaN flag setting for fsub, fsubs, and ps_sub instructions. --- .../Core/Core/PowerPC/Interpreter/Interpreter_FPUtils.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter_FPUtils.h b/Source/Core/Core/PowerPC/Interpreter/Interpreter_FPUtils.h index 5a583b7892..7273b62e7f 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter_FPUtils.h +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter_FPUtils.h @@ -165,16 +165,22 @@ inline double NI_add(double a, double b) inline double NI_sub(double a, double b) { - double t = a - b; + const double t = a - b; + if (std::isnan(t)) { + if (Common::IsSNAN(a) || Common::IsSNAN(b)) + SetFPException(FPSCR_VXSNAN); + if (std::isnan(a)) return MakeQuiet(a); if (std::isnan(b)) return MakeQuiet(b); + SetFPException(FPSCR_VXISI); return PPC_NAN; } + return t; }