Re: [PATCH 0/3] Updates to the new math code

Corinna Vinschen <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
Hi Szabolcs,

On Jul  4 16:49, Szabolcs Nagy wrote:
> There are some modifications and bug fixes in the Arm Optimized
> Routines repo and i'd like to sync newlib with it.
> 
> Szabolcs Nagy (3):
>   Fix code style and comments of new math code
>   Change the return type of converttoint and document the semantics
>   Fix large ulp error in pow without fma very near 1.0
> 
>  newlib/libm/common/exp.c         | 22 +++++++++++++------
>  newlib/libm/common/exp2.c        | 18 +++++++++++-----
>  newlib/libm/common/log.c         | 46 ++++++++++++++++++++++------------------
>  newlib/libm/common/log2.c        | 31 ++++++++++++++-------------
>  newlib/libm/common/math_config.h | 44 ++++++++++++++++++++++++++++++++------
>  newlib/libm/common/pow.c         | 35 ++++++++++++++++++++++--------
>  newlib/libm/common/sincosf.c     | 16 +++++++-------
>  newlib/libm/common/sinf.c        | 12 +++++------
>  8 files changed, 147 insertions(+), 77 deletions(-)

while you're working on this, I have three questions:

1. There's __HAVE_FAST_FMA defined in libc/include/machine/ieeefp.h and
   HAVE_FAST_ROUND/HAVE_FAST_LROUND defined in libm/common/math_config.h.
   Wouldn't it make more sense to define all of them in one file?
   Not sure which one, but libm/common/math_config.h looks right to me.

2. You're changing converttoint to return int32_t, but the #else
   branch is casting to long:

    # if HAVE_FAST_LROUND
      return lround (x);
    # else
      return (long) round (x);
    # endif
   
   This looks wrong to me independent of the return type of
   converttoint.  Shouldn't that cast to an int of fixed size, i.e.,
   int32_t?

3. Along the same lines, in newlib/libm/common/sf_exp.c there's the
   following expression:

    #if TOINT_INTRINSICS
      kd = roundtoint (z);
      ki = converttoint (z);
    #elif TOINT_RINT
      kd = rint (z);
      ki = (long) kd;
      ^^^^^^^^^^^^^^^

   Shouldn't this cast to int32_t as well?


Thanks,
Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAls922UACgkQ9TYGna5E
T6CqhBAAhjiwXmqSSACSxETHn8ofMs/GPOJPf3P4RBVRjcTs3T39AzldZhfzP174
91QSF8vpbvA+RW7bLSSXLX4Tz+OYdehb/krXdOUiGl+2J4n9EYYcC1jiYYbpbx7+
RlmiF4G6jYXQseaz/goindBoFlEyQ729oWJlOQh7WVPp84FmcWyP5ePQTDPOW9OC
FDimExLkI6ntCfmQ32qJJrQxE+u/AlYyQ+EiyoigYgVQ71UYdWJyc/MAEUKm1vFk
y8TxP6OFs0YJBw0v9YbeA2abqTy7AmHlYhUypoLGgDzD1StmWyJP9Iwmwz8PP64c
cV/nilUypNcJ1glGOJQNvMiCrtBIt4B6fNnRGTDc41peg4MzjmuN/eQTvW8H0rJq
ZEp768h8PV3HR75Ri4cNRAyn3Unp8/3xFEmKd88a4QrAnfXZZW55gHLsmIdLkMWt
/JjMZHFj6DdYcURLcY5V+Skow6mn9FzX+UAdB1j+87YMJ53/pB27z6j3LlXlhQgo
Kc4ZHdoyzFtFcqWm4fwNJOGNk+DQ+xl6eIJUr+mS0VlhS/HB53lP1HFzg3YJAqJy
HSjN+byV3WUW6h7eKPyT9m/aX25R5jbGNjUI8ypBo6D16doevYe7kgPJP9CZmiwa
WKFA7CtbceA6o+3cQME/d+/X/2Io7+G21FQ8xERpSwBjh4TiO1E=
=nRHI
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.