Re: [PATCH 0/3] Updates to the new math code
Corinna Vinschen <[email protected]>
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <[email protected]> |
On Jul 5 12:21, Szabolcs Nagy wrote: > On 05/07/18 11:01, Szabolcs Nagy wrote: > > On 05/07/18 09:48, Corinna Vinschen wrote: > > > 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? > > > > > > > the (long) cast was used so it's the same operation as > > lround (assuming -fno-math-errno semantics) since the > > compiler has a builtin for that which targets may inline, > > but i guess (int32_t) would work too (since out of bound > > conversion is either undefined or unspecified). > > > > the int32_t cast changes code generation with clang (it adds > sign extension instructions) it seems compilers can figure out > > (uint64_t)(int32_t)(long)round() << 32; > > but not > > (uint64_t)(int32_t)round() << 32; > > because the former lowers into a double->int64 conversion > on 64bit systems the latter lowers into double->int32 > conversion and then the int32 requires a sign extend. > > so i'll keep the code as is for now. > > > > 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? > > > > > > > likewise. > > > > i'll experiment and if int32_t works i'll change it. > > i think i should remove this part and only use TOINT_INTRINSICS > vs !TOINT_INTRINSICS instead of various TOINT_* macros that > nobody uses. Sounds good. Thanks, Corinna -- Corinna Vinschen Cygwin Maintainer Red Hat
signature.asc
(application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAls+CUoACgkQ9TYGna5E T6DcWw//aGM/x6unaCzmTqho2LLg6CHtEGV4rAUyEClHlW/x3ck35vXXXagNTSyP 70NsnJgpCfjMIgUEGr6E1Chy8ipIok7pe6cP1uTgr7x6c0kR8sgDBTKKbDVSpc3m G29mYtJwKDlUenyIdLNLeanZ/hb5IhKrO4Liv8bDxEshE771OzYHcAMy4g56Swqy V7dD+u6URl0dXxZLH8nKHiGaag0857W3+5ay1aieb3DC6hMJ2j5B1vw/3yIbfjtl 2f3tT4NxB+8OnjV8xBnaofSjuBy/750nYNN3tfahOMzaASmsHL6Iqw8qA8HRcFFg yb9ArFTxTQrWCOOgZ1z7QbZPiOybuVQFC9RVFOdNwDOTHqhnDehireVafGbxpoYz rCvkryANHRyojExhF6VB9arSUUSCOVx3UZwzfzgPCVKgZLWs3uzJ+evHICOTmlS3 N0RYfvyibIy3/kQsPYLNhS7sFb14TPqmEbYqh+H+hEfLlOQI8eNcf4Z7ToO/NgSc lp5PBKdX2V/P0JVzKADFY5mjDob4FyDopiHrO8nscpWFDV0XFl2oxJQaD7GHh5Ns FD8tBevLypySZdpg2n5FxzrMXFrHJv9So9xicJ+PNfawsX6D19aFUCzuK/29ArW4 zGiPj/7bO5xw7B6A3AiZ4q4gd/J4TFfaVfDFA7OqGELCnNwCAGE= =au22 -----END PGP SIGNATURE-----