This is the mail archive of the
mailing list for the GCC project.
Re: FloatingPointMath and transformations
- From: Geert Bosch <boschg at mac dot com>
- To: Vincent Lefevre <vincent+gcc at vinc17 dot org>
- Cc: gcc at gcc dot gnu dot org
- Date: Mon, 02 Jun 2014 10:33:37 -0400
- Subject: Re: FloatingPointMath and transformations
- Authentication-results: sourceware.org; auth=none
- References: <20140602140635 dot GA5214 at ypig dot lip dot ens-lyon dot fr>
On Jun 2, 2014, at 10:06 AM, Vincent Lefevre <email@example.com> wrote:
> I've looked at
> and there may be some mistakes or missing info.
That’s quite possible. I created the page many years ago, based on my
understanding of GCC at that time.
> First, it is said that x / C is replaced by x * (1.0 / C) when C is
> a power of two. But this condition is not sufficient: if 1.0 / C
> overflows, the transformation is incorrect. From some testing,
> it seems that GCC detects the overflow case, so that it behaves
> correctly. In this case I think that the wiki should say:
> "When C is a power of two and 1.0 / C doesn't overflow.”
Yes, that was implied, but should indeed be made explicit.
> It is also said that x / 1.0 and x / -1.0 are respectively replaced
> by x and -x. But what about x * 1.0 and x * -1.0?
> Ditto with -(a / b) -> a / -b and -(a / b) -> -a / b. Is there
> anything similar with multiplication?
It should, or it would be a bug. Please feel free to add/correct anything on this page.