3 ms·
What requires the complex speculation is not the pipeline depth, it's the memory access latency. Consider the following simple C code: "if (arr[idx]) { ... }".
by cesarb 9y ago
What requires the complex speculation is not the pipeline depth, it's the memory access latency.
Consider the following simple C code: "if (arr[idx]) { ... }". Without speculation, the core must stall until the condition has been read from memory, which can be hundreds of cycles if it's not in the cache. With speculation, these wasted cycles are instead used to do some of the work from most probable side of the branch, so when the condition finally arrives from memory, there's less work left to do.
The pipeline depth only affects what happens when the speculation predicted the wrong way: since the correct way is not on the pipeline, it has to fill the pipeline from scratch.