Search code examples
armneonintrinsics

About vsubq_u16(uint16x8_t, uint16x8_t)


About

vsubq_u16(uint16x8_t a, uint16x8_t b)

The return value is also uint16x8_t. Then if a is smaller than b, we will get a very large uint16x8_t instead of a negative value, it's not what I need.

If I have such requirement,

uint16_t c = fabs(uint16_t a - uint16_t b);

How can I transform to neon intrinsics? Thanks.


Solution

  • looks like you want the absolute difference between your inputs. If so the following intrinsic does exactly this:

    uint16x8_t vabdq_u16 (uint16x8_t, uint16x8_t)