Standard way to supply hints to branches

claptrap clap at trap.com
Fri Sep 13 22:25:56 UTC 2024


On Friday, 13 September 2024 at 20:59:01 UTC, Richard (Rikki) 
Andrew Cattermole wrote:
> On 14/09/2024 8:50 AM, claptrap wrote:
>> On Friday, 13 September 2024 at 18:53:11 UTC, Walter Bright 
>> wrote:
>>> On 9/13/2024 4:56 AM, Timon Gehr wrote:
>>>> Well, it is the attribute being associated with the program 
>>>> path being ill-defined that is being criticized in that blog 
>>>> post. The difference is that for path-associated, you are 
>>>> saying that a specific statement is likely or unlikely to be 
>>>> executed, for branch-associated, you are saying in which 
>>>> direction a specific branch is likely to go.
>>>
>>> Ok, thanks for the explanation. The branch predictor on CPUs 
>>> defaults to a forward branch being considered unlikely, and a 
>>> backwards branch being considered likely.
>> 
>> That was pretty much only the Pentiums, older AMDs just 
>> assumed branch not taken if wasn't in the BTB already. Newer 
>> CPUs, Core2 onwards, Zen, nobody seems to know for sure what 
>> they do, but the Intel SDMs do state that the Core 
>> architecture doesn't use static prediction. I think Agner Fog 
>> says it's essentially random.
>
> https://www.agner.org/optimize/microarchitecture.pdf
>
> Not quite random, but certainly has changed to a significantly 
> more complicated design since the 90's.

Read 3.7

"Static prediction in PM and Core2
These processors do not use static prediction. The predictor 
simply makes a random prediction the first time a branch is seen, 
depending on what happens to be in the BTB entry that is assigned 
to the new branch. There is simply a 50% chance of making the 
right prediction of jump or no jump, but the predicted target is 
correct."

I mean I assume we're talking about static prediction here, 
because there's no point trying to out think the branch predictor 
once it's got history for the branch.


More information about the Digitalmars-d mailing list