▲ | eigenform 2 days ago | ||||||||||||||||
Think you're referring to the idea that "my compiler can know that some branch is always/never taken" and turn it into an unconditional control-flow instruction (either "always jump here", or "always continue sequentially" and don't emit anything!). But the parent comment is talking about "hinting" for branches where the compiler cannot compute this ahead of time, and the CPU is responsible for resolving it during runtime. This is usually exposed by the ISA, ie. a bit in the branch instruction encoding that tells the machine "when you encounter this instruction for the first time, the default prediction should be 'taken'." In practice, branches are usually predicted "not-taken" by default: - It's advantageous to assume that control-flow is sequential because [pre-]fetching sequentially is the easy case - It's wasteful to track the target addresses of branches in your predictor if they aren't taken at least once! | |||||||||||||||||
▲ | zzo38computer 10 hours ago | parent | next [-] | ||||||||||||||||
One of the situations I was describing is if there is a branch which, whether or not it is taken is the same each time it is reached during one execution of the program, but whether or not it will be taken will be decided during the initialization of the program, before the first time that branch is reached. | |||||||||||||||||
▲ | gpderetta 2 days ago | parent | prev [-] | ||||||||||||||||
A few ISAs have used branch prediction hints but they have gone out of fashion (those on x86 are now ignored for example). | |||||||||||||||||
|