Andreas Jaeger | 9 Feb 22:49
Gravatar

Fix for bz#13658 - using fsincos on x86-64

We should not use the inaccurate fsincos instruction on x86-64 (see 
bugzilla and the discussion on the gcc mailing list). Let's just remove 
the double version and use the IBM libm sincos implementation.

Unfortunately the same fix does not work for the long double version - 
since there's no sincos implementation for ldbl-96 yet ;-(. Jakub, you 
wrote the ldb-128 versions - do you have any suggestions?

Andreas

2012-02-09  Andreas Jaeger  <aj <at> suse.de>

	[BZ#13658]
	* sysdeps/x86_64/fpu/s_sincos.S: Remove, let's not use the
	inaccurate fsincos instruction.

--

-- 
  Andreas Jaeger aj@{suse.com,opensuse.org} Twitter/Identica: jaegerandi
   SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
    GF: Jeff Hawn,Jennifer Guild,Felix Imendörffer,HRB16746 (AG Nürnberg)
     GPG fingerprint = 93A3 365E CE47 B889 DF7F  FED1 389A 563C C272 A126
commit b9443d818d7046f903a5135fa5201c95601a68fa
Author: Andreas Jaeger <aj <at> suse.de>
Date:   Thu Feb 9 22:45:02 2012 +0100

    2012-02-09  Andreas Jaeger  <aj <at> suse.de>

    	[BZ#13658]
(Continue reading)

Carlos O'Donell | 13 Feb 05:49
Gravatar

Re: Fix for bz#13658 - using fsincos on x86-64

On Thu, Feb 9, 2012 at 4:49 PM, Andreas Jaeger <aj <at> suse.com> wrote:
> We should not use the inaccurate fsincos instruction on x86-64 (see bugzilla
> and the discussion on the gcc mailing list). Let's just remove the double
> version and use the IBM libm sincos implementation.
>
> Unfortunately the same fix does not work for the long double version - since
> there's no sincos implementation for ldbl-96 yet ;-(. Jakub, you wrote the
> ldb-128 versions - do you have any suggestions?
>
> Andreas
>
> 2012-02-09  Andreas Jaeger  <aj <at> suse.de>
>
>        [BZ#13658]
>        * sysdeps/x86_64/fpu/s_sincos.S: Remove, let's not use the
>        inaccurate fsincos instruction.

Is there any reason we don't do long-form argument reduction (as
normal sin and cos do) followed by fsincos?

Does this effect i386 which also uses fsincos?

Does this also effect m68k which uses fsincos (M68000PM/AD REV.1
states loss of accuracy if the input is > 10^20).

Cheers,
Carlos.

Joseph S. Myers | 23 Feb 22:29

Re: Fix for bz#13658 - using fsincos on x86-64

On Sun, 12 Feb 2012, Carlos O'Donell wrote:

> On Thu, Feb 9, 2012 at 4:49 PM, Andreas Jaeger <aj <at> suse.com> wrote:
> > We should not use the inaccurate fsincos instruction on x86-64 (see bugzilla
> > and the discussion on the gcc mailing list). Let's just remove the double
> > version and use the IBM libm sincos implementation.
> >
> > Unfortunately the same fix does not work for the long double version - since
> > there's no sincos implementation for ldbl-96 yet ;-(. Jakub, you wrote the
> > ldb-128 versions - do you have any suggestions?

What's actually missing is k_sinl.c / k_cosl.c.  Apart from the bits 
dealing with extracting integer values from the bits of a long double, you 
could probably just reuse the ldbl-128 versions (the numbers in the tables 
may have more decimal digits specified than needed, and approximations may 
be computed with more terms than needed, but they should still work once 
you fix up the integer bits).

> > 2012-02-09  Andreas Jaeger  <aj <at> suse.de>
> >
> >        [BZ#13658]
> >        * sysdeps/x86_64/fpu/s_sincos.S: Remove, let's not use the
> >        inaccurate fsincos instruction.
> 
> Is there any reason we don't do long-form argument reduction (as
> normal sin and cos do) followed by fsincos?

The long-form reduction actually produces a sum of two values rather than 
just a single reduced value, for greater accuracy (although not correctly 
rounded results).  I don't know how accurate fsincos is for reduced values 
(Continue reading)

Andreas Jaeger | 24 Feb 17:01
Gravatar

Re: Fix for bz#13658 - using fsincos on x86-64

On 02/23/2012 10:29 PM, Joseph S. Myers wrote:
> On Sun, 12 Feb 2012, Carlos O'Donell wrote:
>
>> On Thu, Feb 9, 2012 at 4:49 PM, Andreas Jaeger<aj <at> suse.com>  wrote:
>>> We should not use the inaccurate fsincos instruction on x86-64 (see bugzilla
>>> and the discussion on the gcc mailing list). Let's just remove the double
>>> version and use the IBM libm sincos implementation.
>>>
>>> Unfortunately the same fix does not work for the long double version - since
>>> there's no sincos implementation for ldbl-96 yet ;-(. Jakub, you wrote the
>>> ldb-128 versions - do you have any suggestions?
>
> What's actually missing is k_sinl.c / k_cosl.c.  Apart from the bits
> dealing with extracting integer values from the bits of a long double, you
> could probably just reuse the ldbl-128 versions (the numbers in the tables
> may have more decimal digits specified than needed, and approximations may
> be computed with more terms than needed, but they should still work once
> you fix up the integer bits).

Sorry, I won't have time in the near future to do this myself.

>>> 2012-02-09  Andreas Jaeger<aj <at> suse.de>
>>>
>>>         [BZ#13658]
>>>         * sysdeps/x86_64/fpu/s_sincos.S: Remove, let's not use the
>>>         inaccurate fsincos instruction.
>>
>> Is there any reason we don't do long-form argument reduction (as
>> normal sin and cos do) followed by fsincos?
>
(Continue reading)

Carlos O'Donell | 24 Feb 17:15
Gravatar

Re: Fix for bz#13658 - using fsincos on x86-64

On Fri, Feb 24, 2012 at 11:01 AM, Andreas Jaeger <aj <at> suse.com> wrote:
> I can add a couple of testcases. How do we want to continue? Should we use
> the patch to fix the double case - and then later handle long double, or do
> you want everything fixed at the same time?

Andreas, Thanks for helping!

Incremental improvement is the best way forward in my opinion.

* Fix the double case.
* File a new bugzilla issue to fix the long double case noting
Joseph's suggestion.
* Add new test cases to cover the problem.

Cheers,
Carlos.

Joseph S. Myers | 24 Feb 18:32

Re: Fix for bz#13658 - using fsincos on x86-64

On Fri, 24 Feb 2012, Carlos O'Donell wrote:

> On Fri, Feb 24, 2012 at 11:01 AM, Andreas Jaeger <aj <at> suse.com> wrote:
> > I can add a couple of testcases. How do we want to continue? Should we use
> > the patch to fix the double case - and then later handle long double, or do
> > you want everything fixed at the same time?
> 
> Andreas, Thanks for helping!
> 
> Incremental improvement is the best way forward in my opinion.

Agreed.

> * Fix the double case.

Yes.  For 32-bit x86 it looks like all of float, double and long double 
are affected (float and double should be easy to fix).

> * File a new bugzilla issue to fix the long double case noting
> Joseph's suggestion.

Yes.  Point to this discussion.

> * Add new test cases to cover the problem.

Yes.  If necessary, disable them for the affected long double format, with 
a comment pointing to the new bug (rather than adding enormous numbers of 
ulps as expected for the new tests for long double).

--

-- 
(Continue reading)

Joseph S. Myers | 6 Mar 21:51

Re: Fix for bz#13658 - using fsincos on x86-64

Any news here?  As noted in 
<http://sourceware.org/ml/libc-alpha/2012-02/msg00578.html> I'd like to 
see incremental progress here - some cases fixed, with testcases added, 
even if not all cases are fixed (eventually we should have reasonably 
accurate results for large arguments for all of sin, cos, sincos, tan, for 
all argument types, with associated testcases).  That would then provide a 
basis for other people to fix the long double version on top of fixes for 
other types, for example.

Given the use of sincos in other functions, having fixes for sincos is 
important to be able to add tests for large inputs to various other 
functions (in particular, fixing the Bessel function TLOSS issues).

--

-- 
Joseph S. Myers
joseph <at> codesourcery.com

Andreas Jaeger | 7 Mar 14:40
Gravatar

Re: Fix for bz#13658 - using fsincos on x86-64

On Tuesday, March 06, 2012 21:51:53 Joseph S. Myers wrote:
> Any news here?  As noted in
> <http://sourceware.org/ml/libc-alpha/2012-02/msg00578.html> I'd like to
> see incremental progress here - some cases fixed, with testcases added,
> even if not all cases are fixed (eventually we should have reasonably
> accurate results for large arguments for all of sin, cos, sincos, tan,
> for all argument types, with associated testcases).  That would then
> provide a basis for other people to fix the long double version on top
> of fixes for other types, for example.
> 
> Given the use of sincos in other functions, having fixes for sincos is
> important to be able to add tests for large inputs to various other
> functions (in particular, fixing the Bessel function TLOSS issues).

Adding a test for double sincos - after my change for x86-64, gives the following error in the math testsuite:

$ cat math/test-double.out 
testing double (without inline functions)
Failure: Test: sincos (1e22, &sin_res, &cos_res) puts -0.8522008497671888017727058937530 in sin_res
Result:
 is:          4.62613040764601746169e-01   0x1.d9b73ba325f820000000p-2
 should be:  -8.52200849767188794992e-01  -0x1.b453ab76bf3970000000p-1
 difference:  1.31481389053179054116e+00   0x1.5097a4a4291ac0000000p+0
 ulp       :  11842790694921048.0000
 max.ulp   :  0.0000
Failure: Test: sincos (1e22, &sin_res, &cos_res) puts 0.5232147853951389454975944733847 in cos_res
Result:
 is:         -8.86560305063636922007e-01  -0x1.c5eb3b785c3690000000p-1
 should be:   5.23214785395138992641e-01   0x1.0be2cef01c8f40000000p-1
 difference:  1.40977509045877580363e+00   0x1.68e705343c62e0000000p+0
(Continue reading)

Joseph S. Myers | 7 Mar 14:51

Re: Fix for bz#13658 - using fsincos on x86-64

On Wed, 7 Mar 2012, Andreas Jaeger wrote:

> So, the result has nothing to do with the expected result. The test 
> passes on x86-64.
> 
> I could add the testcase and the fix for x86-64 and not run it on i386 - 
> or only run it on x86-64. What do you propose?

Is this failing on i386 with sysdeps/i386/fpu/s_sincos.S removed?  Because 
I'd expect both x86-64 and i386 to need the same fix at the same time.

Actually it looks like s_sincos.c is using __sin and __cos - meaning that 
i386 would need s_sin.S and s_cos.S removed as well.  But I'd guess that 
sin and cos have the same problems for large inputs (insufficiently 
accurate range reduction) as sincos and so that making i386 follow x86-64 
in using the generic dbl-64 versions of those functions would also be an 
improvement.

(Eventually all of sin, cos, tan, sincos should have testcases for large 
inputs covering all of float, double, long double - but that will need 
quite a few more fixes including ldbl-96 implementations of a few 
functions.  So I think we should get in the minimum that can be done 
incrementally, then follow up later with more fixes and tests for more 
functions, for more input formats.)

--

-- 
Joseph S. Myers
joseph <at> codesourcery.com

(Continue reading)

Andreas Jaeger | 7 Mar 15:10
Gravatar

Re: Fix for bz#13658 - using fsincos on x86-64

On Wednesday, March 07, 2012 14:51:34 Joseph S. Myers wrote:
> On Wed, 7 Mar 2012, Andreas Jaeger wrote:
> > So, the result has nothing to do with the expected result. The test
> > passes on x86-64.
> > 
> > I could add the testcase and the fix for x86-64 and not run it on i386
> > - or only run it on x86-64. What do you propose?
> 
> Is this failing on i386 with sysdeps/i386/fpu/s_sincos.S removed? 

In either case.

> Because I'd expect both x86-64 and i386 to need the same fix at the
> same time.
> 
> Actually it looks like s_sincos.c is using __sin and __cos - meaning
> that i386 would need s_sin.S and s_cos.S removed as well.  But I'd
> guess that sin and cos have the same problems for large inputs
> (insufficiently accurate range reduction) as sincos and so that making
> i386 follow x86-64 in using the generic dbl-64 versions of those
> functions would also be an improvement.

Yes, indeed. Let me check this...

> (Eventually all of sin, cos, tan, sincos should have testcases for large
> inputs covering all of float, double, long double - but that will need
> quite a few more fixes including ldbl-96 implementations of a few
> functions.  So I think we should get in the minimum that can be done
> incrementally, then follow up later with more fixes and tests for more
> functions, for more input formats.)
(Continue reading)

Andreas Jaeger | 7 Mar 15:28
Gravatar

Re: Fix for bz#13658 - using fsincos on x86-64

On Wednesday, March 07, 2012 15:10:55 Andreas Jaeger wrote:
> On Wednesday, March 07, 2012 14:51:34 Joseph S. Myers wrote:
> > On Wed, 7 Mar 2012, Andreas Jaeger wrote:
> > > So, the result has nothing to do with the expected result. The test
> > > passes on x86-64.
> > > 
> > > I could add the testcase and the fix for x86-64 and not run it on
> > > i386 - or only run it on x86-64. What do you propose?
> > 
> > Is this failing on i386 with sysdeps/i386/fpu/s_sincos.S removed?
> 
> In either case.
> 
> > Because I'd expect both x86-64 and i386 to need the same fix at the
> > same time.
> > 
> > Actually it looks like s_sincos.c is using __sin and __cos - meaning
> > that i386 would need s_sin.S and s_cos.S removed as well.  But I'd
> > guess that sin and cos have the same problems for large inputs
> > (insufficiently accurate range reduction) as sincos and so that making
> > i386 follow x86-64 in using the generic dbl-64 versions of those
> > functions would also be an improvement.
> 
> Yes, indeed. Let me check this...

A couple of files need to be removed - and atest-sincos.out fails now :-(

cat math/atest-sincos.out 
sin:
785997 failures; 188 errors; error rate 0.02%
(Continue reading)

Joseph S. Myers | 7 Mar 16:25

Re: Fix for bz#13658 - using fsincos on x86-64

On Wed, 7 Mar 2012, Andreas Jaeger wrote:

> test-double fails with a lot of tests, starting with:
> testing double (without inline functions)
> Failure: Test: cos (M_PI_6l * 2.0) == 0.5
> Result:
>  is:          4.99861241344128237607e-01   0x1.ffdba01071a860000000p-2
>  should be:   5.00000000000000000000e-01   0x1.00000000000000000000p-1
>  difference:  1.38758655871762393019e-04   0x1.22ff7c72bd0000000000p-13
>  ulp       :  1249826861757.0000
>  max.ulp   :  1.0000
> 
> I need some more time to investigate this - and would appreciate any help,

One possibility is that the C implementations of sin and cos only work 
with rounding to 53 bits, not with x87 excess precision.  If so, then 
setting the FPU to 53-bit mode should help (and the libc_feupdateenv calls 
should handle restoring 64-bit mode), though some new macro would be 
needed to handle the environment setup for the affected functions (or 
you could have an i386 version of s_sin.c that includes headers, redefines 
libc_feholdexcept_setround then includes the main s_sin.c).

--

-- 
Joseph S. Myers
joseph <at> codesourcery.com

Joseph S. Myers | 14 Mar 16:12

Re: Fix for bz#13658 - using fsincos on x86-64

On Wed, 7 Mar 2012, Joseph S. Myers wrote:

> On Wed, 7 Mar 2012, Andreas Jaeger wrote:
> 
> > test-double fails with a lot of tests, starting with:
> > testing double (without inline functions)
> > Failure: Test: cos (M_PI_6l * 2.0) == 0.5
> > Result:
> >  is:          4.99861241344128237607e-01   0x1.ffdba01071a860000000p-2
> >  should be:   5.00000000000000000000e-01   0x1.00000000000000000000p-1
> >  difference:  1.38758655871762393019e-04   0x1.22ff7c72bd0000000000p-13
> >  ulp       :  1249826861757.0000
> >  max.ulp   :  1.0000
> > 
> > I need some more time to investigate this - and would appreciate any help,
> 
> One possibility is that the C implementations of sin and cos only work 
> with rounding to 53 bits, not with x87 excess precision.  If so, then 
> setting the FPU to 53-bit mode should help (and the libc_feupdateenv calls 
> should handle restoring 64-bit mode), though some new macro would be 
> needed to handle the environment setup for the affected functions (or 
> you could have an i386 version of s_sin.c that includes headers, redefines 
> libc_feholdexcept_setround then includes the main s_sin.c).

Something like this.  Together with removing the files you listed in 
<http://sourceware.org/ml/libc-alpha/2012-03/msg00164.html>, this appears 
to work on x86 (some tests of j1/jn/yn increase their ulps from 1ulp to 
2ulp to me, but I think that's fine as a side-effect of slightly more 
accurate sincos; there are no other math/ failures) - though I haven't 
tested with any new cases.  Defining new macros for setting 53-bit 
(Continue reading)

Andreas Jaeger | 14 Mar 16:29
Gravatar

Re: Fix for bz#13658 - using fsincos on x86-64

On Wednesday, March 14, 2012 16:12:04 Joseph S. Myers wrote:
> On Wed, 7 Mar 2012, Joseph S. Myers wrote:
> > On Wed, 7 Mar 2012, Andreas Jaeger wrote:
> > > test-double fails with a lot of tests, starting with:
> > > testing double (without inline functions)
> > > Failure: Test: cos (M_PI_6l * 2.0) == 0.5
> > > 
> > > Result:
> > >  is:          4.99861241344128237607e-01  
> > >  0x1.ffdba01071a860000000p-2 should be:  
> > >  5.00000000000000000000e-01   0x1.00000000000000000000p-1
> > >  difference:  1.38758655871762393019e-04  
> > >  0x1.22ff7c72bd0000000000p-13 ulp       :  1249826861757.0000
> > >  max.ulp   :  1.0000
> > > 
> > > I need some more time to investigate this - and would appreciate any
> > > help,
> > 
> > One possibility is that the C implementations of sin and cos only work
> > with rounding to 53 bits, not with x87 excess precision.  If so, then
> > setting the FPU to 53-bit mode should help (and the libc_feupdateenv
> > calls should handle restoring 64-bit mode), though some new macro
> > would be needed to handle the environment setup for the affected
> > functions (or you could have an i386 version of s_sin.c that includes
> > headers, redefines libc_feholdexcept_setround then includes the main
> > s_sin.c).
> 
> Something like this.  Together with removing the files you listed in
> <http://sourceware.org/ml/libc-alpha/2012-03/msg00164.html>, this
> appears to work on x86 (some tests of j1/jn/yn increase their ulps from
(Continue reading)

Joseph S. Myers | 14 Mar 16:35

Re: Fix for bz#13658 - using fsincos on x86-64

On Wed, 14 Mar 2012, Andreas Jaeger wrote:

> I hope so as well. Will you continue this or shall I make a combined patch 
> tomorrow?

I suggest you make the combined patch tomorrow.

> > +
> > +#ifdef NEED_53BIT_PRECISION
> 
> Where do you define NEED_53BIT_PRECISION ?

It looks like I pruned the patch too heavily when cutting out the removed 
files; there should be:

diff --git a/sysdeps/i386/fpu/s_sin.c b/sysdeps/i386/fpu/s_sin.c
new file mode 100644
index 0000000..dccff13
--- /dev/null
+++ b/sysdeps/i386/fpu/s_sin.c
@@ -0,0 +1,2 @@
+#define NEED_53BIT_PRECISION
+#include <sysdeps/ieee754/dbl-64/s_sin.c>

But actually that's redundant; the conditions and #define are relics of my 
older idea of redefining existing macros only in certain files, rather 
than having new macros making it explicit for the affected functions that 
they need 53-bit precision rather than hiding it elsewhere.  So you can 
remove the #ifdef NEED_53BIT_PRECISION, and then don't need the x86 
version of s_sin.c.
(Continue reading)

Andreas Jaeger | 14 Mar 16:43
Gravatar

Re: Fix for bz#13658 - using fsincos on x86-64

On Wednesday, March 14, 2012 16:35:52 Joseph S. Myers wrote:
> On Wed, 14 Mar 2012, Andreas Jaeger wrote:
> > I hope so as well. Will you continue this or shall I make a combined
> > patch tomorrow?
> 
> I suggest you make the combined patch tomorrow.

Will do my best.

> > > +
> > > +#ifdef NEED_53BIT_PRECISION
> > 
> > Where do you define NEED_53BIT_PRECISION ?
> 
> It looks like I pruned the patch too heavily when cutting out the
> removed files; there should be:

;)

No problem.

> diff --git a/sysdeps/i386/fpu/s_sin.c b/sysdeps/i386/fpu/s_sin.c
> new file mode 100644
> index 0000000..dccff13
> --- /dev/null
> +++ b/sysdeps/i386/fpu/s_sin.c
> @@ -0,0 +1,2 @@
> +#define NEED_53BIT_PRECISION
> +#include <sysdeps/ieee754/dbl-64/s_sin.c>
> 
(Continue reading)

Andreas Jaeger | 15 Mar 09:20
Gravatar

Re: Fix for bz#13658 - using fsincos on x86-64

Here's a patch that has been tested on i386 (via gcc -m32) and x86-64.

Ok now?

Andreas

2012-03-14  Andreas Jaeger  <aj <at> suse.de>,
	Joseph Myers  <joseph <at> codesourcery.com>

	[BZ #13658]
	* sysdeps/x86_64/fpu/s_sincos.S: Delete Remove files so that
	x86-64 and i386 use the iee754/dbl-64 sin and cos implementation.
	* sysdeps/i386/fpu/branred.c: Likewise.
	* sysdeps/i386/fpu/dosincos.c: Likewise.
	* sysdeps/i386/fpu/mpa.c: Likewise.
	* sysdeps/i386/fpu/s_cos.S: Likewise.
	* sysdeps/i386/fpu/s_sin.S: Likewise.
	* sysdeps/i386/fpu/s_sincos.S: Likewise.
	* sysdeps/i386/fpu/sincos32.c: Likewise.

	* sysdeps/generic/math_private.h (libc_feholdexcept_setround_53bit):
	Define.
	(libc_feupdateenv_53bit): Define.
	* sysdeps/i386/fpu/math_private.h (libc_feholdexcept_setround_53bit):
	Define.
	(libc_feupdateenv_53bit): Define.

	* sysdeps/ieee754/dbl-64/s_sin.c (__sin): Do double arithmetic in
	53 bit (without extend i386 double precision).

(Continue reading)

Joseph S. Myers | 15 Mar 14:09

Re: Fix for bz#13658 - using fsincos on x86-64

On Thu, 15 Mar 2012, Andreas Jaeger wrote:

>  #include_next <math_private.h>
> +
> +# include <fpu_control.h>
> +
> +# undef libc_feholdexcept_setround_53bit

The indentation after the "#" here was a relic of the unnecessary 
NEED_53BIT_PRECISION condition in my patch - thus, I think that 
indentation should be removed.  Otherwise, the patch looks good to me; I 
think you should commit it, and I'll look at implementing the missing 
ldbl-96 pieces so the remaining cases can be fixed.

--

-- 
Joseph S. Myers
joseph <at> codesourcery.com

Andreas Jaeger | 15 Mar 14:12
Gravatar

Re: Fix for bz#13658 - using fsincos on x86-64

On Thursday, March 15, 2012 14:09:07 Joseph S. Myers wrote:
> On Thu, 15 Mar 2012, Andreas Jaeger wrote:
> >  #include_next <math_private.h>
> > 
> > +
> > +# include <fpu_control.h>
> > +
> > +# undef libc_feholdexcept_setround_53bit
> 
> The indentation after the "#" here was a relic of the unnecessary
> NEED_53BIT_PRECISION condition in my patch - thus, I think that
> indentation should be removed.  Otherwise, the patch looks good to me; I
>
> think you should commit it, and I'll look at implementing the missing
> ldbl-96 pieces so the remaining cases can be fixed.

Great!

Thanks, I'll cleanup and commit,

Andreas
--

-- 
 Andreas Jaeger aj@{suse.com,opensuse.org} Twitter/Identica: jaegerandi
  SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
   GF: Jeff Hawn,Jennifer Guild,Felix Imendörffer,HRB16746 (AG Nürnberg)
    GPG fingerprint = 93A3 365E CE47 B889 DF7F  FED1 389A 563C C272 A126

Joseph S. Myers | 15 Mar 14:28

Re: Fix for bz#13658 - using fsincos on x86-64

I don't see a ChangeLog entry for your commit....

--

-- 
Joseph S. Myers
joseph <at> codesourcery.com

Andreas Jaeger | 15 Mar 14:37
Gravatar

Re: Fix for bz#13658 - using fsincos on x86-64

On Thursday, March 15, 2012 14:28:12 Joseph S. Myers wrote:
> I don't see a ChangeLog entry for your commit....

It's there now...

Thanks,
Andreas
--

-- 
 Andreas Jaeger aj@{suse.com,opensuse.org} Twitter/Identica: jaegerandi
  SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
   GF: Jeff Hawn,Jennifer Guild,Felix Imendörffer,HRB16746 (AG Nürnberg)
    GPG fingerprint = 93A3 365E CE47 B889 DF7F  FED1 389A 563C C272 A126

Andreas Jaeger | 15 Mar 16:26
Gravatar

Re: Fix for bz#13658 - using fsincos on x86-64

Since the x86 manual mentions the range -2^63 to 2^63 for accurate numbers, I just added tests for 2^65 and
-2^65 as well and submitted after testing on 
i386 and x86-64.

Andreas

diff --git a/math/libm-test.inc b/math/libm-test.inc
index 0801ca6..2204064 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -2115,6 +2115,8 @@ cos_test (void)
 #ifdef TEST_DOUBLE
   TEST_f_f (cos, 0.80190127184058835, 0.69534156199418473);
   TEST_f_f (cos, 1e22, 0.5232147853951389454975944733847);
+  TEST_f_f (cos, 0x1p65, 0.998886220660580136106421721793);
+  TEST_f_f (cos, -0x1p65, 0.998886220660580136106421721793);
   TEST_f_f (cos, 0x1p1023, -0.8263698346141479945007856808117);
 #endif

@@ -6393,6 +6395,8 @@ sin_test (void)
   TEST_f_f (sin, 0.80190127184058835, 0.71867942238767868);
   TEST_f_f (sin, 2.522464e-1, 2.4957989804940911e-1);
   TEST_f_f (sin, 1e22, -0.8522008497671888017727058937530);
+  TEST_f_f (sin, 0x1p65, -0.0471838762123546738051061498057);
+  TEST_f_f (sin, -0x1p65, 0.0471838762123546738051061498057);
   TEST_f_f (sin, 0x1p1023, 0.5631277798508840248814522055909);
 #endif

@@ -6566,6 +6570,8 @@ sincos_test (void)
 #ifdef TEST_DOUBLE
(Continue reading)

Andreas Jaeger | 15 Mar 15:55
Gravatar

Re: Fix for bz#13658 - using fsincos on x86-64


Btw. the same bug in sin, cos and sincos hits us in tan as well:

On x86-64:
double: 
x = 1e+22
s1 = -1.6287782256068988

float: 
x = 9.9999997781963084e+21
s1 = -1.0810239315032959

long double: 
x = 1e+22
s1 = -0.52180662513577755

And on x86:
double: 
x = 1e+22
s1 = -0.52180662513577758

float: 
x = 9.9999997781963084e+21
s1 = -0.29305437207221985

long double: 
x = 1e+22
s1 = -0.52180662513577755

The correct result of tan (1e22) is:
(Continue reading)


Gmane