[Cbe-oss-dev] [PATCH 1/3] Fix Unlikely(x) == y

Roel Kluin 12o3l at tiscali.nl
Tue Feb 19 01:59:48 EST 2008


David Howells wrote:
> Geert Uytterhoeven <Geert.Uytterhoeven at sonycom.com> wrote:
> 
>> Hence shouldn't we ask the gcc people what's the purpose of
>> __builtin_expect(), if it doesn't live up to its promise?
> 
> __builtin_expect() is useful on FRV where you _have_ to give each branch and
> conditional branch instruction a measure of probability whether the branch
> will be taken.
> 
> David

I was wondering whether some of the uses of likely illustrated below are
incorrect or not useful.

x = likely(X) || Y

for ( ... ; likely(...); ... )

while ( likely(X) )

if ( unlikely(X) &&/|| likely(Y) )

if ( X &&/|| unlikely(Y) ) 

return likely(X);

return likely(X) ? a : b;



More information about the cbe-oss-dev mailing list