From patchwork Mon Jun 29 17:52:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 489369 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 E85CE140783 for ; Tue, 30 Jun 2015 03:52:27 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=sourceware.org header.i=@sourceware.org header.b=PmYhVEWz; 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=hWD7PvW39OcQMFH751CX3Eyvwtc3k m+pyCsKglBkp9sorrRNGP8jXjLWEFBtqRewH/JM8IyyQoIoheJIWfBzll07UL65N 6kjqRV68pcUl18M5WZxBkxNSOxklUlfGRt++6oPiAhJ2j2TMggCliyWWtS32X6xm zMetyJ/S4ePKwM= 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=FXJNatdkiJ+p1X7NYOZbWswxtyk=; b=PmY hVEWzJSwRsNLQ2xnzmfzQIEfmYpCVMDAljhvDAp3JDbtxrJtodutYtZLd0VBwZXW I6fpwZDce1R9J+DmlnhIQ4263OkB37hwa6sSVfFkn8+3pwyK3okoyhtbkYt8iYXj ArSTs8zYA8NrROWEnJOKdNNtIFaimCFMgPh1xh4Y= Received: (qmail 124333 invoked by alias); 29 Jun 2015 17:52:21 -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 124316 invoked by uid 89); 29 Jun 2015 17:52:19 -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: Mon, 29 Jun 2015 17:52:13 +0000 From: Joseph Myers To: Subject: Fix ldbl-128 j1l spurious underflows (bug 18612) [committed] Message-ID: User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 The ldbl-128 implementation of j1l produces spurious underflow exceptions for some small arguments, as a result of squaring the argument. This patch fixes it just to use a linear approximation for sufficiently small arguments, and then to force an underflow exception only in the cases where it is required. Tested for mips64. Committed. (auto-libm-test-out diffs omitted below.) 2015-06-29 Joseph Myers [BZ #18612] * sysdeps/ieee754/ldbl-128/e_j1l.c (__ieee754_j1l): For small arguments, just return 0.5 times the argument, with underflow forced as needed. * math/auto-libm-test-in: Add more tests of j1. * math/auto-libm-test-out: Regenerated. diff --git a/math/auto-libm-test-in b/math/auto-libm-test-in index 34b02c9..f4313a2 100644 --- a/math/auto-libm-test-in +++ b/math/auto-libm-test-in @@ -1812,6 +1812,9 @@ j1 0x1.ff00000000002p+840 j1 0x1p1023 j1 0x1p16382 j1 0x1p16383 +j1 0x1p-100 +j1 0x1p-600 +j1 0x1p-10000 # Bug 18611: errno setting may be missing. j1 min missing-errno j1 -min missing-errno diff --git a/sysdeps/ieee754/ldbl-128/e_j1l.c b/sysdeps/ieee754/ldbl-128/e_j1l.c index 958077d..591c38e 100644 --- a/sysdeps/ieee754/ldbl-128/e_j1l.c +++ b/sysdeps/ieee754/ldbl-128/e_j1l.c @@ -697,6 +697,16 @@ __ieee754_j1l (long double x) if (x == 0.0L) return x; xx = fabsl (x); + if (xx <= 0x1p-58L) + { + long double ret = x * 0.5L; + if (fabsl (ret) < LDBL_MIN) + { + long double force_underflow = ret * ret; + math_force_eval (force_underflow); + } + return ret; + } if (xx <= 2.0L) { /* 0 <= x <= 2 */