[APSInt] Make use of APInt's recently acquired in place lshr and shl capabilities...
authorCraig Topper <craig.topper@gmail.com>
Fri, 21 Apr 2017 22:30:06 +0000 (22:30 +0000)
committerCraig Topper <craig.topper@gmail.com>
Fri, 21 Apr 2017 22:30:06 +0000 (22:30 +0000)
APInt hasn't acquired an in place ashr yet, but hopefully soon.

llvm-svn: 301052

llvm/include/llvm/ADT/APSInt.h

index 5b6dfa4..5553421 100644 (file)
@@ -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;
   }