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 gen-auto-libm-tests sticky bit setting for negative results


gen-auto-libm-tests has a bug in the logic for setting a sticky bit
based on the ternary value from MPFR: it is correct for positive
results, but for negative results mpz_setbit acts as if a two's
complement representation is used, whereas the low bit needs setting
based on the sign-magnitude representation GMP actually uses.  (This
showed up in converting fma tests to use auto-libm-test-in /
gen-auto-libm-tests.)

This patch fixes the problem by negating the mpz_t value to set its
low bit.  There are lots of changes to auto-libm-test-out (mainly 1ulp
fixes to ldbl-128 expected results), but only a few ulps updates are
needed on x86 / x86_64 (ulps updates included below,
auto-libm-test-out changes omitted below).  In one case, a corrected
expectation showed up a spurious underflow exception where the correct
result is slightly outside the underflowing range.

Tested x86_64 and x86 and ulps updated accordingly.

2014-02-18  Joseph Myers  <joseph@codesourcery.com>

	* math/gen-auto-libm-tests.c (adjust_real): Ensure integers are
	non-negative before setting low bit.
	* math/auto-libm-test-in: Mark one asin test possibly having
	spurious underflow.
	* sysdeps/i386/fpu/libm-test-ulps: Update.
	* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.

diff --git a/math/auto-libm-test-in b/math/auto-libm-test-in
index c620361..17158ea 100644
--- a/math/auto-libm-test-in
+++ b/math/auto-libm-test-in
@@ -61,8 +61,9 @@ asin -0x0.ffffffffffffp0
 asin 0x0.ffffffffffffffffp0
 asin -0x0.ffffffffffffffffp0
 # Bug 16351: underflow exception may be missing.
+# Bug 16599: spurious underflow may occur.
 asin min missing-underflow
-asin -min missing-underflow
+asin -min missing-underflow spurious-underflow:dbl-64:x86
 asin min_subnorm missing-underflow
 asin -min_subnorm missing-underflow
 
diff --git a/math/gen-auto-libm-tests.c b/math/gen-auto-libm-tests.c
index 2f521d5..198d001 100644
--- a/math/gen-auto-libm-tests.c
+++ b/math/gen-auto-libm-tests.c
@@ -987,7 +987,14 @@ adjust_real (mpfr_t r, bool inexact)
       mpz_t tmp;
       mpz_init (tmp);
       mpfr_exp_t e = mpfr_get_z_2exp (tmp, r);
-      mpz_setbit (tmp, 0);
+      if (mpz_sgn (tmp) < 0)
+	{
+	  mpz_neg (tmp, tmp);
+	  mpz_setbit (tmp, 0);
+	  mpz_neg (tmp, tmp);
+	}
+      else
+	mpz_setbit (tmp, 0);
       assert_exact (mpfr_set_z_2exp (r, tmp, e, MPFR_RNDN));
       mpz_clear (tmp);
     }
diff --git a/sysdeps/i386/fpu/libm-test-ulps b/sysdeps/i386/fpu/libm-test-ulps
index 4a921b1..6a59247 100644
--- a/sysdeps/i386/fpu/libm-test-ulps
+++ b/sysdeps/i386/fpu/libm-test-ulps
@@ -53,28 +53,47 @@ ildouble: 1
 ldouble: 1
 
 # asin_downward
+Test "asin_downward (-0x2p-16384)":
+ildouble: 1
+ldouble: 1
 Test "asin_downward (-0x4p-1024)":
 double: 1
 idouble: 1
+ildouble: 1
+ldouble: 1
 Test "asin_downward (-0x4p-1076)":
 double: 1
 idouble: 1
+ildouble: 1
+ldouble: 1
 Test "asin_downward (-0x4p-128)":
 double: 1
 float: 1
 idouble: 1
 ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "asin_downward (-0x4p-16384)":
+ildouble: 1
+ldouble: 1
 Test "asin_downward (-0x8p-152)":
 double: 1
 float: 1
 idouble: 1
 ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "asin_downward (-0x8p-16448)":
+ildouble: 1
+ldouble: 1
 Test "asin_downward (-0x8p-4)":
 ildouble: 1
 ldouble: 1
 Test "asin_downward (-0x8p-972)":
 double: 1
 idouble: 1
+ildouble: 1
+ldouble: 1
 Test "asin_downward (-0xf.fffffff8p-4)":
 ildouble: 1
 ldouble: 1
@@ -136,9 +155,13 @@ Test "asin_upward (-0x2p-16384)":
 ildouble: 1
 ldouble: 1
 Test "asin_upward (-0x4p-1024)":
+double: 1
+idouble: 1
 ildouble: 1
 ldouble: 1
 Test "asin_upward (-0x4p-1076)":
+double: 1
+idouble: 1
 ildouble: 1
 ldouble: 1
 Test "asin_upward (-0x4p-128)":
