Subject: Re: [PATCH 1/3] Fix Unlikely(x) == y

From: Michael Ellerman <[email-masked]>
Date: Tue, 19 Feb 2008 08:46:03 +1100

On Mon, 2008-02-18 at 16:13 +0200, Adrian Bunk wrote:
> On Mon, Feb 18, 2008 at 03:01:35PM +0100, Geert Uytterhoeven wrote:
> > On Mon, 18 Feb 2008, Adrian Bunk wrote:
> > > 
> > > This means it generates faster code with a current gcc for your platform.
> > > 
> > > But a future gcc might e.g. replace the whole loop with a division
> > > (gcc SVN head (that will soon become gcc 4.3) already does 
> > > transformations like replacing loops with divisions [1]).
> > 
> > Hence shouldn't we ask the gcc people what's the purpose of __builtin_expect(),
> > if it doesn't live up to its promise?
> 
> That's a different issue.
> 
> My point here is that we do not know how the latest gcc available in the 
> year 2010 might transform this code, and how a likely/unlikely placed 
> there might influence gcc's optimizations then.

You're right, we don't know. But if giving the compiler _more_
information causes it to produce vastly inferior code then we should be
filing gcc bugs. After all the unlikely/likely is just a hint, if gcc
knows better it can always ignore it.

cheers

-- 
Michael Ellerman
OzLabs, IBM Australia Development Lab

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person