diff --git a/Source/Core/Common/FloatUtils.cpp b/Source/Core/Common/FloatUtils.cpp index a671eb278c..312d4a88a2 100644 --- a/Source/Core/Common/FloatUtils.cpp +++ b/Source/Core/Common/FloatUtils.cpp @@ -108,7 +108,7 @@ double ApproximateReciprocalSquareRoot(double val) return 0.0; } - return 0.0 + val; + return MakeQuiet(val); } // Negative numbers return NaN @@ -165,7 +165,7 @@ double ApproximateReciprocal(double val) { if (mantissa == 0) return std::copysign(0.0, val); - return 0.0 + val; + return MakeQuiet(val); } // Special case small inputs diff --git a/Source/Core/Common/FloatUtils.h b/Source/Core/Common/FloatUtils.h index 0456a7665e..bc950f90e2 100644 --- a/Source/Core/Common/FloatUtils.h +++ b/Source/Core/Common/FloatUtils.h @@ -68,6 +68,13 @@ inline double FlushToZero(double d) return std::bit_cast(i); } +inline double MakeQuiet(double d) +{ + const u64 integral = std::bit_cast(d) | Common::DOUBLE_QBIT; + + return std::bit_cast(integral); +} + enum PPCFpClass { PPC_FPCLASS_QNAN = 0x11, diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter_FPUtils.h b/Source/Core/Core/PowerPC/Interpreter/Interpreter_FPUtils.h index 67b6af7560..7f74ed9a01 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter_FPUtils.h +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter_FPUtils.h @@ -123,13 +123,6 @@ inline double Force25Bit(double d) return std::bit_cast(integral); } -inline double MakeQuiet(double d) -{ - const u64 integral = std::bit_cast(d) | Common::DOUBLE_QBIT; - - return std::bit_cast(integral); -} - // these functions allow globally modify operations behaviour // 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)) { - result.value = MakeQuiet(a); + result.value = Common::MakeQuiet(a); return result; } if (std::isnan(b)) { - result.value = MakeQuiet(b); + result.value = Common::MakeQuiet(b); return result; } @@ -200,12 +193,12 @@ inline FPResult NI_div(PowerPC::PowerPCState& ppc_state, double a, double b) if (std::isnan(a)) { - result.value = MakeQuiet(a); + result.value = Common::MakeQuiet(a); return result; } if (std::isnan(b)) { - result.value = MakeQuiet(b); + result.value = Common::MakeQuiet(b); return result; } @@ -234,12 +227,12 @@ inline FPResult NI_add(PowerPC::PowerPCState& ppc_state, double a, double b) if (std::isnan(a)) { - result.value = MakeQuiet(a); + result.value = Common::MakeQuiet(a); return result; } if (std::isnan(b)) { - result.value = MakeQuiet(b); + result.value = Common::MakeQuiet(b); return result; } @@ -267,12 +260,12 @@ inline FPResult NI_sub(PowerPC::PowerPCState& ppc_state, double a, double b) if (std::isnan(a)) { - result.value = MakeQuiet(a); + result.value = Common::MakeQuiet(a); return result; } if (std::isnan(b)) { - result.value = MakeQuiet(b); + result.value = Common::MakeQuiet(b); return result; } @@ -303,17 +296,17 @@ inline FPResult NI_madd(PowerPC::PowerPCState& ppc_state, double a, double c, do if (std::isnan(a)) { - result.value = MakeQuiet(a); + result.value = Common::MakeQuiet(a); return result; } if (std::isnan(b)) { - result.value = MakeQuiet(b); // ! + result.value = Common::MakeQuiet(b); // ! return result; } if (std::isnan(c)) { - result.value = MakeQuiet(c); + result.value = Common::MakeQuiet(c); return result; } @@ -341,17 +334,17 @@ inline FPResult NI_msub(PowerPC::PowerPCState& ppc_state, double a, double c, do if (std::isnan(a)) { - result.value = MakeQuiet(a); + result.value = Common::MakeQuiet(a); return result; } if (std::isnan(b)) { - result.value = MakeQuiet(b); // ! + result.value = Common::MakeQuiet(b); // ! return result; } if (std::isnan(c)) { - result.value = MakeQuiet(c); + result.value = Common::MakeQuiet(c); return result; }