llvm.org GIT mirror llvm / c125c00
Using APInt more efficiently. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36475 91177308-0d34-0410-b5e6-96231b3b80d8 Zhou Sheng 13 years ago
2 changed file(s) with 7 addition(s) and 10 deletion(s). Raw diff Collapse all Expand all
4343 Lower(L), Upper(U) {
4444 assert(L.getBitWidth() == U.getBitWidth() &&
4545 "ConstantRange with unequal bit widths");
46 uint32_t BitWidth = L.getBitWidth();
47 assert((L != U || (L == APInt::getMaxValue(BitWidth) ||
48 L == APInt::getMinValue(BitWidth))) &&
46 assert((L != U || (L.isMaxValue() || L.isMinValue())) &&
4947 "Lower == Upper, but they aren't min or max value!");
5048 }
5149
5250 /// isFullSet - Return true if this set contains all of the elements possible
5351 /// for this data-type
5452 bool ConstantRange::isFullSet() const {
55 return Lower == Upper && Lower == APInt::getMaxValue(getBitWidth());
53 return Lower == Upper && Lower.isMaxValue();
5654 }
5755
5856 /// isEmptySet - Return true if this set contains no members.
5957 ///
6058 bool ConstantRange::isEmptySet() const {
61 return Lower == Upper && Lower == APInt::getMinValue(getBitWidth());
59 return Lower == Upper && Lower.isMinValue();
6260 }
6361
6462 /// isWrappedSet - Return true if this set wraps around the top of the range,
747747 return ConstantRange(APInt::getSignedMinValue(W), CR.getSignedMax());
748748 case ICmpInst::ICMP_ULE: {
749749 APInt UMax(CR.getUnsignedMax());
750 if (UMax == APInt::getMaxValue(W))
750 if (UMax.isMaxValue())
751751 return ConstantRange(W);
752752 return ConstantRange(APInt::getMinValue(W), UMax + 1);
753753 }
754754 case ICmpInst::ICMP_SLE: {
755755 APInt SMax(CR.getSignedMax());
756 if (SMax == APInt::getSignedMaxValue(W) ||
757 SMax + 1 == APInt::getSignedMaxValue(W))
756 if (SMax.isMaxSignedValue() || (SMax+1).isMaxSignedValue())
758757 return ConstantRange(W);
759758 return ConstantRange(APInt::getSignedMinValue(W), SMax + 1);
760759 }
765764 APInt::getSignedMinValue(W));
766765 case ICmpInst::ICMP_UGE: {
767766 APInt UMin(CR.getUnsignedMin());
768 if (UMin == APInt::getMinValue(W))
767 if (UMin.isMinValue())
769768 return ConstantRange(W);
770769 return ConstantRange(UMin, APInt::getNullValue(W));
771770 }
772771 case ICmpInst::ICMP_SGE: {
773772 APInt SMin(CR.getSignedMin());
774 if (SMin == APInt::getSignedMinValue(W))
773 if (SMin.isMinSignedValue())
775774 return ConstantRange(W);
776775 return ConstantRange(SMin, APInt::getSignedMinValue(W));
777776 }