Re-commit the safe parts of my 6/9 patch. Still working on fixing the unsafe parts.
[oota-llvm.git] / lib / Analysis / LoopInfo.cpp
index c7ce58ef915a9634c13110b0f7ef15d4b1de7998..eed2cd6c4ef2930865429c8d6dc8315f63229f46 100644 (file)
@@ -479,6 +479,22 @@ Value *Loop::getTripCount() const {
   return 0;
 }
 
+/// isLCSSAForm - Return true if the Loop is in LCSSA form
+bool Loop::isLCSSAForm() const {  
+  for (Loop::block_iterator BB = block_begin(), E = block_end();
+       BB != E; ++BB) {
+    for (BasicBlock::iterator I = (*BB)->begin(), E = (*BB)->end(); I != E; ++I)
+      for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); UI != E;
+           ++UI) {
+        BasicBlock *UserBB = cast<Instruction>(*UI)->getParent();
+        if (!isa<PHINode>(*UI) && !contains(UserBB)) {
+          return false;
+        }
+      }
+  }
+  
+  return true;
+}
 
 //===-------------------------------------------------------------------===//
 // APIs for updating loop information after changing the CFG