[libc-commits] [libc] a1fb514 - [libc] Prevent constant propagation for atanf(+-Inf) in gcc. (#85733)

via libc-commits libc-commits at lists.llvm.org
Tue Mar 19 08:15:10 PDT 2024


Author: lntue
Date: 2024-03-19T11:15:06-04:00
New Revision: a1fb51453d9b47ea011f8b948f2f099da2edf2c9

URL: https://github.com/llvm/llvm-project/commit/a1fb51453d9b47ea011f8b948f2f099da2edf2c9
DIFF: https://github.com/llvm/llvm-project/commit/a1fb51453d9b47ea011f8b948f2f099da2edf2c9.diff

LOG: [libc] Prevent constant propagation for atanf(+-Inf) in gcc. (#85733)

gcc bot failures with `atanf(+-Inf)`:
https://lab.llvm.org/buildbot/#/builders/250/builds/20331/steps/8/logs/stdio

Added: 
    

Modified: 
    libc/src/math/generic/atanf.cpp

Removed: 
    


################################################################################
diff  --git a/libc/src/math/generic/atanf.cpp b/libc/src/math/generic/atanf.cpp
index 69fd45ddd767e5..5f66ea52d0d7ae 100644
--- a/libc/src/math/generic/atanf.cpp
+++ b/libc/src/math/generic/atanf.cpp
@@ -37,8 +37,10 @@ LLVM_LIBC_FUNCTION(float, atanf, (float x)) {
     double const_term = 0.0;
     if (LIBC_UNLIKELY(x_abs >= 0x4180'0000)) {
       // atan(+-Inf) = +-pi/2.
-      if (x_bits.is_inf())
-        return static_cast<float>(SIGNED_PI_OVER_2[sign.is_neg()]);
+      if (x_bits.is_inf()) {
+        volatile double sign_pi_over_2 = SIGNED_PI_OVER_2[sign.is_neg()];
+        return static_cast<float>(sign_pi_over_2);
+      }
       if (x_bits.is_nan())
         return x;
       // x >= 16


        


More information about the libc-commits mailing list