HomePhabricator

[LoopInterchange] fix tightlyNested() in LoopInterchange legality

Authored by congzhe on Mar 24 2021, 12:20 PM.

Description

[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

Details