@@ -3894,6 +3917,9 @@ ifloat: 1
 Test "Imaginary part of: ccos (0x4p-1076 + 0x5.ap+8 i)":
 double: 1
 idouble: 1
+Test "Imaginary part of: ccos (0x4p-16328 + 0x1p-120 i)":
+ildouble: 1
+ldouble: 1
 Test "Real part of: ccos (0xcp-4 + 0x1.4p+0 i)":
 double: 1
 float: 1
@@ -6840,6 +6866,13 @@ float: 1
 ifloat: 1
 ildouble: 2
 ldouble: 2
+Test "Imaginary part of: ctan_downward (-0xc.35p+12 - 0xc.35p+12 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
 Test "Real part of: ctan_downward (0x1.921fb4p+0 + +0 i)":
 ildouble: 1
 ldouble: 1
@@ -6982,6 +7015,13 @@ ifloat: 1
 Test "Imaginary part of: ctan_downward (0x8p+16380 + 0x1p+0 i)":
 ildouble: 1
 ldouble: 1
+Test "Imaginary part of: ctan_downward (0xc.35p+12 - 0xc.35p+12 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
 Test "Real part of: ctan_downward (0xcp-4 + 0x1.4p+0 i)":
 double: 1
 idouble: 1
@@ -7701,6 +7741,20 @@ double: 2
 idouble: 2
 ildouble: 1
 ldouble: 1
+Test "Real part of: ctanh_downward (-0xc.35p+12 + 0xc.35p+12 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ctanh_downward (-0xc.35p+12 - 0xc.35p+12 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
 Test "Imaginary part of: ctanh_downward (0x1.63p+8 + 0x1p+0 i)":
 ildouble: 1
 ldouble: 1
diff --git a/sysdeps/x86_64/fpu/libm-test-ulps b/sysdeps/x86_64/fpu/libm-test-ulps
index 02b6d5b..4cb77d9 100644
--- a/sysdeps/x86_64/fpu/libm-test-ulps
+++ b/sysdeps/x86_64/fpu/libm-test-ulps
@@ -123,11 +123,49 @@ double: 1
 Test "asin_downward (-0x1p+0)":
 double: 1
 idouble: 1
+Test "asin_downward (-0x2p-16384)":
+ildouble: 1
+ldouble: 1
+Test "asin_downward (-0x4p-1024)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "asin_downward (-0x4p-1076)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
+Test "asin_downward (-0x4p-128)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "asin_downward (-0x4p-16384)":
+ildouble: 1
+ldouble: 1
+Test "asin_downward (-0x8p-152)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "asin_downward (-0x8p-16448)":
+ildouble: 1
+ldouble: 1
 Test "asin_downward (-0x8p-4)":
 double: 1
 idouble: 1
 ildouble: 1
 ldouble: 1
+Test "asin_downward (-0x8p-972)":
+double: 1
+idouble: 1
+ildouble: 1
+ldouble: 1
 Test "asin_downward (-0xf.fffffff8p-4)":
 double: 1
 idouble: 1
@@ -5127,6 +5165,9 @@ ldouble: 1
 Test "Imaginary part of: ccos (0x4p-1076 + 0x5.ap+8 i)":
 double: 1
 idouble: 1
+Test "Imaginary part of: ccos (0x4p-16328 + 0x1p-120 i)":
+ildouble: 1
+ldouble: 1
 Test "Real part of: ccos (0xcp-4 + 0x1.4p+0 i)":
 double: 1
 float: 1
@@ -8485,6 +8526,13 @@ double: 2
 idouble: 2
 ildouble: 2
 ldouble: 2
+Test "Imaginary part of: ctan_downward (-0xc.35p+12 - 0xc.35p+12 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
 Test "Real part of: ctan_downward (0x1.921fb4p+0 + +0 i)":
 float: 1
 ifloat: 1
@@ -8631,6 +8679,13 @@ ifloat: 1
 Test "Imaginary part of: ctan_downward (0x8p+16380 + 0x1p+0 i)":
 ildouble: 1
 ldouble: 1
+Test "Imaginary part of: ctan_downward (0xc.35p+12 - 0xc.35p+12 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
 Test "Real part of: ctan_downward (0xcp-4 + 0x1.4p+0 i)":
 float: 1
 ifloat: 1
@@ -9479,6 +9534,20 @@ idouble: 1
 ifloat: 3
 ildouble: 1
 ldouble: 1
+Test "Real part of: ctanh_downward (-0xc.35p+12 + 0xc.35p+12 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
+Test "Real part of: ctanh_downward (-0xc.35p+12 - 0xc.35p+12 i)":
+double: 1
+float: 1
+idouble: 1
+ifloat: 1
+ildouble: 1
+ldouble: 1
 Test "Imaginary part of: ctanh_downward (0x1.63p+8 + 0x1p+0 i)":
 ildouble: 1
 ldouble: 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]