* [PATCH] libm: switch sf_log1p from double error routines to float
@ 2019-11-29 19:23 Keith Packard
2019-12-02 9:05 ` Corinna Vinschen
0 siblings, 1 reply; 2+ messages in thread
From: Keith Packard @ 2019-11-29 19:23 UTC (permalink / raw)
To: newlib; +Cc: Keith Packard
sf_log1p was using __math_divzero and __math_invalid, which
drag in a pile of double-precision code. Switch to using the
single-precision variants. This also required making those
available in __OBSOLETE_MATH mode.
Signed-off-by: Keith Packard <keithp@keithp.com>
---
newlib/libm/common/math_errf.c | 2 --
newlib/libm/common/sf_log1p.c | 4 ++--
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/newlib/libm/common/math_errf.c b/newlib/libm/common/math_errf.c
index 762fc2799..53c68b1cf 100644
--- a/newlib/libm/common/math_errf.c
+++ b/newlib/libm/common/math_errf.c
@@ -75,7 +75,6 @@ __math_oflowf (uint32_t sign)
return xflowf (sign, 0x1p97f);
}
-#if !__OBSOLETE_MATH
HIDDEN float
__math_divzerof (uint32_t sign)
{
@@ -89,4 +88,3 @@ __math_invalidf (float x)
float y = (x - x) / (x - x);
return isnan (x) ? y : with_errnof (y, EDOM);
}
-#endif /* !__OBSOLETE_MATH */
diff --git a/newlib/libm/common/sf_log1p.c b/newlib/libm/common/sf_log1p.c
index d86768082..d326e00ba 100644
--- a/newlib/libm/common/sf_log1p.c
+++ b/newlib/libm/common/sf_log1p.c
@@ -56,9 +56,9 @@ static float zero = 0.0;
if (hx < 0x3ed413d7) { /* x < 0.41422 */
if(ax>=0x3f800000) { /* x <= -1.0 */
if(x==(float)-1.0)
- return __math_divzero (1); /* log1p(-1)=-inf */
+ return __math_divzerof (1); /* log1p(-1)=-inf */
else
- return __math_invalid (x); /* log1p(x<-1)=NaN */
+ return __math_invalidf (x); /* log1p(x<-1)=NaN */
}
if(ax<0x31000000) { /* |x| < 2**-29 */
if(two25+x>zero /* raise inexact */
--
2.24.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] libm: switch sf_log1p from double error routines to float
2019-11-29 19:23 [PATCH] libm: switch sf_log1p from double error routines to float Keith Packard
@ 2019-12-02 9:05 ` Corinna Vinschen
0 siblings, 0 replies; 2+ messages in thread
From: Corinna Vinschen @ 2019-12-02 9:05 UTC (permalink / raw)
To: Keith Packard; +Cc: newlib
[-- Attachment #1: Type: text/plain, Size: 1841 bytes --]
On Nov 29 11:23, Keith Packard wrote:
> sf_log1p was using __math_divzero and __math_invalid, which
> drag in a pile of double-precision code. Switch to using the
> single-precision variants. This also required making those
> available in __OBSOLETE_MATH mode.
>
> Signed-off-by: Keith Packard <keithp@keithp.com>
> ---
> newlib/libm/common/math_errf.c | 2 --
> newlib/libm/common/sf_log1p.c | 4 ++--
> 2 files changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/newlib/libm/common/math_errf.c b/newlib/libm/common/math_errf.c
> index 762fc2799..53c68b1cf 100644
> --- a/newlib/libm/common/math_errf.c
> +++ b/newlib/libm/common/math_errf.c
> @@ -75,7 +75,6 @@ __math_oflowf (uint32_t sign)
> return xflowf (sign, 0x1p97f);
> }
>
> -#if !__OBSOLETE_MATH
> HIDDEN float
> __math_divzerof (uint32_t sign)
> {
> @@ -89,4 +88,3 @@ __math_invalidf (float x)
> float y = (x - x) / (x - x);
> return isnan (x) ? y : with_errnof (y, EDOM);
> }
> -#endif /* !__OBSOLETE_MATH */
> diff --git a/newlib/libm/common/sf_log1p.c b/newlib/libm/common/sf_log1p.c
> index d86768082..d326e00ba 100644
> --- a/newlib/libm/common/sf_log1p.c
> +++ b/newlib/libm/common/sf_log1p.c
> @@ -56,9 +56,9 @@ static float zero = 0.0;
> if (hx < 0x3ed413d7) { /* x < 0.41422 */
> if(ax>=0x3f800000) { /* x <= -1.0 */
> if(x==(float)-1.0)
> - return __math_divzero (1); /* log1p(-1)=-inf */
> + return __math_divzerof (1); /* log1p(-1)=-inf */
> else
> - return __math_invalid (x); /* log1p(x<-1)=NaN */
> + return __math_invalidf (x); /* log1p(x<-1)=NaN */
> }
> if(ax<0x31000000) { /* |x| < 2**-29 */
> if(two25+x>zero /* raise inexact */
> --
> 2.24.0
Pushed.
Thanks,
Corinna
--
Corinna Vinschen
Cygwin Maintainer
Red Hat
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-12-02 9:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-29 19:23 [PATCH] libm: switch sf_log1p from double error routines to float Keith Packard
2019-12-02 9:05 ` Corinna Vinschen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).