[libc-commits] [libc] [libc][math] Qualify fdim funtions to constexpr (PR #194137)

Muhammad Bassiouni via libc-commits libc-commits at lists.llvm.org
Sat Apr 25 13:47:20 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();
----------------
bassiounix wrote:

This is fine in constexpr context because `OutFPBits::zero` is valid as a constant expression.
Why did you add the if here?

https://github.com/llvm/llvm-project/pull/194137


More information about the libc-commits mailing list