This is the mail archive of the
mailing list for the GCC project.
FloatingPointMath and transformations
- From: Vincent Lefevre <vincent+gcc at vinc17 dot org>
- To: gcc at gcc dot gnu dot org
- Date: Mon, 2 Jun 2014 16:06:35 +0200
- Subject: FloatingPointMath and transformations
- Authentication-results: sourceware.org; auth=none
I've looked at
and there may be some mistakes or missing info.
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."
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?
Vincent Lefèvre <firstname.lastname@example.org> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)