simplify getSetSize() per Duncan's comments

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160368 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Nuno Lopes 2012-07-17 15:43:59 +00:00
parent f30135c519
commit 5d2fada44c

View File

@ -146,14 +146,13 @@ APInt ConstantRange::getSetSize() const {
if (isEmptySet()) if (isEmptySet())
return APInt(getBitWidth()+1, 0); return APInt(getBitWidth()+1, 0);
if (isFullSet()) if (isFullSet()) {
return APInt::getMaxValue(getBitWidth()).zext(getBitWidth()+1) + 1; APInt Size(getBitWidth()+1, 0);
Size.setBit(getBitWidth());
if (isWrappedSet()) { return Size;
APInt Result = Upper + (APInt::getMaxValue(getBitWidth()) - Lower + 1);
return Result.zext(getBitWidth()+1);
} }
// This is also correct for wrapped sets.
return (Upper - Lower).zext(getBitWidth()+1); return (Upper - Lower).zext(getBitWidth()+1);
} }