[llvm-commits] [llvm] r61009 - /llvm/trunk/lib/Transforms/Scalar/GVN.cpp

Owen Anderson resistor at mac.com
Sun Dec 14 11:10:35 PST 2008


Author: resistor
Date: Sun Dec 14 13:10:35 2008
New Revision: 61009

URL: http://llvm.org/viewvc/llvm-project?rev=61009&view=rev
Log:
Generalize GVN's phi construciton routine to work for things other than loads.

Modified:
    llvm/trunk/lib/Transforms/Scalar/GVN.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=61009&r1=61008&r2=61009&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Sun Dec 14 13:10:35 2008
@@ -728,7 +728,7 @@
     bool processNonLocalLoad(LoadInst* L,
                              SmallVectorImpl<Instruction*> &toErase);
     bool processBlock(DomTreeNode* DTN);
-    Value *GetValueForBlock(BasicBlock *BB, LoadInst* orig,
+    Value *GetValueForBlock(BasicBlock *BB, Instruction* orig,
                             DenseMap<BasicBlock*, Value*> &Phis,
                             bool top_level = false);
     void dump(DenseMap<uint32_t, Value*>& d);
@@ -789,7 +789,7 @@
 
 /// GetValueForBlock - Get the value to use within the specified basic block.
 /// available values are in Phis.
-Value *GVN::GetValueForBlock(BasicBlock *BB, LoadInst* orig,
+Value *GVN::GetValueForBlock(BasicBlock *BB, Instruction* orig,
                              DenseMap<BasicBlock*, Value*> &Phis,
                              bool top_level) { 
                                  
@@ -837,7 +837,11 @@
   Value* v = CollapsePhi(PN);
   if (!v) {
     // Cache our phi construction results
-    phiMap[orig->getPointerOperand()].insert(PN);
+    if (LoadInst* L = dyn_cast<LoadInst>(orig))
+      phiMap[L->getPointerOperand()].insert(PN);
+    else
+      phiMap[orig].insert(PN);
+    
     return PN;
   }
     





More information about the llvm-commits mailing list