[FFmpeg-devel] [PATCH] x86inc: Make cpuflag() and notcpuflag() return 0 or 1

Ronald S. Bultje rsbultje at gmail.com
Thu Oct 1 03:46:22 CEST 2015


Hi,

On Wed, Sep 30, 2015 at 5:27 PM, Henrik Gramner <henrik at gramner.com> wrote:

> Makes it possible to use them in arithmetic expressions.
> ---
>  libavutil/x86/x86inc.asm | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libavutil/x86/x86inc.asm b/libavutil/x86/x86inc.asm
> index 6ad9785..929d0d2 100644
> --- a/libavutil/x86/x86inc.asm
> +++ b/libavutil/x86/x86inc.asm
> @@ -773,8 +773,8 @@ BRANCH_INSTR jz, je, jnz, jne, jl, jle, jnl, jnle, jg,
> jge, jng, jnge, ja, jae,
>  %assign cpuflags_bmi1     (1<<22)|cpuflags_lzcnt
>  %assign cpuflags_bmi2     (1<<23)|cpuflags_bmi1
>
> -%define    cpuflag(x) ((cpuflags & (cpuflags_ %+ x)) == (cpuflags_ %+ x))
> -%define notcpuflag(x) ((cpuflags & (cpuflags_ %+ x)) != (cpuflags_ %+ x))
> +%define    cpuflag(x) (((((cpuflags & (cpuflags_ %+ x)) ^ (cpuflags_ %+
> x)) - 1) >> 31) & 1)
> +%define notcpuflag(x) (cpuflag(x) ^ 1)
>
>  ; Takes an arbitrary number of cpuflags from the above list.
>  ; All subsequent functions (up to the next INIT_CPUFLAGS) is built for
> the specified cpu.
> --
> 1.9.1


Wow, many operands. Looks OK, although I have to admit this isn't exactly
world-readable anymore :) I guess for this type of code that's OK...

Ronald


More information about the ffmpeg-devel mailing list