ArticleslgStudy

computer science

Branch target predictor

Branch target predictor is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Branch target predictor rather than just read about it. In short: In computer architecture, a branch target predictor is the part of a processor that predicts the target, i.e., the address of the instruction that is executed next, of a taken conditional branch or unconditional branch instruction before the target of the branch instruction is computed by the execution unit of the processor. Branch target prediction is not the same as branch prediction, which guesses whether a condi…

Key takeaways

  • Branch target predictor belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Branch target predictor to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Branch target predictor from memory before moving on to harder problems.

Reference excerpt

In computer architecture, a branch target predictor is the part of a processor that predicts the target, i.e., the address of the instruction that is executed next, of a taken conditional branch or unconditional branch instruction before the target of the branch instruction is computed by the execution unit of the processor. Branch target prediction is not the same as branch prediction, which guesses whether a conditional branch will be taken or not-taken in a binary manner. In more parallel processor designs, as the instruction cache latency grows longer and the fetch width grows wider, branch target extraction becomes a bottleneck. The recurrence is:

Instruction cache fetches block of instructions Instructions in block are scanned to identify branches First predicted taken branch is identified Target of that branch is computed Instruction fetch restarts at branch target In machines where this recurrence takes two cycles, the machine loses one full cycle of fetch after every predicted taken branch. As predicted branches happen every 10 instructions or so, this can force a substantial drop in fetch bandwidth. Some machines with longer instruction cache latencies would have an even larger loss. To ameliorate the loss, some machines implement branch target prediction: given the address of a branch, they predict the target of that branch. A refinement of the idea predicts the start of a sequential run of instructions given the address of the start of the previous sequential run of instructions. This predictor reduces the recurrence above to:

Hash the address of the first instruction in a run Fetch the prediction for the addresses of the targets of branches in that run of instructions Select the address corresponding to the branch predicted taken Branch target histories are either stored in a dedicated branch target buffer (BTB) unit, or share their storage with instruction cache. BTB can have widely varying sizes, but are typically 5–10% of the size of the instruction cache, the fetch happens much faster than the instruction cache fetch, and so this recurrence is much faster. If it were not fast enough, it could be parallelized, by predicting target addresses of target branches.

See also Indirect branch control (IBC) Indirect branch prediction barrier (IBPB) Indirect branch restricted speculation (IBRS) Single thread indirect branch predictor (STIBP)

Further reading Driesen; Hölzle (1992), Accurate Indirect Branch Prediction Ertl; Gregg (2001), The Behavior of Efficient Virtual Machine Interpreters on Modern Architectures

External links "Branch Target Buffers". (EE461) Fog, Agner. "The microarchitecture of Intel, AMD and VIA CPUs" (PDF). Retrieved 2017-08-09.

Worked examples

Example 1 — a first encounter with Branch target predictor

Start with the simplest possible case. Write down what Branch target predictor claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Branch target predictor before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Branch target predictor ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Branch target predictor

In research
Branch target predictor appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Branch target predictor in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Branch target predictor is common in secondary-school and first-year university syllabi. It links to neighbouring topics Computer science stubs, Instruction processing, so understanding it makes those chapters shorter.
In everyday life
Look for Branch target predictor outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Branch target predictor” →

How to study Branch target predictor in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Branch target predictor means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Branch target predictor out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Branch target predictor in simple terms?

In computer architecture, a branch target predictor is the part of a processor that predicts the target, i.e., the address of the instruction that is executed next, of a taken conditional branch or unconditional branch instruction before the target of the branch instruction is computed by the execu…

Why does Branch target predictor matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Branch target predictor?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Branch target predictor.

Tags

  • Computer science stubs
  • Instruction processing

Keep exploring