mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-01-29 22:00:58 +02:00
libavutil: add bmi2 optimized av_mod_uintp2
Reviewed-by: Michael Niedermayer <michaelni@gmx.at> Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
parent
d13e521cc8
commit
60b9373dbd
@ -24,15 +24,35 @@
|
||||
#include <stdint.h>
|
||||
#include "config.h"
|
||||
|
||||
#if defined(__GNUC__)
|
||||
|
||||
/* Our generic version of av_popcount is faster than GCC's built-in on
|
||||
* CPUs that don't support the popcnt instruction.
|
||||
*/
|
||||
#if defined(__GNUC__) && defined(__POPCNT__)
|
||||
#if defined(__POPCNT__)
|
||||
#define av_popcount __builtin_popcount
|
||||
#if ARCH_X86_64
|
||||
#define av_popcount64 __builtin_popcountll
|
||||
#endif
|
||||
|
||||
#endif /* defined(__GNUC__) && defined(__POPCNT__) */
|
||||
#endif /* __POPCNT__ */
|
||||
|
||||
#if defined(__BMI2__)
|
||||
|
||||
#define av_mod_uintp2 av_mod_uintp2_bmi2
|
||||
static av_always_inline av_const unsigned av_mod_uintp2_bmi2(unsigned a, unsigned p)
|
||||
{
|
||||
if (av_builtin_constant_p(p))
|
||||
return a & ((1 << p) - 1);
|
||||
else {
|
||||
unsigned x;
|
||||
__asm__ ("bzhi %2, %1, %0 \n\t" : "=r"(x) : "rm"(a), "r"(p));
|
||||
return x;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* __BMI2__ */
|
||||
|
||||
#endif /* __GNUC__ */
|
||||
|
||||
#endif /* AVUTIL_X86_INTMATH_H */
|
||||
|
Loading…
x
Reference in New Issue
Block a user