Hello ppl,

Do any of you have a sample branch prediction algorithm? I m trying to study deep into branch prediction and I need to see what things are being used in the code.

Thanks in advance
Sunny

Recommended Answers

All 5 Replies

Branch prediction depends upon which processor family and which exact processor. Branch prediction has changed over time!

For example on older 80x86 processors, "if a branch to an earlier address, then it is predicted that the branch will be taken! As it is a loop!" On newer processors last branch will be remembered and used as a hint. There are also hint pre-processor instructions as to what the branch condition will do!

@wildgoose
Thanks for the reply

Can I ask u if u have any algorithm (any processor), that is helpful in understanding the logical flow of branch prediction.

Thanks
Sunnny

Here's a branch prediction algorithm:

1. Assume the conditional jump won't jump.

That's it.

Here's another.

1. Assume it will do what it did last time.

There's a pretty good explanation on page 293-298 in the book "32/64-Bit 80x86 Assembly Language Architecture".

Thank you both of u

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.