diff options
author | Sanjay Patel <spatel@rotateright.com> | 2018-11-19 14:35:22 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2018-11-19 14:35:22 +0000 |
commit | c036d844be3aaf95a1479ccfd07607777ec86522 (patch) | |
tree | 3764955122dd6d9f934fc13b5a2b1441b9d1996a /llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | |
parent | bbab546a7195350ca58a189247d6baf6ab5fb81a (diff) | |
download | bcm5719-llvm-c036d844be3aaf95a1479ccfd07607777ec86522.tar.gz bcm5719-llvm-c036d844be3aaf95a1479ccfd07607777ec86522.zip |
[SelectionDAG] add simplifySelect() to reduce code duplication; NFC
This should be extended to handle FP and vectors in follow-up patches.
llvm-svn: 347210
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 20 |
1 files changed, 2 insertions, 18 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 0f428b72d52..31589fe586b 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -7236,24 +7236,8 @@ SDValue DAGCombiner::visitSELECT(SDNode *N) { EVT VT0 = N0.getValueType(); SDLoc DL(N); - // select undef, N1, N2 --> N1 (if it's a constant), otherwise N2 - if (N0.isUndef()) - return isa<ConstantSDNode>(N1) ? N1 : N2; - // select, ?, undef, N2 --> N2 - if (N1.isUndef()) - return N2; - // select, ?, N1, undef --> N1 - if (N2.isUndef()) - return N1; - - // fold (select true, X, Y) -> X - // fold (select false, X, Y) -> Y - if (auto *N0C = dyn_cast<const ConstantSDNode>(N0)) - return N0C->isNullValue() ? N2 : N1; - - // select ?, N1, N1 --> N1 - if (N1 == N2) - return N1; + if (SDValue V = DAG.simplifySelect(N0, N1, N2)) + return V; // fold (select X, X, Y) -> (or X, Y) // fold (select X, 1, Y) -> (or C, Y) |