HomePhabricator

[LoopInterchange] Fix transformation bugs in loop interchange

Authored by congzhe on Apr 7 2021, 5:44 PM.

Description

[LoopInterchange] Fix transformation bugs in loop interchange

After loop interchange, the (old) outer loop header should not jump to
LoopExit. Note that the old outer loop becomes the new inner loop
after interchange. If we branched to LoopExit then after interchange
we would jump directly from the (new) inner loop header to LoopExit
without executing the rest of (new) outer loop.

This patch modifies adjustLoopBranches() such that the old outer
loop header (which becomes the new inner loop header) jumps to the
old inner loop latch which becomes the new outer loop latch after
interchange.

Reviewed By: bmahjour

Differential Revision: https://reviews.llvm.org/D98475