diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2007-03-02 01:19:42 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2007-03-02 01:19:42 +0000 |
commit | c442c84c8f0cdb277deeeb98296b672e0eba8138 (patch) | |
tree | 179d077f76f5640559a21b429a5582f3e6b33ae9 /llvm/lib/Support | |
parent | 32bc81341bdb27830cd1f4677ea4d4a7362d5ddf (diff) | |
download | bcm5719-llvm-c442c84c8f0cdb277deeeb98296b672e0eba8138.tar.gz bcm5719-llvm-c442c84c8f0cdb277deeeb98296b672e0eba8138.zip |
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".
llvm-svn: 34825
Diffstat (limited to 'llvm/lib/Support')
-rw-r--r-- | llvm/lib/Support/APInt.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/Support/APInt.cpp b/llvm/lib/Support/APInt.cpp index 9b000da0ee3..36f88a24798 100644 --- a/llvm/lib/Support/APInt.cpp +++ b/llvm/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 |