]> granicus.if.org Git - llvm/commitdiff
[APInt] Make the single word cases of isMaxSignedValue/isMinSignedValue just compare...
authorCraig Topper <craig.topper@intel.com>
Fri, 23 Jun 2017 20:28:52 +0000 (20:28 +0000)
committerCraig Topper <craig.topper@intel.com>
Fri, 23 Jun 2017 20:28:52 +0000 (20:28 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306155 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/APInt.h

index 1289335fd2a038de88a57a173b463c8a0d132fab..e5f0c35534ac94b590c10dced846487b89f9626d 100644 (file)
@@ -414,7 +414,9 @@ public:
   /// This checks to see if the value of this APInt is the maximum signed
   /// value for the APInt's bit width.
   bool isMaxSignedValue() const {
-    return !isNegative() && countTrailingOnes() == BitWidth - 1;
+    if (isSingleWord())
+      return U.VAL == ((WordType(1) << (BitWidth - 1)) - 1);
+    return !isNegative() && countTrailingOnesSlowCase() == BitWidth - 1;
   }
 
   /// \brief Determine if this is the smallest unsigned value.
@@ -428,7 +430,9 @@ public:
   /// This checks to see if the value of this APInt is the minimum signed
   /// value for the APInt's bit width.
   bool isMinSignedValue() const {
-    return isNegative() && countTrailingZeros() == BitWidth - 1;
+    if (isSingleWord())
+      return U.VAL == (WordType(1) << (BitWidth - 1));
+    return isNegative() && countTrailingZerosSlowCase() == BitWidth - 1;
   }
 
   /// \brief Check if this APInt has an N-bits unsigned integer value.