Re: Branch prediction
- From: "robertwessel2@xxxxxxxxx" <spamtrap@xxxxxxxxxx>
- Date: Wed, 27 Feb 2008 22:13:10 -0800 (PST)
On Feb 27, 11:14 pm, Tim Roberts <spamt...@xxxxxxxxxx> wrote:
Although, unless my memory has gone completely faulty, the more recent
processors actually use register renaming to execute BOTH paths of the
conditional, and simply discard half of the results when the result of the
jump is finally known.
I'm not aware of any mainstream processors that actually speculatively
execute both legs of a branch in a general way. A major problem is
the combinatorial explosion - after all there's a conditional branch
every 5-10 instructions in most cases, and once you get past three or
four of those 90% of the instructions you're issuing are going to be
discarded. And since execution resources are limited, executing
useless instructions will negatively impact performance. This also
impacts power consumption rater severely, which is a big issue these
days.
Several research processors do manage something like that, and in some
cases some CPUs can rewrite short blocks in a predicated fashion (for
example, a forward conditional branch that skips a small number of non-
branching instructions), but it's not really common.
OTOH, processors with predicated ISAs, like IPF, do allow both legs of
an condition to execute, and to avoid committing either leg until the
predicate is known. IPF compilers manage a steep reduction in the
number of conditional branches because they can convert most small if
blocks to predicated sequences. A major hazard is overdoing that,
since you again end up with the processor doing a large amount of
useless work.
In any event, executing both legs would be of value only if you didn't
have a pretty good prediction on the direction of the branch, and in
practice, branch predictors are quite good. The tradeoff is
approximately the misspredict rate times the time wasted on the wrong
path plus misspredict (backup) penalty, vs. the time wasted always
executing instruction from the wrong path. Unless the misspredict
rate is high, or enough extra resources are available to execute the
wrong leg with little penalty (or equivalently, the wrong path is very
short), trying to run down both legs isn't going to help - which
unfortunately is the case much (although certainly not all) of the
time.
.
- References:
- Branch prediction
- From: Muscipula
- Re: Branch prediction
- From: robertwessel2@xxxxxxxxx
- Re: Branch prediction
- From: Tim Roberts
- Branch prediction
- Prev by Date: Re: Branch prediction
- Next by Date: Re: Seg fault with hla 1.99 on Fedora 8 linux
- Previous by thread: Re: Branch prediction
- Next by thread: Jumping into middle of instruction
- Index(es):
Relevant Pages
|