[llvm] r273727 - [APInt] Don't shift into the sign bit
David Majnemer via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 24 14:15:37 PDT 2016
Author: majnemer
Date: Fri Jun 24 16:15:36 2016
New Revision: 273727
URL: http://llvm.org/viewvc/llvm-project?rev=273727&view=rev
Log:
[APInt] Don't shift into the sign bit
Modified:
llvm/trunk/lib/Support/APInt.cpp
Modified: llvm/trunk/lib/Support/APInt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APInt.cpp?rev=273727&r1=273726&r2=273727&view=diff
==============================================================================
--- llvm/trunk/lib/Support/APInt.cpp (original)
+++ llvm/trunk/lib/Support/APInt.cpp Fri Jun 24 16:15:36 2016
@@ -880,7 +880,7 @@ double APInt::roundToDouble(bool isSigne
// 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));
More information about the llvm-commits
mailing list