[DAG] Cleanup unused nodes after store merge. NFCI.

llvm-svn: 310648
This commit is contained in:
Nirav Dave 2017-08-10 18:53:14 +00:00
parent 4ad374ea76
commit 99d9d24553
1 changed files with 11 additions and 1 deletions

View File

@ -12552,8 +12552,15 @@ bool DAGCombiner::MergeStoresOfConstantsOrVecElts(
} }
// Replace all merged stores with the new store. // Replace all merged stores with the new store.
for (unsigned i = 0; i < NumStores; ++i) for (unsigned i = 0; i < NumStores; ++i) {
SDValue Val = StoreNodes[i].MemNode->getOperand(1);
SDValue Addr = StoreNodes[i].MemNode->getOperand(2);
CombineTo(StoreNodes[i].MemNode, NewStore); CombineTo(StoreNodes[i].MemNode, NewStore);
if (Val.getNode()->use_empty())
recursivelyDeleteUnusedNodes(Val.getNode());
if (Addr.getNode()->use_empty())
recursivelyDeleteUnusedNodes(Addr.getNode());
}
AddToWorklist(NewChain.getNode()); AddToWorklist(NewChain.getNode());
return true; return true;
@ -13186,9 +13193,12 @@ bool DAGCombiner::MergeConsecutiveStores(StoreSDNode *St) {
// corresponding value if its no longer used. // corresponding value if its no longer used.
for (unsigned i = 0; i < NumElem; ++i) { for (unsigned i = 0; i < NumElem; ++i) {
SDValue Val = StoreNodes[i].MemNode->getOperand(1); SDValue Val = StoreNodes[i].MemNode->getOperand(1);
SDValue Addr = StoreNodes[i].MemNode->getOperand(2);
CombineTo(StoreNodes[i].MemNode, NewStore); CombineTo(StoreNodes[i].MemNode, NewStore);
if (Val.getNode()->use_empty()) if (Val.getNode()->use_empty())
recursivelyDeleteUnusedNodes(Val.getNode()); recursivelyDeleteUnusedNodes(Val.getNode());
if (Addr.getNode()->use_empty())
recursivelyDeleteUnusedNodes(Addr.getNode());
} }
RV = true; RV = true;