[PATCH] D45970: [LoopInterchange] Do not change LI for BBs in child loops.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 23 09:40:29 PDT 2018


fhahn created this revision.
fhahn added reviewers: efriedma, karthikthecool, mcrosier.

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.


Repository:
  rL LLVM

https://reviews.llvm.org/D45970

Files:
  lib/Transforms/Scalar/LoopInterchange.cpp


Index: lib/Transforms/Scalar/LoopInterchange.cpp
===================================================================
--- lib/Transforms/Scalar/LoopInterchange.cpp
+++ lib/Transforms/Scalar/LoopInterchange.cpp
@@ -1220,6 +1220,9 @@
   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);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45970.143579.patch
Type: text/x-patch
Size: 654 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180423/6342a804/attachment.bin>


More information about the llvm-commits mailing list