Before unroll and jam:
for i for j for k A[i][j][k] = 0
After unroll and jam loop-i by a factor of 2:
for i +=2 for j { for k A[i][j][k] = 0 for k' A[i+1][j][k] = 0 }
Notice that there exists a new child loop loop-k' of loop-j, after unroll and jam loop-i by 2.
This patch correctly update LoopInfo with new loops created during unroll and jamming.
Side discussion:
With the example above, we can see that changing the order of how loops are traverse in a loop nest doesn't actually solve the only one subloop limitation. We need to think of other ways to have more loops able to unroll and jam. One way is try to fuse subloops before giving up. Another way could be unroll and jam the whole loop nest in one attempt, i.e. no need to create the loop-k'. Other ideas are welcome.
BasicBlockSet &Blocks,