[macstl-dev] not all rosey in the gcc-4.0.0 land
Ilya Lipovsky
lipovsky at skycomputers.com
Sat Jul 2 07:24:33 WST 2005
Glen,
Looks like the expression
(u * v).sum()
produces bad code in gcc 4.0.0, if inline is NOT #defined as "inline
__attribute__ ((always_inline)).
If, however, inline IS #defined as "inline __attribute__
((always_inline)), then the code is correct and the run-time results are
OK.
This is a bug in the compiler's optimizer :( . This time I have rechecked
myself by running gdb and looking at the actual instruction sequences.
When reducing my -O3 option down to -O1 everything is *fine*!!!
Without redefining inline gcc's O3/O2-level optimizer "thinks" that the
operands can be safely taken out of the loop, thus producing an empty loop
(i.e. a bdnz onto itself!).
Another thing, since we're on the "inline" subject: it looks like
inline almost never helps to produce more efficient code. This is in
contrast to the situation I faced on the 3.3 compiler. Actually sometimes
it drastically reduces performance (for example in the operator/ case).
Will be exploring all that further. Who knows, maybe 4.0.0 is not
enough... We'll try 4.0.1, then!
-Ilya
_____________________________________________________________________
Ilya Lipovsky
Engineer, Algorithms Group
SKY Computers(R), Inc., 8 Centennial Drive M/S A-14, Peabody MA 01960
More information about the macstl-dev
mailing list