case ISD::SIGN_EXTEND: {
EVT InVT = Op.getOperand(0).getValueType();
unsigned InBits = InVT.getScalarSizeInBits();
- APInt NewBits = APInt::getHighBitsSet(BitWidth, BitWidth - InBits);
KnownZero = KnownZero.trunc(InBits);
KnownOne = KnownOne.trunc(InBits);
computeKnownBits(Op.getOperand(0), KnownZero, KnownOne, DemandedElts,
Depth + 1);
- // Note if the sign bit is known to be zero or one.
- bool SignBitKnownZero = KnownZero.isNegative();
- bool SignBitKnownOne = KnownOne.isNegative();
-
- KnownZero = KnownZero.zext(BitWidth);
- KnownOne = KnownOne.zext(BitWidth);
-
- // If the sign bit is known zero or one, the top bits match.
- if (SignBitKnownZero)
- KnownZero |= NewBits;
- else if (SignBitKnownOne)
- KnownOne |= NewBits;
+ // If the sign bit is known to be zero or one, then sext will extend
+ // it to the top bits, else it will just zext.
+ KnownZero = KnownZero.sext(BitWidth);
+ KnownOne = KnownOne.sext(BitWidth);
break;
}
case ISD::ANY_EXTEND: {