From patchwork Tue Apr 22 08:24:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 633 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx20.g.dreamhost.com (mx2.sub5.homie.mail.dreamhost.com [208.113.200.128]) by wilcox.dreamhost.com (Postfix) with ESMTP id C10583608A3 for ; Tue, 22 Apr 2014 01:25:13 -0700 (PDT) Received: by homiemail-mx20.g.dreamhost.com (Postfix, from userid 14307373) id 6F44C412488B6; Tue, 22 Apr 2014 01:25:13 -0700 (PDT) X-Original-To: glibc@patchwork.siddhesh.in Delivered-To: x14307373@homiemail-mx20.g.dreamhost.com 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 homiemail-mx20.g.dreamhost.com (Postfix) with ESMTPS id 4C3854124888F for ; Tue, 22 Apr 2014 01:25:13 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:to:from:subject:date:message-id:references :mime-version:content-type:in-reply-to; q=dns; s=default; b=xtkQ 5e7i6CuONFUU/qVqoC8GrH/ERuF8WQHqWG1FmkBRg1QLjwlkm8DBHqF6W2is/TiK trJqnlu3B5OYrxXza8xb40GQTJTLSXwl9PuS1L9dbIg9MAGA6Bkm3w3JXOs/JZ+X fQZH/aloBgGN4+dIHcjDuS+AIG6XCmcQFcJB9n0= 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:to:from:subject:date:message-id:references :mime-version:content-type:in-reply-to; s=default; bh=L7gslyRheS Ufx+30kOgiVcg4ihM=; b=oVx3kYb6SQxgqi8k1tfpt6Ac1IwqVU3dlWox3LzIgs jBRgWaKSOeagwyoKEHtZAv5JtZoJyA59L0vVuDKOYXYbk3y3qUJO7PPU3r6G2SIS Fsuad80ajDuIs32536unoPBUKYTF0nf9HxejDbeZJ2m1sUcHRAA64UZGI0/m8m4L g= Received: (qmail 29660 invoked by alias); 22 Apr 2014 08:25: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 29595 invoked by uid 89); 22 Apr 2014 08:25:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: plane.gmane.org To: libc-alpha@sourceware.org From: Stefan Liebler Subject: Re: [PATCH][BZ #16823] Fix log1pl returning wrong infinity sign Date: Tue, 22 Apr 2014 10:24:52 +0200 Lines: 91 Message-ID: <53562754.3040706@linux.vnet.ibm.com> References: Mime-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 In-Reply-To: X-DH-Original-To: glibc@patchwork.siddhesh.in Hi, log1pl (-1) now returns with -inf instead of +inf in FE_DOWNWARD rounding mode. The source code producing the -inf for the double/float variants is the same, but on S390 the compiler generates a division by constant +zero and ignores the (x-x). Thus i also changed it to the constant zero in the double/float functions. I´ve tested it on S390. Please test it on other platforms because there are also reports for the same failure on aarch64 (see bug comment 1) and sparc (https://www.sourceware.org/ml/libc-alpha/2014-04/msg00410.html). Give feedback in order to commit the patch. Bye --- 2014-04-22 Stefan Liebler [BZ #16823] * sysdeps/ieee754/ldbl-128/s_log1pl.c (__log1pl): Always divide by positive zero when computing -Inf result. * sysdeps/ieee754/dbl-64/s_log1p.c (__log1p): Likewise. * sysdeps/ieee754/flt-32/s_log1pf.c (__log1pf): Likewise. --- On 04/09/2014 03:24 PM, Stefan Liebler wrote: > Hi, > > on S390 test-double fails for log1pl(-1) with infinity has wrong sign in > rounding mode FE_DOWNWARD. See Bug 16823. > In this rounding mode, (x-x) = -0. > In all other rounding modes, (x-x) = +0. > A division with divisor -0 leads to +inf, while +0 results in -inf as > expected. This patch changes the divisor to a const +0. > Tested on s390/s390x. > > Is this okay? > > Bye > > --- > 2014-04-09 Stefan Liebler > > [BZ #16823] > * sysdeps/ieee754/ldbl-128/s_log1pl.c (__log1pl): > Use const positive zero instead of (x-x). > --- diff --git a/sysdeps/ieee754/dbl-64/s_log1p.c b/sysdeps/ieee754/dbl-64/s_log1p.c index fd4dce5..c922148 100644 --- a/sysdeps/ieee754/dbl-64/s_log1p.c +++ b/sysdeps/ieee754/dbl-64/s_log1p.c @@ -110,7 +110,7 @@ __log1p (double x) if (__glibc_unlikely (ax >= 0x3ff00000)) /* x <= -1.0 */ { if (x == -1.0) - return -two54 / (x - x); /* log1p(-1)=+inf */ + return -two54 / zero; /* log1p(-1)=-inf */ else return (x - x) / (x - x); /* log1p(x<-1)=NaN */ } diff --git a/sysdeps/ieee754/flt-32/s_log1pf.c b/sysdeps/ieee754/flt-32/s_log1pf.c index 0307277..5f00feb 100644 --- a/sysdeps/ieee754/flt-32/s_log1pf.c +++ b/sysdeps/ieee754/flt-32/s_log1pf.c @@ -42,7 +42,7 @@ __log1pf(float x) k = 1; if (hx < 0x3ed413d7) { /* x < 0.41422 */ if(ax>=0x3f800000) { /* x <= -1.0 */ - if(x==(float)-1.0) return -two25/(x-x); /* log1p(-1)=+inf */ + if(x==(float)-1.0) return -two25/zero; /* log1p(-1)=-inf */ else return (x-x)/(x-x); /* log1p(x<-1)=NaN */ } if(ax<0x31000000) { /* |x| < 2**-29 */ diff --git a/sysdeps/ieee754/ldbl-128/s_log1pl.c b/sysdeps/ieee754/ldbl-128/s_log1pl.c index d991e8a..d8d89f0 100644 --- a/sysdeps/ieee754/ldbl-128/s_log1pl.c +++ b/sysdeps/ieee754/ldbl-128/s_log1pl.c @@ -150,7 +150,7 @@ __log1pl (long double xm1) if (x <= 0.0L) { if (x == 0.0L) - return (-1.0L / (x - x)); + return (-1.0L / zero); /* log1p(-1) = -inf */ else return (zero / (x - x)); }