6 ms·
In actual compiled code, conditional branches (without branch prediction) are translated to jumps to different targets, which are specified inline with the inst
by xitrium 13y ago
In actual compiled code, conditional branches (without branch prediction) are translated to jumps to different targets, which are specified inline with the instructions. Specifying a modifiable target would mean fetching it from a register (or worse, memory) and delaying execution until the fetch is complete (several cycles minimum on a pipelined machine). With branch prediction, instructions are predicated on a condition inline and we avoid the costly jump instructions.
Read more: http://en.wikipedia.org/wiki/Branch_predication http://en.wikipedia.org/wiki/Branch_predication
EDIT: Also: http://en.wikipedia.org/wiki/Branch_predictor http://en.wikipedia.org/wiki/Branch_predictor
I think we more commonly use the latter, which tries to guess which way the code will branch and load the appropriate jump target. It's actually typically very successful in modern processors.
- tiglionabbit 13y agoWhat if it modified the program text, instead of some external load-able value? Self-modifying code could allow explicit branch prediction.