[libc-commits] [libc] [libc] Fix value in Atan2f128 (PR #215023)

via libc-commits libc-commits at lists.llvm.org
Sat Aug 8 13:51:02 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Zorojuro (Sukumarsawant)

<details>
<summary>Changes</summary>

It fixes the THREE_PI_OVER_4 value in atan2f128 and adds a small smoke test against the failure.
The result or comparison value is directly taken from the failure while comparing with core math :
```CPP
FAIL x=inf y=-inf ref=0x1.2d97c7f3321d234f272993d1414ap+1 z=0x1.2d97c7f3321d234f272993d1414ap-1
```


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


2 Files Affected:

- (modified) libc/src/__support/math/atan2f128.h (+1-1) 
- (modified) libc/test/src/math/smoke/atan2f128_test.cpp (+3) 


``````````diff
diff --git a/libc/src/__support/math/atan2f128.h b/libc/src/__support/math/atan2f128.h
index f99de5be3472c..3c0b2620848ca 100644
--- a/libc/src/__support/math/atan2f128.h
+++ b/libc/src/__support/math/atan2f128.h
@@ -97,7 +97,7 @@ LIBC_INLINE float128 atan2f128(float128 y, float128 x) {
   constexpr DFloat128 PI_OVER_4 = {Sign::POS, -128,
                                    0xc90fdaa2'2168c234'c4c6628b'80dc1cd1_u128};
   constexpr DFloat128 THREE_PI_OVER_4 = {
-      Sign::POS, -128, 0x96cbe3f9'990e91a7'9394c9e8'a0a5159d_u128};
+      Sign::POS, -126, 0x96cbe3f9'990e91a7'9394c9e8'a0a5159d_u128};
 
   // Adjustment for constant term:
   //   CONST_ADJ[x_sign][y_sign][recip]
diff --git a/libc/test/src/math/smoke/atan2f128_test.cpp b/libc/test/src/math/smoke/atan2f128_test.cpp
index 28b15ae71cac8..0b135c5166d6a 100644
--- a/libc/test/src/math/smoke/atan2f128_test.cpp
+++ b/libc/test/src/math/smoke/atan2f128_test.cpp
@@ -26,6 +26,9 @@ TEST_F(LlvmLibcAtan2f128Test, SpecialNumbers) {
   float128 r = 0x1.921fb54442d18469898cc51701b3p-1q;
   EXPECT_FP_EQ(r, LIBC_NAMESPACE::atan2f128(x, y));
 
+  EXPECT_FP_EQ(0x1.2d97c7f3321d234f272993d1414ap+1q,
+               LIBC_NAMESPACE::atan2f128(inf, neg_inf));
+
   x = -0x1.f122e07fff556143p+3524q;
   y = 0x1.f122e07fff55615b75p+6316q;
   r = -0x1.ffffffffffffffe6cfcdc604fc99p-2793q;

``````````

</details>


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


More information about the libc-commits mailing list