From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22841 invoked by alias); 18 Mar 2010 15:35:05 -0000 Received: (qmail 22833 invoked by uid 22791); 18 Mar 2010 15:35:05 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from vinc17.pck.nerim.net (HELO prunille.vinc17.org) (213.41.242.187) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 18 Mar 2010 15:34:59 +0000 Received: by prunille.vinc17.org (Postfix, from userid 501) id A604548EBF34; Thu, 18 Mar 2010 16:34:56 +0100 (CET) Date: Thu, 18 Mar 2010 15:41:00 -0000 From: Vincent Lefevre To: gcc@gcc.gnu.org Subject: Re: Questions about "Handle constant exponents." in gcc/builtins.c Message-ID: <20100318153456.GD12663@prunille.vinc17.org> Mail-Followup-To: gcc@gcc.gnu.org References: <20100316151100.BD92D3BE0F@mailhost.lps.ens.fr> <84fc9c001003160818o230920eei84f0558a81fdcf7@mail.gmail.com> <20100318134339.GC1758@prunille.vinc17.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Mailer-Info: http://www.vinc17.org/mutt/ User-Agent: Mutt/1.5.20-6061-vl-r35499 (2010-03-08) X-IsSubscribed: yes Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2010-03/txt/msg00266.txt.bz2 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 - Web: 100% accessible validated (X)HTML - Blog: Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)