* regression in tgamma?
@ 2020-12-16 13:48 Paul Zimmermann
2020-12-16 20:31 ` Jeff Johnston
0 siblings, 1 reply; 16+ messages in thread
From: Paul Zimmermann @ 2020-12-16 13:48 UTC (permalink / raw)
To: newlib
Hi,
the regression I observed also concerns the binary32 code.
Consider the following code:
$ cat /tmp/test_tgamma.c
#include <stdio.h>
#include <math.h>
#ifdef NEWLIB
int errno;
int* __errno () { return &errno; }
#endif
int main()
{
float x = -0.0f;
float y = tgammaf (x);
printf ("x=%a y=%a\n", x, y);
{
double x = -0x1.53f198fe3b278p+7, y;
y = tgamma (x);
printf ("x=%a y=%a\n", x, y);
}
}
With commit a0d7982ff486292540078c0121a435013c5ee1ea it gives on x86_64/linux
(Intel(R) Core(TM) i5-4590):
$ gcc -no-pie -DNEWLIB /tmp/test_tgamma.c build/x86_64/newlib/libm/tmp/libm.a
$ ./a.out
x=-0x0p+0 y=inf
x=-0x1.53f198fe3b278p+7 y=0x1.fd6d312572d9cp-1015
and with commit 1f8e5847dff27e504949cd21bfeadb987d36ad19:
$ gcc -no-pie -DNEWLIB /tmp/test_tgamma.c build/x86_64/newlib/libm/tmp/libm.a
$ ./a.out
x=-0x0p+0 y=0x1p+0
x=-0x1.53f198fe3b278p+7 y=0x1p+0
Paul
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: regression in tgamma?
2020-12-16 13:48 regression in tgamma? Paul Zimmermann
@ 2020-12-16 20:31 ` Jeff Johnston
2020-12-17 7:29 ` Paul Zimmermann
0 siblings, 1 reply; 16+ messages in thread
From: Jeff Johnston @ 2020-12-16 20:31 UTC (permalink / raw)
To: Paul Zimmermann; +Cc: Newlib
Hi Paul,
I believe I found the problem.
The __ieee754_tgamma functions are not declared in fdlibm.h so the calls in
tgamma and tgammaf are using
default parms and getting things wrong. My test calling __ieee754_tgamma
directly only worked after I added
a declaration to __ieee754_tgamma locally.
I have pushed a change to master. Please try it out.
-- Jeff J.
On Wed, Dec 16, 2020 at 8:49 AM Paul Zimmermann <Paul.Zimmermann@inria.fr>
wrote:
> Hi,
>
> the regression I observed also concerns the binary32 code.
> Consider the following code:
>
> $ cat /tmp/test_tgamma.c
> #include <stdio.h>
> #include <math.h>
>
> #ifdef NEWLIB
> int errno;
> int* __errno () { return &errno; }
> #endif
>
> int main()
> {
> float x = -0.0f;
> float y = tgammaf (x);
> printf ("x=%a y=%a\n", x, y);
> {
> double x = -0x1.53f198fe3b278p+7, y;
> y = tgamma (x);
> printf ("x=%a y=%a\n", x, y);
> }
> }
>
> With commit a0d7982ff486292540078c0121a435013c5ee1ea it gives on
> x86_64/linux
> (Intel(R) Core(TM) i5-4590):
>
> $ gcc -no-pie -DNEWLIB /tmp/test_tgamma.c
> build/x86_64/newlib/libm/tmp/libm.a
> $ ./a.out
> x=-0x0p+0 y=inf
> x=-0x1.53f198fe3b278p+7 y=0x1.fd6d312572d9cp-1015
>
> and with commit 1f8e5847dff27e504949cd21bfeadb987d36ad19:
>
> $ gcc -no-pie -DNEWLIB /tmp/test_tgamma.c
> build/x86_64/newlib/libm/tmp/libm.a
> $ ./a.out
> x=-0x0p+0 y=0x1p+0
> x=-0x1.53f198fe3b278p+7 y=0x1p+0
>
> Paul
>
>
>
>
>
>
>
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: regression in tgamma?
2020-12-16 20:31 ` Jeff Johnston
@ 2020-12-17 7:29 ` Paul Zimmermann
2020-12-17 16:13 ` Keith Packard
0 siblings, 1 reply; 16+ messages in thread
From: Paul Zimmermann @ 2020-12-17 7:29 UTC (permalink / raw)
To: Jeff Johnston; +Cc: newlib
Hi Jeff,
> From: Jeff Johnston <jjohnstn@redhat.com>
> Date: Wed, 16 Dec 2020 15:31:47 -0500
>
> Hi Paul,
>
> I believe I found the problem.
>
> The __ieee754_tgamma functions are not declared in fdlibm.h so the calls in
> tgamma and tgammaf are using
> default parms and getting things wrong. My test calling __ieee754_tgamma
> directly only worked after I added
> a declaration to __ieee754_tgamma locally.
>
> I have pushed a change to master. Please try it out.
>
> -- Jeff J.
with revision 865cd30 I now get:
zimmerma@tomate:/tmp/newlib-cygwin$ ./a.out
x=-0x0p+0 y=inf
x=-0x1.53f198fe3b278p+7 y=0x1.fd6d312572d9cp-1015
The double value is ok, however the float result should be -inf.
This should have been fixed by Keith Packard in commit 4641693.
Paul
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: regression in tgamma?
2020-12-17 7:29 ` Paul Zimmermann
@ 2020-12-17 16:13 ` Keith Packard
2020-12-17 18:27 ` Jeff Johnston
0 siblings, 1 reply; 16+ messages in thread
From: Keith Packard @ 2020-12-17 16:13 UTC (permalink / raw)
To: Paul Zimmermann, Jeff Johnston; +Cc: newlib
[-- Attachment #1: Type: text/plain, Size: 478 bytes --]
Paul Zimmermann <Paul.Zimmermann@inria.fr> writes:
> zimmerma@tomate:/tmp/newlib-cygwin$ ./a.out
> x=-0x0p+0 y=inf
> x=-0x1.53f198fe3b278p+7 y=0x1.fd6d312572d9cp-1015
>
> The double value is ok, however the float result should be -inf.
> This should have been fixed by Keith Packard in commit 4641693.
And it remains fixed in my code here (which is in picolibc instead of
newlib)?
x=-0 y=-inf
x=-169.972 y=5.66756e-306
(using %g instead of %a)
--
-keith
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: regression in tgamma?
2020-12-17 16:13 ` Keith Packard
@ 2020-12-17 18:27 ` Jeff Johnston
2020-12-17 19:16 ` Keith Packard
0 siblings, 1 reply; 16+ messages in thread
From: Jeff Johnston @ 2020-12-17 18:27 UTC (permalink / raw)
To: Keith Packard; +Cc: Paul Zimmermann, Newlib
I am also seeing inf instead of -inf for both tgamma and tgammaf in my
testing.
-- Jeff J.
On Thu, Dec 17, 2020 at 11:13 AM Keith Packard <keithp@keithp.com> wrote:
> Paul Zimmermann <Paul.Zimmermann@inria.fr> writes:
>
> > zimmerma@tomate:/tmp/newlib-cygwin$ ./a.out
> > x=-0x0p+0 y=inf
> > x=-0x1.53f198fe3b278p+7 y=0x1.fd6d312572d9cp-1015
> >
> > The double value is ok, however the float result should be -inf.
> > This should have been fixed by Keith Packard in commit 4641693.
>
> And it remains fixed in my code here (which is in picolibc instead of
> newlib)?
>
> x=-0 y=-inf
> x=-169.972 y=5.66756e-306
>
> (using %g instead of %a)
> --
> -keith
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: regression in tgamma?
2020-12-17 18:27 ` Jeff Johnston
@ 2020-12-17 19:16 ` Keith Packard
2020-12-17 21:28 ` Jeff Johnston
0 siblings, 1 reply; 16+ messages in thread
From: Keith Packard @ 2020-12-17 19:16 UTC (permalink / raw)
To: Jeff Johnston; +Cc: Paul Zimmermann, Newlib
[-- Attachment #1: Type: text/plain, Size: 809 bytes --]
Jeff Johnston <jjohnstn@redhat.com> writes:
> I am also seeing inf instead of -inf for both tgamma and tgammaf in my
> testing.
Yeah, looks like there are quite a few fixes in picolibc that I haven't
had time to send over to newlib.
I've also fixed a bunch of exception problems when compiling with clang,
which is happy to evaluate expressions known at compile time, even
though that doesn't generate exceptions at runtime. (things like 'return
one/zero;')
I've also generated tests for return values, exceptions and errnos for
the math functions to make sure they match the relevant specs and also
match glibc (mostly as a way to check the tests).
Anyone is welcome to pull those fixes out of picolibc and get them into
newlib; I probably won't have time for a while.
--
-keith
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: regression in tgamma?
2020-12-17 19:16 ` Keith Packard
@ 2020-12-17 21:28 ` Jeff Johnston
2020-12-18 6:36 ` Paul Zimmermann
2020-12-18 8:37 ` Paul Zimmermann
0 siblings, 2 replies; 16+ messages in thread
From: Jeff Johnston @ 2020-12-17 21:28 UTC (permalink / raw)
To: Keith Packard; +Cc: Paul Zimmermann, Newlib
Thanks Keith,
I have modified er_lgamma.c, erf_lgamma.c, w_tgamma.c, wf_tgamma.c based on
code changes in picolibc.
I did not add the new ___ieee754_ sub-functions and instead modified the
existing code assuming that the function
was called with *signgam = 0. We can always do a merge from picolibc in
the future.
With the new code, the test runs as expected.
Paul, please confirm before tomorrow.
Thanks,
-- Jeff J.
On Thu, Dec 17, 2020 at 2:17 PM Keith Packard <keithp@keithp.com> wrote:
> Jeff Johnston <jjohnstn@redhat.com> writes:
>
> > I am also seeing inf instead of -inf for both tgamma and tgammaf in my
> > testing.
>
> Yeah, looks like there are quite a few fixes in picolibc that I haven't
> had time to send over to newlib.
>
> I've also fixed a bunch of exception problems when compiling with clang,
> which is happy to evaluate expressions known at compile time, even
> though that doesn't generate exceptions at runtime. (things like 'return
> one/zero;')
>
> I've also generated tests for return values, exceptions and errnos for
> the math functions to make sure they match the relevant specs and also
> match glibc (mostly as a way to check the tests).
>
> Anyone is welcome to pull those fixes out of picolibc and get them into
> newlib; I probably won't have time for a while.
>
> --
> -keith
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: regression in tgamma?
2020-12-17 21:28 ` Jeff Johnston
@ 2020-12-18 6:36 ` Paul Zimmermann
2020-12-18 8:42 ` Corinna Vinschen
2020-12-18 8:37 ` Paul Zimmermann
1 sibling, 1 reply; 16+ messages in thread
From: Paul Zimmermann @ 2020-12-18 6:36 UTC (permalink / raw)
To: Jeff Johnston; +Cc: keithp, newlib
Hi Jeff,
> I have modified er_lgamma.c, erf_lgamma.c, w_tgamma.c, wf_tgamma.c based on
> code changes in picolibc.
> I did not add the new ___ieee754_ sub-functions and instead modified the
> existing code assuming that the function
> was called with *signgam = 0. We can always do a merge from picolibc in the
> future.
>
> With the new code, the test runs as expected.
>
> Paul, please confirm before tomorrow.
version b2f3d59 fails to compile on my x86_64 machine:
../../../../../newlib/libm/math/w_tgamma.c: In function ‘tgamma’:
../../../../../newlib/libm/math/w_tgamma.c:38:6: error: ‘errno’ undeclared (first use in this function)
38 | errno = EDOM;
| ^~~~~
../../../../../newlib/libm/math/w_tgamma.c:19:1: note: ‘errno’ is defined in header ‘<errno.h>’; did you forget to ‘#include <errno.h>’?
18 | #include "fdlibm.h"
+++ |+#include <errno.h>
../../../../../newlib/libm/math/w_tgamma.c:38:6: note: each undeclared identifier is reported only once for each function it appears in
38 | errno = EDOM;
| ^~~~~
../../../../../newlib/libm/math/w_tgamma.c:38:14: error: ‘EDOM’ undeclared (first use in this function)
38 | errno = EDOM;
| ^~~~
../../../../../newlib/libm/math/w_tgamma.c:40:14: error: ‘ERANGE’ undeclared (first use in this function)
40 | errno = ERANGE;
| ^~~~~~
It does after the following changes:
diff --git a/newlib/libm/math/w_tgamma.c b/newlib/libm/math/w_tgamma.c
index 0f90dd4c6..52d5d71d3 100644
--- a/newlib/libm/math/w_tgamma.c
+++ b/newlib/libm/math/w_tgamma.c
@@ -16,6 +16,7 @@
*/
#include "fdlibm.h"
+#include <errno.h>
#ifndef _DOUBLE_IS_32BITS
diff --git a/newlib/libm/math/wf_tgamma.c b/newlib/libm/math/wf_tgamma.c
index 80aacf757..504cb4c29 100644
--- a/newlib/libm/math/wf_tgamma.c
+++ b/newlib/libm/math/wf_tgamma.c
@@ -15,6 +15,7 @@
#include "math.h"
#include "fdlibm.h"
+#include <errno.h>
#ifdef __STDC__
float tgammaf(float x)
@@ -34,7 +35,6 @@
errno = EDOM;
else if (finite(x))
errno = ERANGE;
- }
return y;
#endif
}
and my small test program gives:
zimmerma@tomate:/tmp/newlib-cygwin$ ./a.out
x=-0x0p+0 y=-inf
x=-0x1.53f198fe3b278p+7 y=0x1.fd6d312572d9cp-1015
which is ok. I'll do some further tests.
Paul
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: regression in tgamma?
2020-12-17 21:28 ` Jeff Johnston
2020-12-18 6:36 ` Paul Zimmermann
@ 2020-12-18 8:37 ` Paul Zimmermann
1 sibling, 0 replies; 16+ messages in thread
From: Paul Zimmermann @ 2020-12-18 8:37 UTC (permalink / raw)
To: Jeff Johnston; +Cc: keithp, newlib
Hi again,
I have checked both tgammaf and tgamma with commit b2f3d59 (on x86_64).
tgammaf (exhaustive test of all the 2^32 inputs) no longer has the issue
of tgammaf(-0) = +inf instead of -inf, and similarly for -2^-128 <= x < 0.
The larger ulp error is 239 ulps as in 3.3.0 (for x=-0x1.01743cp+5).
For tgamma, by random testing I get the same maximal error as before:
2244.45 ulps for x=-0x1.53f198fe3b278p+7.
Thus the regression we had in 4.0.0 has gone.
Thanks Jeff,
Paul
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: regression in tgamma?
2020-12-18 6:36 ` Paul Zimmermann
@ 2020-12-18 8:42 ` Corinna Vinschen
2020-12-18 8:54 ` Paul Zimmermann
0 siblings, 1 reply; 16+ messages in thread
From: Corinna Vinschen @ 2020-12-18 8:42 UTC (permalink / raw)
To: Paul Zimmermann; +Cc: newlib
Paul,
could you please send patches in `git format-patch' format?
Even with `patch -p1', the below patch doesn't apply cleanly.
Thanks,
Corinna
On Dec 18 07:36, Paul Zimmermann wrote:
> Hi Jeff,
>
> > I have modified er_lgamma.c, erf_lgamma.c, w_tgamma.c, wf_tgamma.c based on
> > code changes in picolibc.
> > I did not add the new ___ieee754_ sub-functions and instead modified the
> > existing code assuming that the function
> > was called with *signgam = 0. We can always do a merge from picolibc in the
> > future.
> >
> > With the new code, the test runs as expected.
> >
> > Paul, please confirm before tomorrow.
>
> version b2f3d59 fails to compile on my x86_64 machine:
>
> ../../../../../newlib/libm/math/w_tgamma.c: In function ‘tgamma’:
> ../../../../../newlib/libm/math/w_tgamma.c:38:6: error: ‘errno’ undeclared (first use in this function)
> 38 | errno = EDOM;
> | ^~~~~
> ../../../../../newlib/libm/math/w_tgamma.c:19:1: note: ‘errno’ is defined in header ‘<errno.h>’; did you forget to ‘#include <errno.h>’?
> 18 | #include "fdlibm.h"
> +++ |+#include <errno.h>
>
> ../../../../../newlib/libm/math/w_tgamma.c:38:6: note: each undeclared identifier is reported only once for each function it appears in
> 38 | errno = EDOM;
> | ^~~~~
> ../../../../../newlib/libm/math/w_tgamma.c:38:14: error: ‘EDOM’ undeclared (first use in this function)
> 38 | errno = EDOM;
> | ^~~~
> ../../../../../newlib/libm/math/w_tgamma.c:40:14: error: ‘ERANGE’ undeclared (first use in this function)
> 40 | errno = ERANGE;
> | ^~~~~~
>
> It does after the following changes:
>
> diff --git a/newlib/libm/math/w_tgamma.c b/newlib/libm/math/w_tgamma.c
> index 0f90dd4c6..52d5d71d3 100644
> --- a/newlib/libm/math/w_tgamma.c
> +++ b/newlib/libm/math/w_tgamma.c
> @@ -16,6 +16,7 @@
> */
>
> #include "fdlibm.h"
> +#include <errno.h>
>
> #ifndef _DOUBLE_IS_32BITS
>
> diff --git a/newlib/libm/math/wf_tgamma.c b/newlib/libm/math/wf_tgamma.c
> index 80aacf757..504cb4c29 100644
> --- a/newlib/libm/math/wf_tgamma.c
> +++ b/newlib/libm/math/wf_tgamma.c
> @@ -15,6 +15,7 @@
>
> #include "math.h"
> #include "fdlibm.h"
> +#include <errno.h>
>
> #ifdef __STDC__
> float tgammaf(float x)
> @@ -34,7 +35,6 @@
> errno = EDOM;
> else if (finite(x))
> errno = ERANGE;
> - }
> return y;
> #endif
> }
>
> and my small test program gives:
>
> zimmerma@tomate:/tmp/newlib-cygwin$ ./a.out
> x=-0x0p+0 y=-inf
> x=-0x1.53f198fe3b278p+7 y=0x1.fd6d312572d9cp-1015
>
> which is ok. I'll do some further tests.
>
> Paul
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: regression in tgamma?
2020-12-18 8:42 ` Corinna Vinschen
@ 2020-12-18 8:54 ` Paul Zimmermann
2020-12-18 9:07 ` Corinna Vinschen
0 siblings, 1 reply; 16+ messages in thread
From: Paul Zimmermann @ 2020-12-18 8:54 UTC (permalink / raw)
To: newlib; +Cc: newlib
Dear Corinna,
sorry, here is the patch generated by "git format-patch".
Paul
From bb94a62d68012fc38a0b6b14cedb806ff86b5c29 Mon Sep 17 00:00:00 2001
From: Paul Zimmermann <Paul.Zimmermann@inria.fr>
Date: Fri, 18 Dec 2020 09:52:40 +0100
Subject: [PATCH] fixes to make compilation succeeds
---
newlib/libm/math/w_tgamma.c | 1 +
newlib/libm/math/wf_tgamma.c | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/newlib/libm/math/w_tgamma.c b/newlib/libm/math/w_tgamma.c
index 0f90dd4c6..52d5d71d3 100644
--- a/newlib/libm/math/w_tgamma.c
+++ b/newlib/libm/math/w_tgamma.c
@@ -16,6 +16,7 @@
*/
#include "fdlibm.h"
+#include <errno.h>
#ifndef _DOUBLE_IS_32BITS
diff --git a/newlib/libm/math/wf_tgamma.c b/newlib/libm/math/wf_tgamma.c
index 80aacf757..504cb4c29 100644
--- a/newlib/libm/math/wf_tgamma.c
+++ b/newlib/libm/math/wf_tgamma.c
@@ -15,6 +15,7 @@
#include "math.h"
#include "fdlibm.h"
+#include <errno.h>
#ifdef __STDC__
float tgammaf(float x)
@@ -34,7 +35,6 @@
errno = EDOM;
else if (finite(x))
errno = ERANGE;
- }
return y;
#endif
}
--
2.29.2
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: regression in tgamma?
2020-12-18 8:54 ` Paul Zimmermann
@ 2020-12-18 9:07 ` Corinna Vinschen
2020-12-18 17:42 ` Jeff Johnston
0 siblings, 1 reply; 16+ messages in thread
From: Corinna Vinschen @ 2020-12-18 9:07 UTC (permalink / raw)
To: newlib
On Dec 18 09:54, Paul Zimmermann wrote:
> Dear Corinna,
>
> sorry, here is the patch generated by "git format-patch".
Thanks, I pushed the patch.
Corinna
>
> Paul
>
> >From bb94a62d68012fc38a0b6b14cedb806ff86b5c29 Mon Sep 17 00:00:00 2001
> From: Paul Zimmermann <Paul.Zimmermann@inria.fr>
> Date: Fri, 18 Dec 2020 09:52:40 +0100
> Subject: [PATCH] fixes to make compilation succeeds
>
> ---
> newlib/libm/math/w_tgamma.c | 1 +
> newlib/libm/math/wf_tgamma.c | 2 +-
> 2 files changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/newlib/libm/math/w_tgamma.c b/newlib/libm/math/w_tgamma.c
> index 0f90dd4c6..52d5d71d3 100644
> --- a/newlib/libm/math/w_tgamma.c
> +++ b/newlib/libm/math/w_tgamma.c
> @@ -16,6 +16,7 @@
> */
>
> #include "fdlibm.h"
> +#include <errno.h>
>
> #ifndef _DOUBLE_IS_32BITS
>
> diff --git a/newlib/libm/math/wf_tgamma.c b/newlib/libm/math/wf_tgamma.c
> index 80aacf757..504cb4c29 100644
> --- a/newlib/libm/math/wf_tgamma.c
> +++ b/newlib/libm/math/wf_tgamma.c
> @@ -15,6 +15,7 @@
>
> #include "math.h"
> #include "fdlibm.h"
> +#include <errno.h>
>
> #ifdef __STDC__
> float tgammaf(float x)
> @@ -34,7 +35,6 @@
> errno = EDOM;
> else if (finite(x))
> errno = ERANGE;
> - }
> return y;
> #endif
> }
> --
> 2.29.2
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: regression in tgamma?
2020-12-18 9:07 ` Corinna Vinschen
@ 2020-12-18 17:42 ` Jeff Johnston
0 siblings, 0 replies; 16+ messages in thread
From: Jeff Johnston @ 2020-12-18 17:42 UTC (permalink / raw)
To: Newlib; +Cc: Corinna Vinschen
Thanks Paul, Corinna. I was testing locally in my directory and had a
work-around for errno already in place.
I will make the snapshot later this afternoon.
-- Jeff J.
On Fri, Dec 18, 2020 at 4:07 AM Corinna Vinschen via Newlib <
newlib@sourceware.org> wrote:
> On Dec 18 09:54, Paul Zimmermann wrote:
> > Dear Corinna,
> >
> > sorry, here is the patch generated by "git format-patch".
>
> Thanks, I pushed the patch.
>
>
> Corinna
>
>
> >
> > Paul
> >
> > >From bb94a62d68012fc38a0b6b14cedb806ff86b5c29 Mon Sep 17 00:00:00 2001
> > From: Paul Zimmermann <Paul.Zimmermann@inria.fr>
> > Date: Fri, 18 Dec 2020 09:52:40 +0100
> > Subject: [PATCH] fixes to make compilation succeeds
> >
> > ---
> > newlib/libm/math/w_tgamma.c | 1 +
> > newlib/libm/math/wf_tgamma.c | 2 +-
> > 2 files changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/newlib/libm/math/w_tgamma.c b/newlib/libm/math/w_tgamma.c
> > index 0f90dd4c6..52d5d71d3 100644
> > --- a/newlib/libm/math/w_tgamma.c
> > +++ b/newlib/libm/math/w_tgamma.c
> > @@ -16,6 +16,7 @@
> > */
> >
> > #include "fdlibm.h"
> > +#include <errno.h>
> >
> > #ifndef _DOUBLE_IS_32BITS
> >
> > diff --git a/newlib/libm/math/wf_tgamma.c b/newlib/libm/math/wf_tgamma.c
> > index 80aacf757..504cb4c29 100644
> > --- a/newlib/libm/math/wf_tgamma.c
> > +++ b/newlib/libm/math/wf_tgamma.c
> > @@ -15,6 +15,7 @@
> >
> > #include "math.h"
> > #include "fdlibm.h"
> > +#include <errno.h>
> >
> > #ifdef __STDC__
> > float tgammaf(float x)
> > @@ -34,7 +35,6 @@
> > errno = EDOM;
> > else if (finite(x))
> > errno = ERANGE;
> > - }
> > return y;
> > #endif
> > }
> > --
> > 2.29.2
>
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: regression in tgamma?
2020-12-15 17:11 ` Jeff Johnston
@ 2020-12-16 6:36 ` Paul Zimmermann
0 siblings, 0 replies; 16+ messages in thread
From: Paul Zimmermann @ 2020-12-16 6:36 UTC (permalink / raw)
To: Jeff Johnston; +Cc: newlib
Hi Jeff,
thank you for your answer. Here are the steps I followed to compile Newlib
(thanks Alexei Sibidanov):
# from newlib-3.3.0 or newlib-4.0.0
mkdir build
cd build
../configure --prefix=`pwd` --target=x86_64
# perform the following in $HOME/bin
ln -sf `which ar` x86_64-ar
ln -sf `which as` x86_64-as
ln -sf `which cc` x86_64-cc
ln -sf `which gcc` x86_64-gcc
ln -sf `which c++` x86_64-c++
ln -sf `which ld` x86_64-ld
ln -sf `which nm` x86_64-nm
ln -sf `which objdump` x86_64-objdump
ln -sf `which objcopy` x86_64-objcopy
ln -sf `which ranlib` x86_64-ranlib
ln -sf `which readelf` x86_64-readelf
ln -sf `which strip` x86_64-strip
make # it will fail but it is ok
cd x86_64/newlib/libm
make # fails too
cd tmp
ar cr libm.a *.o
If you have access to the GCC Compile Farm [1], you can reproduce on gcc67:
$ cd /home/zimmerma
$ gcc -DNEWLIB -no-pie test3.c newlib-3.3.0/build/x86_64/newlib/libm/tmp/libm.a
$ ./a.out
x=-0x1.53f198fe3b278p+7 y=0x1.fd6d312572d9cp-1015
$ gcc -DNEWLIB -no-pie test3.c newlib-4.0.0/build/x86_64/newlib/libm/tmp/libm.a
$ ./a.out
x=-0x1.53f198fe3b278p+7 y=0x1p+0
If you have a simpler way to compile Newlib, please tell me.
Best regards,
Paul
[1] https://gcc.gnu.org/wiki/CompileFarm#List_of_machines
> From: Jeff Johnston <jjohnstn@redhat.com>
> Date: Tue, 15 Dec 2020 12:11:25 -0500
>
> Hi Paul,
>
> I copied the newlib/libm/common directory and header files from master to a
> separate directory and called __ieee754_tgamma directly in your test (adding
> a declaration of __ieee754_tgamma as well). I then built as follows:
>
> gcc -g -O0 -I. -DNEWLIB testtgamma.c e_tgamma.c e_exp.c k_sin.c math_err.c
> er_lgamma.c k_cos.c s_floor.c e_log.c w_log.c
>
> I get the same result as you get for 3.3.0.
>
> Can you possibly recheck to see if your 4.0.0 library has been built
> correctly? Perhaps I have somehow by-passed the cause of the problem by
> compiling directly.
>
> -- Jeff J.
>
> On Tue, Dec 15, 2020 at 8:36 AM Paul Zimmermann <Paul.Zimmermann@inria.fr>
> wrote:
>
> Hi,
>
> while updating my comparison from Newlib 3.3.0 to Newlib 4.0.0, I found
> a
> regression in tgamma on x86_64/Linux:
>
> $ cat test3.c
> #include <stdio.h>
> #include <math.h>
>
> #ifdef NEWLIB
> int errno;
> int* __errno () { return &errno; }
> #endif
>
> int main()
> {
> double x = -0x1.53f198fe3b278p+7, y;
> y = tgamma (x);
> printf ("x=%a y=%a\n", x, y);
> }
>
> Newlib 3.3.0:
> $ gcc -DNEWLIB -no-pie test3.c /localdisk/zimmerma/newlib-3.3.0/libm.a;
> ./a.out
> x=-0x1.53f198fe3b278p+7 y=0x1.fd6d312572d9cp-1015
>
> Newlib 4.0.0:
> $ gcc -DNEWLIB -no-pie test3.c /localdisk/zimmerma/newlib-4.0.0/libm.a;
> ./a.out
> x=-0x1.53f198fe3b278p+7 y=0x1p+0
>
> Please can someone confirm?
>
> Best regards,
> Paul
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: regression in tgamma?
2020-12-15 13:35 Paul Zimmermann
@ 2020-12-15 17:11 ` Jeff Johnston
2020-12-16 6:36 ` Paul Zimmermann
0 siblings, 1 reply; 16+ messages in thread
From: Jeff Johnston @ 2020-12-15 17:11 UTC (permalink / raw)
To: Paul Zimmermann; +Cc: Newlib
Hi Paul,
I copied the newlib/libm/common directory and header files from master to a
separate directory and called __ieee754_tgamma directly in your test (adding
a declaration of __ieee754_tgamma as well). I then built as follows:
gcc -g -O0 -I. -DNEWLIB testtgamma.c e_tgamma.c e_exp.c k_sin.c math_err.c
er_lgamma.c k_cos.c s_floor.c e_log.c w_log.c
I get the same result as you get for 3.3.0.
Can you possibly recheck to see if your 4.0.0 library has been built
correctly? Perhaps I have somehow by-passed the cause of the problem by
compiling directly.
-- Jeff J.
On Tue, Dec 15, 2020 at 8:36 AM Paul Zimmermann <Paul.Zimmermann@inria.fr>
wrote:
> Hi,
>
> while updating my comparison from Newlib 3.3.0 to Newlib 4.0.0, I found a
> regression in tgamma on x86_64/Linux:
>
> $ cat test3.c
> #include <stdio.h>
> #include <math.h>
>
> #ifdef NEWLIB
> int errno;
> int* __errno () { return &errno; }
> #endif
>
> int main()
> {
> double x = -0x1.53f198fe3b278p+7, y;
> y = tgamma (x);
> printf ("x=%a y=%a\n", x, y);
> }
>
> Newlib 3.3.0:
> $ gcc -DNEWLIB -no-pie test3.c /localdisk/zimmerma/newlib-3.3.0/libm.a;
> ./a.out
> x=-0x1.53f198fe3b278p+7 y=0x1.fd6d312572d9cp-1015
>
> Newlib 4.0.0:
> $ gcc -DNEWLIB -no-pie test3.c /localdisk/zimmerma/newlib-4.0.0/libm.a;
> ./a.out
> x=-0x1.53f198fe3b278p+7 y=0x1p+0
>
> Please can someone confirm?
>
> Best regards,
> Paul
>
>
^ permalink raw reply [flat|nested] 16+ messages in thread
* regression in tgamma?
@ 2020-12-15 13:35 Paul Zimmermann
2020-12-15 17:11 ` Jeff Johnston
0 siblings, 1 reply; 16+ messages in thread
From: Paul Zimmermann @ 2020-12-15 13:35 UTC (permalink / raw)
To: newlib
Hi,
while updating my comparison from Newlib 3.3.0 to Newlib 4.0.0, I found a
regression in tgamma on x86_64/Linux:
$ cat test3.c
#include <stdio.h>
#include <math.h>
#ifdef NEWLIB
int errno;
int* __errno () { return &errno; }
#endif
int main()
{
double x = -0x1.53f198fe3b278p+7, y;
y = tgamma (x);
printf ("x=%a y=%a\n", x, y);
}
Newlib 3.3.0:
$ gcc -DNEWLIB -no-pie test3.c /localdisk/zimmerma/newlib-3.3.0/libm.a; ./a.out
x=-0x1.53f198fe3b278p+7 y=0x1.fd6d312572d9cp-1015
Newlib 4.0.0:
$ gcc -DNEWLIB -no-pie test3.c /localdisk/zimmerma/newlib-4.0.0/libm.a; ./a.out
x=-0x1.53f198fe3b278p+7 y=0x1p+0
Please can someone confirm?
Best regards,
Paul
^ permalink raw reply [flat|nested] 16+ messages in thread
end of thread, other threads:[~2020-12-18 17:42 UTC | newest]
Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-16 13:48 regression in tgamma? Paul Zimmermann
2020-12-16 20:31 ` Jeff Johnston
2020-12-17 7:29 ` Paul Zimmermann
2020-12-17 16:13 ` Keith Packard
2020-12-17 18:27 ` Jeff Johnston
2020-12-17 19:16 ` Keith Packard
2020-12-17 21:28 ` Jeff Johnston
2020-12-18 6:36 ` Paul Zimmermann
2020-12-18 8:42 ` Corinna Vinschen
2020-12-18 8:54 ` Paul Zimmermann
2020-12-18 9:07 ` Corinna Vinschen
2020-12-18 17:42 ` Jeff Johnston
2020-12-18 8:37 ` Paul Zimmermann
-- strict thread matches above, loose matches on Subject: below --
2020-12-15 13:35 Paul Zimmermann
2020-12-15 17:11 ` Jeff Johnston
2020-12-16 6:36 ` Paul Zimmermann
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).