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

Chris Lattner clattner at apple.com
Sun Dec 14 12:21:10 PST 2008


On Dec 14, 2008, at 11:10 AM, Owen Anderson wrote:

> 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.

What if the scalar value being analyzed is a load?

-Chris

>
>
> 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;
>   }
>
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list