aboutsummaryrefslogtreecommitdiff
path: root/lib/Support/APInt.cpp
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2007-03-02 01:19:42 +0000
committerReid Spencer <rspencer@reidspencer.com>2007-03-02 01:19:42 +0000
commit36184ed4cd8dc0dc302b8f51f169c334b7460168 (patch)
treea16381bcee74ba73de6d9855d6ef130ca54025ca /lib/Support/APInt.cpp
parent9f8e50d4ed7dcc5ca0f137830ff1185b2afa38bf (diff)
Fix a problem where shifting by 64-bits leads to incorrect results on PPC
but not on X86 becuase shift by word size is "undefined". git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34825 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/APInt.cpp')
-rw-r--r--lib/Support/APInt.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/Support/APInt.cpp b/lib/Support/APInt.cpp
index 9b000da0ee..36f88a2479 100644
--- a/lib/Support/APInt.cpp
+++ b/lib/Support/APInt.cpp
@@ -938,7 +938,10 @@ APInt &APInt::sext(uint32_t width) {
if (wordsBefore == wordsAfter) {
uint32_t newWordBits = width % APINT_BITS_PER_WORD;
// The extension is contained to the wordsBefore-1th word.
- uint64_t mask = (~0ULL >> (APINT_BITS_PER_WORD - newWordBits)) << wordBits;
+ uint64_t mask = ~0ULL;
+ if (newWordBits)
+ mask >>= APINT_BITS_PER_WORD - newWordBits;
+ mask <<= wordBits;
if (wordsBefore == 1)
VAL |= mask;
else