Re: Branch prediction hints in an ISA

torbenm@diku.dk (Torben AEgidius Mogensen)
19 Oct 2000 14:29:40 -0400

          From comp.compilers

Related articles
[5 earlier articles]
Re: Branch prediction hints in an ISA erik@arbat.com (Erik Corry) (2000-10-12)
Re: Branch prediction hints in an ISA vbdis@aol.com (2000-10-12)
Re: Branch prediction hints in an ISA zs@ender.cs.mu.oz.au (2000-10-15)
Re: Branch prediction hints in an ISA david.thompson1@worldnet.att.net (David Thompson) (2000-10-18)
Re: Branch prediction hints in an ISA anton@mips.complang.tuwien.ac.at (2000-10-18)
Re: Branch prediction hints in an ISA dietrich@216.26.55.26 (Dietrich Epp) (2000-10-19)
Re: Branch prediction hints in an ISA torbenm@diku.dk (2000-10-19)
| List of all articles for this month |
From: torbenm@diku.dk (Torben AEgidius Mogensen)
Newsgroups: comp.compilers
Date: 19 Oct 2000 14:29:40 -0400
Organization: Department of Computer Science, U of Copenhagen
References: 00-10-078 00-10-092 00-10-106
Keywords: architecture

zs@ender.cs.mu.oz.au (Zoltan Somogyi) writes:


>Erik Corry <erik@arbat.com> writes:
>>But according to the Alpha optimisation guide, if you know
>>which way a branch is likely to go it is almost always worth
>>moving the less taken branch to somewhere completely different.
>>This reduces the working set. If you move it to the end of
>>the function then it will be a forward branch, and so will be
>>predicted not taken.


>However, there are occasions where you cannot follow this piece of
>advice. One such sitation is where a basic block ends with a
>conditional branch to its own start; putting a basic block *after*
>itself is pretty tough :-) Therefore having a mechanism that tells the
>branch predictor that a branch should be predicted to be taken is
>still useful.


A possible solution is to duplicate this basic block: The copy on the
main trace will jump (conditionally) forwards to the second copy,
which will jump (conditionally) back to the first. Assuming the branch
is rarely taken it wil be predicted correctly most of the time (in the
main trace). If there is a positive correlation between consecutive
branches (i.e, if the branch is most likely taken if it was so in the
previous case), the copy can branch back to itself to yield even
better prediction.


This will give some degree of code duplication, but the situation
occurs rarely enough that it shouldn't matter.


Torben Mogensen (torbenm@diku.dk)


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.