gcc: speed problem with several g++ versions

Falk Hueffner hueffner@informatik.uni-tuebingen.de
Wed Aug 4 09:12:00 GMT 2004


Andreas Kowarz <kowarz@math.tu-dresden.de> writes:

> we made some interesting experience while implementing and testing a
> software package, which makes use of overloaded operators. One aspect
> of the implementation is the speed of the resulting binaries. To find
> the best solution we have tested the following approaches: normal
> overloading and templates. The example (attachment) contains the
> source code for 3 programms:
>
> prog     - execution without overloading
> progtemp - template based
> progover - normal overloading
>
> Compiled with g++ version 3.2 we got the following runtime:
> prog       about 2.9 seconds
> progtemp   about 2.9 seconds
> progover   about 3.5 seconds
> It seems clear that the template based implementation should be the one to use.
>
> After recompiling with g++ version 3.4.1 we got a complete different result:
> prog       about 2.9 seconds
> progtemp   about 15.4 seconds !!!
> progover   about 3.5 seconds
> This time the template version is not really good. :-(
> (Same problem with g++ version 3.3.2 on a different machine)
>
> My questions are:
> - Is this a known problem?
> - Is there a compiler switch which can solve the problem?

This seems to be something target specific; on Alpha, I get the exact
same time for all three programs with both 3.3 and 3.4. I guess one
would have to look at the assembly to see what causes it... might be
register allocation or inlining. You could try changing inline
settings and -fomit-frame-pointer and -fnew-ra.

-- 
	Falk



More information about the Gcc-help mailing list