Changes in directory llvm/lib/Transforms/Scalar:

LoopUnswitch.cpp updated: 1.72 -> 1.73
---
Log message:

- Undo previous check and allow loop switch for condtion that is not inside
loop.
- Avoid loop unswich for loop header branch.
- While cloning dominators fix typo and handle self dominating blocks.


---
Diffs of the changes:  (+7 -8)

 LoopUnswitch.cpp |   15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)


Index: llvm/lib/Transforms/Scalar/LoopUnswitch.cpp
diff -u llvm/lib/Transforms/Scalar/LoopUnswitch.cpp:1.72 
llvm/lib/Transforms/Scalar/LoopUnswitch.cpp:1.73
--- llvm/lib/Transforms/Scalar/LoopUnswitch.cpp:1.72    Wed Jun 27 19:49:00 2007
+++ llvm/lib/Transforms/Scalar/LoopUnswitch.cpp Wed Jun 27 21:05:46 2007
@@ -136,13 +136,6 @@
   // Constants should be folded, not unswitched on!
   if (isa<Constant>(Cond)) return false;
 
-  // If cond is not in loop then it is not suitable.
-  if (Instruction *I = dyn_cast<Instruction>(Cond))
-    if (!L->contains(I->getParent()))
-      return 0;
-  if (isa<Argument>(Cond))
-    return 0;
-
   // TODO: Handle: br (VARIANT|INVARIANT).
   // TODO: Hoist simple expressions out of loops.
   if (L->isLoopInvariant(Cond)) return Cond;
@@ -173,6 +166,8 @@
   // loop.
   for (Loop::block_iterator I = L->block_begin(), E = L->block_end();
        I != E; ++I) {
+    if (*I == L->getHeader())
+      continue;
     TerminatorInst *TI = (*I)->getTerminator();
     if (BranchInst *BI = dyn_cast<BranchInst>(TI)) {
       // If this isn't branching on an invariant condition, we can't unswitch
@@ -491,7 +486,11 @@
       CloneDomInfo(NewIDom, OrigIDom, L, DT, VM);
     NewIDom = cast<BasicBlock>(VM[OrigIDom]);
   }
-  DT->addNewBlock(NewBB, OrigIDom);
+  if (NewBB == NewIDom) {
+    DT->addNewBlock(NewBB, OrigIDom);
+    DT->changeImmediateDominator(NewBB, NewIDom);
+  } else
+    DT->addNewBlock(NewBB, NewIDom);
 }
 
 /// CloneLoop - Recursively clone the specified loop and all of its children,



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

Reply via email to