[llvm-commits] CVS: llvm/lib/Transforms/Scalar/LoopUnswitch.cpp

Devang Patel dpatel at apple.com
Wed Jun 27 17:44:33 PDT 2007



Changes in directory llvm/lib/Transforms/Scalar:

LoopUnswitch.cpp updated: 1.70 -> 1.71
---
Log message:

If a condition is not inside a loop then the condition is suitable
to loop unswitch candidate for the loop.


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

 LoopUnswitch.cpp |    7 +++++++
 1 files changed, 7 insertions(+)


Index: llvm/lib/Transforms/Scalar/LoopUnswitch.cpp
diff -u llvm/lib/Transforms/Scalar/LoopUnswitch.cpp:1.70 llvm/lib/Transforms/Scalar/LoopUnswitch.cpp:1.71
--- llvm/lib/Transforms/Scalar/LoopUnswitch.cpp:1.70	Tue Jun  5 19:21:03 2007
+++ llvm/lib/Transforms/Scalar/LoopUnswitch.cpp	Wed Jun 27 19:44:10 2007
@@ -128,6 +128,13 @@
 static Value *FindLIVLoopCondition(Value *Cond, Loop *L, bool &Changed) {
   // 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.






More information about the llvm-commits mailing list