OSDN Git Service

[LoopInterchange] Do not change LI for BBs in child loops.
authorFlorian Hahn <florian.hahn@arm.com>
Mon, 23 Apr 2018 21:38:19 +0000 (21:38 +0000)
committerFlorian Hahn <florian.hahn@arm.com>
Mon, 23 Apr 2018 21:38:19 +0000 (21:38 +0000)
If a loop with child loops becomes our new inner loop after
interchanging, we only need to update LoopInfo for the blocks defined in
the old outer loop. BBs in child loops will stay there.

Reviewers: efriedma, karthikthecool, mcrosier

Reviewed By: efriedma

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@330653 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/LoopInterchange.cpp

index cab6acc..a641afe 100644 (file)
@@ -1220,6 +1220,9 @@ void LoopInterchangeTransform::restructureLoops(
   BasicBlock *OuterHeader = NewOuter->getHeader();
   BasicBlock *OuterLatch = NewOuter->getLoopLatch();
   for (BasicBlock *BB : OrigInnerBBs) {
+    // Nothing will change for BBs in child loops.
+    if (LI->getLoopFor(BB) != NewOuter)
+      continue;
     // Remove the new outer loop header and latch from the new inner loop.
     if (BB == OuterHeader || BB == OuterLatch)
       NewInner->removeBlockFromLoop(BB);