Changes in directory llvm/lib/Transforms/Scalar:

LoopUnswitch.cpp updated: 1.28 -> 1.29
---
Log message:

When unswitching a loop, make sure to update loop info with exit blocks in
the right loop.



---
Diffs of the changes:  (+4 -2)

 LoopUnswitch.cpp |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)


Index: llvm/lib/Transforms/Scalar/LoopUnswitch.cpp
diff -u llvm/lib/Transforms/Scalar/LoopUnswitch.cpp:1.28 
llvm/lib/Transforms/Scalar/LoopUnswitch.cpp:1.29
--- llvm/lib/Transforms/Scalar/LoopUnswitch.cpp:1.28    Fri Feb 17 00:39:56 2006
+++ llvm/lib/Transforms/Scalar/LoopUnswitch.cpp Fri Feb 17 18:55:32 2006
@@ -590,6 +590,7 @@
   // Split all of the edges from inside the loop to their exit blocks.  This
   // unswitching trivial: no phi nodes to update.
   unsigned NumBlocks = L->getBlocks().size();
+  
   for (unsigned i = 0, e = ExitBlocks.size(); i != e; ++i) {
     BasicBlock *ExitBlock = ExitBlocks[i];
     std::vector<BasicBlock*> Preds(pred_begin(ExitBlock), pred_end(ExitBlock));
@@ -639,8 +640,9 @@
   
   for (unsigned i = 0, e = ExitBlocks.size(); i != e; ++i) {
     BasicBlock *NewExit = cast<BasicBlock>(ValueMap[ExitBlocks[i]]);
-    if (ParentLoop)
-      ParentLoop->addBasicBlockToLoop(cast<BasicBlock>(NewExit), *LI);
+    // The new exit block should be in the same loop as the old one.
+    if (Loop *ExitBBLoop = LI->getLoopFor(ExitBlocks[i]))
+      ExitBBLoop->addBasicBlockToLoop(NewExit, *LI);
     
     assert(NewExit->getTerminator()->getNumSuccessors() == 1 &&
            "Exit block should have been split to have one successor!");



_______________________________________________
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

Reply via email to