Home | Notifications | New Note | Local | Federated | Search | Logout

Note Detail


David Chisnall (*Now with 50% more sarcasm!*)@david_chisnall@infosec.exchange (2026-07-29 21:00:58)
When Arm introduced AArch64, they removed most predication.  Conditional moves are very useful (and they added a fairly rich selection of these) and can significantly reduce the amount of branch predictor state that you need, but most other predicated instructions aren't that useful on modern pipelines.  The cost of an ALU operation is so low that doing an ALU operation followed by a conditional move is still a big win over a branch in a lot of cases.

The one exception that caused a lot of discussion was memory operations. Predicated loads are really useful because you can replace a load of null-guarded things with them: do the null check and conditionally load if the check failed, and avoid the branch.

I've been pondering a few alternatives for a while and one I keep coming back to is a non-trapping load. A load that will give 0 and set a bit in the condition codes register if it would trap. This requires burning a PTE bit in not-present PTEs, because you need to differentiate between not-present-physically-but-present-logically pages (e.g. lazily allocated or swapped out pages), which should trap, and really-not-present pages (which should not trap in this mechanism).

I'm not 100% sure it would be a win, because a lot of TLBs don't bother caching not-present mappings, so you might trigger a page-table walk, but if a non-trapping load were followed by a conditional move, it could retire immediately once the condition was known and skip the load.

I still think there's probably a better approach somewhere.
Reply

---Replies---
Sun Microdevil Pte Ltd@koakuma@uwu.social (2026-08-17 01:43:56)
@david_chisnall In SPARC, at least, there's the #ASI_PNF loads that would eat the trap and return zeros instead (though it doesn't set any status codes in the CCR)

I've yet to see any compilers emitting it, I suppose partly cus you can't really tell between a failed load and a successful one that just happens to return zero :char_nachoneko_baa: