Remove some DAG combiner assumptions about sizes

of integer types.  Fix the isMask APInt method to
actually work (hopefully) rather than crashing
because it adds apints of different bitwidths.
It looks like isShiftedMask is also broken, but
I'm leaving that one to the APInt people (it is
not used anywhere).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52142 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan Sands
2008-06-09 11:32:28 +00:00
parent eddc8f1f8b
commit 8eab8a2798
2 changed files with 24 additions and 30 deletions

View File

@@ -130,7 +130,7 @@ class APInt {
// the word size (64).
return *this;
// Mask out the hight bits.
// Mask out the high bits.
uint64_t mask = ~uint64_t(0ULL) >> (APINT_BITS_PER_WORD - wordBits);
if (isSingleWord())
VAL &= mask;
@@ -1280,7 +1280,8 @@ inline bool isSignedIntN(uint32_t N, const APInt& APIVal) {
/// @returns true if the argument APInt value is a sequence of ones
/// starting at the least significant bit with the remainder zero.
inline bool isMask(uint32_t numBits, const APInt& APIVal) {
return APIVal.getBoolValue() && ((APIVal + APInt(numBits,1)) & APIVal) == 0;
return numBits <= APIVal.getBitWidth() &&
APIVal == APInt::getLowBitsSet(APIVal.getBitWidth(), numBits);
}
/// @returns true if the argument APInt value contains a sequence of ones