Skip to content

Commit

Permalink
Interpreter: optimize NaN checks
Browse files Browse the repository at this point in the history
NaNs always propagate, so we can get away with only checking for NaN
inputs in the rare case that the result is NaN (as already done in
Jit64::HandleNaNs()).
  • Loading branch information
Tilka committed Jun 10, 2015
1 parent 9b8eb55 commit d3e6520
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions Source/Core/Core/PowerPC/Interpreter/Interpreter_FPUtils.h
Expand Up @@ -83,11 +83,11 @@ inline double Force25Bit(double d)

inline double NI_mul(double a, double b)
{
if (a != a) return a;
if (b != b) return b;
double t = a * b;
if (t != t)
{
if (a != a) return a;
if (b != b) return b;
SetFPException(FPSCR_VXIMZ);
return PPC_NAN;
}
Expand All @@ -96,11 +96,11 @@ inline double NI_mul(double a, double b)

inline double NI_add(double a, double b)
{
if (a != a) return a;
if (b != b) return b;
double t = a + b;
if (t != t)
{
if (a != a) return a;
if (b != b) return b;
SetFPException(FPSCR_VXISI);
return PPC_NAN;
}
Expand All @@ -109,11 +109,11 @@ inline double NI_add(double a, double b)

inline double NI_sub(double a, double b)
{
if (a != a) return a;
if (b != b) return b;
double t = a - b;
if (t != t)
{
if (a != a) return a;
if (b != b) return b;
SetFPException(FPSCR_VXISI);
return PPC_NAN;
}
Expand All @@ -122,18 +122,19 @@ inline double NI_sub(double a, double b)

inline double NI_madd(double a, double c, double b, bool negate = false)
{
if (a != a) return a;
if (b != b) return b;
if (c != c) return c;
double t = a * c;
if (t != t)
{
if (a != a) return a;
if (b != b) return b;
if (c != c) return c;
SetFPException(FPSCR_VXIMZ);
return PPC_NAN;
}
t = t + b;
if (t != t)
{
if (b != b) return b;
SetFPException(FPSCR_VXISI);
return PPC_NAN;
}
Expand All @@ -142,19 +143,20 @@ inline double NI_madd(double a, double c, double b, bool negate = false)

inline double NI_msub(double a, double c, double b, bool negate = false)
{
if (a != a) return a;
if (b != b) return b;
if (c != c) return c;
double t = a * c;
if (t != t)
{
if (a != a) return a;
if (b != b) return b;
if (c != c) return c;
SetFPException(FPSCR_VXIMZ);
return PPC_NAN;
}

t = t - b;
if (t != t)
{
if (b != b) return b;
SetFPException(FPSCR_VXISI);
return PPC_NAN;
}
Expand Down

0 comments on commit d3e6520

Please sign in to comment.