Skip to content

Commit

Permalink
SimplifyDemandedBits - Remove duplicate getOperand() call. NFC.
Browse files Browse the repository at this point in the history
Pulled out from D56387 - cleanup variable names, move shift amount legalization inside if() of its only user and remove duplicate getOperand() call.
  • Loading branch information
RKSimon committed Dec 28, 2019
1 parent 128f39d commit 34769e0
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
Expand Up @@ -1769,15 +1769,11 @@ bool TargetLowering::SimplifyDemandedBits(
// undesirable.
break;

auto *ShAmt = dyn_cast<ConstantSDNode>(Src.getOperand(1));
if (!ShAmt || ShAmt->getAPIntValue().uge(BitWidth))
SDValue ShAmt = Src.getOperand(1);
auto *ShAmtC = dyn_cast<ConstantSDNode>(ShAmt);
if (!ShAmtC || ShAmtC->getAPIntValue().uge(BitWidth))
break;

SDValue Shift = Src.getOperand(1);
uint64_t ShVal = ShAmt->getZExtValue();

if (TLO.LegalTypes())
Shift = TLO.DAG.getConstant(ShVal, dl, getShiftAmountTy(VT, DL));
uint64_t ShVal = ShAmtC->getZExtValue();

APInt HighBits =
APInt::getHighBitsSet(OperandBitWidth, OperandBitWidth - BitWidth);
Expand All @@ -1787,10 +1783,12 @@ bool TargetLowering::SimplifyDemandedBits(
if (!(HighBits & DemandedBits)) {
// None of the shifted in bits are needed. Add a truncate of the
// shift input, then shift it.
if (TLO.LegalTypes())
ShAmt = TLO.DAG.getConstant(ShVal, dl, getShiftAmountTy(VT, DL));
SDValue NewTrunc =
TLO.DAG.getNode(ISD::TRUNCATE, dl, VT, Src.getOperand(0));
return TLO.CombineTo(
Op, TLO.DAG.getNode(ISD::SRL, dl, VT, NewTrunc, Shift));
Op, TLO.DAG.getNode(ISD::SRL, dl, VT, NewTrunc, ShAmt));
}
break;
}
Expand Down

0 comments on commit 34769e0

Please sign in to comment.