[llvm-branch-commits] [llvm-branch] r168596 - in /llvm/branches/release_32: ./ lib/CodeGen/SelectionDAG/DAGCombiner.cpp test/CodeGen/X86/pr14333.ll

Pawel Wodnicki pawel at 32bitmicro.com
Mon Nov 26 09:01:12 PST 2012


Author: pawel
Date: Mon Nov 26 11:01:12 2012
New Revision: 168596

URL: http://llvm.org/viewvc/llvm-project?rev=168596&view=rev
Log:
Merging r167912: into the 3.2 release branch.

Handle DAG CSE adding new uses during ReplaceAllUsesWith. Fixes PR14333.

Added:
    llvm/branches/release_32/test/CodeGen/X86/pr14333.ll
      - copied unchanged from r167912, llvm/trunk/test/CodeGen/X86/pr14333.ll
Modified:
    llvm/branches/release_32/   (props changed)
    llvm/branches/release_32/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Propchange: llvm/branches/release_32/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Nov 26 11:01:12 2012
@@ -1,3 +1,3 @@
 /llvm/branches/Apple/Pertwee:110850,110961
 /llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,167718-167719,167731,167737,167743,167750,167784,167811,167817,167855,167860-167864,167875,167942,167948,167966,168001,168035,168181,168186,168189,168196-168198,168227,168280,168291,168316,168319-168320,168346,168352,168354,168361,168364,168512
+/llvm/trunk:155241,167718-167719,167731,167737,167743,167750,167784,167811,167817,167855,167860-167864,167875,167912,167942,167948,167966,168001,168035,168181,168186,168189,168196-168198,168227,168280,168291,168316,168319-168320,168346,168352,168354,168361,168364,168512

Modified: llvm/branches/release_32/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_32/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=168596&r1=168595&r2=168596&view=diff
==============================================================================
--- llvm/branches/release_32/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/branches/release_32/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Mon Nov 26 11:01:12 2012
@@ -7728,7 +7728,18 @@
       if (StoreNodes[i].MemNode == EarliestOp)
         continue;
       StoreSDNode *St = cast<StoreSDNode>(StoreNodes[i].MemNode);
-      DAG.ReplaceAllUsesOfValueWith(SDValue(St, 0), St->getChain());
+      // ReplaceAllUsesWith will replace all uses that existed when it was
+      // called, but graph optimizations may cause new ones to appear. For
+      // example, the case in pr14333 looks like
+      //
+      //  St's chain -> St -> another store -> X
+      //
+      // And the only difference from St to the other store is the chain.
+      // When we change it's chain to be St's chain they become identical,
+      // get CSEed and the net result is that X is now a use of St.
+      // Since we know that St is redundant, just iterate.
+      while (!St->use_empty())
+        DAG.ReplaceAllUsesWith(SDValue(St, 0), St->getChain());
       removeFromWorkList(St);
       DAG.DeleteNode(St);
     }





More information about the llvm-branch-commits mailing list