summaryrefslogtreecommitdiff
path: root/gcc/hwint.h
diff options
context:
space:
mode:
authorSteven Bosscher <steven@gcc.gnu.org>2012-06-17 21:01:25 +0000
committerSteven Bosscher <steven@gcc.gnu.org>2012-06-17 21:01:25 +0000
commit46d33ae927892aa2fbec97dfa90f7bd9a055a1bb (patch)
treea4d54b10f7c0db155dd485fd849fee5c27f1b77c /gcc/hwint.h
parent0df965d73f62798d8b9288a27c351502edbb1831 (diff)
expmed.c (ceil_log2): Move from here...
* expmed.c (ceil_log2): Move from here... * hwint.c: ... to here for older GCCs... * hwint.h: ... and here for newer GCCs. * rtl.h (ceil_log2): Remove prototype. * tree-phinodes.c: Do not include rtl.h. * Makefile.in (tree-phinodes.o): Do not depend on RTL_H. From-SVN: r188710
Diffstat (limited to 'gcc/hwint.h')
-rw-r--r--gcc/hwint.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/gcc/hwint.h b/gcc/hwint.h
index 17346392f91..00c9538fb11 100644
--- a/gcc/hwint.h
+++ b/gcc/hwint.h
@@ -185,6 +185,9 @@ extern int exact_log2 (unsigned HOST_WIDE_INT);
/* Return floor of log2, with -1 for zero. */
extern int floor_log2 (unsigned HOST_WIDE_INT);
+/* Return the smallest n such that 2**n >= X. */
+extern int ceil_log2 (unsigned HOST_WIDE_INT);
+
#else /* GCC_VERSION >= 3004 */
/* For convenience, define 0 -> word_size. */
@@ -235,6 +238,12 @@ floor_log2 (unsigned HOST_WIDE_INT x)
}
static inline int
+ceil_log2 (unsigned HOST_WIDE_INT x)
+{
+ return floor_log2 (x - 1) + 1;
+}
+
+static inline int
exact_log2 (unsigned HOST_WIDE_INT x)
{
return x == (x & -x) && x ? ctz_hwi (x) : -1;