When Arm introduced AArch64, they removed most predication. Conditional moves ar...

@david_chisnall@infosec.exchange

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.