Question

I want to compare 2 int8x8_t, From http://gcc.gnu.org/onlinedocs/gcc/ARM-NEON-Intrinsics.html we can get the description for vclt_s8, but it does not tell us much details.

`uint8x8_t vclt_s8 (int8x8_t, int8x8_t)`

Form of expected instruction(s): vcgt.s8 d0, d0, d0

the return value uint8x8_t, it confuse me for I can not use if(vclt_s8(a, b)) to decide the first is smaller.

Then suppose we have two int8x8_t: int8x8_t a and int8x8_t b, how do we know whether a is smaller?

Était-ce utile?

La solution

You may find more details in the official ARM documentation for NEON.

The generic description for all comparison functions states:

If the comparison is true for a lane, the result in that lane is all bits set to one. If the comparison is false for a lane, all bits are set to zero. The return type is an unsigned integer type.

Suppose you have: (this is pseudo code, [] meaning the 8 values of each vector)

 int8x8_t a = [-1, -1, -1, -1,  1,  1,  1,  1];
 int8x8_t b = [ 0,  0,  0,  0,  0,  0,  0,  0];
uint8x8_t c = vclt_s8(a, b);

You'll get:

c = [255, 255, 255, 255, 0, 0, 0, 0];

The 4 first values of a are less than the 4 first values of b: all bits of the first 4 values of c are set to 1, making them 255.

In the same way, all 4 last values are greater: all bits of the 4 last values of c are set to 0, making them 0.

Hope this helps!

Autres conseils

vclt_s8 - Vector Compare for Less Than with each vector datatype is signed char. vclt.datatype dest, reg1, reg2. reg1 - a signed char vector- carrying 8 elements of that datatype. reg2 - must be of same datatype as the above one.

compare element by element of reg1 with reg2. place all bits as one in the corresponding vector in dest if the condition is true, else places all the bits as zeros.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top