[DAG] Avoid redundant chain transversal in store merge cycle check. NFCI.
authorNirav Dave <niravd@google.com>
Tue, 14 Aug 2018 16:20:43 +0000 (16:20 +0000)
committerNirav Dave <niravd@google.com>
Tue, 14 Aug 2018 16:20:43 +0000 (16:20 +0000)
Patch by Henric Karlsson.

llvm-svn: 339688

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

index aaff88ab5ea4a90113439f6c10ac538985f226a3..5405f794b084f3738dd26f997463a5a95f335135 100644 (file)
@@ -13971,11 +13971,12 @@ bool DAGCombiner::checkMergeStoreCandidatesForDependencies(
   Worklist.push_back(RootNode);
   while (!Worklist.empty()) {
     auto N = Worklist.pop_back_val();
+    if (!Visited.insert(N).second)
+      continue; // Already present in Visited.
     if (N->getOpcode() == ISD::TokenFactor) {
       for (SDValue Op : N->ops())
         Worklist.push_back(Op.getNode());
     }
-    Visited.insert(N);
   }
 
   // Don't count pruning nodes towards max.