Skip to content

[libc] Fix signed zeros for exp10m1f16 and tanhf16. #116654

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 18, 2024
Merged

Conversation

lntue
Copy link
Contributor

@lntue lntue commented Nov 18, 2024

No description provided.

@llvmbot llvmbot added the libc label Nov 18, 2024
@lntue lntue requested review from overmighty and jhuber6 November 18, 2024 16:55
@llvmbot
Copy link
Member

llvmbot commented Nov 18, 2024

@llvm/pr-subscribers-libc

Author: None (lntue)

Changes

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

1 Files Affected:

  • (modified) libc/src/math/generic/exp10m1f16.cpp (+3)
diff --git a/libc/src/math/generic/exp10m1f16.cpp b/libc/src/math/generic/exp10m1f16.cpp
index 9f2c1959fa5ec9..449aedf254ca50 100644
--- a/libc/src/math/generic/exp10m1f16.cpp
+++ b/libc/src/math/generic/exp10m1f16.cpp
@@ -119,6 +119,9 @@ LLVM_LIBC_FUNCTION(float16, exp10m1f16, (float16 x)) {
 
     // When |x| <= 2^(-3).
     if (x_abs <= 0x3000U) {
+      if (LIBC_UNLIKELY(x_abs == 0))
+        return x;
+
       if (auto r = EXP10M1F16_EXCEPTS_LO.lookup(x_u);
           LIBC_UNLIKELY(r.has_value()))
         return r.value();

Copy link
Contributor

@jhuber6 jhuber6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@lntue lntue changed the title [libc] Fix signed zeros for exp10m1f16. [libc] Fix signed zeros for exp10m1f16 and tanhf16. Nov 18, 2024
@lntue lntue merged commit 6a863f7 into llvm:main Nov 18, 2024
7 checks passed
@lntue lntue deleted the exp10m1f16 branch November 18, 2024 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants