[PATCH v4 17/21] math: Remove the SVID error handling from tgammaf

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Fri Oct 31 13:27:34 GMT 2025



On 29/10/25 18:41, Wilco Dijkstra wrote:
> Hi Adhemerval,
> 
> +      /* tgamma(x) overflows for:
> +       * 0 <= x < 0x1p-128 whatever the rounding mode
> +       * x = 0x1p-128 and rounding to nearest or away from zero
> +	 (in which case the result is +Inf)
> +       * -0x1p-128 <= x <= 0 whatever the rounding mode
> +       */
> +      if (fabsf (x) < 0x1p-128f ||
> +	  (x == 0x1p-128f && r > 0x1.fffffep+127f) || x == -0x1p-128f)
> +	errno = ERANGE; /* overflow */
> 
> It doesn't look like this could be added to the exception table, but
> wouldn't it be simpler to check whether final result r is infinite?

It is indeed.

> 
> if (is_inf (asuint (r)) return __math_oflowf (t >> 31);
> 
> -      return math_narrow_eval (x * 0x1p127f);
> +      return __math_oflowf_value (math_narrow_eval (x * 0x1p127f));
> 
> Why not just use return __math_oflowf (0);

Ack.

> 
>        if (x == 0.0f)
> -	return 1.0f / x;
> +	return __math_oflowf_value (1.0f / x);
> 
> Possibly still use __math_oflowf (t >> 31)?

Ack.

> 
> -      return math_narrow_eval (0x1p-127f * sgn[k & 1]);
> +      return __math_oflowf_value (math_narrow_eval (0x1p-127f * sgn[k & 1]));
> 
> Really? It's underflow, just use return __math_uflowf (k & 1);
> 

Ack.

> +  if (fabsf (r) < 0x1p-126f)
> +    errno = ERANGE; // underflow
> 
> That should be if (__glibc_unlikely (r == 0)) return __math_uflowf (rt >> 63);
>

Ack.

 
> Cheers,
> Wilco



More information about the Libc-alpha mailing list