[PATCH] Change bb-reorder.c to use succ block frequency

Pat Haugen pthaugen@us.ibm.com
Tue Jun 14 14:29:00 GMT 2005





Richard Henderson <rth@redhat.com> wrote on 06/13/2005 07:46:25 PM:

> On Mon, Jun 13, 2005 at 04:06:29PM -0400, David Edelsohn wrote:
> > >>>>> Richard Henderson writes:
> >
> > Richard> Why?  It seems to me that edge frequency is what's going to
matter
> > Richard> to the cpu when considering the branch.  Particularly forcpus
that
> > Richard> don't have horrendously sophisticated branch predictors.
> >
> >    From Pat's original message:
> >
> > "Since edge frequency is based off the source block's frequency (src
blk
> > freq * edge prob), this means the code in better_edge_p() which
compares
> > frequencies if edge probabilities are equivalent is useless (if
> > probabilities are equivalent then the edge frequencies will also be
> > equivalent since they're based off the same block frequency)."
> >
> > http://gcc.gnu.org/ml/gcc/2005-04/msg00638.html
>
> I don't see that that answers the question.  The patch *completely
replaces*
> the use of edge frequencies with block frequencies.  It doesn't just use
> block frequencies to break ties in edge frequencies.  I see no
justification
> for this change except "the algorithm described in the comments".  Why
are
> we not instead changing the comments to match the code?
>
> I've given you a plausible reason for why we might *want* to use edge
> frequencies.  Please refute that in some way.
>
> When the edge frequencies are identical for conditional branches, I don't
> figure it matters one way or the other which successor we choose.  I also
> expect this isn't the normal case or profiling would be useless.

better_edge_p() first compares edge probabilities to see which is the
better edge, if probabilities are equivalent then it proceeds to the
frequency test. It makes no sense to compare edge frequencies as a
tie-breaker when probabilities are equivalent because edge frequencies are
also going to be equivalent. The algorithm is trying to find the succ block
with the greatest affinity to the current block. The succ block with the
smallest frequency would be that block since the block with the larger
frequency is obtaining that larger frequency from a different predecessor
and therfore possibly has a better affinity to that predecessor.

-Pat



More information about the Gcc-patches mailing list