|
|
|
|
|
by tlb
2495 days ago
|
|
There are styles of programming with no conditionals, especially in purely functional languages. A common technique inside compilers is to separate out which code gets run, and which result gets used. If everything is side-effect-free, then there's no harm in running the code whose result won't get used. In highly parallel systems, you can just run both versions and select at the end. So you can rewrite: if foo < 2:
a = foo
else
a = 2
to: a = phi(foo<2, 2, foo)
(the phi operator is taken from SSA notation. See https://llvm.org/docs/LangRef.html#phi-instruction if you're unfamiliar) |
|