diff options
| author | Sanjay Patel <spatel@rotateright.com> | 2019-10-10 15:38:29 +0000 |
|---|---|---|
| committer | Sanjay Patel <spatel@rotateright.com> | 2019-10-10 15:38:29 +0000 |
| commit | 7f0e7c0b1ca25dfe571acebdbdf7a32cf4e72459 (patch) | |
| tree | b932c0ee9a09ba23270fd1e86cb1ac1fee2c1d49 /llvm/lib/CodeGen | |
| parent | ff054b9e32307960fbbfde5dbb04a8b79be26fc4 (diff) | |
| download | bcm5719-llvm-7f0e7c0b1ca25dfe571acebdbdf7a32cf4e72459.tar.gz bcm5719-llvm-7f0e7c0b1ca25dfe571acebdbdf7a32cf4e72459.zip | |
[DAGCombiner] reduce code duplication; NFC
llvm-svn: 374370
Diffstat (limited to 'llvm/lib/CodeGen')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index edc5c2ee5dc..377c6086b1a 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -8225,13 +8225,15 @@ SDValue DAGCombiner::foldSelectOfConstants(SDNode *N) { // extend and add. Use a target hook because some targets may prefer to // transform in the other direction. if (TLI.convertSelectOfConstantsToMath(VT)) { - if (C1->getAPIntValue() - 1 == C2->getAPIntValue()) { + const APInt &C1Val = C1->getAPIntValue(); + const APInt &C2Val = C2->getAPIntValue(); + if (C1Val - 1 == C2Val) { // select Cond, C1, C1-1 --> add (zext Cond), C1-1 if (VT != MVT::i1) Cond = DAG.getNode(ISD::ZERO_EXTEND, DL, VT, Cond); return DAG.getNode(ISD::ADD, DL, VT, Cond, N2); } - if (C1->getAPIntValue() + 1 == C2->getAPIntValue()) { + if (C1Val + 1 == C2Val) { // select Cond, C1, C1+1 --> add (sext Cond), C1+1 if (VT != MVT::i1) Cond = DAG.getNode(ISD::SIGN_EXTEND, DL, VT, Cond); |

