[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 14:13:34 PDT 2026


================
@@ -132,11 +148,15 @@ add_or_sub(InType x, InType y) {
   InType y_abs = y_bits.abs().get_val();
 
   if (x_abs == y_abs && !is_effectively_add) {
-    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:

What is the problem with the `switch` statement?

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


More information about the libc-commits mailing list