3 ms·
Don't forget, the CPU needs to know the current PC for relative branch instructions too. Relative branch instructions and calls are pretty common, so flushing
by phire 3y ago
Don't forget, the CPU needs to know the current PC for relative branch instructions too.
Relative branch instructions and calls are pretty common, so flushing the entite pipeline just to get the current PC would be way too expensive.
So pipelined CPUs actually implementate extra resources to track the current PC of every single instruction (at least as far as the execute stage) just so they can get the PC rapidly.
And you will find almost every single modern CPU has an instruction to copy the current PC to a register.