Ammar
Ammar

Reputation: 71

neon assembly vector instructions that affect flags

I use arm assembly and NEON SIMD instructions. I want to get the maximum of 16 bit unsigned values which are in two Q registers and compare them with a threshold. If all the 16 bit values are smaller than the threshold, I call a function. If one or more values are larger than a threshold, I call another function.

The following SIMD instructions gets the maximum.

// threshold is an r register

vdup.16       q15, threshold  
vmax.u16      q12, q14, q13  
vcgt.u16      q11, q12, q15

Does vcgt affect the FPSCR flags? I think not. Then I have to check if q11 is zero or not. If it is zeor, call function1, otherwise call function2. It would be like

if (q11 == 0)
//call function1
else
//call function2 

How can I do it without moving q11 to 4 r registers?

Thanks

Upvotes: 3

Views: 386

Answers (1)

There isn't any - at least not in the user mode. Those cmp instructions create mask vectors that you choose values between two results based upon.

  1. create a mask with the appropriate vcmp
  2. calculate results for both cases
  3. use the mask from 1 to put the corresponding elements to each lane from both results above.

Currently I cannot tell you precisely what the instructions are since I'm writing this on my iPhone in a train. But it won't be a problem finding them in the reference manual.

Upvotes: 2

Related Questions