Re: Does the gcc optimizer rearrange floating point expressions?

dmoore@reed.edu (Dave Moore)
Tue, 28 Jun 1994 02:35:30 GMT

          From comp.compilers

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)
| List of all articles for this month |
Newsgroups: comp.compilers
From: dmoore@reed.edu (Dave Moore)
Keywords: GCC, C, optimize
Organization: Reed College, Portland, Oregon
References: 94-06-188
Date: Tue, 28 Jun 1994 02:35:30 GMT

Jonathan R Shewchuk <jrs+@cs.cmu.edu> wrote:
>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.


    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. However, setting the variables to be "volatile" seems to
correct the problem. Incidentally, aren't the values in <float.h> what
you are looking for? i.e., DBL_EPSILON, the smallest number such that
1.0 + x != 1.0? I may just misunderstand your question tho.


...Dave
--
                                    Dave Moore - Student at Large - Reed College
                                  dmoore@reed.edu - http://www.reed.edu/~dmoore/
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.