[LoopReroll] Relax some assumptions a little.
[oota-llvm.git] / lib / Transforms / Scalar / LoopRerollPass.cpp
index 704299f3041e916c924b97998abf6ffdfb9ef87f..fdf7e3b1b191f9615506373cadb0ea58b9d88eca 100644 (file)
@@ -719,14 +719,17 @@ collectPossibleRoots(Instruction *Base, std::map<int64_t,Instruction*> &Roots) {
 
   if (Roots.empty())
     return false;
-  
-  assert(Roots.find(0) == Roots.end() && "Didn't expect a zero index!");
 
   // If we found non-loop-inc, non-root users of Base, assume they are
   // for the zeroth root index. This is because "add %a, 0" gets optimized
   // away.
-  if (BaseUsers.size())
+  if (BaseUsers.size()) {
+    if (Roots.find(0) != Roots.end()) {
+      DEBUG(dbgs() << "LRR: Multiple roots found for base - aborting!\n");
+      return false;
+    }
     Roots[0] = Base;
+  }
 
   // Calculate the number of users of the base, or lowest indexed, iteration.
   unsigned NumBaseUses = BaseUsers.size();