From 00b47eec0fb07236269bab00d1a5d085b39acff3 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Sun, 2 Apr 2017 19:35:18 +0000 Subject: [PATCH] [APInt] Make use of whichWord and maskBit to simplify some code. NFC llvm-svn: 299342 --- llvm/lib/Support/APInt.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp index 6f5df52..00b340e 100644 --- a/llvm/lib/Support/APInt.cpp +++ b/llvm/lib/Support/APInt.cpp @@ -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 -- 2.7.4