summaryrefslogtreecommitdiff
path: root/AK
diff options
context:
space:
mode:
authorHendiadyoin1 <leon.a@serenityos.org>2022-04-08 17:13:11 +0200
committerLinus Groh <mail@linusgroh.de>2022-05-07 20:27:05 +0200
commitd4fe02152a55601be285f8e9acef04c28bb5444b (patch)
treeea70633f4bf32355ae9d3f1fced363ea09ffe5e7 /AK
parent6c41267dcfdcf5cb01aa2397bca25aa9e2ea8926 (diff)
downloadserenity-d4fe02152a55601be285f8e9acef04c28bb5444b.zip
AK: Add an SSE2 specific implementation of sqrt(double)
Diffstat (limited to 'AK')
-rw-r--r--AK/Math.h15
1 files changed, 15 insertions, 0 deletions
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)
{