|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 (David Robinson)|
|Keywords:||GCC, C, optimize|
|Organization:||Institute of Astronomy, Cambridge|
|Date:||Wed, 29 Jun 1994 10:42:56 GMT|
Jonathan R Shewchuk <email@example.com> wrote:
>[does GCC reorganize floating point expresions like]
>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.
firstname.lastname@example.org (Dave Moore) writes:
> From an examination of the assembler output of gcc with and without
>the -O flag, it appears that gcc does indeed optimize away the
Which version of gcc are you using? I do not see this effect with 2.5.8.
I believe that the answer to the original question is that the gcc
optimiser tries to preserve the exact behaviour of any floating-point
program, and that any effect such as you describe will be considered a bug
by the maintainers. This includes pedantic observation of the IEEE spec
on IEEE fp based machines. (Note; I am not a gcc maintainer, so I do not
speak from authority.)
The only problem you might encounter is if your program changes the
rounding mode at run-time; gcc assumes a particular rounding mode at
compile time when doing constant folding.
What is definitely true (look in combine.c) is that the gcc optimiser _is_
aware that floating-point numbers are not subject to the usual rules of
David Robinson. (email@example.com)
Return to the
Search the comp.compilers archives again.