|Does the gcc optimizer rearrange floating point expressions? firstname.lastname@example.org (1994-06-26)|
|Re: Does the gcc optimizer rearrange floating point expressions? email@example.com (1994-06-28)|
|Re: Does the gcc optimizer rearrange floating point expressions? firstname.lastname@example.org (1994-06-29)|
|Re: Does the gcc optimizer rearrange floating point expressions? email@example.com (1994-06-30)|
|From:||firstname.lastname@example.org (Jonathan R Shewchuk)|
|Keywords:||GCC, question, C, optimize|
|Organization:||School of Computer Science, Carnegie Mellon|
|Date:||Sun, 26 Jun 1994 03:06:39 GMT|
I'm planning to implement some complicated floating point algorithms.
Rounding behavior is of great importance, so I want to ensure that the
expressions I write are executed exactly as written.
Although I havent started coding yet, I'm worried that optimizing C
compilers, particularly gcc (which is my main compiler), may foolishly
rearrange expressions under the mistaken belief that floating point
numbers are subject to the usual rules of arithmetic. For instance, given
the expression (x + y) - y, which I use to determine the amount of
floating point roundoff error in (x + y), a non-floating point-aware
optimizer might mistakenly reduce it to x.
Can anybody tell me whether gcc behaves intelligently under these
circumstances? Are there any compiler flags I can use to disable the
optimizations that might cause trouble?
P.S. If anyone's curious, I'm trying to implement exact geometric
primitives for a Delaunay triangulation algorithm using floating
point arithmetic. I believe that the expression (x + y) - y
should give the precise rounding error of (x + y) if
|y| > |x|.
Return to the
Search the comp.compilers archives again.