Fix LSR compile time.
[oota-llvm.git] / lib / Transforms / Scalar / LoopStrengthReduce.cpp
index fbc8e0e1e7b4f2cd600b510521aa8166539a59b3..e1d18e8f99b15928828c794a34341b656d30f18f 100644 (file)
@@ -3117,10 +3117,15 @@ void
 LSRInstance::CollectLoopInvariantFixupsAndFormulae() {
   SmallVector<const SCEV *, 8> Worklist(RegUses.begin(), RegUses.end());
   SmallPtrSet<const SCEV *, 8> Inserted;
+  SmallPtrSet<const SCEV *, 32> Done;
 
   while (!Worklist.empty()) {
     const SCEV *S = Worklist.pop_back_val();
 
+    // Don't process the same SCEV twice
+    if (!Done.insert(S))
+      continue;
+
     if (const SCEVNAryExpr *N = dyn_cast<SCEVNAryExpr>(S))
       Worklist.append(N->op_begin(), N->op_end());
     else if (const SCEVCastExpr *C = dyn_cast<SCEVCastExpr>(S))