optimization levels for 6-STABLE build{kernel,world}

Oliver Fromme olli at lurza.secnetix.de
Thu Sep 14 06:32:40 PDT 2006


Gary Kline wrote:
 > A couple of things.  Will having gcc unroll loops have any
 > negative consequences?

Yes.  It will make the code slower, in most cases.
In modern processors, the loop overhead is almost zero.
That's because the "branch prediction unit" of a processor
also predicts loop instructions (which are just a special
case of conditional branches), and chances are that the
whole loop body is in the L1 cache.  If it is too large
to fit into the L1 cache, then the loop overhead doesn't
matter anyhow.

There are very, very few special cases where unrolling a
small loop might give a little speed improvement.  Bit in
most cases, it makes things worse.

Also, don't expect miracles from -O3.  It certainly won't
make your kernel run twice as fast, and I even doubt that
there would be any measurable difference.  Therefore I'm
not concerned at all that -O3 isn't officially supported.

Best regards
   Oliver

-- 
Oliver Fromme,  secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing
Dienstleistungen mit Schwerpunkt FreeBSD: http://www.secnetix.de/bsd
Any opinions expressed in this message may be personal to the author
and may not necessarily reflect the opinions of secnetix in any way.

"C++ is to C as Lung Cancer is to Lung."
        -- Thomas Funke


More information about the freebsd-stable mailing list