Using APInt more efficiently.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36475 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Support/ConstantRange.cpp b/lib/Support/ConstantRange.cpp
index 7179649..1e2a637 100644
--- a/lib/Support/ConstantRange.cpp
+++ b/lib/Support/ConstantRange.cpp
@@ -44,22 +44,20 @@
   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,
diff --git a/lib/Transforms/Scalar/PredicateSimplifier.cpp b/lib/Transforms/Scalar/PredicateSimplifier.cpp
index 7eef9ac..289f9c9 100644
--- a/lib/Transforms/Scalar/PredicateSimplifier.cpp
+++ b/lib/Transforms/Scalar/PredicateSimplifier.cpp
@@ -748,14 +748,13 @@
           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 @@
                                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));
         }