Factor some code into a new FoldSingleEntryPHINodes method.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60501 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp
index f4faeb3..d6465f5 100644
--- a/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1101,10 +1101,7 @@
   
   // Degenerate case of a single entry PHI.
   if (PN->getNumIncomingValues() == 1) {
-    if (PN->getIncomingValue(0) != PN)
-      PN->replaceAllUsesWith(PN->getIncomingValue(0));
-    else
-      PN->replaceAllUsesWith(UndefValue::get(PN->getType()));
+    FoldSingleEntryPHINodes(PN->getParent());
     PN->eraseFromParent();
     return true;    
   }