Re: [mpm@selenic.com: Re: buggy ia64_fls() ? (was Re: /dev/random problem on 2.6.12-rc1)]

Grant Grundler
2005-04-09T00:46:03Z

On Fri, Apr 08, 2005 at 04:15:43PM -0700, Matt Mackall wrote:
> > static inline int
> > fls (int x)
> > {
> > if (!x)
> > return 0;
> > return ia64_fls((unsigned int) x) + 1;
> > }
>
> I was trying desperately to avoid the branch, as I understand there
> are issues there on IA64.

ia64 will inline this routine (no return branch) and the "if ()" case
will be predicated (which is very efficient).

parisc/et al pay a penalty for un-/mis-predicted branches.
But not as bad a cache miss by a long shot.
Adding "likely()" (or unlikely as approrpiate) can help
mitigate where the compiler doesn't pick the right thing.

grant