This is a straightforward extension of what LoopUnswitch does to
branches to guards. That is, we unswitch
for (;;) { ... guard(loop_invariant_cond); ... }
into
if (loop_invariant_cond) { for (;;) { ... // There is no need to emit guard(true) ... } } else { for (;;) { ... guard(false); // SimplifyCFG will clean this up by adding an // unreachable after the guard(false) ... } }
For some reason my eye is hunting for punctuation, maybe throw on a ':'