From patchwork Thu Dec 8 18:51:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Frysinger X-Patchwork-Id: 704193 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 3tZPcH13Gcz9vDZ for ; Fri, 9 Dec 2016 05:52:14 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="mcWgx3/b"; 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:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=VNBkOQy/YIhKrXO2PXWkeJQV79aDW/6 XkvI787Qz5gUNK8n1poDq9wDLJIAcnyT+jCng7Bg6p78I7Wc5A4VYkNhUTF8kV6e wEQh8d7QTgv7F8hrIXzm3u/JqhMnB8jZNBcxY+F1s7ccefLCZK4LowZOWMbd9rRL 6XsQ8l7Qcbls= 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:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=pAQyVsizlaXWuRwRf4obYqPxrsE=; b=mcWgx 3/b3jR/R0P4CVtDxCmp3vAJRblZzcsNVfZo3EnlqLuCSvd7jfddLDNgXFBsMHjnb jhIVrejFjOpPLg3AEGcpMk7A1F77xZ3WQ3FXZ1y0M1yt6fvVTdRDZPYPs10TQNDU veymVAfjjUvIW/AWaJV2LuwP8dVXXJgg27m3j0= Received: (qmail 73103 invoked by alias); 8 Dec 2016 18:52:05 -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 73013 invoked by uid 89); 8 Dec 2016 18:52:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.9 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=0.0000, suc, sk:matthew, matthew.fortune@imgtec.com X-HELO: smtp.gentoo.org From: Mike Frysinger To: libc-alpha@sourceware.org Subject: [PATCH 4/4] alpha: fix trunc for big input values [committed/2.23] Date: Thu, 8 Dec 2016 13:51:49 -0500 Message-Id: <20161208185149.22707-4-vapier@gentoo.org> In-Reply-To: <20161208185149.22707-1-vapier@gentoo.org> References: <20161208185149.22707-1-vapier@gentoo.org> From: Aurelien Jarno The alpha specific version of trunc and truncf always add and subtract 0x1.0p23 or 0x1.0p52 even for big values. This causes this kind of errors in the testsuite: Failure: Test: trunc_towardzero (0x1p107) Result: is: 1.6225927682921334e+32 0x1.fffffffffffffp+106 should be: 1.6225927682921336e+32 0x1.0000000000000p+107 difference: 1.8014398509481984e+16 0x1.0000000000000p+54 ulp : 0.5000 max.ulp : 0.0000 Change this by returning the input value when its absolute value is greater than 0x1.0p23 or 0x1.0p52. NaN have to go through the add and subtract operations to get possibly silenced. Finally remove the code to handle inexact exception, trunc should never generate such an exception. Changelog: * sysdeps/alpha/fpu/s_trunc.c (__trunc): Return the input value when its absolute value is greater than 0x1.0p52. [_IEEE_FP_INEXACT] Remove. * sysdeps/alpha/fpu/s_truncf.c (__truncf): Return the input value when its absolute value is greater than 0x1.0p23. [_IEEE_FP_INEXACT] Remove. (cherry picked from commit b74d259fe793499134eb743222cd8dd7c74a31ce) --- ChangeLog | 6 ++++++ sysdeps/alpha/fpu/s_trunc.c | 7 +++---- sysdeps/alpha/fpu/s_truncf.c | 7 +++---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index b4d4b6af2ae6..5a49870eb15b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,6 +13,12 @@ * sysdeps/alpha/fpu/s_rint.c (__rint): Add argument with itself when it is a NaN. * sysdeps/alpha/fpu/s_rintf.c (__rintf): Likewise. + * sysdeps/alpha/fpu/s_trunc.c (__trunc): Return the input value + when its absolute value is greater than 0x1.0p52. + [_IEEE_FP_INEXACT] Remove. + * sysdeps/alpha/fpu/s_truncf.c (__truncf): Return the input value + when its absolute value is greater than 0x1.0p23. + [_IEEE_FP_INEXACT] Remove. 2016-11-23 Matthew Fortune Maciej W. Rozycki diff --git a/sysdeps/alpha/fpu/s_trunc.c b/sysdeps/alpha/fpu/s_trunc.c index 16cb114a72f5..4b986a6926eb 100644 --- a/sysdeps/alpha/fpu/s_trunc.c +++ b/sysdeps/alpha/fpu/s_trunc.c @@ -28,12 +28,11 @@ __trunc (double x) double two52 = copysign (0x1.0p52, x); double r, tmp; + if (isgreaterequal (fabs (x), 0x1.0p52)) + return x; + __asm ( -#ifdef _IEEE_FP_INEXACT - "addt/suic %2, %3, %1\n\tsubt/suic %1, %3, %0" -#else "addt/suc %2, %3, %1\n\tsubt/suc %1, %3, %0" -#endif : "=&f"(r), "=&f"(tmp) : "f"(x), "f"(two52)); diff --git a/sysdeps/alpha/fpu/s_truncf.c b/sysdeps/alpha/fpu/s_truncf.c index 2290f282954d..3e933561663b 100644 --- a/sysdeps/alpha/fpu/s_truncf.c +++ b/sysdeps/alpha/fpu/s_truncf.c @@ -27,12 +27,11 @@ __truncf (float x) float two23 = copysignf (0x1.0p23, x); float r, tmp; + if (isgreaterequal (fabsf (x), 0x1.0p23)) + return x; + __asm ( -#ifdef _IEEE_FP_INEXACT - "adds/suic %2, %3, %1\n\tsubs/suic %1, %3, %0" -#else "adds/suc %2, %3, %1\n\tsubs/suc %1, %3, %0" -#endif : "=&f"(r), "=&f"(tmp) : "f"(x), "f"(two23));