Using APInt more efficiently.

llvm-svn: 36475
This commit is contained in:
Zhou Sheng 2007-04-26 16:42:07 +00:00
parent 34d6dc5574
commit 8c150f133c
2 changed files with 7 additions and 10 deletions

View File

@ -44,22 +44,20 @@ ConstantRange::ConstantRange(const APInt &L, const APInt &U) :
Lower(L), Upper(U) {
assert(L.getBitWidth() == U.getBitWidth() &&
"ConstantRange with unequal bit widths");
uint32_t BitWidth = L.getBitWidth();
assert((L != U || (L == APInt::getMaxValue(BitWidth) ||
L == APInt::getMinValue(BitWidth))) &&
assert((L != U || (L.isMaxValue() || L.isMinValue())) &&
"Lower == Upper, but they aren't min or max value!");
}
/// isFullSet - Return true if this set contains all of the elements possible
/// for this data-type
bool ConstantRange::isFullSet() const {
return Lower == Upper && Lower == APInt::getMaxValue(getBitWidth());
return Lower == Upper && Lower.isMaxValue();
}
/// isEmptySet - Return true if this set contains no members.
///
bool ConstantRange::isEmptySet() const {
return Lower == Upper && Lower == APInt::getMinValue(getBitWidth());
return Lower == Upper && Lower.isMinValue();
}
/// isWrappedSet - Return true if this set wraps around the top of the range,

View File

@ -748,14 +748,13 @@ namespace {
return ConstantRange(APInt::getSignedMinValue(W), CR.getSignedMax());
case ICmpInst::ICMP_ULE: {
APInt UMax(CR.getUnsignedMax());
if (UMax == APInt::getMaxValue(W))
if (UMax.isMaxValue())
return ConstantRange(W);
return ConstantRange(APInt::getMinValue(W), UMax + 1);
}
case ICmpInst::ICMP_SLE: {
APInt SMax(CR.getSignedMax());
if (SMax == APInt::getSignedMaxValue(W) ||
SMax + 1 == APInt::getSignedMaxValue(W))
if (SMax.isMaxSignedValue() || (SMax+1).isMaxSignedValue())
return ConstantRange(W);
return ConstantRange(APInt::getSignedMinValue(W), SMax + 1);
}
@ -766,13 +765,13 @@ namespace {
APInt::getSignedMinValue(W));
case ICmpInst::ICMP_UGE: {
APInt UMin(CR.getUnsignedMin());
if (UMin == APInt::getMinValue(W))
if (UMin.isMinValue())
return ConstantRange(W);
return ConstantRange(UMin, APInt::getNullValue(W));
}
case ICmpInst::ICMP_SGE: {
APInt SMin(CR.getSignedMin());
if (SMin == APInt::getSignedMinValue(W))
if (SMin.isMinSignedValue())
return ConstantRange(W);
return ConstantRange(SMin, APInt::getSignedMinValue(W));
}