public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Steve Kargl <sgk@troutmask.apl.washington.edu>
To: Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
Cc: Eric Botcazou <ebotcazou@adacore.com>,
	Tobias Burnus <burnus@net-b.de>,
	       gcc-patches@gcc.gnu.org, gfortran <fortran@gcc.gnu.org>
Subject: Re: [Patch, Fortran, committed] Add libquadmath testcase gfortran.dg/quad_2.f90
Date: Tue, 08 Nov 2011 16:34:00 -0000	[thread overview]
Message-ID: <20111108161126.GA55203@troutmask.apl.washington.edu> (raw)
In-Reply-To: <yddbosmvcyb.fsf@manam.CeBiTec.Uni-Bielefeld.DE>

On Tue, Nov 08, 2011 at 04:41:32PM +0100, Rainer Orth wrote:
> Steve Kargl <sgk@troutmask.apl.washington.edu> 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 <math.h>

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

  parent reply	other threads:[~2011-11-08 16:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-05 21:09 Tobias Burnus
2011-11-07 21:00 ` Eric Botcazou
2011-11-07 21:05   ` Steve Kargl
2011-11-08 10:33     ` Rainer Orth
2011-11-08 15:41       ` Steve Kargl
2011-11-08 16:23         ` Rainer Orth
2011-11-08 16:34           ` Janne Blomqvist
2011-11-08 16:58             ` Tobias Burnus
2011-11-08 16:34           ` Steve Kargl [this message]
2011-11-08 18:56 Dominique Dhumieres
2011-11-08 19:20 ` Steve Kargl

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20111108161126.GA55203@troutmask.apl.washington.edu \
    --to=sgk@troutmask.apl.washington.edu \
    --cc=burnus@net-b.de \
    --cc=ebotcazou@adacore.com \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=ro@CeBiTec.Uni-Bielefeld.DE \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).