Standard way to supply hints to branches

Manu turkeyman at gmail.com
Fri Aug 23 01:47:37 UTC 2024


I'm working on microcontrollers, and many don't have a branch predictor.
They do "static" prediction, that is, they just predict branch-not-taken
and it's on you to write your code as such, and that's not always possible.
(like the loop condition in a for loop)

This leads to a lot of awkward looking if's written in unnatural
'backwards' terms, and also, leads to undesirable depth of nested scopes.

The compiler backend can and should re-jig the comparisons, but it needs to
receive a hint which way is 'likely' from the programmer.

How can we add an attribute to the branch condition that the backend can
take advantage of? I think it needs to be in the language spec...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20240823/a966758c/attachment.htm>


More information about the Digitalmars-d mailing list