mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-12 13:38:21 +00:00
APInt's countLeadingOnes() was broken for negative i128 values,
causing assertion failures in getSExtValue(). Fix it by making highWordBits actually contain what its name says, and add some more unit-tests for APInt. This fixes PR3419. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63107 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -683,7 +683,13 @@ unsigned APInt::countLeadingOnes() const {
|
||||
return countLeadingOnes_64(VAL, APINT_BITS_PER_WORD - BitWidth);
|
||||
|
||||
unsigned highWordBits = BitWidth % APINT_BITS_PER_WORD;
|
||||
unsigned shift = (highWordBits == 0 ? 0 : APINT_BITS_PER_WORD - highWordBits);
|
||||
unsigned shift;
|
||||
if (!highWordBits) {
|
||||
highWordBits = APINT_BITS_PER_WORD;
|
||||
shift = 0;
|
||||
} else {
|
||||
shift = APINT_BITS_PER_WORD - highWordBits;
|
||||
}
|
||||
int i = getNumWords() - 1;
|
||||
unsigned Count = countLeadingOnes_64(pVal[i], shift);
|
||||
if (Count == highWordBits) {
|
||||
|
Reference in New Issue
Block a user