Justin Ruggles <justin.rugg...@gmail.com> writes: > +/** > + * @addtogroup lavu_math > + * @{ > + */ > + > +#if AV_GCC_VERSION_AT_LEAST(3,4) > +#ifndef ff_ctz > +# define ff_ctz(v) (__builtin_ctz(v)) > +#endif > +#endif > + > +#ifndef ff_ctz > +#define ff_ctz ff_ctz_c > +static av_always_inline av_const int ff_ctz_c(int v) > +{ > + return av_log2(v & -v); > +} > +#endif
Sorry, I was a bit unclear earlier. We probably don't want to use the table-based av_log2 for this. There are a bunch of CPUs that don't have a CTZ instruction but do have a CLZ instruction, and those benefit from that trick. However, gcc seems to know about that in the cases I checked. I'd be more worried about gcc messing up completely with __builtin_ctz() when there is no CTZ or CLZ instruction. Their fallback implementation of __builtin_clz() at least used to be pretty poor. -- Måns Rullgård m...@mansr.com _______________________________________________ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel