Replace a hand-coded leading one counting loop with the magic from MathExtras.h.
authorBenjamin Kramer <benny.kra@googlemail.com>
Sun, 11 Mar 2012 19:32:35 +0000 (19:32 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Sun, 11 Mar 2012 19:32:35 +0000 (19:32 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152545 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/APInt.cpp

index 031bbb8882423a60fdb41fd652fcd6235eabc7dd..a60bff330633269e01b03160d734d8d645bd1e98 100644 (file)
@@ -723,14 +723,7 @@ unsigned APInt::countLeadingZerosSlowCase() const {
 }
 
 static unsigned countLeadingOnes_64(uint64_t V, unsigned skip) {
-  unsigned Count = 0;
-  if (skip)
-    V <<= skip;
-  while (V && (V & (1ULL << 63))) {
-    Count++;
-    V <<= 1;
-  }
-  return Count;
+  return CountLeadingOnes_64(V << skip);
 }
 
 unsigned APInt::countLeadingOnes() const {