[LoopInterchange] fix tightlyNested() in LoopInterchange legality
authorCongzhe Cao <congzhe.cao@huawei.com>
Wed, 24 Mar 2021 19:20:23 +0000 (15:20 -0400)
committerCongzheUalberta <congzhecao@gmail.com>
Wed, 24 Mar 2021 19:49:25 +0000 (15:49 -0400)
commit829c1b644390e35bd179c06f45223f778dfc5ab2
tree0dc0e77052ffbd6021bae1d399a7b08147f32379
parent26e0fb88a30ad1ab96f66969f4d6da3e71c697b1
[LoopInterchange] fix tightlyNested() in LoopInterchange legality

This is yet another attempt to fix tightlyNested().

Add checks in tightlyNested() for the inner loop exit block,
such that 1) if there is control-flow divergence in between the inner
loop exit block and the outer loop latch, or 2) if the inner loop exit
block contains unsafe instructions, tightlyNested() returns false.

The reasoning behind is that after interchange, the original inner loop
exit block, which was part of the outer loop, would be put into the new
inner loop, and will be executed different number of times before and
after interchange. Thus it should be dealt with appropriately.

Reviewed By: Whitney

Differential Revision: https://reviews.llvm.org/D98263
llvm/lib/Transforms/Scalar/LoopInterchange.cpp
llvm/test/Transforms/LoopInterchange/not-interchanged-tightly-nested.ll