As comments said, for negative value, the arithmetic
authorZhou Sheng <zhousheng00@gmail.com>
Thu, 5 Jun 2008 13:27:38 +0000 (13:27 +0000)
committerZhou Sheng <zhousheng00@gmail.com>
Thu, 5 Jun 2008 13:27:38 +0000 (13:27 +0000)
over-shift-right should return -1. So here it should be signed-extended,
when bitwidth larger than 64.

test case: llvm/test/ExecutionEngine/2008-06-05-APInt-OverAShr.ll

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51999 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/APInt.cpp

index ef35e1c554c8c20d74b2a3a2d33b075229700bcf..e13011faeac3f1fe5f3ac29c843138d6f832ed03 100644 (file)
@@ -1113,7 +1113,7 @@ APInt APInt::ashr(uint32_t shiftAmt) const {
   // issues in the algorithm below.
   if (shiftAmt == BitWidth) {
     if (isNegative())
-      return APInt(BitWidth, -1ULL);
+      return APInt(BitWidth, -1ULL, true);
     else
       return APInt(BitWidth, 0);
   }