From 19ce7adc7fcf900a78d6b61875b0920085603ba8 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Fri, 21 Apr 2017 22:30:06 +0000 Subject: [PATCH] [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. llvm-svn: 301052 --- llvm/include/llvm/ADT/APSInt.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/llvm/include/llvm/ADT/APSInt.h b/llvm/include/llvm/ADT/APSInt.h index 5b6dfa4..5553421 100644 --- a/llvm/include/llvm/ADT/APSInt.h +++ b/llvm/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; } -- 2.7.4