This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: [BZ #14803] Different ULPs depending on size of long intin GCC


On Sun, Nov 4, 2012 at 6:42 PM, Joseph S. Myers <joseph@codesourcery.com> wrote:
> On Sun, 4 Nov 2012, H.J. Lu wrote:
>
>> Hi,
>>
>> GCC generates encodes float-pointing constants slightly different,
>> depend on size of long int.  This patch uses hex float for one
>> problematic 96-bit long double constant.  Tested on x86-64 with x32
>> GCC and x86-64 GCC.  OK to install?
>
> Did you make sure that the hex float you chose for this half-way value is
> the correct one to add to pio2_lo to create an accurate approximation to

PI/2 is between 0xc.90fdaa22168c234p-3L and 0xc.90fdaa22168c235p-3L.
pio2_hi = 0xc.90fdaa22168c234p-3L is correct.

> pi/2?  (If neither is - if pio2_lo is actually pi/2 minus the 65-bit value
> that was wrongly given for pio2_hi - then you should replace both
> constants, pio2_hi by the correct result of rounding pi/2 to 64-bit, to
> nearest, and pio2_lo by the correct result of rounding pi/2 - pio2_hi, to
> nearest.)

I don't know how to compute  the result of rounding pi/2 - pio2_hi, to
nearest in C. I simply replaced

pio2_lo = 2.9127320560933561582586004641843300502121E-20L,

with

pio2_lo = 0x8.98cc51701b839a2p-68,

It passed glibc math tests on ia32 and x86-64.

> Also, is pio4_hi the correct value of pio2_hi/2 after your patch?  It's
> probably a good idea to replace all three constants with hex float values
> at the same time, to make sure they all match up properly.
>

I compute  pio4_hi by dividing 0xc.90fdaa22168c234p-3L by 2.


-- 
H.J.
----
2012-11-04  H.J. Lu  <hongjiu.lu@intel.com>

	[BZ #14803]
	* sysdeps/ieee754/ldbl-96/e_asinl.c (pio2_hi): Use hex float.
	(pio2_lo): Likewise.
	(pio4_hi): Likewise.

diff --git a/sysdeps/ieee754/ldbl-96/e_asinl.c
b/sysdeps/ieee754/ldbl-96/e_asinl.c
index c33701f..ebed63f 100644
--- a/sysdeps/ieee754/ldbl-96/e_asinl.c
+++ b/sysdeps/ieee754/ldbl-96/e_asinl.c
@@ -64,9 +64,10 @@
 static const long double
   one = 1.0L,
   huge = 1.0e+4932L,
- pio2_hi = 1.5707963267948966192021943710788178805159986950457096099853515625L,
-  pio2_lo = 2.9127320560933561582586004641843300502121E-20L,
-  pio4_hi = 7.8539816339744830960109718553940894025800E-1L,
+ /* Use hex float to avoid GCC PRs 21718/55145.  */
+  pio2_hi = 0xc.90fdaa22168c234p-3L,
+  pio2_lo = 0x8.98cc51701b839a2p-68,
+  pio4_hi = 0xc.90fdaa22168c234p-4L,

 	/* coefficient for R(x^2) */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]