Change the way in which error case is being handled.
authorDaniel Jasper <djasper@google.com>
Fri, 6 Mar 2015 10:39:14 +0000 (10:39 +0000)
committerDaniel Jasper <djasper@google.com>
Fri, 6 Mar 2015 10:39:14 +0000 (10:39 +0000)
Specifically this:
* Prevents an "unused" warning in non-assert builds.
* In that error case return with out removing a child loop instead of
  looping forever.

llvm-svn: 231459

llvm/lib/Transforms/Scalar/LoopInterchange.cpp

index 6ded56e..f8c865b 100644 (file)
@@ -901,14 +901,16 @@ bool LoopInterchangeProfitability::isProfitable(unsigned InnerLoopId,
 
 void LoopInterchangeTransform::removeChildLoop(Loop *OuterLoop,
                                                Loop *InnerLoop) {
-  for (Loop::iterator I = OuterLoop->begin(), E = OuterLoop->end();; ++I) {
-    assert(I != E && "Couldn't find loop");
+  for (Loop::iterator I = OuterLoop->begin(), E = OuterLoop->end(); I != E;
+       ++I) {
     if (*I == InnerLoop) {
       OuterLoop->removeChildLoop(I);
       return;
     }
   }
+  assert(false && "Couldn't find loop");
 }
+
 void LoopInterchangeTransform::restructureLoops(Loop *InnerLoop,
                                                 Loop *OuterLoop) {
   Loop *OuterLoopParent = OuterLoop->getParentLoop();