From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22079 invoked by alias); 8 Nov 2011 16:12:10 -0000 Received: (qmail 22059 invoked by uid 22791); 8 Nov 2011 16:12:07 -0000 X-SWARE-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,TW_BG,TW_IB X-Spam-Check-By: sourceware.org Received: from troutmask.apl.washington.edu (HELO troutmask.apl.washington.edu) (128.95.76.21) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 08 Nov 2011 16:11:53 +0000 Received: from troutmask.apl.washington.edu (localhost.apl.washington.edu [127.0.0.1]) by troutmask.apl.washington.edu (8.14.5/8.14.5) with ESMTP id pA8GBQBZ055415; Tue, 8 Nov 2011 08:11:26 -0800 (PST) (envelope-from sgk@troutmask.apl.washington.edu) Received: (from sgk@localhost) by troutmask.apl.washington.edu (8.14.5/8.14.5/Submit) id pA8GBQNs055414; Tue, 8 Nov 2011 08:11:26 -0800 (PST) (envelope-from sgk) Date: Tue, 08 Nov 2011 16:34:00 -0000 From: Steve Kargl To: Rainer Orth Cc: Eric Botcazou , Tobias Burnus , gcc-patches@gcc.gnu.org, gfortran Subject: Re: [Patch, Fortran, committed] Add libquadmath testcase gfortran.dg/quad_2.f90 Message-ID: <20111108161126.GA55203@troutmask.apl.washington.edu> References: <4EB5A1C2.7090606@net-b.de> <201111072155.48747.ebotcazou@adacore.com> <20111107210011.GA50212@troutmask.apl.washington.edu> <20111108152408.GA55075@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.4.2.3i Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-11/txt/msg01201.txt.bz2 On Tue, Nov 08, 2011 at 04:41:32PM +0100, Rainer Orth wrote: > Steve Kargl writes: > > >> Please no: sqrtl is a C99 addition, and we don't want lists of non-C99 > >> targets in tests that require them. > >> > > > > OK, so, then we simply accept that running a regression test > > on these targets will always FAIL? If the answer is 'yes', > > then please close this PR because I doubt anyone will implement > > sqrtl(). > > No. AFAICS so far C99 functions have been implemented in > intrinsics/c99_functions.c for the benefit of platforms that aren't > C99. Has this policy changed recently? The policy has not changed. However, it took me >3 years to get an implementation of sqrtl() into FreeBSD's libm. On the surface, sqrtl() looks almost trivial to implement, but the IEEE 754 requirement of correct rounding in all rounding modes can be a nightmare to get right. Adopting FreeBSD sqrtl() has some issues. > I don't think it's a good idea for libgfortran to contain references to > nonexistant functions (or for gfortran to emit references to C99 > functions on non-C99 platforms, if that's the case). At least that's > not what any other GCC language frontend does. AFAIK, gfortran has always assumed that it is being built/run on a system with C99 functions. If one does not care about correct rounding, then one can do #include long double sqrtl(long double x) { if (x == 0) return x; if (x < 0) return ((x - x) / (x - x)); if (isfinite(x)) { reduce x to 2*f*2**n. check if x is subnormal and adjust f and n. if (n is odd) { f = 2*f; n--; } use Newtow's iteration to compute sqrtl(f) with a starting value of xn = sqrt(f) now combine everything return (xn*2**(n/2)) } else return (x * x + x); } -- Steve