public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Vincent Lefevre <vincent+gcc@vinc17.org>
To: gcc@gcc.gnu.org
Subject: Re: Questions about "Handle constant exponents." in gcc/builtins.c
Date: Thu, 18 Mar 2010 15:41:00 -0000	[thread overview]
Message-ID: <20100318153456.GD12663@prunille.vinc17.org> (raw)
In-Reply-To: <Pine.LNX.4.64.1003181510520.18785@wotan.suse.de>

On 2010-03-18 15:32:04 +0100, Michael Matz wrote:
> > So, pow(-0.0, 0.5) should return +0. But sqrt(-0.0) should return -0
> > according to the IEEE 754 standard (and F.9.4.5 from ISO C99).
> 
> Yes, and I don't know why they specified it like that.  After all 
> (-0)*(-0)==+0 (not ==-0), so the above definition is internally 
> insonsistent.  Defining sqrt(-0) as +0 would be equally inconsistent, but 
> at least agree with the pow(-0, 0.5) result.

sqrt(-0) was defined first by the IEEE 754 standard in 1985.
AFAIK, -0 was chosen to allow a hack for some convention in
interval arithmetic (there may be other reasons). pow(-0, y)
was defined by the C committee.

> But unfortunately you are right, this expansion can only be done for
> -fno-signed-zeros. (FWIW the general expandsion of pow(x,N/2) where
> N!=1 is already guarded by unsafe_math, but for N==1 we do it
> unconditionally).

If GCC is able to track range of values, the transformation could
be allowed when it can be proved that the value -0 is not possible
(e.g. when x > 0).

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)

  reply	other threads:[~2010-03-18 15:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-16 15:18 Dominique Dhumieres
2010-03-16 15:37 ` Richard Guenther
2010-03-18 13:51   ` Vincent Lefevre
2010-03-18 14:30     ` Vincent Lefevre
2010-03-18 14:51     ` Michael Matz
2010-03-18 15:41       ` Vincent Lefevre [this message]
2010-03-18 15:49         ` Nathan Froyd
2010-03-18 15:56         ` Joseph S. Myers
2010-03-18 17:06           ` Vincent Lefevre
2010-03-18 15:10 Dominique Dhumieres
2010-03-18 15:13 ` Jakub Jelinek
2010-03-18 20:53 Dominique Dhumieres

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=20100318153456.GD12663@prunille.vinc17.org \
    --to=vincent+gcc@vinc17.org \
    --cc=gcc@gcc.gnu.org \
    /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).