]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix x86/x86_64 scalb (qNaN, -Inf) (bug 16783).
authorJoseph Myers <joseph@codesourcery.com>
Tue, 24 Feb 2015 17:30:02 +0000 (17:30 +0000)
committerJoseph Myers <joseph@codesourcery.com>
Tue, 24 Feb 2015 17:30:02 +0000 (17:30 +0000)
Various x86 / x86_64 versions of scalb / scalbf / scalbl produce
spurious "invalid" exceptions for (qNaN, -Inf) arguments, because this
is wrongly handled like (+/-Inf, -Inf) which *should* raise such an
exception.  (In fact the NaN case of the code determining whether to
quietly return a zero or a NaN for second argument -Inf was
accidentally dead since the code had been made to return a NaN with
exception.)  This patch fixes the code to do the proper test for an
infinity as distinct from a NaN.

(Since the existing code does nothing to distinguish qNaNs and sNaNs
here, this patch doesn't either.  If in future we systematically
implement proper sNaN semantics following TS 18661-1:2014, there will
be lots of bugs to address - Thomas found lots of issues with his
patch <https://sourceware.org/ml/libc-ports/2013-04/msg00008.html> to
add SNaN tests (which never went in and would now require significant
reworking).)

Tested for x86_64 and x86.  Committed.

[BZ #16783]
* sysdeps/i386/fpu/e_scalb.S (__ieee754_scalb): Do not handle
arguments (NaN, -Inf) the same as (+/-Inf, -Inf).
* sysdeps/i386/fpu/e_scalbf.S (__ieee754_scalbf): Likewise.
* sysdeps/i386/fpu/e_scalbl.S (__ieee754_scalbl): Likewise.
* sysdeps/x86_64/fpu/e_scalbl.S (__ieee754_scalbl): Likewise.
* math/libm-test.inc (scalb_test_data): Add more tests.

ChangeLog
NEWS
math/libm-test.inc
sysdeps/i386/fpu/e_scalb.S
sysdeps/i386/fpu/e_scalbf.S
sysdeps/i386/fpu/e_scalbl.S
sysdeps/x86_64/fpu/e_scalbl.S

index c3068676a4b26ab08304d5b3fbd5db005d331234..8ae6cf1f56514a84c17abbc032770aeceeee872d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2015-02-24  Joseph Myers  <joseph@codesourcery.com>
+
+       [BZ #16783]
+       * sysdeps/i386/fpu/e_scalb.S (__ieee754_scalb): Do not handle
+       arguments (NaN, -Inf) the same as (+/-Inf, -Inf).
+       * sysdeps/i386/fpu/e_scalbf.S (__ieee754_scalbf): Likewise.
+       * sysdeps/i386/fpu/e_scalbl.S (__ieee754_scalbl): Likewise.
+       * sysdeps/x86_64/fpu/e_scalbl.S (__ieee754_scalbl): Likewise.
+       * math/libm-test.inc (scalb_test_data): Add more tests.
+
 2015-02-24  Paul Pluzhnikov  <ppluzhnikov@google.com>
 
        [BZ #17916]
diff --git a/NEWS b/NEWS
index 3f005fedafcdca0c94221a2cf4185d3f9e35be37..f1127a041e6bfdf01cb3a62b23190f069b465a11 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -9,9 +9,9 @@ Version 2.22
 
 * The following bugs are resolved with this release:
 
-  4719, 14841, 13064, 14094, 15319, 15467, 15790, 16560, 17269, 17523,
-  17569, 17588, 17792, 17836, 17912, 17916, 17932, 17944, 17949, 17964,
-  17965, 17967, 17969, 17978, 17987, 17991, 17996, 17998, 17999.
+  4719, 14841, 13064, 14094, 15319, 15467, 15790, 16560, 16783, 17269,
+  17523, 17569, 17588, 17792, 17836, 17912, 17916, 17932, 17944, 17949,
+  17964, 17965, 17967, 17969, 17978, 17987, 17991, 17996, 17998, 17999.
 
 * Character encoding and ctype tables were updated to Unicode 7.0.0, using
   new generator scripts contributed by Pravin Satpute and Mike FABIAN (Red
index ffdc1536724843d2483b97de113ead963a0f1414..b3396b6a7907b607f47fa67e32889e0bf28235e9 100644 (file)
@@ -9139,6 +9139,8 @@ static const struct test_ff_f_data scalb_test_data[] =
     TEST_ff_f (scalb, 0, qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
     TEST_ff_f (scalb, qnan_value, plus_infty, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
     TEST_ff_f (scalb, plus_infty, qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_f (scalb, qnan_value, minus_infty, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
+    TEST_ff_f (scalb, minus_infty, qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
     TEST_ff_f (scalb, qnan_value, qnan_value, qnan_value, NO_INEXACT_EXCEPTION|ERRNO_UNCHANGED),
 
     TEST_ff_f (scalb, max_value, max_value, plus_oflow, OVERFLOW_EXCEPTION|ERRNO_PLUS_OFLOW),
index 20d489efdeee92a504b5200d30153276dc81da83..6a01aa64d694ee37599bc64c09d5ff4215f114bf 100644 (file)
@@ -65,8 +65,10 @@ ENTRY(__ieee754_scalb)
        fstp    %st
        fstp    %st
        andl    $0x80000000, %edx
+       andl    $0x0228, %eax
+       cmpl    $0x0028, %eax
+       je      4f
        andl    $8, %eax
-       jnz     4f
        shrl    $27, %edx
        addl    %edx, %eax
        fldl    MOX(zero_nan, %eax, 1)
index b6dd02122a8673af591bd9b225d9bca83fbb5b95..12b25159acefcb51115bc30ad9bbf6105847bf54 100644 (file)
@@ -67,8 +67,10 @@ ENTRY(__ieee754_scalbf)
        fstp    %st
        fstp    %st
        andl    $0x80000000, %edx
+       andl    $0x0228, %eax
+       cmpl    $0x0028, %eax
+       je      4f
        andl    $8, %eax
-       jnz     4f
        shrl    $27, %edx
        addl    %edx, %eax
        fldl    MOX(zero_nan, %eax, 1)
index 83f17b233b0cd209351bc08c0faba82b87cf0b9f..d10b22ea834424efe1ffc046810ff8606837703e 100644 (file)
@@ -67,8 +67,10 @@ ENTRY(__ieee754_scalbl)
        fstp    %st
        fstp    %st
        andl    $0x8000, %edx
+       andl    $0x0228, %eax
+       cmpl    $0x0028, %eax
+       je      4f
        andl    $8, %eax
-       jnz     4f
        shrl    $11, %edx
        addl    %edx, %eax
        fldl    MOX(zero_nan, %eax, 1)
index c422d53b1c994b7cccf03ed61a2c97f347c2e64a..331bee580c49b641ba7b7d3ff1467d1a4dd959a7 100644 (file)
@@ -61,8 +61,10 @@ ENTRY(__ieee754_scalbl)
        fstp    %st
        fstp    %st
        andl    $0x8000, %edx
+       andl    $0x0228, %eax
+       cmpl    $0x0028, %eax
+       je      4f
        andl    $8, %eax
-       jnz     4f
        shrl    $11, %edx
        addl    %edx, %eax
 #ifdef PIC