[1] https://cranelift.readthedocs.io/en/latest/ir.html#boolean-t...
x = some_bool ? a : b;
can be compiled as a branchless: x = (some_bool & a) | (~some_bool & b);
This is why Forth also represents true as -1.C arguably picked the wrong semantics here. Hardware picks up the slack, however, with the setcc instructions on x86, csinc on AArch64, etc.
I assume someone once upon a time thought it was a nice thing for ~x to be equal to !x.
"Cranelift is designed to be a code generator for WebAssembly, but it is general enough to be useful elsewhere too. The initial planned uses that affected its design are:
WebAssembly compiler for the SpiderMonkey engine in Firefox. Backend for the IonMonkey JavaScript JIT compiler in Firefox. Debug build backend for the Rust compiler."