[libc-commits] [libc] [libc][math] Fix the FTZ/DAZ checks for log1p. (PR #174424)
via libc-commits
libc-commits at lists.llvm.org
Mon Jan 5 07:44:53 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: None (lntue)
<details>
<summary>Changes</summary>
The previous checks will fail with https://github.com/llvm/llvm-project/pull/174123.
See https://github.com/llvm/llvm-project/pull/174290#issuecomment-3708052716 for the discussion.
---
Full diff: https://github.com/llvm/llvm-project/pull/174424.diff
1 Files Affected:
- (modified) libc/src/math/generic/log1p.cpp (+2-2)
``````````diff
diff --git a/libc/src/math/generic/log1p.cpp b/libc/src/math/generic/log1p.cpp
index 1595981ac309b..ddac3c2bacc05 100644
--- a/libc/src/math/generic/log1p.cpp
+++ b/libc/src/math/generic/log1p.cpp
@@ -935,7 +935,7 @@ LLVM_LIBC_FUNCTION(double, log1p, (double x)) {
// log(1 + x) = nextafter(x, -inf) for FE_DOWNWARD, or
// FE_TOWARDZERO and x > 0,
// = x otherwise.
- if (x == 0.0)
+ if (x + x == 0.0)
return x + x; // Handle FTZ/DAZ correctly.
volatile float tp = 1.0f;
@@ -951,7 +951,7 @@ LLVM_LIBC_FUNCTION(double, log1p, (double x)) {
return FPBits_t(x_u + 1).get_val();
}
- return (x + x == 0.0) ? x + x : x;
+ return x;
}
x_dd = fputil::exact_add(1.0, x);
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/174424
More information about the libc-commits
mailing list