New expf, exp2f, logf, log2f and powf implementations
Based on code from https://github.com/ARM-software/optimized-routines/ This patch adds a highly optimized generic implementation of expf, exp2f, logf, log2f and powf. The new functions are not only faster (6x for powf!), but are also smaller and more accurate. In order to achieve this, the algorithm uses double precision arithmetic for accuracy, avoids divisions and uses small table lookups to minimize the polynomials. Special cases are handled inline to avoid the unnecessary overhead of wrapper functions and set errno to POSIX requirements. The new functions are added under newlib/libm/common, but the old implementations are kept (in newlib/libm/math) for non-IEEE or pre-C99 systems. Targets can enable the new math code by defining __OBSOLETE_MATH_DEFAULT to 0 in newlib/libc/include/machine/ieeefp.h, users can override the default by defining __OBSOLETE_MATH. Currently the new code is enabled for AArch64 and AArch32 with VFP. Targets with a single precision FPU may still prefer the old implementation. libm.a size changes: arm: -1692 arm/thumb/v7-a/nofp: -878 arm/thumb/v7-a+fp/hard: -864 arm/thumb/v7-a+fp/softfp: -908 aarch64: -1476
This commit is contained in:
committed by
Corinna Vinschen
parent
c165a27c01
commit
c156098271
@ -48,6 +48,23 @@
|
||||
This represents what type a float arg is passed as. It is used when the type is
|
||||
not promoted to double.
|
||||
|
||||
|
||||
__OBSOLETE_MATH_DEFAULT
|
||||
|
||||
Default value for __OBSOLETE_MATH if that's not set by the user.
|
||||
It should be set here based on predefined feature macros.
|
||||
|
||||
__OBSOLETE_MATH
|
||||
|
||||
If set to 1 then some new math code will be disabled and older libm
|
||||
code will be used instead. This is necessary because the new math
|
||||
code does not support all targets, it assumes that the toolchain has
|
||||
ISO C99 support (hexfloat literals, standard fenv semantics), the
|
||||
target has IEEE-754 conforming binary32 float and binary64 double
|
||||
(not mixed endian) representation, standard SNaN representation,
|
||||
double and single precision arithmetics has similar latency and it
|
||||
has no legacy SVID matherr support, only POSIX errno and fenv
|
||||
exception based error handling.
|
||||
*/
|
||||
|
||||
#if (defined(__arm__) || defined(__thumb__)) && !defined(__MAVERICK__)
|
||||
@ -61,6 +78,7 @@
|
||||
# else
|
||||
# define __IEEE_BIG_ENDIAN
|
||||
# endif
|
||||
# define __OBSOLETE_MATH_DEFAULT 0
|
||||
#else
|
||||
# define __IEEE_BIG_ENDIAN
|
||||
# ifdef __ARMEL__
|
||||
@ -75,6 +93,7 @@
|
||||
#else
|
||||
#define __IEEE_BIG_ENDIAN
|
||||
#endif
|
||||
#define __OBSOLETE_MATH_DEFAULT 0
|
||||
#endif
|
||||
|
||||
#ifdef __epiphany__
|
||||
@ -427,6 +446,14 @@
|
||||
#define __IEEE_BIG_ENDIAN
|
||||
#endif
|
||||
|
||||
#ifndef __OBSOLETE_MATH_DEFAULT
|
||||
/* Use old math code by default. */
|
||||
#define __OBSOLETE_MATH_DEFAULT 1
|
||||
#endif
|
||||
#ifndef __OBSOLETE_MATH
|
||||
#define __OBSOLETE_MATH __OBSOLETE_MATH_DEFAULT
|
||||
#endif
|
||||
|
||||
#ifndef __IEEE_BIG_ENDIAN
|
||||
#ifndef __IEEE_LITTLE_ENDIAN
|
||||
#error Endianess not declared!!
|
||||
|
Reference in New Issue
Block a user