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]

Fix y1l spurious overflows for ldbl-96 (bug 15283)


Bug 15283 is spurious overflows in y1l for ldbl-96, because a test to
see whether (x + x) would overflow wasn't correctly converted from
double to long double.  This patch fixes this in the obvious way,
agreeing with the correct tests used in j0l, y0l and j1l, and adds
tests of large inputs to all those functions.

The patch is relative to a tree with my previous patch
<http://sourceware.org/ml/libc-alpha/2013-03/msg00424.html> applied.

Tested x86_64 and x86 and ulps updated accordingly.

2013-03-16  Joseph Myers  <joseph@codesourcery.com>

	[BZ #15283]
	* sysdeps/ieee754/ldbl-96/e_j1l.c (__ieee754_y1l): Correct test
	for arguments at most half maximum finite value.
	* math/libm-test.inc (j0_test): Add more tests.
	(j1_test): Likewise.
	(y0_test): Likewise.
	(y1_test): Likewise.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.

diff --git a/math/libm-test.inc b/math/libm-test.inc
index d9df034..914aab3 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -6246,6 +6246,11 @@ j0_test (void)
   TEST_f_f (j0, -0x1.001000001p+593L, -3.927269966354206207832593635798954916263e-90L);
 #endif
 
+#if defined TEST_LDOUBLE && LDBL_MAX_EXP >= 16384
+  TEST_f_f (j0, 0x1p16382L, -1.2193782500509000574176799046642541129387e-2466L);
+  TEST_f_f (j0, 0x1p16383L, 9.5859502826270374691362975419147645151233e-2467L);
+#endif
+
   END (j0);
 }
 
@@ -6287,6 +6292,11 @@ j1_test (void)
   TEST_f_f (j1, 0x1.ff00000000002p+840L, 1.846591691699331493194965158699937660696e-127L);
 #endif
 
+#if defined TEST_LDOUBLE && LDBL_MAX_EXP >= 16384
+  TEST_f_f (j1, 0x1p16382L, 8.0839224448726336195866026476176740513439e-2467L);
+  TEST_f_f (j1, 0x1p16383L, -3.8895531955766020648617743624167352352217e-2467L);
+#endif
+
   END (j1);
 }
 
@@ -10458,6 +10468,11 @@ y0_test (void)
   TEST_f_f (y0, 0x1.ff00000000002p+840L, 1.846591691699331493194965158699937660696e-127L);
 #endif
 
+#if defined TEST_LDOUBLE && LDBL_MAX_EXP >= 16384
+  TEST_f_f (y0, 0x1p16382L, 8.0839224448726336195866026476176740513439e-2467L);
+  TEST_f_f (y0, 0x1p16383L, -3.8895531955766020648617743624167352352217e-2467L);
+#endif
+
   TEST_f_f (y0, 0x1p-10L, -4.4865150767109739412411806297168793661098L);
   TEST_f_f (y0, 0x1p-20L, -8.8992283012125827603076426611387876938160L);
   TEST_f_f (y0, 0x1p-30L, -1.3311940304267782826037118027401817264906e+1L);
@@ -10511,6 +10526,11 @@ y1_test (void)
   TEST_f_f (y1, 0x1.001000001p+593L, 3.927269966354206207832593635798954916263e-90L);
 #endif
 
+#if defined TEST_LDOUBLE && LDBL_MAX_EXP >= 16384
+  TEST_f_f (y1, 0x1p16382L, 1.2193782500509000574176799046642541129387e-2466L);
+  TEST_f_f (y1, 0x1p16383L, -9.5859502826270374691362975419147645151233e-2467L);
+#endif
+
   TEST_f_f (y1, 0x1p-10L, -6.5190099301063115047395187618929589514382e+02L);
   TEST_f_f (y1, 0x1p-20L, -6.6754421443450423911167962313100637952285e+05L);
   TEST_f_f (y1, 0x1p-30L, -6.8356527557643159612937462812258975438856e+08L);
diff --git a/sysdeps/i386/fpu/libm-test-ulps b/sysdeps/i386/fpu/libm-test-ulps
index fd0180f..6186c99 100644
--- a/sysdeps/i386/fpu/libm-test-ulps
+++ b/sysdeps/i386/fpu/libm-test-ulps
@@ -2475,6 +2475,9 @@ ldouble: 2
 Test "j0 (0x1.d7ce3ap+107) == 2.775523647291230802651040996274861694514e-17":
 float: 1
 ifloat: 1
