From: Sanjay Patel Date: Thu, 10 Oct 2019 15:38:29 +0000 (+0000) Subject: [DAGCombiner] reduce code duplication; NFC X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6be83c7f8f119dadb3e741ef57ef987919e75e31;p=llvm [DAGCombiner] reduce code duplication; NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@374370 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index edc5c2ee5dc..377c6086b1a 100644 --- a/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/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);