[BUG][!] Optimization bug in gcc! [was: Re: sinful bug]

Stephan Rudlof sr at evolgo.de
Thu Aug 3 23:33:17 UTC 2000


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; 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();
}

works correctly with -O3. 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





More information about the Squeak-dev mailing list