[llvm] r271376 - Revert "Fix up the definition of the integer max function"

Dylan McKay via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 1 02:39:43 PDT 2016


Author: dylanmckay
Date: Wed Jun  1 04:39:42 2016
New Revision: 271376

URL: http://llvm.org/viewvc/llvm-project?rev=271376&view=rev
Log:
Revert "Fix up the definition of the integer max function"

This reverts commit eadf45dafe4597589f0f07f665bb4d1faf7a63fe.

Modified:
    llvm/trunk/include/llvm/Support/MathExtras.h

Modified: llvm/trunk/include/llvm/Support/MathExtras.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/MathExtras.h?rev=271376&r1=271375&r2=271376&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/MathExtras.h (original)
+++ llvm/trunk/include/llvm/Support/MathExtras.h Wed Jun  1 04:39:42 2016
@@ -312,22 +312,22 @@ inline bool isShiftedUInt(uint64_t x) {
 }
 
 /// Gets the maximum value for a N-bit unsigned integer.
-inline uint64_t maxUIntN(uint64_t N) { return (UINT64_C(1) << N) - 1; }
+inline uint64_t maxUIntN(uint64_t N) { return UINT64_C(1) << N; }
 /// Gets the minimum value for a N-bit signed integer.
 inline int64_t minIntN(int64_t N) { return -(INT64_C(1)<<(N-1)); }
 /// Gets the maximum value for a N-bit signed integer.
-inline int64_t maxIntN(int64_t N) { return (INT64_C(1)<<(N-1) - 1); }
+inline int64_t maxIntN(int64_t N) { return INT64_C(1)<<(N-1); }
 
 /// isUIntN - Checks if an unsigned integer fits into the given (dynamic)
 /// bit width.
 inline bool isUIntN(unsigned N, uint64_t x) {
-  return N >= 64 || x <= maxUIntN(N);
+  return N >= 64 || x < maxUIntN(N);
 }
 
 /// isIntN - Checks if an signed integer fits into the given (dynamic)
 /// bit width.
 inline bool isIntN(unsigned N, int64_t x) {
-  return N >= 64 || (minIntN(N) <= x && x <= maxIntN(N));
+  return N >= 64 || (minIntN(N) <= x && x < maxIntN(N));
 }
 
 /// isMask_32 - This function returns true if the argument is a non-empty




More information about the llvm-commits mailing list