Subject: single-precision "expf" super slow on x86-64??

Miles Bader
Mon Apr 30 02:23:00 GMT 2012

2012/4/30 Paul Pluzhnikov <>:
>>> This has very likely been fixed by
>> Was there previously an optimized version of "exp", but not "expf"
>> (since "exp" is already much faster)?
> You can trivially answer that yourself, e.g.

Hmm, thanks for the tip...

The answer doesn't seem so clear tho...

In 2.13, these seem to be the files used:

  sysdeps/ieee754/flt-32/e_expf.c (wrapper)
  sysdeps/ieee754/flt-32/w_expf.c (real function)

  sysdeps/ieee754/dbl-64/w_exp.c (wrapper)
  sysdeps/ieee754/dbl-64/e_exp.c (real function)

The wrappers seem more or less identical for both precisions, so I
guess they can be ignored.

The real functions are both written in C, but are quite different, and
come from different sources.

The single-precision version seems a little bizarre to me, and does
some things that look kinda dubious, e.g. fiddling with the FPU state

      fenv_t oldenv;
      feholdexcept (&oldenv);
      fesetround (FE_TONEAREST);

[my vague impression is that fiddling with the FPU settings can be very slow...]

That's the 2.13 code; the current master has replaced the above FPU
fiddling with some sort of macro... and now the _double_ version of
the C code does some FPU fiddling too...

Is there a better mailing list to post to?  I'd be interested some
maintainer's viewpoint on this stuff...



Cat is power.  Cat is peace.

More information about the Libc-help mailing list