Fix a nondeterministic bug in APInt::roundToDouble;
authorDale Johannesen <dalej@apple.com>
Wed, 12 Aug 2009 17:42:34 +0000 (17:42 +0000)
committerDale Johannesen <dalej@apple.com>
Wed, 12 Aug 2009 17:42:34 +0000 (17:42 +0000)
when !isSingleWord() but getActiveBits() is small,
we were using the pointer value instead of the low
word of the integer value.

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

lib/Support/APInt.cpp

index a034fd1e797076b69a121fcfcee5a77f33861b52..6638fccfef581ca0d549542ae1c838cb8d1025a1 100644 (file)
@@ -897,10 +897,10 @@ double APInt::roundToDouble(bool isSigned) const {
   // Handle the simple case where the value is contained in one uint64_t.
   if (isSingleWord() || getActiveBits() <= APINT_BITS_PER_WORD) {
     if (isSigned) {
-      int64_t sext = (int64_t(VAL) << (64-BitWidth)) >> (64-BitWidth);
+      int64_t sext = (int64_t(getWord(0)) << (64-BitWidth)) >> (64-BitWidth);
       return double(sext);
     } else
-      return double(VAL);
+      return double(getWord(0));
   }
 
   // Determine if the value is negative.