[PATCH v5 6/7] math: Remove the SVID error handling from tgammaf

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Tue Nov 4 15:13:52 GMT 2025



On 31/10/25 15:29, Wilco Dijkstra wrote:
> Hi Adhemerval,
> 
>> It improves latency for about 1.5% and throughput for about 2-4%.
> 
> @@ -89,30 +82,32 @@ __ieee754_gammaf_r (float x, int *signgamp)
>          * z - 0x1.2788cfc6fb619p-1;
>        double f = 1.0 / z + d;
>        float r = f;
> +
>        uint64_t rt = asuint64 (f);
>        if (((rt + 2) & 0xfffffff) < 4)
>          {
> -         for (unsigned i = 0; i < sizeof (tb) / sizeof (tb[0]); i++)
> +         for (unsigned i = 0; i < array_length (tb); i++)
>              if (t == tb[i].u)
> -             return tb[i].f + tb[i].df;
> +             {
> +               r = tb[i].f + tb[i].df;
> +               break;
> +             }
> 
> It's not clear it is useful to assume the table has entries that can
> overflow since it is fixed (and we know it doesn't).

It is not, it is indeed simpler to just return instead of break.

> 
>          }
> +      if (isinf (r))
> +       errno = ERANGE;
> +
>        return r;
> 
> That's just:
> 
>   if (isinf (r)) return __math_oflowf (t >> 31);

Ack, we will need to handle 0.0f input but it I agree that we
should use math_config.h definitions.

> 
> Cheers,
> Wilco



More information about the Libc-alpha mailing list