From owner-freebsd-numerics@FreeBSD.ORG Thu Dec 5 19:52:29 2013 Return-Path: Delivered-To: freebsd-numerics@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id BB0401F2 for ; Thu, 5 Dec 2013 19:52:29 +0000 (UTC) Received: from troutmask.apl.washington.edu (troutmask.apl.washington.edu [128.95.76.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 7D98016FC for ; Thu, 5 Dec 2013 19:52:29 +0000 (UTC) Received: from troutmask.apl.washington.edu (localhost.apl.washington.edu [127.0.0.1]) by troutmask.apl.washington.edu (8.14.7/8.14.7) with ESMTP id rB5JqPMj065813; Thu, 5 Dec 2013 11:52:25 -0800 (PST) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.14.7/8.14.7/Submit) id rB5JqPqw065812; Thu, 5 Dec 2013 11:52:25 -0800 (PST) (envelope-from sgk) Date: Thu, 5 Dec 2013 11:52:25 -0800 From: Steve Kargl To: Filipe Maia Subject: Re: dead code in lgamma_r[f]? Message-ID: <20131205195225.GA65732@troutmask.apl.washington.edu> References: <20131205173700.GA64575@troutmask.apl.washington.edu> <20131205182324.GA65135@troutmask.apl.washington.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Cc: freebsd-numerics@freebsd.org X-BeenThere: freebsd-numerics@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "Discussions of high quality implementation of libm functions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Dec 2013 19:52:29 -0000 On Thu, Dec 05, 2013 at 08:06:22PM +0100, Filipe Maia wrote: > What if ix == 0x433xxxxx? See below. > Wouldn't the if clause be false? See below. > > Index: src/e_lgamma_r.c > > =================================================================== > > --- src/e_lgamma_r.c (revision 1427) > > +++ src/e_lgamma_r.c (working copy) > > @@ -173,19 +173,15 @@ > > */ > > z = floor(y); > > if(z!=y) { /* inexact anyway */ > > - y *= 0.5; > > - y = 2.0*(y - floor(y)); /* y = |x| mod 2.0 */ > > - n = (int) (y*4.0); > > + y /= 2; > > + y = 2*(y - floor(y)); /* y = |x| mod 2.0 */ > > + n = (int)(y*4); If you have a y value that corresponds to ix=0x433xxxxx where one of the x is nonzero, I believe that you end up going through this portion of code. > > } else { You end up here if and only if z==y, which means y is integral. As noted in the original email, the 'if(ix>=0x43400000)' below is dead code because this code in __ieee754_lgamma_r(): if(ix>=0x43300000) /* |x|>=2**52, must be -integer */ return one/zero; t = sin_pi(x); prevents the call to sin_pi(x). > > - if(ix>=0x43400000) { > > - y = zero; n = 0; /* y must be even */ > > - } else { > > - if(ix<0x43300000) z = y+two52; /* exact */ If we again look at the code from __ieee754_lgamma_r(), we see that sin_pi() is called if ix < 0x43300000, so by the time we arrive at the 'if(ix<0x43300000)' statement we already know that the condition is true. > > - GET_LOW_WORD(n,z); > > - n &= 1; > > - y = n; > > - n<<= 2; > > - } > > + z = y+two52; /* exact */ > > + GET_LOW_WORD(n,z); > > + n &= 1; > > + y = n; > > + n<<= 2; > > } > > switch (n) { > > case 0: y = __kernel_sin(pi*y,zero,0); break; -- Steve