[PATCH] D16620: APInt: Simplify and Optimize EqualSlowCase

Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 10 14:17:32 PST 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL260447: APInt: Simplify EqualSlowCase (authored by matze).

Changed prior to commit:
  http://reviews.llvm.org/D16620?vs=46094&id=47522#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D16620

Files:
  llvm/trunk/lib/Support/APInt.cpp

Index: llvm/trunk/lib/Support/APInt.cpp
===================================================================
--- llvm/trunk/lib/Support/APInt.cpp
+++ llvm/trunk/lib/Support/APInt.cpp
@@ -490,21 +490,8 @@
 }
 
 bool APInt::EqualSlowCase(const APInt& RHS) const {
-  // Get some facts about the number of bits used in the two operands.
-  unsigned n1 = getActiveBits();
-  unsigned n2 = RHS.getActiveBits();
-
-  // If the number of bits isn't the same, they aren't equal
-  if (n1 != n2)
-    return false;
-
-  // If the number of bits fits in a word, we only need to compare the low word.
-  if (n1 <= APINT_BITS_PER_WORD)
-    return pVal[0] == RHS.pVal[0];
-
-  // Otherwise, compare everything
-  for (int i = whichWord(n1 - 1); i >= 0; --i)
-    if (pVal[i] != RHS.pVal[i])
+  for (unsigned I = 0, NumWords = getNumWords(); I < NumWords; ++I)
+    if (pVal[I] != RHS.pVal[I])
       return false;
   return true;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16620.47522.patch
Type: text/x-patch
Size: 920 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160210/85bedef8/attachment.bin>


More information about the llvm-commits mailing list