From: Craig Topper Date: Fri, 21 Apr 2017 22:30:06 +0000 (+0000) Subject: [APSInt] Make use of APInt's recently acquired in place lshr and shl capabilities... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e8b9699699499f3dfaf2b76ce6cd0727a34949ec;p=llvm [APSInt] Make use of APInt's recently acquired in place lshr and shl capabilities in APSInt's >>= and <<= operators. APInt hasn't acquired an in place ashr yet, but hopefully soon. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301052 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/ADT/APSInt.h b/include/llvm/ADT/APSInt.h index 5b6dfa4a4b6..5553421fb6c 100644 --- a/include/llvm/ADT/APSInt.h +++ b/include/llvm/ADT/APSInt.h @@ -125,7 +125,10 @@ public: return IsUnsigned ? APSInt(lshr(Amt), true) : APSInt(ashr(Amt), false); } APSInt& operator>>=(unsigned Amt) { - *this = *this >> Amt; + if (IsUnsigned) + lshrInPlace(Amt); + else + *this = *this >> Amt; return *this; } @@ -179,7 +182,7 @@ public: return APSInt(static_cast(*this) << Bits, IsUnsigned); } APSInt& operator<<=(unsigned Amt) { - *this = *this << Amt; + static_cast(*this) <<= Amt; return *this; }