forked from OSchip/llvm-project
[SelectionDAG] ComputeNumSignBits - use Valid Min/Max shift amount helpers directly. NFCI.
We are calling getValidShiftAmountConstant first followed by getValidMinimumShiftAmountConstant/getValidMaximumShiftAmountConstant if that failed. But both are used in the same way in ComputeNumSignBits and the Min/Max variants call getValidShiftAmountConstant internally anyhow.
This commit is contained in:
parent
179f8ad08d
commit
9d0bfcec83
|
@ -3657,23 +3657,17 @@ unsigned SelectionDAG::ComputeNumSignBits(SDValue Op, const APInt &DemandedElts,
|
|||
case ISD::SRA:
|
||||
Tmp = ComputeNumSignBits(Op.getOperand(0), DemandedElts, Depth + 1);
|
||||
// SRA X, C -> adds C sign bits.
|
||||
if (const APInt *ShAmt = getValidShiftAmountConstant(Op, DemandedElts))
|
||||
Tmp = std::min<uint64_t>(Tmp + ShAmt->getZExtValue(), VTBits);
|
||||
else if (const APInt *ShAmt =
|
||||
getValidMinimumShiftAmountConstant(Op, DemandedElts))
|
||||
if (const APInt *ShAmt =
|
||||
getValidMinimumShiftAmountConstant(Op, DemandedElts))
|
||||
Tmp = std::min<uint64_t>(Tmp + ShAmt->getZExtValue(), VTBits);
|
||||
return Tmp;
|
||||
case ISD::SHL:
|
||||
if (const APInt *ShAmt = getValidShiftAmountConstant(Op, DemandedElts)) {
|
||||
if (const APInt *ShAmt =
|
||||
getValidMaximumShiftAmountConstant(Op, DemandedElts)) {
|
||||
// shl destroys sign bits, ensure it doesn't shift out all sign bits.
|
||||
Tmp = ComputeNumSignBits(Op.getOperand(0), DemandedElts, Depth + 1);
|
||||
if (ShAmt->ult(Tmp))
|
||||
return Tmp - ShAmt->getZExtValue();
|
||||
} else if (const APInt *ShAmt =
|
||||
getValidMaximumShiftAmountConstant(Op, DemandedElts)) {
|
||||
Tmp = ComputeNumSignBits(Op.getOperand(0), DemandedElts, Depth + 1);
|
||||
if (ShAmt->ult(Tmp))
|
||||
return Tmp - ShAmt->getZExtValue();
|
||||
}
|
||||
break;
|
||||
case ISD::AND:
|
||||
|
|
Loading…
Reference in New Issue