We have a very broad-brush bailout in JumpThreading - we never thread over a
loop header. This is so we don't create irreducible control flow.
However, as mentioned in the existing comments there are situations where we'd
want to thread over a loop header and it can create significant improvements in
some cases.
As it's hard to know if irreducible control flow would be created, handle
specially the case where we thread from predecessor to itself - essentially
generating a single block loop. Single block loops aren't irreducible by
definition and are easy to check.
Nope. This will break key parts about LVI. The problem here is that there can be facts learned about the Phi along a particular path. The classic example is the backedge test of a loop can tell you that the value along the backedge is restricted to say < 400.