This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: floor_log2_wide speedup
- From: DJ Delorie <dj at redhat dot com>
- To: pinskia at physics dot uc dot edu
- Cc: jsm at polyomino dot org dot uk, gcc-patches at gcc dot gnu dot org
- Date: Fri, 28 May 2004 20:39:16 -0400
- Subject: Re: floor_log2_wide speedup
- References: <200405290007.i4T07oP14191@tin.geop.uc.edu>
> What about changing this into a static inline function and put it into
> toplev.h, this way the compiler can optimize the function call out if
> the instuction is implemented otherwise we would than just call the
> function in libgcc.c as a libcall.
floor_log2_wide is already called through a macro in toplev.h, so we
could #define that macro to an inline with the builtin where
appropriate.
#if ...
#define floor_log2(x) (x) ? (sizeof(x)*8-1) - __builtin_clz(x) : -1
#else
...
Hmmm... might need the inline to handle cases where (x) isn't a simple
variable.
But yeah, good idea.