From d4fe02152a55601be285f8e9acef04c28bb5444b Mon Sep 17 00:00:00 2001 From: Hendiadyoin1 Date: Fri, 8 Apr 2022 17:13:11 +0200 Subject: [PATCH] AK: Add an SSE2 specific implementation of sqrt(double) --- AK/Math.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/AK/Math.h b/AK/Math.h index a382e55299..d7026bb1e5 100644 --- a/AK/Math.h +++ b/AK/Math.h @@ -130,6 +130,21 @@ constexpr float sqrt(float x) return res; } +# ifdef __SSE2__ +template<> +constexpr double sqrt(double x) +{ + if (is_constant_evaluated()) + return __builtin_sqrt(x); + + double res; + asm("sqrtsd %1, %0" + : "=x"(res) + : "x"(x)); + return res; +} +# endif + template<> constexpr float rsqrt(float x) {