As discussed in https://reviews.llvm.org/D73129.
Before unroll and jam:
for A for B for C D E
After unroll and jam (currently):
for A A' for B for C D B' for C' D' E E'
After unroll and jam (Ideal):
for A A' for B B' for C C' D D' E E'
This is the first patch to change unroll and jam to work in the ideal way.
This patch change the safety checks needed to make sure is safe to unroll and jam in the ideal way.