Related articles |
---|
Does the gcc optimizer rearrange floating point expressions? jrs+@cs.cmu.edu (1994-06-26) |
Re: Does the gcc optimizer rearrange floating point expressions? dmoore@reed.edu (1994-06-28) |
Re: Does the gcc optimizer rearrange floating point expressions? drtr@mailer.astronomy.cambridge.ac.uk (1994-06-29) |
Re: Does the gcc optimizer rearrange floating point expressions? dje@cygnus.com (1994-06-30) |
Newsgroups: | comp.compilers |
From: | drtr@mailer.astronomy.cambridge.ac.uk (David Robinson) |
Keywords: | GCC, C, optimize |
Organization: | Institute of Astronomy, Cambridge |
References: | 94-06-188 94-06-219 |
Date: | Wed, 29 Jun 1994 10:42:56 GMT |
Jonathan R Shewchuk <jrs+@cs.cmu.edu> 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.
dmoore@reed.edu (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
>expression. ...
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
arithmetic.
David Robinson. (drtr@mail.ast.cam.ac.uk)
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.