Branch prediction defaults and hints

By: Travis Downs (travis.downs.delete@this.gmail.com), July 25, 2020 7:41 pm
Room: Moderated Discussions
On Intel, there used to be this thing where branches had "default" directions for prediction: default was "taken" for backwards branches, and "not taken" for forwards. The idea was that lacking any specific prediction info (cold branch), the default would be used.

However, if I understand correctly, you'd only have this information once you've decoded the branch instruction, but branch prediction must be happening much earlier to be effective. The decoder can't ask the predictor "hey, I just decoded a branch, where does it go?" as the primary steering mechanism: because by that point you have already fetched way beyond the branch (especially on Intel where fetch & decode are separated by a half dozen cycles or so).

As I understand it, the predictor needs to operate basically autonomously of decode, directing fetch. Now, sometimes errors might be noticed later at decode (e.g., an unconditional jump was decoded that wasn't predicted): resulting in a so-called "resteer" which is a several cycle front-end bubble but not nearly as bad as a full mispredict since the wrong path never escapes the decoders into the OOOE part of the core.

So if my understanding is correct, how could the default direction ever have been implemented for cold branches? The predictor doesn't decode the bytes being fetched, so it can't use the default direction.

The same question applies to P4-style branch "hints", which also require decode to interpret.

At the earliest, I could see the default direction/hints being used for an at-decode resteer, but you'd better be pretty sure if you want to override the default of "fall through" for backwards branches.

I guess another use could be populating the prediction quickly for cold branches without waiting for execution: it doesn't help for the first time the branch is encountered, but for the few times after that before any history has time to accumulate?
 Next Post in Thread >
TopicPosted ByDate
Branch prediction defaults and hintsTravis Downs2020/07/25 07:41 PM
  Branch prediction defaults and hintsanon.12020/07/25 08:44 PM
  Branch prediction defaults and hintsanon2020/07/25 09:05 PM
  Branch prediction defaults and hintsPaul A. Clayton2020/07/26 11:52 AM
Reply to this Topic
Name:
Email:
Topic:
Body: No Text
How do you spell avocado?