Add an overload
authorChris Lattner <sabre@nondot.org>
Tue, 17 Aug 2004 19:17:10 +0000 (19:17 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 17 Aug 2004 19:17:10 +0000 (19:17 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15889 91177308-0d34-0410-b5e6-96231b3b80d8

include/Support/MathExtras.h
include/llvm/Support/MathExtras.h

index d5209854877e2fbda589385fd658d3660c504506..c1384d3eff502556bf2098eb5905fdaca8e3810d 100644 (file)
@@ -29,6 +29,13 @@ inline unsigned log2(uint64_t C) {
   return getPow;
 }
 
+inline unsigned log2(unsigned C) {
+  unsigned getPow;
+  for (getPow = 0; C > 1; ++getPow)
+    C >>= 1;
+  return getPow;
+}
+
 inline bool isPowerOf2(int64_t C, unsigned &getPow) {
   if (C < 0) C = -C;
   if (C > 0 && C == (C & ~(C - 1))) {
index d5209854877e2fbda589385fd658d3660c504506..c1384d3eff502556bf2098eb5905fdaca8e3810d 100644 (file)
@@ -29,6 +29,13 @@ inline unsigned log2(uint64_t C) {
   return getPow;
 }
 
+inline unsigned log2(unsigned C) {
+  unsigned getPow;
+  for (getPow = 0; C > 1; ++getPow)
+    C >>= 1;
+  return getPow;
+}
+
 inline bool isPowerOf2(int64_t C, unsigned &getPow) {
   if (C < 0) C = -C;
   if (C > 0 && C == (C & ~(C - 1))) {