+Test "j0 (0x1p16382) == -1.2193782500509000574176799046642541129387e-2466":
+ildouble: 1
+ldouble: 1
 Test "j0 (10.0) == -0.245935764451348335197760862485328754":
 double: 3
 float: 1
@@ -2508,6 +2511,9 @@ ldouble: 1
 Test "j1 (0x1.ff00000000002p+840) == 1.846591691699331493194965158699937660696e-127":
 double: 1
 idouble: 1
+Test "j1 (0x1p16382) == 8.0839224448726336195866026476176740513439e-2467":
+ildouble: 1
+ldouble: 1
 Test "j1 (10.0) == 0.0434727461688614366697487680258592883":
 double: 2
 float: 1
@@ -3285,6 +3291,9 @@ idouble: 1
 Test "y0 (0x1p-80) == -3.5375500319532942168707373066828113573541e+1":
 double: 1
 idouble: 1
+Test "y0 (0x1p16382) == 8.0839224448726336195866026476176740513439e-2467":
+ildouble: 1
+ldouble: 1
 Test "y0 (1.0) == 0.0882569642156769579829267660235151628":
 double: 2
 float: 1
@@ -3329,6 +3338,9 @@ ldouble: 1
 Test "y1 (0x1p-10) == -6.5190099301063115047395187618929589514382e+02":
 float: 1
 ifloat: 1
+Test "y1 (0x1p16382) == 1.2193782500509000574176799046642541129387e-2466":
+ildouble: 1
+ldouble: 1
 Test "y1 (1.0) == -0.781212821300288716547150000047964821":
 double: 1
 idouble: 1
diff --git a/sysdeps/ieee754/ldbl-96/e_j1l.c b/sysdeps/ieee754/ldbl-96/e_j1l.c
index 785c0b0..4c13018 100644
--- a/sysdeps/ieee754/ldbl-96/e_j1l.c
+++ b/sysdeps/ieee754/ldbl-96/e_j1l.c
@@ -203,7 +203,7 @@ __ieee754_y1l (long double x)
       __sincosl (x, &s, &c);
       ss = -s - c;
       cc = s - c;
-      if (ix < 0x7fe00000)
+      if (ix < 0x7ffe)
 	{			/* make sure x+x not overflow */
 	  z = __cosl (x + x);
 	  if ((s * c) > zero)
diff --git a/sysdeps/x86_64/fpu/libm-test-ulps b/sysdeps/x86_64/fpu/libm-test-ulps
index b828774..f190ed8 100644
--- a/sysdeps/x86_64/fpu/libm-test-ulps
+++ b/sysdeps/x86_64/fpu/libm-test-ulps
@@ -2390,6 +2390,9 @@ ifloat: 1
 Test "j0 (0x1.d7ce3ap+107) == 2.775523647291230802651040996274861694514e-17":
 float: 2
 ifloat: 2
+Test "j0 (0x1p16382) == -1.2193782500509000574176799046642541129387e-2466":
+ildouble: 1
+ldouble: 1
 Test "j0 (10.0) == -0.245935764451348335197760862485328754":
 double: 2
 float: 1
@@ -2420,6 +2423,9 @@ ldouble: 1
 Test "j1 (0x1.ff00000000002p+840) == 1.846591691699331493194965158699937660696e-127":
 double: 1
 idouble: 1
+Test "j1 (0x1p16382) == 8.0839224448726336195866026476176740513439e-2467":
+ildouble: 1
+ldouble: 1
 Test "j1 (10.0) == 0.0434727461688614366697487680258592883":
 float: 2
 ifloat: 2
@@ -3073,6 +3079,9 @@ double: 1
 float: 1
 idouble: 1
 ifloat: 1
+Test "y0 (0x1p16382) == 8.0839224448726336195866026476176740513439e-2467":
+ildouble: 1
+ldouble: 1
 Test "y0 (1.0) == 0.0882569642156769579829267660235151628":
 double: 2
 float: 1
@@ -3117,6 +3126,9 @@ ldouble: 1
 Test "y1 (0x1p-10) == -6.5190099301063115047395187618929589514382e+02":
 double: 1
 idouble: 1
+Test "y1 (0x1p16382) == 1.2193782500509000574176799046642541129387e-2466":
+ildouble: 1
+ldouble: 1
 Test "y1 (1.5) == -0.412308626973911295952829820633445323":
 float: 1
 ifloat: 1

-- 
Joseph S. Myers
joseph@codesourcery.com


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