This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Any way to do branch hints?
On Tue, May 25, 2004 at 10:12:40AM -0700, Joe Buck wrote:
> On Tue, May 25, 2004 at 06:56:15PM +0200, Andi Kleen wrote:
> > Intel P4 has a new branch hint prefix for conditional jumps, but afaik
> > gcc doesn't generate it right now even with -march=pentium4 and
> > __builtin_expect. I think that is what Kean asked about.
> >
> > Of course you get some part of this from the block reordering
> > and the "if it jumps backwards it must be taken" heuristics,
> > but telling the CPU explicitely may be a stronger hint.
>
> Ah, but the conditional branch hint field just changes the default
> branch hint, right? (This is typically to assume that forward branches
I don't know how Intel implemented it internally.
I assume it is a relatively complex system, with many input variables
(branch prediction, direction, prefix, other black magic). But my assumption i
would be that having the explicit prefix would give a stronger hint
than just using implicit direction.
Another advantage is that block reordering often causes code size
increases (because it tends to add more jumps). Maybe it could
help generating smaller code when the prefix is used.
-Andi