[llvm-branch-commits] [llvm-branch] r295380 - Merging r293124:

Hans Wennborg via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Feb 16 13:50:01 PST 2017


Author: hans
Date: Thu Feb 16 15:50:00 2017
New Revision: 295380

URL: http://llvm.org/viewvc/llvm-project?rev=295380&view=rev
Log:
Merging r293124:
------------------------------------------------------------------------
r293124 | mkuper | 2017-01-25 17:04:11 -0800 (Wed, 25 Jan 2017) | 9 lines

[LoopUnroll] Properly update loopinfo for runtime unrolling by 2

Even when we don't create a remainder loop (that is, when we unroll by 2), we
may duplicate nested loops into the remainder. This is complicated by the fact
the remainder may itself be either inserted into an outer loop, or at the top
level. In the latter case, we may need to create new top-level loops.

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

------------------------------------------------------------------------

Added:
    llvm/branches/release_40/test/Transforms/LoopUnroll/runtime-li.ll
      - copied unchanged from r293124, llvm/trunk/test/Transforms/LoopUnroll/runtime-li.ll
Modified:
    llvm/branches/release_40/   (props changed)
    llvm/branches/release_40/lib/Transforms/Utils/LoopUnroll.cpp
    llvm/branches/release_40/lib/Transforms/Utils/LoopUnrollRuntime.cpp

Propchange: llvm/branches/release_40/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Feb 16 15:50:00 2017
@@ -1,3 +1,3 @@
 /llvm/branches/Apple/Pertwee:110850,110961
 /llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,291858-291859,291863,291875,291909,291918,291966,291968,291979,292117,292133,292167,292169-292170,292242,292254-292255,292280,292323,292444,292467,292516,292583,292624-292625,292641,292651,292667,292711-292713,292758,292949,293017,293021,293025,293230,293259,293291,293293,293309,293345,293417,293522,293542,293629,293635,293658,293673,293727,293730,294003,294102,294129,294203,294267,294318,294348-294349,294357,294527,294551,294982,295018,295213,295215,295230
+/llvm/trunk:155241,291858-291859,291863,291875,291909,291918,291966,291968,291979,292117,292133,292167,292169-292170,292242,292254-292255,292280,292323,292444,292467,292516,292583,292624-292625,292641,292651,292667,292711-292713,292758,292949,293017,293021,293025,293124,293230,293259,293291,293293,293309,293345,293417,293522,293542,293629,293635,293658,293673,293727,293730,294003,294102,294129,294203,294267,294318,294348-294349,294357,294527,294551,294982,295018,295213,295215,295230

Modified: llvm/branches/release_40/lib/Transforms/Utils/LoopUnroll.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_40/lib/Transforms/Utils/LoopUnroll.cpp?rev=295380&r1=295379&r2=295380&view=diff
==============================================================================
--- llvm/branches/release_40/lib/Transforms/Utils/LoopUnroll.cpp (original)
+++ llvm/branches/release_40/lib/Transforms/Utils/LoopUnroll.cpp Thu Feb 16 15:50:00 2017
@@ -189,11 +189,14 @@ const Loop* llvm::addClonedBlockToLoopIn
     assert(OriginalBB == OldLoop->getHeader() &&
            "Header should be first in RPO");
 
+    NewLoop = new Loop();
     Loop *NewLoopParent = NewLoops.lookup(OldLoop->getParentLoop());
-    assert(NewLoopParent &&
-           "Expected parent loop before sub-loop in RPO");
-    NewLoop = new Loop;
-    NewLoopParent->addChildLoop(NewLoop);
+
+    if (NewLoopParent)
+      NewLoopParent->addChildLoop(NewLoop);
+    else
+      LI->addTopLevelLoop(NewLoop);
+
     NewLoop->addBasicBlockToLoop(ClonedBB, *LI);
     return OldLoop;
   } else {

Modified: llvm/branches/release_40/lib/Transforms/Utils/LoopUnrollRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_40/lib/Transforms/Utils/LoopUnrollRuntime.cpp?rev=295380&r1=295379&r2=295380&view=diff
==============================================================================
--- llvm/branches/release_40/lib/Transforms/Utils/LoopUnrollRuntime.cpp (original)
+++ llvm/branches/release_40/lib/Transforms/Utils/LoopUnrollRuntime.cpp Thu Feb 16 15:50:00 2017
@@ -302,17 +302,22 @@ static void CloneLoopBlocks(Loop *L, Val
   }
 
   NewLoopsMap NewLoops;
-  NewLoops[L] = NewLoop;
+  if (NewLoop)
+    NewLoops[L] = NewLoop;
+  else if (ParentLoop)
+    NewLoops[L] = ParentLoop;
+
   // For each block in the original loop, create a new copy,
   // and update the value map with the newly created values.
   for (LoopBlocksDFS::RPOIterator BB = BlockBegin; BB != BlockEnd; ++BB) {
     BasicBlock *NewBB = CloneBasicBlock(*BB, VMap, "." + suffix, F);
     NewBlocks.push_back(NewBB);
-
-    if (NewLoop) {
+   
+    // If we're unrolling the outermost loop, there's no remainder loop,
+    // and this block isn't in a nested loop, then the new block is not
+    // in any loop. Otherwise, add it to loopinfo.
+    if (CreateRemainderLoop || LI->getLoopFor(*BB) != L || ParentLoop)
       addClonedBlockToLoopInfo(*BB, NewBB, LI, NewLoops);
-    } else if (ParentLoop)
-      ParentLoop->addBasicBlockToLoop(NewBB, *LI);
 
     VMap[*BB] = NewBB;
     if (Header == *BB) {




More information about the llvm-branch-commits mailing list