Standard way to supply hints to branches

claptrap clap at trap.com
Fri Sep 13 20:50:50 UTC 2024


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.



More information about the Digitalmars-d mailing list