forked from OSchip/llvm-project
[SelectionDAG] Use getActiveBits() and countTrailingZeros() to avoid creating temporary APInts with lshr and trunc. NFCI
llvm-svn: 300819
This commit is contained in:
parent
ff04109ca2
commit
d3884b8402
|
@ -839,7 +839,7 @@ bool TargetLowering::SimplifyDemandedBits(SDValue Op,
|
||||||
SDValue InnerOp = InOp.getNode()->getOperand(0);
|
SDValue InnerOp = InOp.getNode()->getOperand(0);
|
||||||
EVT InnerVT = InnerOp.getValueType();
|
EVT InnerVT = InnerOp.getValueType();
|
||||||
unsigned InnerBits = InnerVT.getSizeInBits();
|
unsigned InnerBits = InnerVT.getSizeInBits();
|
||||||
if (ShAmt < InnerBits && NewMask.lshr(InnerBits) == 0 &&
|
if (ShAmt < InnerBits && NewMask.getActiveBits() <= InnerBits &&
|
||||||
isTypeDesirableForOp(ISD::SHL, InnerVT)) {
|
isTypeDesirableForOp(ISD::SHL, InnerVT)) {
|
||||||
EVT ShTy = getShiftAmountTy(InnerVT, DL);
|
EVT ShTy = getShiftAmountTy(InnerVT, DL);
|
||||||
if (!APInt(BitWidth, ShAmt).isIntN(ShTy.getSizeInBits()))
|
if (!APInt(BitWidth, ShAmt).isIntN(ShTy.getSizeInBits()))
|
||||||
|
@ -865,9 +865,8 @@ bool TargetLowering::SimplifyDemandedBits(SDValue Op,
|
||||||
->getZExtValue();
|
->getZExtValue();
|
||||||
if (InnerShAmt < ShAmt &&
|
if (InnerShAmt < ShAmt &&
|
||||||
InnerShAmt < InnerBits &&
|
InnerShAmt < InnerBits &&
|
||||||
NewMask.lshr(std::min(InnerBits - InnerShAmt + ShAmt,
|
NewMask.getActiveBits() <= (InnerBits - InnerShAmt + ShAmt) &&
|
||||||
BitWidth)) == 0 &&
|
NewMask.countTrailingZeros() >= ShAmt) {
|
||||||
NewMask.trunc(ShAmt) == 0) {
|
|
||||||
SDValue NewSA =
|
SDValue NewSA =
|
||||||
TLO.DAG.getConstant(ShAmt - InnerShAmt, dl,
|
TLO.DAG.getConstant(ShAmt - InnerShAmt, dl,
|
||||||
Op.getOperand(1).getValueType());
|
Op.getOperand(1).getValueType());
|
||||||
|
|
Loading…
Reference in New Issue