diff options
| author | Nirav Dave <niravd@google.com> | 2019-02-07 17:13:55 +0000 |
|---|---|---|
| committer | Nirav Dave <niravd@google.com> | 2019-02-07 17:13:55 +0000 |
| commit | 24e60819f6bb413a7a1063f715c50a1af272cc52 (patch) | |
| tree | 7a2c843a85b17f2b2c94d9258628637da58f8917 /llvm/lib/CodeGen | |
| parent | a5c4a5e958fd497be7366a3c5feb9ccf6b7c0bf2 (diff) | |
| download | bcm5719-llvm-24e60819f6bb413a7a1063f715c50a1af272cc52.tar.gz bcm5719-llvm-24e60819f6bb413a7a1063f715c50a1af272cc52.zip | |
[DAG] Cleanup of unused node in SimplifySelectCC.
llvm-svn: 353428
Diffstat (limited to 'llvm/lib/CodeGen')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index b6023d52d6e..33e8a79c4b9 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -18660,14 +18660,21 @@ SDValue DAGCombiner::SimplifySelectCC(const SDLoc &DL, SDValue N0, SDValue N1, 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 = |

