enhance RecursivelyDeleteTriviallyDeadInstructions to make
authorChris Lattner <sabre@nondot.org>
Thu, 27 Nov 2008 23:18:11 +0000 (23:18 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 27 Nov 2008 23:18:11 +0000 (23:18 +0000)
PHIs dead if they are single-value.

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

lib/Transforms/Utils/Local.cpp

index 1e1b3869446ecb930230260f507a0c9543e10e13..cab7f03ab0fc7a9121b70ab31fa9c7377dfef18c 100644 (file)
@@ -190,6 +190,15 @@ void llvm::RecursivelyDeleteTriviallyDeadInstructions(Value *V,
   while (!Insts.empty()) {
     I = *Insts.begin();
     Insts.erase(I);
+    
+    // If this is a PHI node, we may be able to make it dead if we know all the
+    // input values are the same.
+    if (PHINode *PN = dyn_cast<PHINode>(I)) {
+      if (Value *PNV = PN->hasConstantValue())
+        PN->replaceAllUsesWith(PNV);
+    }
+    
+    // Okay, if the instruction is dead, delete it.
     if (!isInstructionTriviallyDead(I))
       continue;