[llvm-commits] [llvm] r45398 - /llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Dale Johannesen dalej at apple.com
Fri Dec 28 22:35:09 PST 2007


On Dec 28, 2007, at 10:26 PM, Chris Lattner wrote:

> Author: lattner
> Date: Sat Dec 29 00:26:16 2007
> New Revision: 45398
>
> URL: http://llvm.org/viewvc/llvm-project?rev=45398&view=rev
> Log:
> Delete a store whose input is a load from the same pointer:
>  x = load p
>  store x -> p

This is unsafe for volatile.  I don't see a check?

>
> Modified:
>    llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
>
> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=45398&r1=45397&r2=45398&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
> +++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Sat Dec 29  
> 00:26:16 2007
> @@ -4223,7 +4223,7 @@
>   if (CombineToPreIndexedLoadStore(N) ||  
> CombineToPostIndexedLoadStore(N))
>     return SDOperand(N, 0);
>
> -  // FIXME: is there such a think as a truncating indexed store?
> +  // FIXME: is there such a thing as a truncating indexed store?
>   if (ST->isTruncatingStore() && ST->getAddressingMode() ==  
> ISD::UNINDEXED &&
>       MVT::isInteger(Value.getValueType())) {
>     // See if we can simplify the input to this truncstore with  
> knowledge that
> @@ -4243,6 +4243,17 @@
>       return SDOperand(N, 0);
>   }
>
> +  // If this is a load followed by a store to the same location,  
> then the store
> +  // is dead/noop.
> +  if (LoadSDNode *Ld = dyn_cast<LoadSDNode>(Value)) {
> +    if (Chain.Val == Ld && Ld->getBasePtr() == Ptr &&
> +        ST->getAddressingMode() == ISD::UNINDEXED &&
> +        ST->getStoredVT() == Ld->getLoadedVT()) {
> +      // The store is dead, remove it.
> +      return Chain;
> +    }
> +  }
> +
>   return SDOperand();
> }
>
>
>
> _______________________________________________
> 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