Using APInt more efficiently.
authorZhou Sheng <zhousheng00@gmail.com>
Thu, 26 Apr 2007 16:42:07 +0000 (16:42 +0000)
committerZhou Sheng <zhousheng00@gmail.com>
Thu, 26 Apr 2007 16:42:07 +0000 (16:42 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36475 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/ConstantRange.cpp
lib/Transforms/Scalar/PredicateSimplifier.cpp

index 71796493301bb53e048c45eafe17796e491f4481..1e2a6375c457985cbd523c2a003136ba3ce7c22e 100644 (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,
index 7eef9ac69118a56ba64597694b91c5b320de2f88..289f9c96557c7e85036f6614c73edeadb6a31de4 100644 (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));
         }