[MPlayer-dev-eng] [PATCH] Multiple fixes for darwin

Zoltan Hidvegi mplayer at hzoli.2y.net
Mon Oct 13 23:59:09 CEST 2003


> > >> sometimes causes problems ;-) we usually use -Os
> > > Huh? That's _size_ optimization!
> > correct, it has most of the opts that O3 has, but doesn't include the 
> > ones that make the binary larger
> So the compiler will probably discard some inline attributes...which
> will make the code much slower.

I do not think so.  I have some extensively optimized code with lots
of inlining where -Os actually performs better than -O3.  -Os will
still inline functions that are declared inline, but it will not
speculatively inline functions that were not declared inline, which is
usually better if you use the inline declarations carefully.  If you
have lots of inlining, you may have to use -finline-limit-<number>.
Also use -Winline to get warnings about functions declared inline but
not inlined, and keep increasing the inline limit until you get no
warnings.

-Os will probably avoid loop unrolling.  Loop unrolling helps normal C
code, since it allows the compiler to exploit redundancies between two
loop iterations, it can schedule instructions better etc.  But if you
have a carefully hand-written optimized loop with perhaps inline
assembly, then you do not want to unroll that.  Also loop unrolling
will increase the register pressure, so on x86 with so few registers
the register allocator will surly fail to allocate everything to
registers, it will spill, and it is usually not very smart about
spilling, so it may spill the most frequently used register.

The difference between -Os, -O2 and -O3 may vary between source files.
On platforms with few registers, -Os is often the best.  But the only
way to tell is to run tests to see what's best.  The difference can
also vary between different implementations of the same architecture,
like P3 vs. Athlon XP.



More information about the MPlayer-dev-eng mailing list