Make the code do what the comment says it does.
authorDale Johannesen <dalej@apple.com>
Tue, 2 Dec 2008 18:40:09 +0000 (18:40 +0000)
committerDale Johannesen <dalej@apple.com>
Tue, 2 Dec 2008 18:40:09 +0000 (18:40 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60431 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/LoopStrengthReduce.cpp

index 35bfae8121b3ad0a9170b01454d7c112541e3747..96ed932edac02806dece0a665faa037af101a210 100644 (file)
@@ -598,10 +598,11 @@ Value *BasedUser::InsertCodeForBaseAtPosition(const SCEVHandle &NewBase,
   
   // If InsertLoop is not L, and InsertLoop is nested inside of L, figure out
   // the preheader of the outer-most loop where NewBase is not loop invariant.
-  while (InsertLoop && NewBase->isLoopInvariant(InsertLoop)) {
-    BaseInsertPt = InsertLoop->getLoopPreheader()->getTerminator();
-    InsertLoop = InsertLoop->getParentLoop();
-  }
+  if (L->contains(IP->getParent()))
+    while (InsertLoop && NewBase->isLoopInvariant(InsertLoop)) {
+      BaseInsertPt = InsertLoop->getLoopPreheader()->getTerminator();
+      InsertLoop = InsertLoop->getParentLoop();
+    }
   
   // If there is no immediate value, skip the next part.
   if (Imm->isZero())