arm neon compare operations generate negative one

后端 未结 2 1511
灰色年华
灰色年华 2021-01-22 07:00

I am trying the following assembly code:

vclt.f32 q9,q0,#0
vst1.i32 q9,[r2:128]

But if the condition is true, the corresponding element in q9 i

2条回答
  •  猫巷女王i
    2021-01-22 07:28

    This is normal for vector compare instructions, so you can use the compare result as a mask with AND or XOR instructions, or various other use-cases.

    You usually don't need a +1. If you want to count the number of elements that match, for example, just use a subtract instruction to subtract 0 or -1 from a vector accumulator.


    To get an integer +1, you could subtract it from 0, or right-shift by element-size -1. (e.g. logical right-shift by 31 to leave just the low bit 0 or 1, and the rest of the bits all-zero). You could also AND with a vector of +1s that you created earlier.

    I don't know which of these would be best for ARM, or if that would depend on the microarchitecture. (I really only know SIMD for x86 SSE/AVX.) I'm sure NEON can do at least one of the options I described, though.

提交回复
热议问题