On Fri, Apr 27, 2001 at 06:08:34PM -0700, Kris Kennaway wrote:
> On Fri, Apr 27, 2001 at 08:38:30PM -0400, User Witr wrote:
> > 
> > [EMAIL PROTECTED] said:
> > :-As far as I know FreeBSD doesn't support nor recommened compiling
> > :-things (especially large mission critical programs) with anything
> > :-higher than -O. 
> > 
> > Out of curiosity, how much potential performance is FreeBSD throwing
> > away by banning -O2 and -O3?  To my naive eyes it would seem better
> > to light that candle (try fix the -O2 bug) than curse the darkness.
> > Assuming there is significant performance gain and there truly is only
> > one major -O2 bug.  -O2 used to be considered "safe" didn't it?
> 
> It's not that significant in many cases, it's mostly just useful to
> make you feel studly about how massively optimized your system must
> be.
> 
> Kris

Also, compiling with -O3 can sometimes actually make your code *slower*.
This is probably due to the fact that -O3 causes inlining to take place
which can easily make the code larger which in turn make the code not fit
in the CPU-cache any longer.

Generally I would say that one shouldn't use -O3 unless some measurements
have been made and -O3 can be shown to actually have a positive effect on
the code in question.

Compiling with -O2 is usually not worth the bother unless your program is
fairly CPU-intensive. Many programs (like text-editors or the kernel)
spend most of their time waiting for I/O. In these cases the improvements
that -O2 might create are barely measurable.

The best way is usually to try to compile a program with different
optimization levels and try to measure what difference it makes.
For some programs -O2 can cause much better performance than -O. For
others the difference is very small and for some -O2 might even generate
worse code than -O.

The difference between -O and no optimization is usually significant
though if only because the code generated by gcc without any optimization
being done is fairly inefficient.


-- 
<Insert your favourite quote here.>
Erik Trulsson
[EMAIL PROTECTED]


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-stable" in the body of the message

Reply via email to