[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <alpine.DEB.1.10.0901281255440.21401@alien.or.mcafeemobile.com>
Date: Wed, 28 Jan 2009 13:10:43 -0800 (PST)
From: Davide Libenzi <davidel@...ilserver.org>
To: Chris Snook <csnook@...hat.com>
cc: Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: if (unlikely(...)) == unnecessary?
On Wed, 28 Jan 2009, Chris Snook wrote:
> When you turn on optimizations, gcc will try to avoid branching just to
> execute a few instructions, since the cache miss and page fault penalties
> greatly exceed the cost of a branch mispredict. The thresholds and heuristics
> vary, but in general, if you stick something like this:
>
> if (condition) foo++;
> else if (complex condition) {do lots of stuff}
>
> In the middle of a long function body and compile with optimizations enabled,
> gcc will try to put the foo++ right after the evaluation. Some ISAs support
> conditional instructions to let the compiler help fill pipeline bubbles, and
> some superscalar processors will speculatively execute it in parallel with
> their evaluation of the second condition, and proceed with whichever execution
> path is chosen when they retire the instruction evaluating the first
> conditional.
OK, been finally able to trigger a different behavior. I thought that
became a somehow rule, after quite a few trials yesterday all leading to
the same results.
- Davide
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists