- APInt API(*this);
- if (API.isSingleWord())
- API.VAL =
- (((int64_t(API.VAL) << (APINT_BITS_PER_WORD - API.BitWidth)) >>
- (APINT_BITS_PER_WORD - API.BitWidth)) >> shiftAmt) &
- (~uint64_t(0UL) >> (APINT_BITS_PER_WORD - API.BitWidth));
- else {
- if (shiftAmt >= API.BitWidth) {
- memset(API.pVal, API[API.BitWidth-1] ? 1 : 0,
- (API.getNumWords()-1) * APINT_WORD_SIZE);
- API.pVal[API.getNumWords() - 1] =
- ~uint64_t(0UL) >>
- (APINT_BITS_PER_WORD - API.BitWidth % APINT_BITS_PER_WORD);
- } else {
- uint32_t i = 0;
- for (; i < API.BitWidth - shiftAmt; ++i)
- if (API[i+shiftAmt])
- API.set(i);
- else
- API.clear(i);
- for (; i < API.BitWidth; ++i)
- if (API[API.BitWidth-1])
- API.set(i);
- else API.clear(i);
- }
+ if (isSingleWord()) {
+ if (shiftAmt == BitWidth)
+ return APInt(BitWidth, -1ull);
+ else
+ return APInt(BitWidth,
+ (((int64_t(VAL) << (APINT_BITS_PER_WORD - BitWidth)) >>
+ (APINT_BITS_PER_WORD - BitWidth)) >> shiftAmt) &
+ (~uint64_t(0UL) >> (APINT_BITS_PER_WORD - BitWidth)));