This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FloatingPointMath and transformations


I've looked at

  https://gcc.gnu.org/wiki/FloatingPointMath

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 <vincent@vinc17.net> - 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)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]