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

via libc-commits libc-commits at lists.llvm.org
Mon Mar 18 21:50:44 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: None (lntue)

<details>
<summary>Changes</summary>

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

---
Full diff: https://github.com/llvm/llvm-project/pull/85733.diff


1 Files Affected:

- (modified) libc/src/math/generic/atanf.cpp (+4-2) 


``````````diff
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

``````````

</details>


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


More information about the libc-commits mailing list