[PATCH] math: Fix pow special case [BZ #33563]

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Fri Oct 31 16:17:58 GMT 2025



On 30/10/25 12:32, Wilco Dijkstra wrote:
> 
> Fix pow (DBL_MAX, 1.0) to return DBL_MAX when rouding upwards without FMA.
> This fixes BZ #33563.
> 
> Passes regress, OK for commit?

LGTM, thanks.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> 
> ---
> 
> diff --git a/sysdeps/ieee754/dbl-64/e_pow.c b/sysdeps/ieee754/dbl-64/e_pow.c
> index 3d6933137c3558fd2f55972d76c8dd09003764f3..3dc171885a31bc65438040faccbcf9f996bdc4bf 100644
> --- a/sysdeps/ieee754/dbl-64/e_pow.c
> +++ b/sysdeps/ieee754/dbl-64/e_pow.c
> @@ -147,8 +147,14 @@ specialcase (double_t tmp, uint64_t sbits, uint64_t ki)
>        /* k > 0, the exponent of scale might have overflowed by <= 460.  */
>        sbits -= 1009ull << 52;
>        scale = asdouble (sbits);
> -      y = 0x1p1009 * (scale + scale * tmp);
> -      return check_oflow (y);
> +      y = scale + scale * tmp;
> +#ifndef __FP_FAST_FMA
> +      /* Special case pow (0x1.fffffffffffffp+1023, 1.0) when rounding up.  */
> +      if (WANT_ROUNDING && y == 0x1p15
> +	  && (math_opt_barrier (1.0) + 0x1p-60) != 1.0)
> +	return DBL_MAX;
> +#endif
> +      return check_oflow (y * 0x1p1009);
>      }
>    /* k < 0, need special care in the subnormal range.  */
>    sbits += 1022ull << 52;
> 



More information about the Libc-alpha mailing list