[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:15 PDT 2024
https://github.com/lntue created https://github.com/llvm/llvm-project/pull/85733
gcc bot failures with `atanf(+-Inf)`: https://lab.llvm.org/buildbot/#/builders/250/builds/20331/steps/8/logs/stdio
>From 7ee13579835b6f03235d9e08611bc854dafe3569 Mon Sep 17 00:00:00 2001
From: Tue Ly <lntue.h at gmail.com>
Date: Tue, 19 Mar 2024 04:47:24 +0000
Subject: [PATCH] [libc] Prevent constant propagation for atanf(+-Inf) in gcc.
---
libc/src/math/generic/atanf.cpp | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
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