Skip to content

Commit 7f0e7c0

Browse files
committed
[DAGCombiner] reduce code duplication; NFC
llvm-svn: 374370
1 parent ff054b9 commit 7f0e7c0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8225,13 +8225,15 @@ SDValue DAGCombiner::foldSelectOfConstants(SDNode *N) {
82258225
// extend and add. Use a target hook because some targets may prefer to
82268226
// transform in the other direction.
82278227
if (TLI.convertSelectOfConstantsToMath(VT)) {
8228-
if (C1->getAPIntValue() - 1 == C2->getAPIntValue()) {
8228+
const APInt &C1Val = C1->getAPIntValue();
8229+
const APInt &C2Val = C2->getAPIntValue();
8230+
if (C1Val - 1 == C2Val) {
82298231
// select Cond, C1, C1-1 --> add (zext Cond), C1-1
82308232
if (VT != MVT::i1)
82318233
Cond = DAG.getNode(ISD::ZERO_EXTEND, DL, VT, Cond);
82328234
return DAG.getNode(ISD::ADD, DL, VT, Cond, N2);
82338235
}
8234-
if (C1->getAPIntValue() + 1 == C2->getAPIntValue()) {
8236+
if (C1Val + 1 == C2Val) {
82358237
// select Cond, C1, C1+1 --> add (sext Cond), C1+1
82368238
if (VT != MVT::i1)
82378239
Cond = DAG.getNode(ISD::SIGN_EXTEND, DL, VT, Cond);

0 commit comments

Comments
 (0)