[llvm] r301052 - [APSInt] Make use of APInt's recently acquired in place lshr and shl capabilities in APSInt's >>= and <<= operators.

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 21 15:30:06 PDT 2017


Author: ctopper
Date: Fri Apr 21 17:30:06 2017
New Revision: 301052

URL: http://llvm.org/viewvc/llvm-project?rev=301052&view=rev
Log:
[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.

Modified:
    llvm/trunk/include/llvm/ADT/APSInt.h

Modified: llvm/trunk/include/llvm/ADT/APSInt.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/APSInt.h?rev=301052&r1=301051&r2=301052&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/APSInt.h (original)
+++ llvm/trunk/include/llvm/ADT/APSInt.h Fri Apr 21 17:30:06 2017
@@ -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<const APInt&>(*this) << Bits, IsUnsigned);
   }
   APSInt& operator<<=(unsigned Amt) {
-    *this = *this << Amt;
+    static_cast<APInt&>(*this) <<= Amt;
     return *this;
   }
 




More information about the llvm-commits mailing list