[llvm-commits] [llvm] r120911 - /llvm/trunk/include/llvm/ADT/APInt.h

Benjamin Kramer benny.kra at googlemail.com
Sat Dec 4 08:37:48 PST 2010


Author: d0k
Date: Sat Dec  4 10:37:47 2010
New Revision: 120911

URL: http://llvm.org/viewvc/llvm-project?rev=120911&view=rev
Log:
Simplify APInt::getAllOnesValue.

Modified:
    llvm/trunk/include/llvm/ADT/APInt.h

Modified: llvm/trunk/include/llvm/ADT/APInt.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/APInt.h?rev=120911&r1=120910&r2=120911&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/APInt.h (original)
+++ llvm/trunk/include/llvm/ADT/APInt.h Sat Dec  4 10:37:47 2010
@@ -379,15 +379,12 @@
   /// @{
   /// @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 @@
   /// @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.





More information about the llvm-commits mailing list