Home | Notifications | New Note | Local | Federated | Search | Logout
Note Detail
nytpu the wyvern@nytpu@tilde.zone (2026-10-01 07:33:53)
Anyone have suggestions on an assembly syntax for manual branch prediction hints? (As in, marking a branch as being likely or unlikely to be taken)
Even though the Pentium 4‡ actually implemented branch prediction hints, I can't find a single example of assembly syntax for it for any architecture (since manually hinted branch prediction was kinda DOA but I want to implement it anyways lol)
‡ EDIT: and PowerPC, just it's just difficult-to-impossible to research anything at all about it on modern search engines
---Reply---
Sun Microdevil Pte Ltd@koakuma@uwu.social (2026-10-15 14:16:05)
@nytpu Itanium has a quite nice two-part set of hints I think
You have the dynamicity hint (sp/dp), where sp (static prediction) makes it so that the processor will never use the dynamic prediction machinery for that branch
And the usual direction ones (tk/nt) (TaKen/Not Taken)
You can combine it like "sptk", "dpnt", etc.
Reply
---Replies---
Sun Microdevil Pte Ltd@koakuma@uwu.social (2026-10-15 14:26:10)
@nytpu I particularly like the sp* ones cus it allows you to put hints on like asserts or errors or exceptions (especially with modern languages already statically optimizing on the assumption that failures are rare anyway) and not have the checks pollute precious branch predictor entries
See also: FloatZone memory sanitizer, it implements the checks by abusing FP exceptions and they reported that not having to dynamically predict branches helps with its performance :blobcatpeekaboo:
https://www.vusec.net/projects/floatzone/