We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e8f01b0 commit bcb15d0Copy full SHA for bcb15d0
llvm/lib/Support/APInt.cpp
@@ -1055,11 +1055,10 @@ void APInt::ashrSlowCase(unsigned ShiftAmt) {
1055
U.pVal[i] = (U.pVal[i + WordShift] >> BitShift) |
1056
(U.pVal[i + WordShift + 1] << (APINT_BITS_PER_WORD - BitShift));
1057
1058
- // Handle the last word which has no high bits to copy.
1059
- U.pVal[WordsToMove - 1] = U.pVal[WordShift + WordsToMove - 1] >> BitShift;
1060
- // Sign extend one more time.
+ // Handle the last word which has no high bits to copy. Use an arithmetic
+ // shift to preserve the sign bit.
1061
U.pVal[WordsToMove - 1] =
1062
- SignExtend64(U.pVal[WordsToMove - 1], APINT_BITS_PER_WORD - BitShift);
+ (int64_t)U.pVal[WordShift + WordsToMove - 1] >> BitShift;
1063
}
1064
1065
0 commit comments