-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[libc][math] Fix signaling NaN handling for math functions. #133347
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
Changes from all commits
a3081fb
a8c6af9
831d103
7c41335
d8c1756
c6dd13f
444c482
9d1518e
b7ed27d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,9 @@ | |
//===----------------------------------------------------------------------===// | ||
|
||
#include "src/math/atan2f.h" | ||
#include "hdr/fenv_macros.h" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are other .cpp files edited by this PR that use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SGTM |
||
#include "inv_trigf_utils.h" | ||
#include "src/__support/FPUtil/FEnvImpl.h" | ||
#include "src/__support/FPUtil/FPBits.h" | ||
#include "src/__support/FPUtil/PolyEval.h" | ||
#include "src/__support/FPUtil/double_double.h" | ||
|
@@ -264,8 +266,11 @@ LLVM_LIBC_FUNCTION(float, atan2f, (float y, float x)) { | |
double den_d = static_cast<double>(den_f); | ||
|
||
if (LIBC_UNLIKELY(max_abs >= 0x7f80'0000U || num_d == 0.0)) { | ||
if (x_bits.is_nan() || y_bits.is_nan()) | ||
if (x_bits.is_nan() || y_bits.is_nan()) { | ||
if (x_bits.is_signaling_nan() || y_bits.is_signaling_nan()) | ||
fputil::raise_except_if_required(FE_INVALID); | ||
return FPBits::quiet_nan().get_val(); | ||
} | ||
double x_d = static_cast<double>(x); | ||
double y_d = static_cast<double>(y); | ||
size_t x_except = (x_d == 0.0) ? 0 : (x_abs == 0x7f80'0000 ? 2 : 1); | ||
|
Uh oh!
There was an error while loading. Please reload this page.