about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2016-06-09 18:04:30 +0000
committerJoseph Myers <joseph@codesourcery.com>2016-06-09 18:04:30 +0000
commitf00faa4a43706d85ad8d4d2c970d3f52f0f63bfb (patch)
tree3ab8e31041ab2f0cd87b4b1501c1570a10a2d7dd
parentb7519f61fe2c57981c69c0c65996968b9a4d9b62 (diff)
downloadglibc-f00faa4a43706d85ad8d4d2c970d3f52f0f63bfb.tar.gz
glibc-f00faa4a43706d85ad8d4d2c970d3f52f0f63bfb.tar.xz
glibc-f00faa4a43706d85ad8d4d2c970d3f52f0f63bfb.zip
Fix i386/x86_64 log2l (sNaN) (bug 20235).
The i386/x86_64 versions of log2l return sNaN for sNaN input.  This
patch fixes them to add NaN inputs to themselves so that qNaN is
returned in this case.

Tested for x86_64 and x86.

	[BZ #20235]
	* sysdeps/i386/fpu/e_log2l.S (__ieee754_log2l): Add NaN input to
	itself.
	* sysdeps/x86_64/fpu/e_log2l.S (__ieee754_log2l): Likewise.
	* math/libm-test.inc (log2_test_data): Add sNaN tests.
-rw-r--r--ChangeLog6
-rw-r--r--math/libm-test.inc2
-rw-r--r--sysdeps/i386/fpu/e_log2l.S1
-rw-r--r--sysdeps/x86_64/fpu/e_log2l.S1
4 files changed, 10 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 81192ce5b8..c0a32785e7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2016-06-09  Joseph Myers  <joseph@codesourcery.com>
 
+	[BZ #20235]
+	* sysdeps/i386/fpu/e_log2l.S (__ieee754_log2l): Add NaN input to
+	itself.
+	* sysdeps/x86_64/fpu/e_log2l.S (__ieee754_log2l): Likewise.
+	* math/libm-test.inc (log2_test_data): Add sNaN tests.
+
 	[BZ #20234]
 	* sysdeps/ieee754/ldbl-128ibm/s_log1pl.c (__log1pl): Add positive
 	infinity or NaN input to itself.
diff --git a/math/libm-test.inc b/math/libm-test.inc
index 4371c4ca7b..2df6f29a34 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -9076,6 +9076,8 @@ static const struct test_f_f_data log2_test_data[] =
     TEST_f_f (log2, plus_infty, plus_infty, ERRNO_UNCHANGED),
     TEST_f_f (log2, qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
     TEST_f_f (log2, -qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_f_f (log2, snan_value, qnan_value, INVALID_EXCEPTION),
+    TEST_f_f (log2, -snan_value, qnan_value, INVALID_EXCEPTION),
 
     AUTO_TESTS_f_f (log2),
   };
diff --git a/sysdeps/i386/fpu/e_log2l.S b/sysdeps/i386/fpu/e_log2l.S
index 0f5f7e5789..73e62ea908 100644
--- a/sysdeps/i386/fpu/e_log2l.S
+++ b/sysdeps/i386/fpu/e_log2l.S
@@ -64,6 +64,7 @@ ENTRY(__ieee754_log2l)
 3:	jp	4b		// in case x is ħInf
 	fstp	%st(1)
 	fstp	%st(1)
+	fadd	%st(0)
 	ret
 END (__ieee754_log2l)
 strong_alias (__ieee754_log2l, __log2l_finite)
diff --git a/sysdeps/x86_64/fpu/e_log2l.S b/sysdeps/x86_64/fpu/e_log2l.S
index a063255ddd..023ec29164 100644
--- a/sysdeps/x86_64/fpu/e_log2l.S
+++ b/sysdeps/x86_64/fpu/e_log2l.S
@@ -63,6 +63,7 @@ ENTRY(__ieee754_log2l)
 	jnz	4b		// in case x is ħInf
 	fstp	%st(1)
 	fstp	%st(1)
+	fadd	%st(0)
 	ret
 END (__ieee754_log2l)