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


> > #if (__GNUC__ * 1000 + __GNUC_MINOR__) >= 3004
> >   return (sizeof(HOST_WIDE_INT)*8-1) - __builtin_clz(x);
> 
> You've got to choose the proper version of clz, clzl, clzll.

Something like this?

#if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONGLONG
   return (sizeof(HOST_WIDE_INT)*8-1) - __builtin_clzll(x);
#else
#if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
   return (sizeof(HOST_WIDE_INT)*8-1) - __builtin_clzl(x);
#else
   return (sizeof(int)*8-1) - __builtin_clz(x);
#endif
#endif


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