From 87d5e72f1d1ec87799ea1966eb189931b17c2006 Mon Sep 17 00:00:00 2001
From: David Majnemer <david.majnemer@gmail.com>
Date: Fri, 24 Jun 2016 21:15:36 +0000
Subject: [PATCH] [APInt] Don't shift into the sign bit

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273727 91177308-0d34-0410-b5e6-96231b3b80d8
---
 lib/Support/APInt.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/Support/APInt.cpp b/lib/Support/APInt.cpp
index 348f807c91a..9eed2147746 100644
--- a/lib/Support/APInt.cpp
+++ b/lib/Support/APInt.cpp
@@ -880,7 +880,7 @@ double APInt::roundToDouble(bool isSigned) const {
   // It is wrong to optimize getWord(0) to VAL; there might be more than one word.
   if (isSingleWord() || getActiveBits() <= APINT_BITS_PER_WORD) {
     if (isSigned) {
-      int64_t sext = (int64_t(getWord(0)) << (64-BitWidth)) >> (64-BitWidth);
+      int64_t sext = SignExtend64(getWord(0), BitWidth);
       return double(sext);
     } else
       return double(getWord(0));