[libc-commits] [libc] [llvm] [libc][math] Added missing floating point exception for atanpif16 (PR #186597)
via libc-commits
libc-commits at lists.llvm.org
Sat Mar 14 14:11:11 PDT 2026
================
@@ -120,7 +120,19 @@ LLVM_LIBC_FUNCTION(float16, atanpif16, (float16 x)) {
// Case 1: |x| <= 0.5 - Direct polynomial evaluation
if (LIBC_LIKELY(x_abs <= 0.5)) {
double result = atanpi_eval(x_abs);
- return signed_result(result);
+ float16 s_result = signed_result(result);
+ // clear the underflow raised by casting
+ fputil::clear_except_if_required(FE_UNDERFLOW);
+ int rounding = fputil::quick_get_round();
+ // values checked through exhaustive testing which rounded up/down and
+ // caused spurious or missing underflow
+ bool except_value = (rounding == FE_UPWARD && xbits.uintval() == 0x0a48) ||
+ (rounding == FE_DOWNWARD && xbits.uintval() == 0x8a48);
----------------
lntue wrote:
Move the check `x_abs == 0.0` and this check to right before doing `atanpi_eval`, do early return, then you shouldn't need `clear_except_if_required`. Also, there should be a specific value in float that when convert to float16 gives correct answer in all rounding mode for these except values.
https://github.com/llvm/llvm-project/pull/186597
More information about the libc-commits
mailing list