[SelectionDAG] Use APInt::isSubsetOf/intersects to simplify some code.

Also use KnownBits::isNegative/isNonNegative to further simplify.

llvm-svn: 367518
This commit is contained in:
Craig Topper 2019-08-01 06:06:21 +00:00
parent 7a2958bc20
commit 388df2ea19
1 changed files with 2 additions and 2 deletions

View File

@ -3090,12 +3090,12 @@ KnownBits SelectionDAG::computeKnownBits(SDValue Op, const APInt &DemandedElts,
// If the first operand is non-negative or has all low bits zero, then
// the upper bits are all zero.
if (Known2.Zero[BitWidth-1] || ((Known2.Zero & LowBits) == LowBits))
if (Known2.isNonNegative() || LowBits.isSubsetOf(Known2.Zero))
Known.Zero |= ~LowBits;
// If the first operand is negative and not all low bits are zero, then
// the upper bits are all one.
if (Known2.One[BitWidth-1] && ((Known2.One & LowBits) != 0))
if (Known2.isNegative() && LowBits.intersects(Known2.One))
Known.One |= ~LowBits;
assert((Known.Zero & Known.One) == 0&&"Bits known to be one AND zero?");
}