Search code examples
assemblyarm64-bitneon

armv8-a: test if SIMD register is != 0


It's a question very similar to this one.

On armv7-a, I have the following assembly code:

vcmp.f64 d0, #0
vmrs APSR_nzcv, fpscr
beq .jumpover

How can I convert this code to armv8-a? I want to test if there is any non-zero pixel in v0.16b.

EDIT #1

I was thinking about something like:

addv b0, v0.16b
fcmp s0, #0.0
beq .jumpover

Is this correct? Also, I read the following statement "Floating point FCMP and FCCMP instructions set the integer condition flags directly, and do not modify the condition flags in the FPSR." which I'm not 100% sure to understand.


Solution

  • sh1 in the comments found a working solution:

    mov x0, v0.d[0]
    cmp x0, #0
    beq .jumpover
    
    mov x0, v0.d[1]
    cmp x0, #0
    beq .jumpover
    

    You have to do it for both d[0] and d[1] to check the 16 pixels.