Interpreter: use std::isnan(x) instead of x != x

This commit is contained in:
Tillmann Karras 2015-06-10 14:31:08 +02:00
parent c7544719e2
commit d329147871
1 changed files with 24 additions and 23 deletions

View File

@ -4,6 +4,7 @@
#pragma once
#include <cmath>
#include <limits>
#include "Common/CPUDetect.h"
@ -84,10 +85,10 @@ inline double Force25Bit(double d)
inline double NI_mul(double a, double b)
{
double t = a * b;
if (t != t)
if (std::isnan(t))
{
if (a != a) return a;
if (b != b) return b;
if (std::isnan(a)) return a;
if (std::isnan(b)) return b;
SetFPException(FPSCR_VXIMZ);
return PPC_NAN;
}
@ -97,10 +98,10 @@ inline double NI_mul(double a, double b)
inline double NI_add(double a, double b)
{
double t = a + b;
if (t != t)
if (std::isnan(t))
{
if (a != a) return a;
if (b != b) return b;
if (std::isnan(a)) return a;
if (std::isnan(b)) return b;
SetFPException(FPSCR_VXISI);
return PPC_NAN;
}
@ -110,10 +111,10 @@ inline double NI_add(double a, double b)
inline double NI_sub(double a, double b)
{
double t = a - b;
if (t != t)
if (std::isnan(t))
{
if (a != a) return a;
if (b != b) return b;
if (std::isnan(a)) return a;
if (std::isnan(b)) return b;
SetFPException(FPSCR_VXISI);
return PPC_NAN;
}
@ -126,18 +127,18 @@ inline double NI_sub(double a, double b)
inline double NI_madd(double a, double c, double b, bool negate = false)
{
double t = a * c;
if (t != t)
if (std::isnan(t))
{
if (a != a) return a;
if (b != b) return b; // !
if (c != c) return c;
if (std::isnan(a)) return a;
if (std::isnan(b)) return b; // !
if (std::isnan(c)) return c;
SetFPException(FPSCR_VXIMZ);
return PPC_NAN;
}
t = t + b;
if (t != t)
t += b;
if (std::isnan(t))
{
if (b != b) return b;
if (std::isnan(b)) return b;
SetFPException(FPSCR_VXISI);
return PPC_NAN;
}
@ -147,19 +148,19 @@ 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)
{
double t = a * c;
if (t != t)
if (std::isnan(t))
{
if (a != a) return a;
if (b != b) return b; // !
if (c != c) return c;
if (std::isnan(a)) return a;
if (std::isnan(b)) return b; // !
if (std::isnan(c)) return c;
SetFPException(FPSCR_VXIMZ);
return PPC_NAN;
}
t = t - b;
if (t != t)
t -= b;
if (std::isnan(t))
{
if (b != b) return b;
if (std::isnan(b)) return b;
SetFPException(FPSCR_VXISI);
return PPC_NAN;
}