Permalink
Browse files

Merge pull request #6993 from lioncash/nan

Interpreter_FPUtils: Set VXSNAN if any input operands are a signaling NaN in remaining NI_* functions
  • Loading branch information...
leoetlino committed May 28, 2018
2 parents 6865921 + a4cc854 commit a9f022a06770b7236ac6037ec0cb36c08222424e
Showing with 38 additions and 2 deletions.
  1. +38 −2 Source/Core/Core/PowerPC/Interpreter/Interpreter_FPUtils.h
@@ -113,13 +113,18 @@ inline double NI_mul(double a, double b)
inline double NI_div(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);
if (b == 0.0)
{
SetFPException(FPSCR_ZX);
@@ -130,8 +135,10 @@ inline double NI_div(double a, double b)
{
SetFPException(FPSCR_VXIDI);
}
return PPC_NAN;
}
return t;
}
@@ -158,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;
}
@@ -177,51 +190,74 @@ inline double NI_sub(double a, double b)
inline double NI_madd(double a, double c, double b)
{
double t = a * c;
if (std::isnan(t))
{
if (Common::IsSNAN(a) || Common::IsSNAN(b) || Common::IsSNAN(c))
SetFPException(FPSCR_VXSNAN);
if (std::isnan(a))
return MakeQuiet(a);
if (std::isnan(b))
return MakeQuiet(b); // !
if (std::isnan(c))
return MakeQuiet(c);
SetFPException(FPSCR_VXIMZ);
return PPC_NAN;
}
t += b;
if (std::isnan(t))
{
if (Common::IsSNAN(b))
SetFPException(FPSCR_VXSNAN);
if (std::isnan(b))
return MakeQuiet(b);
SetFPException(FPSCR_VXISI);
return PPC_NAN;
}
return t;
}
inline double NI_msub(double a, double c, double b)
{
double t = a * c;
if (std::isnan(t))
{
if (Common::IsSNAN(a) || Common::IsSNAN(b) || Common::IsSNAN(c))
SetFPException(FPSCR_VXSNAN);
if (std::isnan(a))
return MakeQuiet(a);
if (std::isnan(b))
return MakeQuiet(b); // !
if (std::isnan(c))
return MakeQuiet(c);
SetFPException(FPSCR_VXIMZ);
return PPC_NAN;
}
t -= b;
if (std::isnan(t))
{
if (Common::IsSNAN(b))
SetFPException(FPSCR_VXSNAN);
if (std::isnan(b))
return MakeQuiet(b);
SetFPException(FPSCR_VXISI);
return PPC_NAN;
}
return t;
}

0 comments on commit a9f022a

Please sign in to comment.