From patchwork Wed Jul 1 22:28:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 490391 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 92CB31402AD for ; Thu, 2 Jul 2015 08:28:56 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=sourceware.org header.i=@sourceware.org header.b=bfdgy65l; 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=MSCRC4KifK2VfC1o0JpjL6Et5bIEs 9wSo8464iPLAbiZQ5KuWS/CCDiNq0+FiGbw+B3LW+AYORwaOWZPuY04J3eLZWYK6 Mu0L9MQKAAs/SIp9uLaCGdf5bDgnGfZXDcWQObH3CSFxQPAzr4AELoIj4EpA+zak grhGgyJ4eIMZtY= 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=La9AnZSqrr2YQPEUqCYetb+EMJk=; b=bfd gy65lMQ3i8Ocu+YocqDwx6wNtgTGPLsVDs4ORIFA+GOvI7b6OnIfOh6hPqE0YMkm 8b+TVytL6u+1GnaiPUiYpvklmu4DTOeu0lDXLAor5ecw6At8J6RaGD387YNTD7q8 Bg3hUMRMzsiZXmsmRFA/mbToCStwxQhY99OHngLE= Received: (qmail 9499 invoked by alias); 1 Jul 2015 22:28:49 -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 9333 invoked by uid 89); 1 Jul 2015 22:28:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Date: Wed, 1 Jul 2015 22:28:41 +0000 From: Joseph Myers To: Subject: Fix ldbl-128 expm1l (-min_subnorm) result sign (bug 18619) [committed] Message-ID: User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 In the ldbl-128 implementation of expm1l, when expm1l's result should underflow to 0 (argument minus the least subnormal, in some rounding modes), it can be a zero of the wrong sign. This patch fixes this in the same way previously used for the x86 / x86_64 versions. Tested for mips64. Committed. 2015-07-01 Joseph Myers [BZ #18619] * sysdeps/ieee754/ldbl-128/s_expm1l.c (__expm1l): Force underflow and return argument in case of subnormal argument. diff --git a/sysdeps/ieee754/ldbl-128/s_expm1l.c b/sysdeps/ieee754/ldbl-128/s_expm1l.c index f708af5..573d00b 100644 --- a/sysdeps/ieee754/ldbl-128/s_expm1l.c +++ b/sysdeps/ieee754/ldbl-128/s_expm1l.c @@ -137,9 +137,18 @@ __expm1l (long double x) if (x < minarg) return (4.0/big - 1.0L); - /* Avoid internal underflow when result does not underflow. */ - if (fabsl (x) < 0x1p-113L && fabsl (x) >= LDBL_MIN) - return x; + /* Avoid internal underflow when result does not underflow, while + ensuring underflow (without returning a zero of the wrong sign) + when the result does underflow. */ + if (fabsl (x) < 0x1p-113L) + { + if (fabsl (x) < LDBL_MIN) + { + long double force_underflow = x * x; + math_force_eval (force_underflow); + } + return x; + } /* Express x = ln 2 (k + remainder), remainder not exceeding 1/2. */ xx = C1 + C2; /* ln 2. */