]> granicus.if.org Git - llvm/commitdiff
[APInt] Implement operator==(uint64_t) similar to ugt/ult(uint64_t) to remove one...
authorCraig Topper <craig.topper@gmail.com>
Wed, 19 Apr 2017 23:57:51 +0000 (23:57 +0000)
committerCraig Topper <craig.topper@gmail.com>
Wed, 19 Apr 2017 23:57:51 +0000 (23:57 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300799 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ADT/APInt.h
lib/Support/APInt.cpp

index 1eff4b69b2dc2025f34cc59a51db4fff24eff4ca..b87cf89bba5d8064b4e2937db785f6d02e60a230 100644 (file)
@@ -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.
index ad964e2f3c872802199176b2701fe4b1a7f54c7c..805a912501d08ecea72cb0f4a1d2acffecead9dc 100644 (file)
@@ -364,14 +364,6 @@ bool APInt::EqualSlowCase(const APInt& RHS) const {
   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())