diff options
| author | Owen Anderson <resistor@mac.com> | 2008-12-14 19:10:35 +0000 |
|---|---|---|
| committer | Owen Anderson <resistor@mac.com> | 2008-12-14 19:10:35 +0000 |
| commit | e34c2399de70ba1ae60f3be513ed102f1550c20a (patch) | |
| tree | 23d065f6f6ecf2a57edfd4f637c9de8b84048c4a /llvm/lib/Transforms/Scalar/GVN.cpp | |
| parent | 13c2c1eeca551f254f878be64801891a03211296 (diff) | |
| download | bcm5719-llvm-e34c2399de70ba1ae60f3be513ed102f1550c20a.tar.gz bcm5719-llvm-e34c2399de70ba1ae60f3be513ed102f1550c20a.zip | |
Generalize GVN's phi construciton routine to work for things other than loads.
llvm-svn: 61009
Diffstat (limited to 'llvm/lib/Transforms/Scalar/GVN.cpp')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/GVN.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp index 2081811f0d1..5e5e8b77022 100644 --- a/llvm/lib/Transforms/Scalar/GVN.cpp +++ b/llvm/lib/Transforms/Scalar/GVN.cpp @@ -728,7 +728,7 @@ namespace { 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 @@ bool GVN::isSafeReplacement(PHINode* p, Instruction* inst) { /// 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 *GVN::GetValueForBlock(BasicBlock *BB, LoadInst* orig, 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; } |

