From c9808f0d4ae461ec44c5049b0ad324df91ab4086 Mon Sep 17 00:00:00 2001 From: Hediadyoin1 Date: Tue, 16 May 2023 15:23:54 +0200 Subject: [PATCH] AK: Use correct builtins for floor and ceil We were using the double ones, forcing casts to and from them for floats --- AK/Math.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/AK/Math.h b/AK/Math.h index cd544da4a9b..925ebd2b6b1 100644 --- a/AK/Math.h +++ b/AK/Math.h @@ -108,7 +108,12 @@ constexpr T ceil(T num) #if ARCH(AARCH64) AARCH64_INSTRUCTION(frintp, num); #else - return __builtin_ceil(num); + if constexpr (IsSame) + return __builtin_ceill(num); + if constexpr (IsSame) + return __builtin_ceil(num); + if constexpr (IsSame) + return __builtin_ceilf(num); #endif } @@ -126,7 +131,12 @@ constexpr T floor(T num) #if ARCH(AARCH64) AARCH64_INSTRUCTION(frintm, num); #else - return __builtin_floor(num); + if constexpr (IsSame) + return __builtin_floorl(num); + if constexpr (IsSame) + return __builtin_floor(num); + if constexpr (IsSame) + return __builtin_floorf(num); #endif } @@ -389,6 +399,7 @@ constexpr T fmod(T x, T y) return __builtin_fmod(x, y); #endif } + template constexpr T remainder(T x, T y) {