Skip to content

Offer branchless conditional (CMOV) primop

I'd like to see something similar to C's ?:, like

ifI#, boolI# :: Int# -> Int# -> Int# -> Int#

We could then write things like

ifI# (x <# y) 12# (x +# 17#)
boolI# potato cannon (y ># 2)

When the value of the test is difficult to predict, this would be better than the usual branching if or case.

Edited by David Feuer
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information