[PATCH] math: remove exp10 wrappers

Wilco Dijkstra Wilco.Dijkstra@arm.com
Tue Jan 16 15:41:32 GMT 2024


Hi Adhemerval,

> The patch below fixes the numerical stability I found on i686:

So it looks like it is due to incorrect uses of math_narrow_eval with
double_t expressions: kd = math_narrow_eval (z + Shift);
This needs to be: kd = math_narrow_eval ((double) (z + Shift));

> And I think we haven't see it because all ABIs with FLT_EVAL_METHOD=2 uses
> assembly implementations for exp/exp2/exp10 (this is the case for i386
> and m68k).

Indeed.

> Furthermore, at least with i686 the use of double_t also does not show
> better performance either. The current sysdeps/i386/fpu/e_exp10.S
> on a recent CPU (Ryzen 9 5900X) with gcc version 13.2.1:

That's surprising. What happens is that we build with -std=gnu11 which implies
-fexcess-precision=fast. I double-checked on a SkyLake - using double_t is slower
as well. So overall it seems best to let the compiler decide where to use excess
precision.

> So I am not sure if double_t is really helpful here.

Unless we decide to move to -fexcess-precision=standard by default I guess -
but there doesn't seem to be an advantage in doing so given that double_t
is slower.

Cheers,
Wilco


More information about the Libc-alpha mailing list