From 6146e01ab10e97fa19ebfcf70b4597a7ca290d67 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Mon, 27 Mar 2017 20:07:31 +0000 Subject: [PATCH] [APInt] Move operator=(uint64_t) inline as its pretty simple and is often used with small constants that the compiler can optimize. While there recognize that we only need to clearUnusedBits on the single word case. llvm-svn: 298881 --- include/llvm/ADT/APInt.h | 11 ++++++++++- lib/Support/APInt.cpp | 10 ---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/include/llvm/ADT/APInt.h b/include/llvm/ADT/APInt.h index a29cfe5fbca..e527cebc057 100644 --- a/include/llvm/ADT/APInt.h +++ b/include/llvm/ADT/APInt.h @@ -676,7 +676,16 @@ public: /// than 64, the value is zero filled in the unspecified high order bits. /// /// \returns *this after assignment of RHS value. - APInt &operator=(uint64_t RHS); + APInt &operator=(uint64_t RHS) { + if (isSingleWord()) { + VAL = RHS; + clearUnusedBits(); + } else { + pVal[0] = RHS; + memset(pVal+1, 0, (getNumWords() - 1) * APINT_WORD_SIZE); + } + return *this; + } /// \brief Bitwise AND assignment operator. /// diff --git a/lib/Support/APInt.cpp b/lib/Support/APInt.cpp index ebcbb151867..f2c3a2db30c 100644 --- a/lib/Support/APInt.cpp +++ b/lib/Support/APInt.cpp @@ -157,16 +157,6 @@ APInt& APInt::AssignSlowCase(const APInt& RHS) { return clearUnusedBits(); } -APInt& APInt::operator=(uint64_t RHS) { - if (isSingleWord()) - VAL = RHS; - else { - pVal[0] = RHS; - memset(pVal+1, 0, (getNumWords() - 1) * APINT_WORD_SIZE); - } - return clearUnusedBits(); -} - /// This method 'profiles' an APInt for use with FoldingSet. void APInt::Profile(FoldingSetNodeID& ID) const { ID.AddInteger(BitWidth);