This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: disabling branch probability guessing (patch)
- To: Andi Kleen <ak at suse dot de>
- Subject: Re: disabling branch probability guessing (patch)
- From: Aldy Hernandez <aldyh at redhat dot com>
- Date: Tue, 16 Jan 2001 10:05:02 -0400
- Cc: gcc at gcc dot gnu dot org
- References: <20010115181006.A8129@redhat.com> <ouphf2ziu9a.fsf@pigdrop.muc.suse.de>
> > One of our clients is trying to use __builtin_expect and is getting
> > unexpected results because estimate_probability() in predict.c is
> > guessing the branch probability in an undetermined way. This patch
> > solves the problem by providing an option to disable the probability
> > guessing altogether.
>
> Cool. This is useful for the linux kernel too. I found out that the
> prediction guessing undoes some of the carefully crafted goto woods
> to keep fast paths jumpless.
>
>
> e.g.
>
> f()
> {
> int err = -EBLA;
> if (unlikely error case)
> goto error;
Why don't you use __builtin_expect() for this?
ala:
if (__builtin_expect(unlikely error case, 0))
goto error;
blah blah
This will place the code in "blah blah" in the fall through path which
is the expected path. Of course, I have a test case for the i960 in which
this isn't working as advertised, but at least it seems to working fine
for the x86. :-)
Cheers.
Aldy