From 042486c44886369a29534cce7ea914f69d8d2ead Mon Sep 17 00:00:00 2001 From: Nirav Dave Date: Thu, 13 Apr 2017 20:00:27 +0000 Subject: [PATCH] [DAG] Fold away temporary vector in store candidate merge NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300241 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 25 +++++++++++------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 306c1974ab5..c947201da2a 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -12276,26 +12276,23 @@ void DAGCombiner::getStoreMergeCandidates( SDNode *RootNode = (St->getChain()).getNode(); - // Set of Parents of Candidates - std::set CandidateParents; - - if (LoadSDNode *Ldn = dyn_cast(RootNode)) { - RootNode = Ldn->getChain().getNode(); - for (auto I = RootNode->use_begin(), E = RootNode->use_end(); I != E; ++I) - if (I.getOperandNo() == 0 && isa(*I)) // walk down chain - CandidateParents.insert(*I); - } else - CandidateParents.insert(RootNode); - - // check all parents of mergable children - for (auto P = CandidateParents.begin(); P != CandidateParents.end(); ++P) - for (auto I = (*P)->use_begin(), E = (*P)->use_end(); I != E; ++I) + auto FindInNode = [&](SDNode *P) { + for (auto I = P->use_begin(), E = P->use_end(); I != E; ++I) if (I.getOperandNo() == 0) if (StoreSDNode *OtherST = dyn_cast(*I)) { BaseIndexOffset Ptr; if (CandidateMatch(OtherST, Ptr)) StoreNodes.push_back(MemOpLink(OtherST, Ptr.Offset)); } + }; + + if (LoadSDNode *Ldn = dyn_cast(RootNode)) { + RootNode = Ldn->getChain().getNode(); + for (auto I = RootNode->use_begin(), E = RootNode->use_end(); I != E; ++I) + if (I.getOperandNo() == 0 && isa(*I)) // walk down chain + FindInNode(*I); + } else + FindInNode(RootNode); } // We need to check that merging these stores does not cause a loop -- 2.50.1