mirror of
https://github.com/RPCS3/llvm.git
synced 2026-07-19 23:23:38 -04:00
[APInt] In sext single word case, use SignExtend64 and let the APInt constructor mask off any excess bits.
The current code is trying to be clever with shifts to avoid needing to clear unused bits. But it looks like the compiler is unable to optimize out the unused bit handling in the APInt constructor. Given this its better to just use SignExtend64 and have more readable code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301133 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -942,11 +942,8 @@ APInt APInt::trunc(unsigned width) const {
|
||||
APInt APInt::sext(unsigned width) const {
|
||||
assert(width > BitWidth && "Invalid APInt SignExtend request");
|
||||
|
||||
if (width <= APINT_BITS_PER_WORD) {
|
||||
uint64_t val = VAL << (APINT_BITS_PER_WORD - BitWidth);
|
||||
val = (int64_t)val >> (width - BitWidth);
|
||||
return APInt(width, val >> (APINT_BITS_PER_WORD - width));
|
||||
}
|
||||
if (width <= APINT_BITS_PER_WORD)
|
||||
return APInt(width, SignExtend64(VAL, BitWidth));
|
||||
|
||||
APInt Result(getMemory(getNumWords(width)), width);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user