cpu-architecturepredictionspeculative-execution

difference between speculation and prediction


In computer architecture,

what is difference between (branch) prediction and speculation??

These seems very similar, but i think there is a subtle distinction between them.


Solution

  • Branch prediction is done by the processor to try to determine where the execution will continue after a conditional jump, so that it can read the next instruction(s) from memory.

    Speculative execution goes one step further and determines what the result would be from executing the next instruction(s). If the branch prediction was correct, the result is used, otherwise it is discarded.

    Note that speculative execution can be applied even if there isn't an actual conditional branch in the code. The processor can determine the result from several instructions that normally would execute in succession, but the execution could be stopped for example by an arithmetic overflow interrupt.