[APInt] Make use of whichWord and maskBit to simplify some code. NFC

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299342 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Craig Topper 2017-04-02 19:35:18 +00:00
parent 6b60db9e91
commit c94363ef7c

View File

@ -2375,19 +2375,17 @@ bool APInt::tcIsZero(const WordType *src, unsigned parts) {
/* Extract the given bit of a bignum; returns 0 or 1. */
int APInt::tcExtractBit(const WordType *parts, unsigned bit) {
return (parts[bit / APINT_BITS_PER_WORD] &
((WordType) 1 << bit % APINT_BITS_PER_WORD)) != 0;
return (parts[whichWord(bit)] & maskBit(bit)) != 0;
}
/* Set the given bit of a bignum. */
void APInt::tcSetBit(WordType *parts, unsigned bit) {
parts[bit / APINT_BITS_PER_WORD] |= (WordType) 1 << (bit % APINT_BITS_PER_WORD);
parts[whichWord(bit)] |= maskBit(bit);
}
/* Clears the given bit of a bignum. */
void APInt::tcClearBit(WordType *parts, unsigned bit) {
parts[bit / APINT_BITS_PER_WORD] &=
~((WordType) 1 << (bit % APINT_BITS_PER_WORD));
parts[whichWord(bit)] &= ~maskBit(bit);
}
/* Returns the bit number of the least significant set bit of a