This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: disabling branch probability guessing (patch) [another patch]
I've been fighting a lonely battle for "predicting" (or favoring) the
branch which leads to iteration. Some of the current compilers do a
lousy job of
for( ; ; ){
....
if(done){
.....
break;}
.....
}
as the scheme of always assuming forward jumps not taken implies in this
common situation that the loop never repeats. Until I saw the current
crop of compilers, I thought that favoring the branch which leads to
continued iteration was a usual practice. Yes, there's are work-around,
always place a break in an else branch, but I never before saw code
written in this style:
.....
if(!done);
else {
....
break;}
.....
----- Original Message -----
From: "Richard Henderson" <rth@redhat.com>
To: "Aldy Hernandez" <aldyh@redhat.com>
Cc: "Andi Kleen" <ak@suse.de>; "Joe Buck" <jbuck@racerx.synopsys.com>;
<gcc@gcc.gnu.org>
Sent: Monday, January 22, 2001 2:17 PM
Subject: Re: disabling branch probability guessing (patch) [another
patch]
> On Sat, Jan 20, 2001 at 03:03:30AM -0400, Aldy Hernandez wrote:
> > > I agree that that would be a good heuristic. Assume goto as not
taken.
> >
> > Alright. I did some playing around to predict gotos as not taken
> > (patch below). It seems to work pretty good.
>
> I don't necessarily agree that this is a good heuristic. It assumes
> a rather rigid adherence to one programming style. One that doesn't
> apply at all to machine generated code I might add.
>
> Placed as this check is, we get no chance to make potentially better
> guesses based on the shape of the CFG or other tell-tales. I wouldn't
> mind this test as one of several being combined, but on its own I'm
> dubious.
>
>
> r~