[libc-commits] [libc] [libc][math] Fix signaling NaN handling for math functions. (PR #133347)

via libc-commits libc-commits at lists.llvm.org
Fri Mar 28 05:41:42 PDT 2025


================
@@ -657,6 +657,11 @@ LLVM_LIBC_FUNCTION(float, powf, (float x, float y)) {
   uint32_t y_abs = ybits.abs().uintval();
 
   ///////// BEGIN - Check exceptional cases ////////////////////////////////////
+  // if x or y is signaling NaN
----------------
lntue wrote:

Can you move this one inside the condition:
```
if (LIBC_UNLIKELY((y_abs & 0x0007'ffff) == 0) || (y_abs > 0x4f170000)) {
```
and add another one, that only check if `xbits.is_signaling_nan` inside the condition:
```
  if (LIBC_UNLIKELY(((x_u & 0x801f'ffffU) == 0) || x_u >= 0x7f80'0000U ||
                    x_u < 0x0080'0000U)) {
```

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


More information about the libc-commits mailing list