Loop predication's predicateLoopExit pass does two incorrect things:
It sinks the widenable call into the loop, thereby converting an invariant condition to a variant one
It widens the widenable call at a branch thereby converting it into a loop-varying one.
The latter is problematic when the branch may have been a loop-invariant
branch and prior optimizations (such as indvars) may have relied on this
fact, and updated the deopt state accordingly.
Now, when we widen this with a loop-varying condition, the deopt state
is no longer correct. See
https://github.com/llvm/llvm-project/issues/61963.
Is it possible to reduce the test via bugpoint? Just assert whenever you move non-loop-invariant into loop in this transform and let it do the job.