From 461e0b352d5e403b2d0fad59028f9e0681f13c7a Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Tue, 18 Apr 2017 19:13:27 +0000 Subject: [PATCH] [APInt] Inline the single word case of lshrInPlace similar to what we do for <<=. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300577 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/APInt.h | 14 +++++++++++++- lib/Support/APInt.cpp | 10 +--------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/include/llvm/ADT/APInt.h b/include/llvm/ADT/APInt.h index 11fb489eaa7..59b3ba0e685 100644 --- a/include/llvm/ADT/APInt.h +++ b/include/llvm/ADT/APInt.h @@ -191,6 +191,9 @@ private: /// out-of-line slow case for shl void shlSlowCase(unsigned ShiftAmt); + /// out-of-line slow case for lshr. + void lshrSlowCase(unsigned ShiftAmt); + /// out-of-line slow case for operator= APInt &AssignSlowCase(const APInt &RHS); @@ -889,7 +892,16 @@ public: } /// Logical right-shift this APInt by ShiftAmt in place. - void lshrInPlace(unsigned ShiftAmt); + void lshrInPlace(unsigned ShiftAmt) { + if (isSingleWord()) { + if (ShiftAmt >= BitWidth) + VAL = 0; + else + VAL >>= ShiftAmt; + return; + } + lshrSlowCase(ShiftAmt); + } /// \brief Left-shift function. /// diff --git a/lib/Support/APInt.cpp b/lib/Support/APInt.cpp index 8b23179b44b..6303dd84907 100644 --- a/lib/Support/APInt.cpp +++ b/lib/Support/APInt.cpp @@ -1140,15 +1140,7 @@ void APInt::lshrInPlace(const APInt &shiftAmt) { /// Logical right-shift this APInt by shiftAmt. /// @brief Logical right-shift function. -void APInt::lshrInPlace(unsigned ShiftAmt) { - if (isSingleWord()) { - if (ShiftAmt >= BitWidth) - VAL = 0; - else - VAL >>= ShiftAmt; - return; - } - +void APInt::lshrSlowCase(unsigned ShiftAmt) { tcShiftRight(pVal, getNumWords(), ShiftAmt); } -- 2.11.0