[FFmpeg-devel] [PATCH] lavc/aarch64: add some neon pix_abs functions

Martin Storsjö martin at martin.st
Tue Mar 15 00:39:34 EET 2022


On Mon, 7 Mar 2022, Pop, Sebastian wrote:

> Here are a few suggestions:
>
>> +        add     d18, d17, d18               // add to the end result register
>> [...]
>> +        mov     w0, v18.S[0]                // copy result to general purpose register
>
> I think you can use 32-bit register s18 instead of d18.
> The mov with indexed vector is more expensive than fmov.

Oh, I hadn't considered that. In a tight loop, I can indeed measure a 
quite significant difference between those.

> add    s18, s18, s17
> fmov  w0, s18
>
>> +        subs    w4, w4, #1                  // decrement h and set flags for branch below
>> [...]
>> +        b.ne    2b                          // branch based on subs instruction above
>
> Please avoid the flags register to branch.
> Instead you could do:
>
> sub   w4, w4, #1
> cbnz w4, 2b

If there are other instructions between the sub and the b.ne, does this 
make any difference? (In most cases one can move the decrement into a 
suitable gap early in the loop anyway.) I.e. if the flags register already 
is set since long ago, naively I'd expect that b.ne would be faster (or at 
least not slower) than cbnz.

Some benchmarking on Cortex A53, A72 and A73 seems to agree with my 
expectations too. (It'd be good if we'd have the patch at hand hooked up 
in checkasm, so that we could measure and compare exactly the function at 
hand.)

// Martin



More information about the ffmpeg-devel mailing list