[libc-commits] [libc] [libc][math] Qualify fdim funtions to constexpr (PR #194137)
Kiriti Ponduri via libc-commits
libc-commits at lists.llvm.org
Sat Apr 25 14:23:03 PDT 2026
================
@@ -98,11 +103,15 @@ add_or_sub(InType x, InType y) {
if (y_bits.is_zero()) {
if (is_effectively_add)
return OutFPBits::zero(x_bits.sign()).get_val();
- switch (fputil::quick_get_round()) {
- case FE_DOWNWARD:
- return OutFPBits::zero(Sign::NEG).get_val();
- default:
+ if (__builtin_is_constant_evaluated()) {
return OutFPBits::zero(Sign::POS).get_val();
----------------
udaykiriti wrote:
LIBC_INLINE int quick_get_round() {
static volatile float x = 0x1.0p-24f;
float y = x;
float z = (0x1.000002p0f + y) + (-1.0f - y);
if (z == 0.0f)
return FE_DOWNWARD;
if (z == 0x1.0p-23f)
return FE_TOWARDZERO;
return (2.0f + y == 2.0f) ? FE_TONEAREST : FE_UPWARD;
}
it is coming from this functions and it is using volatile keyword and it gives me an error.
https://github.com/llvm/llvm-project/pull/194137
More information about the libc-commits
mailing list