[llvm] r353428 - [DAG] Cleanup of unused node in SimplifySelectCC.
Nirav Dave via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 7 09:13:55 PST 2019
Author: niravd
Date: Thu Feb 7 09:13:55 2019
New Revision: 353428
URL: http://llvm.org/viewvc/llvm-project?rev=353428&view=rev
Log:
[DAG] Cleanup of unused node in SimplifySelectCC.
Modified:
llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp?rev=353428&r1=353427&r2=353428&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/DAGCombiner.cpp Thu Feb 7 09:13:55 2019
@@ -18660,14 +18660,21 @@ SDValue DAGCombiner::SimplifySelectCC(co
auto *N3C = dyn_cast<ConstantSDNode>(N3.getNode());
// Determine if the condition we're dealing with is constant.
- SDValue SCC = SimplifySetCC(getSetCCResultType(CmpOpVT), N0, N1, CC, DL,
- false);
- if (SCC.getNode()) AddToWorklist(SCC.getNode());
-
- if (auto *SCCC = dyn_cast_or_null<ConstantSDNode>(SCC.getNode())) {
- // fold select_cc true, x, y -> x
- // fold select_cc false, x, y -> y
- return !SCCC->isNullValue() ? N2 : N3;
+ if (SDValue SCC =
+ SimplifySetCC(getSetCCResultType(CmpOpVT), N0, N1, CC, DL, false)) {
+ AddToWorklist(SCC.getNode());
+ if (auto *SCCC = dyn_cast<ConstantSDNode>(SCC.getNode())) {
+ // fold select_cc true, x, y -> x
+ // fold select_cc false, x, y -> y
+ bool isNull = SCCC->isNullValue();
+ SDValue RV = isNull ? N3 : N2;
+ // Delete SCC if we don't use it.
+ if (SCCC != RV.getNode())
+ recursivelyDeleteUnusedNodes(SCCC);
+ return RV;
+ }
+ // Don't combine. Cleanup SCC.
+ recursivelyDeleteUnusedNodes(SCC.getNode());
}
if (SDValue V =
More information about the llvm-commits
mailing list