summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@gmail.com>2017-04-24 05:38:26 +0000
committerCraig Topper <craig.topper@gmail.com>2017-04-24 05:38:26 +0000
commitfc03d2d21f9f364b2d5ab41f42625a1c98eab351 (patch)
treed30fb88f74ee5aace8857b28b2ad021ba79f544d /llvm/lib/Support
parent4bac44c8054f30ace47088d7a22e992c02e6c12b (diff)
downloadbcm5719-llvm-fc03d2d21f9f364b2d5ab41f42625a1c98eab351.tar.gz
bcm5719-llvm-fc03d2d21f9f364b2d5ab41f42625a1c98eab351.zip
[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. llvm-svn: 301159
Diffstat (limited to 'llvm/lib/Support')
-rw-r--r--llvm/lib/Support/APInt.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp
index 3f552db7963..e056f8ba853 100644
--- a/llvm/lib/Support/APInt.cpp
+++ b/llvm/lib/Support/APInt.cpp
@@ -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);
}
OpenPOWER on IntegriCloud