From: Nirav Dave Date: Thu, 7 Feb 2019 16:57:50 +0000 (+0000) Subject: [DAG] Cleanup unused node on failed SELECT Combine. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9aa1395994dcc8a7ea07e5144527761447fb681e;p=llvm [DAG] Cleanup unused node on failed SELECT Combine. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353426 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 9ef4f508ef1..b6023d52d6e 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -7444,6 +7444,9 @@ SDValue DAGCombiner::visitSELECT(SDNode *N) { if (normalizeToSequence || !InnerSelect.use_empty()) return DAG.getNode(ISD::SELECT, DL, N1.getValueType(), Cond0, InnerSelect, N2); + // Cleanup on failure. + if (InnerSelect.use_empty()) + recursivelyDeleteUnusedNodes(InnerSelect.getNode()); } // select (or Cond0, Cond1), X, Y -> select Cond0, X, (select Cond1, X, Y) if (N0->getOpcode() == ISD::OR && N0->hasOneUse()) { @@ -7454,6 +7457,9 @@ SDValue DAGCombiner::visitSELECT(SDNode *N) { if (normalizeToSequence || !InnerSelect.use_empty()) return DAG.getNode(ISD::SELECT, DL, N1.getValueType(), Cond0, N1, InnerSelect); + // Cleanup on failure. + if (InnerSelect.use_empty()) + recursivelyDeleteUnusedNodes(InnerSelect.getNode()); } // select Cond0, (select Cond1, X, Y), Y -> select (and Cond0, Cond1), X, Y