Re: [PATCH] Fix powf overflow handling in non-nearest rounding mode

Corinna Vinschen <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <[email protected]>
On Dec 10 15:04, Szabolcs Nagy wrote:
> Follows the fix in https://github.com/ARM-software/optimized-routines

> From 8ff59d2f4e0209f03c30462e9319baf4c6ba79f7 Mon Sep 17 00:00:00 2001
> From: Szabolcs Nagy <[email protected]>
> Date: Mon, 10 Dec 2018 14:40:01 +0000
> Subject: [PATCH] Fix powf overflow handling in non-nearest rounding mode
> 
> The threshold value at which powf overflows depends on the rounding mode
> and the current check did not take this into account. So when the result
> was rounded away from zero it could become infinity without setting
> errno to ERANGE.
> 
> Example: pow(0x1.7ac7cp+5, 23) is 0x1.fffffep+127 + 0.1633ulp
> 
> If the result goes above 0x1.fffffep+127 + 0.5ulp then errno is set,
> which is fine in nearest rounding mode, but
> 
>   powf(0x1.7ac7cp+5, 23) is inf in upward rounding mode
>   powf(-0x1.7ac7cp+5, 23) is -inf in downward rounding mode
> 
> and the previous implementation did not set errno in these cases.
> 
> The fix tries to avoid affecting the common code path or calling a
> function that may introduce a stack frame, so float arithmetics is used
> to check the rounding mode and the threshold is selected accordingly.
> ---
>  newlib/libm/common/sf_pow.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)

Pushed.


Thanks,
Corinna

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

iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAlwPpd4ACgkQ9TYGna5E
T6DPLQ/+K46+8PNyjG4qaFV1dqS/vtxj9p0QxItx96FIA+KkDs6ZddBRfXqmoB4k
w9QF1imWh8zFiz+qDUd4iz3YsnqUqMeokQJxf6FfijpnCbyOGHdRhS2I9NTZsk4P
l6Yj6JJUV8b8+Z2Se2OniaMWojFUOc8eRxRX+z+99LJ/qLsIgDVA2m6fGtNA3v7k
E/hytRu9TiUEq5H5DSdKt5y4xVU/70Zm73+0Bbqv5zai03cqYxc8617usrSdiNBM
61crMgeCb0bi1ix2WxkMzk//NkxWzY9B6QZGRbKzz/8KWEnpQcZrceuN6yT/VeTO
IJeGXsyeA6uf/qemasV5lMQsTZh70WIq4Wo0vRlrqjwmEm8dv7wqhrTfJrBmBzy8
guPK8GR/1SHRZdmBd0YWTRJQ36l4YUEfhMHUj6Pb93ccboZLzpsYTncrlrhBvSkm
CwR8mbEtNuNmpUtvSX80dSimCU7JlXXG0P7AYzTjOCtmnQC7s9isRatEU+GaZ18D
IN/fkwxmhZjsUZ2OVEUrgSA4lr8cegceKeD1dC2ckrUfmEOnMno07T5s1B4Jtis0
ZPe1MGgtv/0XY2OmkGloMl3TB7QZhYxEpA2nDrBaApPUHNAgNVvA2KFljJn8SAtf
S0Q4HU2btTVRtZ1VfJb2G1JzK50pMfGdyVKHB5EqDqYqqUts3XI=
=eP3s
-----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.