[llvm] r300799 - [APInt] Implement operator==(uint64_t) similar to ugt/ult(uint64_t) to remove one of the out of line EqualsSlowCase methods.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 19 16:57:51 PDT 2017
Author: ctopper
Date: Wed Apr 19 18:57:51 2017
New Revision: 300799
URL: http://llvm.org/viewvc/llvm-project?rev=300799&view=rev
Log:
[APInt] Implement operator==(uint64_t) similar to ugt/ult(uint64_t) to remove one of the out of line EqualsSlowCase methods.
Modified:
llvm/trunk/include/llvm/ADT/APInt.h
llvm/trunk/lib/Support/APInt.cpp
Modified: llvm/trunk/include/llvm/ADT/APInt.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/APInt.h?rev=300799&r1=300798&r2=300799&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/APInt.h (original)
+++ llvm/trunk/include/llvm/ADT/APInt.h Wed Apr 19 18:57:51 2017
@@ -200,9 +200,6 @@ private:
/// out-of-line slow case for operator==
bool EqualSlowCase(const APInt &RHS) const LLVM_READONLY;
- /// out-of-line slow case for operator==
- bool EqualSlowCase(uint64_t Val) const LLVM_READONLY;
-
/// out-of-line slow case for countLeadingZeros
unsigned countLeadingZerosSlowCase() const LLVM_READONLY;
@@ -1031,9 +1028,7 @@ public:
///
/// \returns true if *this == Val
bool operator==(uint64_t Val) const {
- if (isSingleWord())
- return VAL == Val;
- return EqualSlowCase(Val);
+ return (isSingleWord() || getActiveBits() <= 64) && getZExtValue() == Val;
}
/// \brief Equality comparison.
Modified: llvm/trunk/lib/Support/APInt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/APInt.cpp?rev=300799&r1=300798&r2=300799&view=diff
==============================================================================
--- llvm/trunk/lib/Support/APInt.cpp (original)
+++ llvm/trunk/lib/Support/APInt.cpp Wed Apr 19 18:57:51 2017
@@ -364,14 +364,6 @@ bool APInt::EqualSlowCase(const APInt& R
return std::equal(pVal, pVal + getNumWords(), RHS.pVal);
}
-bool APInt::EqualSlowCase(uint64_t Val) const {
- unsigned n = getActiveBits();
- if (n <= APINT_BITS_PER_WORD)
- return pVal[0] == Val;
- else
- return false;
-}
-
bool APInt::ult(const APInt& RHS) const {
assert(BitWidth == RHS.BitWidth && "Bit widths must be same for comparison");
if (isSingleWord())
More information about the llvm-commits
mailing list