From patchwork Fri Sep 11 15:35:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 516843 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 F166914012C for ; Sat, 12 Sep 2015 01:35:18 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b=M8ukFsY+; 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=pLje7l/uQQB3MS/0Ank3BHPZbbpED s8P5QEi4iiulFvLROXa7bbrmMJstnlAQMC9pIyS90wC7UyHMQ3Ga6+cBAsDjnTJz 8eRNzIp8zGHWGhqi8VN7nLx+SUaERjOTa/nyt3IwDQqC1aHsf1rbDIXnkd3VthOv A9A6P+tzHbyzZs= 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=zk6vcTNyiUapkxxisLTEl4iF2wU=; b=M8u kFsY+9jORI5g9XOyprMzXr4sXiq+3HCeia/1opoewAZ+BBDCxN4kij756f8r5RgL IioXsspI8ZFeeheH3iJ7EFbfQSzBo5xai949zsc5CXmP6ZJWKO+Akz0wvagB0Lxb avmAFZFuM8cNCa7nNjqcHC0yrSUUGk74LkzW/pSk= Received: (qmail 15922 invoked by alias); 11 Sep 2015 15:35:10 -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 15682 invoked by uid 89); 11 Sep 2015 15:35:10 -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: Fri, 11 Sep 2015 15:35:04 +0000 From: Joseph Myers To: Subject: Fix ldbl-128/ldbl-128ibm lgamma spurious "invalid", incorrect signgam (bug 18952) [committed] Message-ID: User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 The ldbl-128 / ldbl-128ibm implementation of lgammal converts (the floor of minus) non-integer negative arguments to int to determine the value of signgam. When those values are outside the range of int, this produces spurious "invalid" exceptions and incorrect values of signgam. This patch fixes this by instead determining signgam through comparing half the integer in question to floor of half the integer. Tested for mips64, x86_64 and x86. Committed. (auto-libm-test-out diffs omitted below.) 2015-09-11 Joseph Myers [BZ #18952] * sysdeps/ieee754/ldbl-128/e_lgammal_r.c (__ieee754_lgammal_r): Do not convert non-integer negative arguments to int to determine the value of signgam. * math/auto-libm-test-in: Add more tests of lgamma. * math/auto-libm-test-out: Regenerated. diff --git a/math/auto-libm-test-in b/math/auto-libm-test-in index 84b3df0..83eb4cf 100644 --- a/math/auto-libm-test-in +++ b/math/auto-libm-test-in @@ -2047,6 +2047,9 @@ lgamma -0xffffffffffffffffp-1 lgamma -0x3ffffffffffffffffffffffffffp-1 lgamma -0x1ffffffffffffffffffffffffffffp-1 +lgamma -0x100000000.8p0 +lgamma -0x100000001.8p0 + lgamma -0.25 lgamma -0.5 lgamma -0.75 diff --git a/sysdeps/ieee754/ldbl-128/e_lgammal_r.c b/sysdeps/ieee754/ldbl-128/e_lgammal_r.c index abf0f15..500aacc 100644 --- a/sysdeps/ieee754/ldbl-128/e_lgammal_r.c +++ b/sysdeps/ieee754/ldbl-128/e_lgammal_r.c @@ -787,8 +787,8 @@ __ieee754_lgammal_r (long double x, int *signgamp) p = __floorl (q); if (p == q) return (one / (p - p)); - i = p; - if ((i & 1) == 0) + long double halfp = p * 0.5L; + if (halfp == __floorl (halfp)) *signgamp = -1; else *signgamp = 1;