Have I understood this right, if
statements are more dependent on branch prediction and v-table look-up is more dependent on branch target prediction? Regarding v-tables, there is no "branch prediction", just the target prediction?
Trying to understand how a v-table is processed by the CPU.
The branch predictor may, for example, recognize that the conditional jump is taken more often than not, or that it is taken every second time. Branch prediction is not the same as branch target prediction.
The Branch Target Predictor give where the program is going because of a branch. Branches (and jumps, for that matter), are Program Counter (PC) relative. The Branch Target Predictor will add the offset (given by the branch instruction), and add it to the current program counter.
Branch target prediction is not the same as branch prediction which attempts to guess whether a conditional branch will be taken or not-taken (i.e., binary). 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:
Both architectures define branch delay slots in order to utilize these fetched instructions. A more advanced form of static prediction presumes that backward branches will be taken and that forward branches will not. A backward branch is one that has a target address that is lower than its own address.
Branch prediction is predicting whether or not the branch will be taken. Branch target prediction is prediction where the branch is going to. These two things are independent and can occur in all combinations.
Examples of these might be:
goto
statementbreak
or continue
statementif/else
statement (to jump past the else
clause)switch
statement (if compiled into a jump table)if
statementswitch
statement (if compiled into a series of if/else
statements)&&
and ||
operators?:
operatorif (condition) { obj->VirtualFunctionCall(); }
into a conditional indirect jump like jne *%eax
if it appears at the end of a function due to tail call optimization.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With