Inspired by #70597, this issue focuses on its phi form.
For loops like:
c = a;
for(int j = 0; j < xxxxx; j += b)
if(cmp(c))
c = i; // i is invariant
c become invariant after the first iteration. And therefore cmp(c) become invariant after the first iteration.
When it becomes phi, cmp(c) is equivalent to cmp(phi(a,i)).
We could peel out such condition easier when there is no load/store, but PHINode.
A proof for SSA version(without memory operation):
https://alive2.llvm.org/ce/z/TP3WDq
In this way, the loop could be unrolled:
https://godbolt.org/z/Ybnevxn9v
Actually I have no idea which pass is responsible for such fold. So feel free to change the tags.