This makes a code a bit more clear and also gets rid of C4146 warning
on MSVC compiler:
'unary minus operator applied to unsigned type, result still unsigned'.
In case uint64_t variable is initialized or compared against -1U expression,
which corresponds to 32-bit constant, UINT_MAX macro is used to preserve
NFC semantics; -1ULL is replaced with UINT64_MAX.
Reviewed By: dblaikie, craig.topper
Differential Revision: https://reviews.llvm.org/
D143942
BlockFrequency(uint64_t Freq = 0) : Frequency(Freq) { }
/// Returns the maximum possible frequency, the saturation value.
- static uint64_t getMaxFrequency() { return -1ULL; }
+ static uint64_t getMaxFrequency() { return UINT64_MAX; }
/// Returns the frequency as a fixpoint number scaled by the entry
/// frequency.
} while (Byte >= 128);
// Sign extend negative numbers if needed.
if (Shift < 64 && (Byte & 0x40))
- Value |= (-1ULL) << Shift;
+ Value |= UINT64_MAX << Shift;
if (n)
*n = (unsigned)(p - orig_p);
return Value;
/* If we ran off the end it is exactly zero or one-half, otherwise
a little more. */
- if (hexDigit == -1U)
+ if (hexDigit == UINT_MAX)
return digitValue == 0 ? lfExactlyZero: lfExactlyHalf;
else
return digitValue == 0 ? lfLessThanHalf: lfMoreThanHalf;
lsb = APInt::tcLSB(parts, partCount);
- /* Note this is guaranteed true if bits == 0, or LSB == -1U. */
+ /* Note this is guaranteed true if bits == 0, or LSB == UINT_MAX. */
if (bits <= lsb)
return lfExactlyZero;
if (bits == lsb + 1)
}
hex_value = hexDigitValue(*p);
- if (hex_value == -1U)
+ if (hex_value == UINT_MAX)
break;
p++;
if (r < radix)
return r;
- return -1U;
+ return UINT_MAX;
}
}
/// Returns the bit number of the least significant set bit of a number. If the
-/// input number has no bits set -1U is returned.
+/// input number has no bits set UINT_MAX is returned.
unsigned APInt::tcLSB(const WordType *parts, unsigned n) {
for (unsigned i = 0; i < n; i++) {
if (parts[i] != 0) {
}
}
- return -1U;
+ return UINT_MAX;
}
/// Returns the bit number of the most significant set bit of a number.
-/// If the input number has no bits set -1U is returned.
+/// If the input number has no bits set UINT_MAX is returned.
unsigned APInt::tcMSB(const WordType *parts, unsigned n) {
do {
--n;
}
} while (n);
- return -1U;
+ return UINT_MAX;
}
/// Copy the bit vector of width srcBITS from SRC, starting at bit srcLSB, to