This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: floor_log2_wide speedup


> 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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]