coreblocks icon indicating copy to clipboard operation
coreblocks copied to clipboard

Add support for branch speculation

Open lekcyjna123 opened this issue 1 year ago • 3 comments

To use whole potential of out-of-order execution we need a speculation over jumps. As for now we stall whole pipeline till branch is retired. Instead of that we should:

  • have a branch predictor
  • check in fetch if fetched instruction is jump - if yes:
    • use branch predictor to get next_pc
    • make a checkpoint of current CPU state
  • on mispredicted branch CPU state from before speculation should be restored and execution should be started from that point

Comments:

  • first branch predictor can be very easy e.g. always current_pc+4
  • if this will make a task easier we can assume speculation depth = 1

lekcyjna123 avatar Jul 03 '23 07:07 lekcyjna123