Simplify APInt::getAllOnesValue.
authorBenjamin Kramer <benny.kra@googlemail.com>
Sat, 4 Dec 2010 16:37:47 +0000 (16:37 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Sat, 4 Dec 2010 16:37:47 +0000 (16:37 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120911 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/APInt.h

index ec92e8f4b29eb6cdc19a519e87eca7b208b08294..b3cd38af15d39b0e1a3ed359c49a1a6bcddeb694 100644 (file)
@@ -379,15 +379,12 @@ public:
   /// @{
   /// @brief Gets maximum unsigned value of APInt for specific bit width.
   static APInt getMaxValue(unsigned numBits) {
-    APInt API(numBits, 0);
-    API.setAllBits();
-    return API;
+    return getAllOnesValue(numBits);
   }
 
   /// @brief Gets maximum signed value of APInt for a specific bit width.
   static APInt getSignedMaxValue(unsigned numBits) {
-    APInt API(numBits, 0);
-    API.setAllBits();
+    APInt API = getAllOnesValue(numBits);
     API.clearBit(numBits - 1);
     return API;
   }
@@ -414,9 +411,7 @@ public:
   /// @returns the all-ones value for an APInt of the specified bit-width.
   /// @brief Get the all-ones value.
   static APInt getAllOnesValue(unsigned numBits) {
-    APInt API(numBits, 0);
-    API.setAllBits();
-    return API;
+    return APInt(numBits, -1ULL, true);
   }
 
   /// @returns the '0' value for an APInt of the specified bit-width.