From 46d33ae927892aa2fbec97dfa90f7bd9a055a1bb Mon Sep 17 00:00:00 2001 From: Steven Bosscher Date: Sun, 17 Jun 2012 21:01:25 +0000 Subject: 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 --- gcc/hwint.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'gcc/hwint.c') diff --git a/gcc/hwint.c b/gcc/hwint.c index 533133c7b4d..bfc5e3dedcd 100644 --- a/gcc/hwint.c +++ b/gcc/hwint.c @@ -25,10 +25,11 @@ along with GCC; see the file COPYING3. If not see #if GCC_VERSION < 3004 -/* The functions clz_hwi, ctz_hwi, ffs_hwi, floor_log2 and exact_log2 - are defined as inline functions in hwint.h if GCC_VERSION >= 3004. - The definitions here are used for older versions of GCC and non-GCC - bootstrap compilers. */ +/* The functions clz_hwi, ctz_hwi, ffs_hwi, floor_log2, ceil_log2, + and exact_log2 are defined as inline functions in hwint.h + if GCC_VERSION >= 3004. + The definitions here are used for older versions of GCC and + non-GCC bootstrap compilers. */ /* Given X, an unsigned number, return the largest int Y such that 2**Y <= X. If X is 0, return -1. */ @@ -61,6 +62,14 @@ floor_log2 (unsigned HOST_WIDE_INT x) return t; } +/* Given X, an unsigned number, return the largest Y such that 2**Y >= X. */ + +int +ceil_log2 (unsigned HOST_WIDE_INT x) +{ + return floor_log2 (x - 1) + 1; +} + /* Return the logarithm of X, base 2, considering X unsigned, if X is a power of 2. Otherwise, returns -1. */ -- cgit v1.2.3