mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-09-07 08:40:58 +02:00
Merge pull request #13881 from OatmealDome/clang-floating-point-nonsense-2
FloatUtils: Replace quieting SNaNs via `0.0 + x` with MakeQuiet
This commit is contained in:
@@ -108,7 +108,7 @@ double ApproximateReciprocalSquareRoot(double val)
|
|||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0.0 + val;
|
return MakeQuiet(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Negative numbers return NaN
|
// Negative numbers return NaN
|
||||||
@@ -165,7 +165,7 @@ double ApproximateReciprocal(double val)
|
|||||||
{
|
{
|
||||||
if (mantissa == 0)
|
if (mantissa == 0)
|
||||||
return std::copysign(0.0, val);
|
return std::copysign(0.0, val);
|
||||||
return 0.0 + val;
|
return MakeQuiet(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Special case small inputs
|
// Special case small inputs
|
||||||
|
@@ -68,6 +68,13 @@ inline double FlushToZero(double d)
|
|||||||
return std::bit_cast<double>(i);
|
return std::bit_cast<double>(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline double MakeQuiet(double d)
|
||||||
|
{
|
||||||
|
const u64 integral = std::bit_cast<u64>(d) | Common::DOUBLE_QBIT;
|
||||||
|
|
||||||
|
return std::bit_cast<double>(integral);
|
||||||
|
}
|
||||||
|
|
||||||
enum PPCFpClass
|
enum PPCFpClass
|
||||||
{
|
{
|
||||||
PPC_FPCLASS_QNAN = 0x11,
|
PPC_FPCLASS_QNAN = 0x11,
|
||||||
|
@@ -123,13 +123,6 @@ inline double Force25Bit(double d)
|
|||||||
return std::bit_cast<double>(integral);
|
return std::bit_cast<double>(integral);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline double MakeQuiet(double d)
|
|
||||||
{
|
|
||||||
const u64 integral = std::bit_cast<u64>(d) | Common::DOUBLE_QBIT;
|
|
||||||
|
|
||||||
return std::bit_cast<double>(integral);
|
|
||||||
}
|
|
||||||
|
|
||||||
// these functions allow globally modify operations behaviour
|
// these functions allow globally modify operations behaviour
|
||||||
// also, these may be used to set flags like FR, FI, OX, UX
|
// also, these may be used to set flags like FR, FI, OX, UX
|
||||||
|
|
||||||
@@ -162,12 +155,12 @@ inline FPResult NI_mul(PowerPC::PowerPCState& ppc_state, double a, double b)
|
|||||||
|
|
||||||
if (std::isnan(a))
|
if (std::isnan(a))
|
||||||
{
|
{
|
||||||
result.value = MakeQuiet(a);
|
result.value = Common::MakeQuiet(a);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if (std::isnan(b))
|
if (std::isnan(b))
|
||||||
{
|
{
|
||||||
result.value = MakeQuiet(b);
|
result.value = Common::MakeQuiet(b);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,12 +193,12 @@ inline FPResult NI_div(PowerPC::PowerPCState& ppc_state, double a, double b)
|
|||||||
|
|
||||||
if (std::isnan(a))
|
if (std::isnan(a))
|
||||||
{
|
{
|
||||||
result.value = MakeQuiet(a);
|
result.value = Common::MakeQuiet(a);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if (std::isnan(b))
|
if (std::isnan(b))
|
||||||
{
|
{
|
||||||
result.value = MakeQuiet(b);
|
result.value = Common::MakeQuiet(b);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -234,12 +227,12 @@ inline FPResult NI_add(PowerPC::PowerPCState& ppc_state, double a, double b)
|
|||||||
|
|
||||||
if (std::isnan(a))
|
if (std::isnan(a))
|
||||||
{
|
{
|
||||||
result.value = MakeQuiet(a);
|
result.value = Common::MakeQuiet(a);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if (std::isnan(b))
|
if (std::isnan(b))
|
||||||
{
|
{
|
||||||
result.value = MakeQuiet(b);
|
result.value = Common::MakeQuiet(b);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,12 +260,12 @@ inline FPResult NI_sub(PowerPC::PowerPCState& ppc_state, double a, double b)
|
|||||||
|
|
||||||
if (std::isnan(a))
|
if (std::isnan(a))
|
||||||
{
|
{
|
||||||
result.value = MakeQuiet(a);
|
result.value = Common::MakeQuiet(a);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if (std::isnan(b))
|
if (std::isnan(b))
|
||||||
{
|
{
|
||||||
result.value = MakeQuiet(b);
|
result.value = Common::MakeQuiet(b);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -303,17 +296,17 @@ inline FPResult NI_madd(PowerPC::PowerPCState& ppc_state, double a, double c, do
|
|||||||
|
|
||||||
if (std::isnan(a))
|
if (std::isnan(a))
|
||||||
{
|
{
|
||||||
result.value = MakeQuiet(a);
|
result.value = Common::MakeQuiet(a);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if (std::isnan(b))
|
if (std::isnan(b))
|
||||||
{
|
{
|
||||||
result.value = MakeQuiet(b); // !
|
result.value = Common::MakeQuiet(b); // !
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if (std::isnan(c))
|
if (std::isnan(c))
|
||||||
{
|
{
|
||||||
result.value = MakeQuiet(c);
|
result.value = Common::MakeQuiet(c);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -341,17 +334,17 @@ inline FPResult NI_msub(PowerPC::PowerPCState& ppc_state, double a, double c, do
|
|||||||
|
|
||||||
if (std::isnan(a))
|
if (std::isnan(a))
|
||||||
{
|
{
|
||||||
result.value = MakeQuiet(a);
|
result.value = Common::MakeQuiet(a);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if (std::isnan(b))
|
if (std::isnan(b))
|
||||||
{
|
{
|
||||||
result.value = MakeQuiet(b); // !
|
result.value = Common::MakeQuiet(b); // !
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if (std::isnan(c))
|
if (std::isnan(c))
|
||||||
{
|
{
|
||||||
result.value = MakeQuiet(c);
|
result.value = Common::MakeQuiet(c);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user