Get the latest tech news

Understand CPU Branch Instructions Better


Branch instructions are the primary means by which a program running on a CPU makes a decision. This post is part of a series of posts on CPU performance, as part of the Pointer Wars: Linked List E…

Do note that the sequential execution model refers to the semantics that the CPU must follow, not their actual implementations, as implementations violate this rule in ways the programmer isn’t aware of all the time.Instructions that might change the control flow of a program (control flow being the path the program takes through the code) are called branches or jumps, depending on the instruction set of the CPU. The word “some” in the previous sentence only exists because there are publicly known solutions that seek to minimize the amount of work thrown out, but they are well within the realms of graduate school literature and not discussed here (but feel free to research “Dynamic Instruction Reuse”). This is an inherent tradeoff; C++ inheritance support can be incredibly useful, but it sometimes comes at a cost if the C++ compiler cannot devirtualize your code (requiring a virtual table lookup to determine the function address to call based on what type a pointer is).

Get the Android app

Or read this on Hacker News