Instead of clearing the rewriter, don't attempt to rewrite dead phi nodes.
authorTorok Edwin <edwintorok@gmail.com>
Sun, 24 May 2009 19:36:09 +0000 (19:36 +0000)
committerTorok Edwin <edwintorok@gmail.com>
Sun, 24 May 2009 19:36:09 +0000 (19:36 +0000)
Also fix 80 column violation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72371 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/ScalarEvolutionExpander.cpp
lib/Transforms/Scalar/IndVarSimplify.cpp

index 03406271dedee4d67f3b8f52f7c3da1002a2f0c2..191fcc02c4b032dfb552a8034b48d6750ea2b335 100644 (file)
@@ -615,7 +615,8 @@ Value *SCEVExpander::expandCodeFor(SCEVHandle SH, const Type *Ty) {
 
 Value *SCEVExpander::expand(const SCEV *S) {
   // Check to see if we already expanded this.
-  std::map<SCEVHandle, AssertingVH<Value> >::iterator I = InsertedExpressions.find(S);
+  std::map<SCEVHandle, AssertingVH<Value> >::iterator I =
+    InsertedExpressions.find(S);
   if (I != InsertedExpressions.end())
     return I->second;
   
index 07c7d0071fb6b95df9a9bd06507aad6b8c4b6aaf..f0f2d83b6e689ffbdba52a5abeed13b0febe1af5 100644 (file)
@@ -250,7 +250,8 @@ void IndVarSimplify::RewriteLoopExitValues(Loop *L,
     // Iterate over all of the PHI nodes.
     BasicBlock::iterator BBI = ExitBB->begin();
     while ((PN = dyn_cast<PHINode>(BBI++))) {
-
+      if (PN->use_empty())
+        continue; // dead use, don't replace it
       // Iterate over all of the values in all the PHI nodes.
       for (unsigned i = 0; i != NumPreds; ++i) {
         // If the value being merged in is not integer or is not defined
@@ -303,7 +304,6 @@ void IndVarSimplify::RewriteLoopExitValues(Loop *L,
         // in the loop, so we don't need an LCSSA phi node anymore.
         if (NumPreds == 1) {
           PN->replaceAllUsesWith(ExitVal);
-          Rewriter.clear();
           RecursivelyDeleteTriviallyDeadInstructions(PN);
           break;
         }