lkml.org 
[lkml]   [1997]   [Sep]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Subjectbranch prediction hints (was Re: patch for 2.1.55 pre-1 minix/sysv/affs)
Date
> But supporting hints about which way is the likely branch would be good.
> I'd prefer something like
>
> __builtin_unlikely_if (x) {
> }
>
> which would work fine inside #defines and inline functions etc.

Interestingly, I've discovered here at Cygnus a set of patches
(that needs lots of cleaning up) to do something very like this.
It takes the form:

x = __builtin_expect(some_int_expr, const_int_expr);
if (x) {
}

that is, __builtin_expect infects the rtl associated with the
value it got from some_int_expr, which may then be inspected
by a later conditional. The value of X is predicted to be
the same as const_int_expr.

It does need some amount of backend support to be effective,
and is currently only implemented for i960 and rs6000.

> Also, a "__builtin_unlikely_if()" can be used to move the unlikely code
> away from the likely case, so that it doesn't pollute the icache at all
> (into another ELF segment etc).

That is, of course, the ultimate goal, though this code only deals
with setting branch prediction bits. Due to other, extremely nasty
code generation habits of e.g. exception handling, I may look into
general motion of basic blocks, but probably not soon.


r~

\
 
 \ /
  Last update: 2005-03-22 13:40    [W:1.049 / U:0.824 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site