I'd like to perform a SIMD arithmetic right shift (i.e. shifting in the sign bit) by a constant amount on a NEON register using compiler intrinsics. Yet I cannot find this particular kind of shift in all those shift intrinsics mentionend in the documentation. Does NEON even support arithmetic shifts (though, it would be strange if it didn't) and I'm just too dumb to find it (or am looking for the wrong terminology)? Or maybe it is just the normal vshr(q)_n
intrinsic and the kind of shift is decided by the signedness of the actual type used?
1
votes
There is no intrinsic for "right arithmetic shift". It is tough to find a NEON manual with a treatment of intrinsics. The one I use is from Appendix G of ARM Compiler toolchain. It is an older manual but it is well organized and as far as I know the information still applies. I extracted the appendix (pages 603-674) and had it printed and bound. It only cost $5 or $10 USD at Office Depot.
– jww
1 Answers
1
votes
Ah, shifts on ARM-NEON. The sign-ness is easy to miss.
There is of course an arithmetic shift right instruction, and it is the same as the logical shift right instruction. You decide if you want to shift arithmetic or logic by picking the data-type.
E.g.
int8x8_t vshr_n_s8(int8x8_t a, int b);
Will shift arithmetic because the data-type is s8 while:
uint8x8_t vshr_n_u8(uint8x8_t a, int b);
will shift logically (shifing in zeros instead of replicating the sign bit) because the data-type is unsigned.