| |||
| Home > Prefetch Unit > Return stack | |||
The call-return stack predicts procedural returns that are program flow changes such as loads, and branch register. The dynamic branch predictor determines if conditional procedure returns are predicted as taken or not-taken, as described in Branch prediction. The return stack predicts the target address for unconditional procedure returns, and conditional procedure returns that have been predicted as taken by the branch predictor.
The return stack consists of a 4-entry circular buffer. When the PFU detects a taken procedure call instruction, the PFU pushes the return address onto the return stack. The instructions that the PFU recognizes as procedure calls are, in both the ARM and Thumb instruction sets:
BL immediate
BLX immediate
BLX Rm.
When the return stack detects a taken return instruction, the PFU issues an instruction fetch from the location at the top of the return stack, and pops the return stack. The instructions that the PFU recognizes as procedure returns are, in both the ARM and Thumb instruction sets:
LDM Rn{!},
{..,pc}
POP {..,pc}
LDMIB Rn{!}, {..,pc}
LDMDA Rn{!}, {..,pc}
LDMDB Rn{!}, {..,pc}
LDR pc, [sp], #4
BX Rm.
Return stack mispredictions can exist when:
The prediction that a conditional return passed or failed its condition code is not correct.
The return address of an unconditional or predicted-taken return is not correct.
The return stack has no underflow or overflow detection. Either scenario is likely to cause a misprediction.
The MOV PC, LR instruction is not decoded
and is not predicted as a return.