<p dir="ltr">Will do.</p>
<div class="gmail_quote">On 2 Jun 2016 05:05, "David Blaikie" <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Please include/provide a test case - these could probably use a bunch of unit tests.</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 1, 2016 at 4:15 AM, Dylan McKay via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: dylanmckay<br>
Date: Wed Jun  1 06:15:25 2016<br>
New Revision: 271380<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=271380&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=271380&view=rev</a><br>
Log:<br>
Fix off-by-one error in max integer functions<br>
<br>
I recently added these functions, but implemented them poorly. This<br>
fixes that.<br>
<br>
Sorry for the spam.<br>
<br>
Modified:<br>
    llvm/trunk/include/llvm/Support/MathExtras.h<br>
<br>
Modified: llvm/trunk/include/llvm/Support/MathExtras.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/MathExtras.h?rev=271380&r1=271379&r2=271380&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/MathExtras.h?rev=271380&r1=271379&r2=271380&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/Support/MathExtras.h (original)<br>
+++ llvm/trunk/include/llvm/Support/MathExtras.h Wed Jun  1 06:15:25 2016<br>
@@ -312,22 +312,22 @@ inline bool isShiftedUInt(uint64_t x) {<br>
 }<br>
<br>
 /// Gets the maximum value for a N-bit unsigned integer.<br>
-inline uint64_t maxUIntN(uint64_t N) { return UINT64_C(1) << N; }<br>
+inline uint64_t maxUIntN(uint64_t N) { return (UINT64_C(1) << N) - 1; }<br>
 /// Gets the minimum value for a N-bit signed integer.<br>
 inline int64_t minIntN(int64_t N) { return -(INT64_C(1)<<(N-1)); }<br>
 /// Gets the maximum value for a N-bit signed integer.<br>
-inline int64_t maxIntN(int64_t N) { return INT64_C(1)<<(N-1); }<br>
+inline int64_t maxIntN(int64_t N) { return (INT64_C(1)<<(N-1)) - 1; }<br>
<br>
 /// isUIntN - Checks if an unsigned integer fits into the given (dynamic)<br>
 /// bit width.<br>
 inline bool isUIntN(unsigned N, uint64_t x) {<br>
-  return N >= 64 || x < maxUIntN(N);<br>
+  return N >= 64 || x <= maxUIntN(N);<br>
 }<br>
<br>
 /// isIntN - Checks if an signed integer fits into the given (dynamic)<br>
 /// bit width.<br>
 inline bool isIntN(unsigned N, int64_t x) {<br>
-  return N >= 64 || (minIntN(N) <= x && x < maxIntN(N));<br>
+  return N >= 64 || (minIntN(N) <= x && x <= maxIntN(N));<br>
 }<br>
<br>
 /// isMask_32 - This function returns true if the argument is a non-empty<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>
</blockquote></div>