1 From libc-alpha-return-50517-siddhesh=redhat.com@sourceware.org Thu Jun 5 10:36:33 2014
2 Received: (qmail 11948 invoked by alias); 4 Jun 2014 17:51:01 -0000
3 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm
4 List-Id: <libc-alpha.sourceware.org>
5 Sender: libc-alpha-owner@sourceware.org
6 Date: Wed, 4 Jun 2014 17:50:46 +0000
7 From: "Joseph S. Myers" <joseph@codesourcery.com>
8 To: <libc-alpha@sourceware.org>
9 Subject: Fix pow overflow in non-default rounding modes (bug 16315)
10 Message-ID: <Pine.LNX.4.64.1406041749420.3719@digraph.polyomino.org.uk>
12 Content-Type: multipart/mixed;
13 boundary="-1152306461-1522705971-1401904246=:3719"
16 ---1152306461-1522705971-1401904246=:3719
17 Content-Type: text/plain; charset="none"
18 Content-Transfer-Encoding: QUOTED-PRINTABLE
20 This patch, relative to a tree with
21 <https://sourceware.org/ml/libc-alpha/2014-06/msg00076.html> applied,
22 fixes bug 16315, bad pow handling of overflow/underflow in non-default
23 rounding modes. Tests of pow are duly converted to ALL_RM_TEST to run
24 all tests in all rounding modes.
26 There are two main issues here. First, various implementations
27 compute a negative result by negating a positive result, but this
28 yields inappropriate overflow / underflow values for directed
29 rounding, so either overflow / underflow results need recomputing in
30 the correct sign, or the relevant overflowing / underflowing operation
31 needs to be made to have a result of the correct sign. Second, the
32 dbl-64 implementation sets FE_TONEAREST internally; in the overflow /
33 underflow case, the result needs recomputing in the original rounding
36 Tested x86_64 and x86 and ulps updated accordingly.
38 (auto-libm-test-out diffs omitted below.)
40 2014-06-04 Joseph Myers <joseph@codesourcery.com>
43 =09* sysdeps/i386/fpu/e_pow.S (__ieee754_pow): Ensure possibly
44 =09overflowing or underflowing operations take place with sign of
46 =09* sysdeps/i386/fpu/e_powf.S (__ieee754_powf): Likewise.
47 =09* sysdeps/i386/fpu/e_powl.S (__ieee754_powl): Likewise.
48 =09* sysdeps/ieee754/dbl-64/e_pow.c: Include <math.h>.
49 =09(__ieee754_pow): Recompute overflowing and underflowing results in
50 =09original rounding mode.
51 =09* sysdeps/x86/fpu/powl_helper.c: Include <stdbool.h>.
52 =09(__powl_helper): Allow negative argument X and scale negated value
53 =09as needed. Avoid passing value outside [-1, 1] to f2xm1.
54 =09* sysdeps/x86_64/fpu/e_powl.S (__ieee754_powl): Ensure possibly
55 =09overflowing or underflowing operations take place with sign of
57 =09* sysdeps/x86_64/fpu/multiarch/e_pow.c [HAVE_FMA4_SUPPORT]:
59 =09* math/auto-libm-test-in: Add more tests of pow.
60 =09* math/auto-libm-test-out: Regenerated.
61 =09* math/libm-test.inc (pow_test): Use ALL_RM_TEST.
62 =09(pow_tonearest_test_data): Remove.
63 =09(pow_test_tonearest): Likewise.
64 =09(pow_towardzero_test_data): Likewise.
65 =09(pow_test_towardzero): Likewise.
66 =09(pow_downward_test_data): Likewise.
67 =09(pow_test_downward): Likewise.
68 =09(pow_upward_test_data): Likewise.
69 =09(pow_test_upward): Likewise.
70 =09(main): Don't call removed functions.
71 =09* sysdeps/i386/fpu/libm-test-ulps: Update.
72 =09* sysdeps/x86_64/fpu/libm-test-ulps: Likewise.
74 diff --git a/sysdeps/x86_64/fpu/multiarch/e_pow.c b/sysdeps/x86_64/fpu/mult=
76 index a740b6c..433cce0 100644
77 --- a/sysdeps/x86_64/fpu/multiarch/e_pow.c
78 +++ b/sysdeps/x86_64/fpu/multiarch/e_pow.c
80 #ifdef HAVE_FMA4_SUPPORT
81 # include <init-arch.h>
83 # include <math_private.h>
85 extern double __ieee754_pow_sse2 (double, double);
89 joseph@codesourcery.com
90 ---1152306461-1522705971-1401904246=:3719--