This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH]: PR29335 use MPFR for two-argument math builtins (pow, atan2, hypot)
- From: "Kaveh R. GHAZI" <ghazi at caip dot rutgers dot edu>
- To: Roger Sayle <roger at eyesopen dot com>
- Cc: Bradley Lucier <lucier at math dot purdue dot edu>, gcc-patches at gcc dot gnu dot org
- Date: Sat, 28 Oct 2006 22:25:14 -0400 (EDT)
- Subject: Re: [PATCH]: PR29335 use MPFR for two-argument math builtins (pow, atan2, hypot)
- References: <Pine.LNX.4.44.0610281804510.15228-100000@www.eyesopen.com>
On Sat, 28 Oct 2006, Roger Sayle wrote:
>
> On Sat, 28 Oct 2006, Bradley Lucier wrote:
> > > hypot(x,x) -> x*sqrt(2)
> >
> > I think this can change the value computed in some cases, because
> > there's one rounding error computing sqrt(2) and one more computing
> > the multiplication.
>
> Grr. I missed this. I did give some thought to multiple rounding
> when reviewing the patch, but I made the (obvious in retrospect)
> incorrect assumption that the compile-time constant sqrt(2) wasn't
> rounded, so the perfect rounding of the single multiplication was
> acceptable. Alas not.
>
> Kaveh, I'll preapprove the "obvious" simple change to control this
> transformation with flag_unsafe_math_optimizations.
>
> Many thanks to Brad for catching this.
> Roger
Okay I'll take care of adding this as a follow-up. Thanks for the review.
Hmm... after some more thought I'm wondering don't I also need a fabs in
there? I.e.:
hypot(x,x) -> fabs(x)*sqrt(2)
--Kaveh
--
Kaveh R. Ghazi ghazi@caip.rutgers.edu