B
BGB
Kaz Kylheku wrote:
)> an indirect function call involves call/return magic
)> (creating/destroying stack frames, passing any arguments, ...), and also
)> can't generally be branch-predicted
)
) You can safely predict that an indirect function call is always taken,
) since it is unconditional.
But you can't predict *where* it will jump, which is the point.
really?
load r1,<whatever>
add r2, r3
jmp [r1]
We already know where the jmp [r1] will go as soon as r1 is loaded, and can start
prefetching instructions as soon as the value of r1 is stable.
in a use, such as, say:
....
mov eax, [ebp-...]
mov ecx, [eax]
call dword [ecx+0x44]
the CPU may not know the address until the memory loads get done (in the
call instruction), so the pipeline may not get filled.
a lot though depends on how likely it is that one will endlessly jump to
the same address as before, which the CPU can optimize for somewhat.
That is called pipeline prefetch. Branch prediction is an educated guess
whether or not a conditional jump will be taken, or fall through.
never-mind any exactness of terminology or not...
I was meaning in a more general sense, where the branch target is
predicted and pipelined (generally) rather than the specific case of
predicting a branch-taken vs not-taken.