From 9438b237abca11de201dd10483717299eafb1f0b Mon Sep 17 00:00:00 2001 From: Joseph Myers Date: Tue, 24 Feb 2015 17:30:02 +0000 Subject: Fix x86/x86_64 scalb (qNaN, -Inf) (bug 16783). 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 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. --- math/libm-test.inc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'math') diff --git a/math/libm-test.inc b/math/libm-test.inc index ffdc153672..b3396b6a79 100644 --- a/math/libm-test.inc +++ b/math/libm-test.inc @@ -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), -- cgit 1.4.1