3
votes

When program execution flow reaches an unconditional jump, would the CPU pipeline be flushed? (The next prefetched instruction is the next instruction after jump, or the one at the jump target?) And would the branch target prediction buffer work here?

1
The question is insufficiently precise. Is it a direct unconditional jump, or an indirect unconditional jump? Is the jump target correctly predicted? Which microarchitecture are we talking about?EOF
direct. I don't know the meaning of microarchitecture. Probably AMD64.WindChaser
That's an architecture, a microarchitecture is something like a Bulldozer or Haswell.EOF
The only thing I can find is Intel(R) Core(TM) i7-3770S, microcode : 0x16. Do you know how to get this kind of information on Linux?WindChaser
The i7-37xx Series are Ivy Bridge microarchitecture.EOF

1 Answers

1
votes

On most architectures, unconditional branches aren't treated much different than conditional branches...

Your branch predictor will scan instructions ahead, looking for instruction addresses that it thinks are branches based on prior visits, and will predict taken/not taken/target.

So for an unconditional branch that doesn't have any prediction issues, it will be predicted as "taken" with the give target, without affecting the pipeline. If they mispredict (and the can), then you will need to flush the pipe.