From patchwork Wed Apr 8 17:33:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 459392 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 2D77614016A for ; Thu, 9 Apr 2015 03:33:24 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass reason="1024-bit key; unprotected key" header.d=sourceware.org header.i=@sourceware.org header.b=qd0FEa7B; dkim-adsp=none (unprotected policy); dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; q=dns; s=default; b=PLxn5NZKwUda/Jppx1iDtYcuyA99B x6bVFnSLcp4Wfi1QIo1ny/2hEuCRfZJ1DK8HhLO7w+V3X8foUX0OuXpj5ys1dx8i jkjme11f3xzSxvvaDmgBus1YL/glfSaqLuv4KdA04HCucAwx1COel3WGe0wqLt42 ZJM0RRoNNuXPfo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:mime-version :content-type; s=default; bh=FCHN/odwhTWeMDH0f5O5l4r6huY=; b=qd0 FEa7BdJSXNFrR2Z4UKSY6eF6Eovl8bl5SJXjmljRuyF6q8Oi4Fc7suBHiWAS8yBh WPKCDq1dUDRUjjl7h3FW+lSyHrcN/iNpZGGPEithwuJucQDWQShBYAXHGzlKIWnI jtGh0rY/Y8tuXE5jM2nYATvh5LdvaZf06IfqhGL4= Received: (qmail 72979 invoked by alias); 8 Apr 2015 17:33:16 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 72891 invoked by uid 89); 8 Apr 2015 17:33:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=AWL, BAYES_50, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Date: Wed, 8 Apr 2015 17:33:08 +0000 From: Joseph Myers To: Subject: Fix dbl-64 atan2 in non-default rounding modes (bug 18210, bug 18211) [committed] Message-ID: User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 The dbl-64 implementation of atan2 does computations that expect to run in round-to-nearest mode, and in other modes the errors can accumulate to more than the maximum accepted 9ulp. This patch makes it use FE_TONEAREST internally, similar to other functions with such issues. Tests that previously produced large errors are added for atan2 and the closely related carg, clog and clog10 functions. Tested for x86_64 and x86 and ulps updated accordingly. Committed. (auto-libm-test-out diffs omitted below.) 2015-04-08 Joseph Myers [BZ #18210] [BZ #18211] * sysdeps/ieee754/dbl-64/e_atan2.c: Include . (__ieee754_atan2): Set FE_TONEAREST mode for internal computations. * math/auto-libm-test-in: Add more tests of atan2, carg, clog and clog10. * math/auto-libm-test-out: Regenerated. * 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 d0026d5..fca2f70 100644 --- a/math/auto-libm-test-in +++ b/math/auto-libm-test-in @@ -287,6 +287,14 @@ atan2 0.390625 .00029 atan2 1.390625 0.9296875 atan2 -0.00756827042671106339 -.001792735857538728036 atan2 0x1.00000000000001p0 0x1.00000000000001p0 +atan2 0x4.c3841p-4 0x2.f2f308p+0 +atan2 -0xe.cf143p-40 0xd.3de7ap-36 +atan2 0x5.576cf8p-4 0x2.21e65p+0 +atan2 -0x4.29411p-4 0x1.f4755cp+0 +atan2 -0xa.b4101p+20 -0xf.9c4c8p-4 +atan2 0x4.251bb8p-4 0x7.40ac68p+0 +atan2 0x1.47239ep+68 0xa.3ac3cp+68 +atan2 -0x6.b0794p-4 0x3.8ff10cp+0 atan2 min min atan2 min -min atan2 -min min @@ -409,6 +417,14 @@ carg -0 2.0 carg 0 -2.0 # carg (-0 + i y) == -pi/2 for y < 0. carg -0 -2.0 +carg 0x2.f2f308p+0 0x4.c3841p-4 +carg 0xd.3de7ap-36 -0xe.cf143p-40 +carg 0x2.21e65p+0 0x5.576cf8p-4 +carg 0x1.f4755cp+0 -0x4.29411p-4 +carg -0xf.9c4c8p-4 -0xa.b4101p+20 +carg 0x7.40ac68p+0 0x4.251bb8p-4 +carg 0xa.3ac3cp+68 0x1.47239ep+68 +carg 0x3.8ff10cp+0 -0x6.b0794p-4 cbrt 0.0 cbrt -0 @@ -524,6 +540,15 @@ cexp min -min_subnorm spurious-underflow:ldbl-96-intel:x86 spurious-underflow:ld clog 0.75 1.25 clog -2 -3 +clog 0x2.f2f308p+0 0x4.c3841p-4 +clog 0xd.3de7ap-36 -0xe.cf143p-40 +clog 0x2.21e65p+0 0x5.576cf8p-4 +clog 0x1.f4755cp+0 -0x4.29411p-4 +clog -0xf.9c4c8p-4 -0xa.b4101p+20 +clog 0x7.40ac68p+0 0x4.251bb8p-4 +clog 0xa.3ac3cp+68 0x1.47239ep+68 +clog 0x3.8ff10cp+0 -0x6.b0794p-4 + clog 0x1.fffffep+127 0x1.fffffep+127 clog 0x1.fffffep+127 1.0 clog 0x1p-149 0x1p-149 @@ -643,6 +668,15 @@ clog 0x1415bcaf2105940d49a636e98ae59p-115 0x7e6a150adfcd1b0921d44b31f40f4p-115 clog10 0.75 1.25 clog10 -2 -3 +clog10 0x2.f2f308p+0 0x4.c3841p-4 +clog10 0xd.3de7ap-36 -0xe.cf143p-40 +clog10 0x2.21e65p+0 0x5.576cf8p-4 +clog10 0x1.f4755cp+0 -0x4.29411p-4 +clog10 -0xf.9c4c8p-4 -0xa.b4101p+20 +clog10 0x7.40ac68p+0 0x4.251bb8p-4 +clog10 0xa.3ac3cp+68 0x1.47239ep+68 +clog10 0x3.8ff10cp+0 -0x6.b0794p-4 + clog10 0x1.fffffep+127 0x1.fffffep+127 clog10 0x1.fffffep+127 1.0 clog10 0x1p-149 0x1p-149 diff --git a/sysdeps/i386/fpu/libm-test-ulps b/sysdeps/i386/fpu/libm-test-ulps index 2c823ef..538a549 100644 --- a/sysdeps/i386/fpu/libm-test-ulps +++ b/sysdeps/i386/fpu/libm-test-ulps @@ -283,6 +283,10 @@ ifloat: 2 ildouble: 2 ldouble: 2 +Function: "carg": +ildouble: 1 +ldouble: 1 + Function: "carg_downward": double: 1 float: 1 @@ -827,9 +831,9 @@ ldouble: 1 Function: Real part of "clog_upward": double: 1 -float: 1 +float: 2 idouble: 1 -ifloat: 1 +ifloat: 2 ildouble: 2 ldouble: 2 diff --git a/sysdeps/ieee754/dbl-64/e_atan2.c b/sysdeps/ieee754/dbl-64/e_atan2.c index a03ce3e..0c29028 100644 --- a/sysdeps/ieee754/dbl-64/e_atan2.c +++ b/sysdeps/ieee754/dbl-64/e_atan2.c @@ -41,6 +41,7 @@ #include "MathLib.h" #include "uatan.tbl" #include "atnat2.h" +#include #include #include #include @@ -192,6 +193,7 @@ __ieee754_atan2 (double y, double x) return mhpi.d; } + SET_RESTORE_ROUND (FE_TONEAREST); /* either x/y or y/x is very close to zero */ ax = (x < 0) ? -x : x; ay = (y < 0) ? -y : y; diff --git a/sysdeps/x86_64/fpu/libm-test-ulps b/sysdeps/x86_64/fpu/libm-test-ulps index abeeaf9..d0aea07 100644 --- a/sysdeps/x86_64/fpu/libm-test-ulps +++ b/sysdeps/x86_64/fpu/libm-test-ulps @@ -228,9 +228,9 @@ ildouble: 2 ldouble: 2 Function: Real part of "cacos_downward": -double: 1 +double: 2 float: 2 -idouble: 1 +idouble: 2 ifloat: 2 ildouble: 2 ldouble: 2 @@ -244,9 +244,9 @@ ildouble: 5 ldouble: 5 Function: Real part of "cacos_towardzero": -double: 1 +double: 2 float: 2 -idouble: 1 +idouble: 2 ifloat: 2 ildouble: 2 ldouble: 2 @@ -300,9 +300,9 @@ ildouble: 5 ldouble: 5 Function: Imaginary part of "cacosh_downward": -double: 1 +double: 2 float: 2 -idouble: 1 +idouble: 2 ifloat: 2 ildouble: 2 ldouble: 2 @@ -316,9 +316,9 @@ ildouble: 5 ldouble: 5 Function: Imaginary part of "cacosh_towardzero": -double: 1 +double: 2 float: 2 -idouble: 1 +idouble: 2 ifloat: 2 ildouble: 2 ldouble: 2 @@ -339,6 +339,12 @@ ifloat: 2 ildouble: 2 ldouble: 2 +Function: "carg": +float: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 + Function: "carg_downward": double: 1 float: 2 @@ -348,8 +354,10 @@ ildouble: 1 ldouble: 1 Function: "carg_towardzero": -float: 1 -ifloat: 1 +double: 1 +float: 2 +idouble: 1 +ifloat: 2 ildouble: 1 ldouble: 1 @@ -410,9 +418,9 @@ ildouble: 5 ldouble: 5 Function: Real part of "casin_upward": -double: 1 +double: 2 float: 1 -idouble: 1 +idouble: 2 ifloat: 1 ildouble: 2 ldouble: 2 @@ -482,9 +490,9 @@ ildouble: 5 ldouble: 5 Function: Imaginary part of "casinh_upward": -double: 1 +double: 2 float: 2 -idouble: 1 +idouble: 2 ifloat: 2 ildouble: 2 ldouble: 2 @@ -534,9 +542,7 @@ ildouble: 4 ldouble: 4 Function: Real part of "catan_upward": -double: 1 float: 1 -idouble: 1 ifloat: 1 ildouble: 1 ldouble: 1 @@ -602,9 +608,7 @@ ildouble: 4 ldouble: 4 Function: Imaginary part of "catanh_upward": -double: 1 float: 1 -idouble: 1 ifloat: 1 ildouble: 1 ldouble: 1 @@ -820,9 +824,9 @@ ildouble: 4 ldouble: 4 Function: Imaginary part of "clog10_downward": -double: 3 +double: 1 float: 2 -idouble: 3 +idouble: 1 ifloat: 2 ildouble: 2 ldouble: 2 @@ -836,9 +840,9 @@ ildouble: 4 ldouble: 4 Function: Imaginary part of "clog10_towardzero": -double: 3 +double: 1 float: 2 -idouble: 3 +idouble: 1 ifloat: 2 ildouble: 2 ldouble: 2 @@ -852,10 +856,10 @@ ildouble: 4 ldouble: 4 Function: Imaginary part of "clog10_upward": -double: 2 -float: 2 -idouble: 2 -ifloat: 2 +double: 1 +float: 3 +idouble: 1 +ifloat: 3 ildouble: 2 ldouble: 2 @@ -893,16 +897,16 @@ ldouble: 1 Function: Real part of "clog_upward": double: 2 -float: 1 +float: 2 idouble: 2 -ifloat: 1 +ifloat: 2 ildouble: 2 ldouble: 2 Function: Imaginary part of "clog_upward": -double: 2 +double: 1 float: 2 -idouble: 2 +idouble: 1 ifloat: 2 ildouble: 1 ldouble: 1 @@ -984,9 +988,9 @@ ildouble: 7 ldouble: 7 Function: Imaginary part of "cpow_downward": -double: 2 +double: 1 float: 2 -idouble: 2 +idouble: 1 ifloat: 2 ildouble: 2 ldouble: 2 @@ -1000,9 +1004,9 @@ ildouble: 7 ldouble: 7 Function: Imaginary part of "cpow_towardzero": -double: 2 +double: 1 float: 2 -idouble: 2 +idouble: 1 ifloat: 2 ildouble: 1 ldouble: 1