[APInt] Make behavior of ashr by BitWidth consistent between single and multi word.

Previously single word would always return 0 regardless of the original sign. Multi word would return all 0s or all 1s based on the original sign. Now single word takes into account the sign as well.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301159 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Craig Topper
2017-04-24 05:38:26 +00:00
parent ccb223e38e
commit 6a61317c63
2 changed files with 4 additions and 2 deletions
+3 -1
View File
@@ -1041,7 +1041,9 @@ APInt APInt::ashr(unsigned shiftAmt) const {
// Handle single word shifts with built-in ashr
if (isSingleWord()) {
if (shiftAmt == BitWidth)
return APInt(BitWidth, 0); // undefined
// Undefined
return APInt(BitWidth,
SignExtend64(VAL, BitWidth) >> (APINT_BITS_PER_WORD - 1));
return APInt(BitWidth, SignExtend64(VAL, BitWidth) >> shiftAmt);
}