[llvm-commits] [llvm] r60194 - /llvm/trunk/lib/Transforms/Utils/Local.cpp

Chris Lattner sabre at nondot.org
Thu Nov 27 15:18:12 PST 2008


Author: lattner
Date: Thu Nov 27 17:18:11 2008
New Revision: 60194

URL: http://llvm.org/viewvc/llvm-project?rev=60194&view=rev
Log:
enhance RecursivelyDeleteTriviallyDeadInstructions to make
PHIs dead if they are single-value.

Modified:
    llvm/trunk/lib/Transforms/Utils/Local.cpp

Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Local.cpp?rev=60194&r1=60193&r2=60194&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/Local.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/Local.cpp Thu Nov 27 17:18:11 2008
@@ -190,6 +190,15 @@
   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;
     





More information about the llvm-commits mailing list