This is an archive of the discontinued LLVM Phabricator instance.

[LoopInterchange] Preserve LoopInfo after interchanging.
ClosedPublic

Authored by fhahn on Apr 4 2018, 11:45 AM.

Details

Summary

LoopInterchange relies on LoopInfo being up-to-date, so we should
preserve it after interchanging. This patch updates restructureLoops to
move the BBs of the interchanged loops to the right place.

Diff Detail

Repository
rL LLVM

Event Timeline

fhahn created this revision.Apr 4 2018, 11:45 AM

Can you add verify-loop-info to all the LoopInterchange tests?

lib/Transforms/Scalar/LoopInterchange.cpp
1188 ↗(On Diff #141014)

changeLoopFor works correctly even if OuterLoopParent is null, so the "if" isn't necessary.

1221 ↗(On Diff #141014)

This looks weird; you're removing the block from the outer loop, but it's still in the inner loop?

fhahn updated this revision to Diff 141059.Apr 4 2018, 2:30 PM
fhahn marked an inline comment as done.

Thanks Eli! I added -verify-loop-info to all tests. I also renamed the parameters of restructureLoops to NewInner and NewOuter, which makes things slightly clearer, I hope.

lib/Transforms/Scalar/LoopInterchange.cpp
1221 ↗(On Diff #141014)

In this version, the variable OuterLoop refers to the original outer loop, which becomes the inner loop and InnerLoop refers to the loop that becomes the outer loop. I have renamed the variables to NewInner and NewOuter. Do you think it's clearer now?

efriedma accepted this revision.Apr 4 2018, 2:57 PM

LGTM

lib/Transforms/Scalar/LoopInterchange.cpp
1221 ↗(On Diff #141014)

Yes, that helps.

This revision is now accepted and ready to land.Apr 4 2018, 2:57 PM
This revision was automatically updated to reflect the committed changes.