The "never ever use -O3" isn't an absolute rule.

What the -O3 optimization flag does are turning on the following
options: -finline-functions, -funswitch-loops, -fpredictive-commoning,
-fgcse-after-reload and -ftree-vectorize. These, when coupled with
good code, can produce remarkable differences if you compare them with
the results from -O2 given that the compiler is free to optimize the
code by inlining functions, using vectorization on tree structures
(rather than processing it serially), .It is true that with inlining,
etc, there's a possibility that you can get bigger binaries and
greater memory usage - but at the price of faster performing code.

There are other known flags that you can use like -findirect-inlining
that you can use if you compile with profile-guided optimizations.

Use these if you know your code well. Otherwise, refer to the rule of
thumb. There has been tons of improvements in the 4.x line, especially
if you're into C++. But those aren't excuses for unnecessary "ricing".

Hard disk and memory are getting cheaper nowadays... long ago 4GB of
RAM and 500GB of disk space is something you'll spend beyond 5
digits...

if you can produce static binaries for performance-sensitive stuff
that will be better.


On Tue, Sep 15, 2009 at 6:11 PM, Jimmy Lim <jimmyb...@gmail.com> wrote:
> On Mon, Sep 14, 2009 at 11:37 PM, Alec Joseph Rivera <eij...@gmail.com> wrote:
>> Currently, we use GCC with -O3 and target i686 as the LCD for our
>> compilation.
>
> Rule of thumb, never ever use -O3 optimization on gcc-4.x.x.
>
> [0] -O3: This is the highest level of optimization possible, and also
> the riskiest. It will take a longer time to compile your code with
> this option, and in fact it should not be used system-wide with gcc
> 4.x. The behavior of gcc has changed significantly since version 3.x.
> In 3.x, -O3 has been shown to lead to marginally faster execution
> times over -O2, but this is no longer the case with gcc 4.x. Compiling
> all your packages with -O3 will result in larger binaries that require
> more memory, and will significantly increase the odds of compilation
> failure or unexpected program behavior (including errors). The
> downsides outweigh the benefits; remember the principle of diminishing
> returns. Using -O3 is not recommended for gcc 4.x.
>
> [0] http://www.gentoo.org/doc/en/gcc-optimization.xml
>
> --
> Jimmy B. Lim
> j i m m y b l i m @ g m a i l . c o m
> _________________________________________________
> Philippine Linux Users' Group (PLUG) Mailing List
> http://lists.linux.org.ph/mailman/listinfo/plug
> Searchable Archives: http://archives.free.net.ph
>



-- 
Paolo
_________________________________________________
Philippine Linux Users' Group (PLUG) Mailing List
http://lists.linux.org.ph/mailman/listinfo/plug
Searchable Archives: http://archives.free.net.ph

Reply via email to