1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 06:27:45 +00:00

AK: Use correct builtins for floor and ceil

We were using the double ones, forcing casts to and from them for floats
This commit is contained in:
Hediadyoin1 2023-05-16 15:23:54 +02:00 committed by Andreas Kling
parent 29e0494e56
commit c9808f0d4a

View file

@ -108,7 +108,12 @@ constexpr T ceil(T num)
#if ARCH(AARCH64) #if ARCH(AARCH64)
AARCH64_INSTRUCTION(frintp, num); AARCH64_INSTRUCTION(frintp, num);
#else #else
return __builtin_ceil(num); if constexpr (IsSame<T, long double>)
return __builtin_ceill(num);
if constexpr (IsSame<T, double>)
return __builtin_ceil(num);
if constexpr (IsSame<T, float>)
return __builtin_ceilf(num);
#endif #endif
} }
@ -126,7 +131,12 @@ constexpr T floor(T num)
#if ARCH(AARCH64) #if ARCH(AARCH64)
AARCH64_INSTRUCTION(frintm, num); AARCH64_INSTRUCTION(frintm, num);
#else #else
return __builtin_floor(num); if constexpr (IsSame<T, long double>)
return __builtin_floorl(num);
if constexpr (IsSame<T, double>)
return __builtin_floor(num);
if constexpr (IsSame<T, float>)
return __builtin_floorf(num);
#endif #endif
} }
@ -389,6 +399,7 @@ constexpr T fmod(T x, T y)
return __builtin_fmod(x, y); return __builtin_fmod(x, y);
#endif #endif
} }
template<FloatingPoint T> template<FloatingPoint T>
constexpr T remainder(T x, T y) constexpr T remainder(T x, T y)
{ {