Correction: [BUG][!] Optimization bug in gcc! [was: Re: sinful bug]
Stephan Rudlof
sr at evolgo.de
Fri Aug 4 03:10:35 UTC 2000
Squeakers,
there has been some errorneous description of mine, but the gcc optimization
bug
remains.
Stephan Rudlof wrote:
>
> Dear Squeakers,
>
> there seems to be an optimization bug in gcc, arising in interp.c for -O1
> already!
>
> Example: Optimization for sin()'s is possible;
that's *not* true in the following code!
> program
>
> #include <stdio.h>
> #include <math.h>
>
> static void testDoubles () {
> printf("\n_LIB_VERSION == _POSIX_: %d", _LIB_VERSION == _POSIX_);
> { double arg1 = 1.0e20;
> printf("\nsin(arg1): %e", sin(arg1));
> }
> _LIB_VERSION = _IEEE_;
> printf("\n_LIB_VERSION == _IEEE_: %d", _LIB_VERSION == _IEEE_);
> {
> double arg2 = 1.0e20;
> printf("\nsin(arg2): %e", sin(arg2));
> }
> }
>
> int main () {
> testDoubles();
> }
>
doesn't work with -O1 (or higher), it works only without optimization!
Sorry: I should go to bed...
The interpreter code *also* doesn't work with optimization (the optimization
bug
remains, see below).
But the former works with
gcc -O3 -fno-inline -c sinTest2.c
; and the latter with
gcc -O3 -fno-inline -I. -I../src -I../src/CoreVM -DHAVE_CONFIG_H
-DUNIX -c gnu-interp.c
.
It's the no-inline flag, that makes it work.
Stephan
Correct:
> But the sin() called by primitiveSine() in
> interp.c not (works only with O0)!
>
> Bad, bad, bad...
>
> What about other - newer? - gcc versions?
>
> Greetings,
>
> - somewhat shocked (where are the other optimization bugs?) - Stephan
>
> Stephan Rudlof wrote:
> >
> > I have catched the bug!
> >
> > Compiling the interpreter with different optimizations results in:
> >
> > 1.0e20 sin 1.0e20 "-O2"
> > 1.0e20 sin 1.0e20 "-O1"
> > 1.0e20 sin -0.746921891259493 "without optimization"
> >
> > So using just an -O1 optimization leads to wrong results! That's bad...
> >
> > Compiling without any optimizations is really bad: Selective optimizations?
> >
> > Comments?
> >
> > Without setting the lib to
> > _LIB_VERSION = _IEEE_;
> > this also works (_LIB_VERSION == _POSIX_ at my machine). So my earlier
> > assumption, that it could be a lib setting problem, was wrong.
> >
> > Platform:
> > Linux SuSE 6.2
> > sr at Klaus:~/Squeak/Unix_2.8/i686-pc-linux-gnu > gcc -v
> > Reading specs from /usr/lib/gcc-lib/i486-linux/egcs-2.91.66/specs
> > gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
> >
> > Greetings,
> >
> > Stephan
> >
> > Luciano Notarfrancesco wrote:
> > >
> > > x sin = x for all x >= 16r7FFFFFFFFFFFFDFC
> > >
> > > Why?
> > >
> > > Luciano.-
> > >
> > > __________________________________________________
> > > Do You Yahoo!?
> > > Kick off your party with Yahoo! Invites.
> > > http://invites.yahoo.com/
> >
> > --
> > Stephan Rudlof (sr at evolgo.de)
> > "Genius doesn't work on an assembly line basis.
> > You can't simply say, 'Today I will be brilliant.'"
> > -- Kirk, "The Ultimate Computer", stardate 4731.3
>
> --
> Stephan Rudlof (sr at evolgo.de)
> "Genius doesn't work on an assembly line basis.
> You can't simply say, 'Today I will be brilliant.'"
> -- Kirk, "The Ultimate Computer", stardate 4731.3
--
Stephan Rudlof (sr at evolgo.de)
"Genius doesn't work on an assembly line basis.
You can't simply say, 'Today I will be brilliant.'"
-- Kirk, "The Ultimate Computer", stardate 4731.3
More information about the Squeak-dev
mailing list
|