3 ms·
> That is, it’s a doubly-indirect call. I seriously doubt any processor can do proper branch prediction, speculative execution, and prefetching of code under th
by Tuna-Fish 14y ago
> That is, it’s a doubly-indirect call. I seriously doubt any processor can do proper branch prediction, speculative execution, and prefetching of code under those circumstances.
His doubts are entirely unfounded. Branch prediction of indirect calls is not done at all based on the value they are provided, but on the address of the call instruction, and the previous targets called from that instruction. A one-target trampoline will add one cycle of latency to a path, and will be predicted perfectly every time after the first. The largest cost is that no useful instructions can be decoded on the cycle that the trampoline is fetched (which does not hurt you at all if you have excess decode throughput to make it up on the cycle before or after), and that the second indirect call takes another entry in the BTB.