This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: disabling branch probability guessing (patch)
- To: Aldy Hernandez <aldyh at redhat dot com>
- Subject: Re: disabling branch probability guessing (patch)
- From: Andi Kleen <ak at suse dot de>
- Date: 16 Jan 2001 12:58:09 +0100
- Cc: gcc at gcc dot gnu dot org
- References: <20010115181006.A8129@redhat.com>
Aldy Hernandez <aldyh@redhat.com> writes:
> hi guys.
>
> Here is a patch that adds an option to disable guessing of branch
> probabilities (-fno-guess-branch-probability).
>
> 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;
...
err = 0;
out:
return err;
}
is turned by 2.97 when the error test isn't liked by predict.c
into
f()
{
if (error case) {
return -EBLA;
}
...
}
which involves a jump in the common path.
-Andi