Convert between SSE and NEON Intrinsics-Shuffling

I am trying to convert code written in SSE3 intrinsics to NEON SIMD and am stuck due to shuffle function. I looked at GCC Intrinsic , ARM manuals, and other forums, but couldn't find a solution.

CODE:

_m128i upper = _mm_loadu_si128((__m128i*)p1);

register __m128i mask1 = _mm_set_epi8 (0x80,0x80,0x80,0x80,0x80,0x80,0x80,12,0x80,10,0x80,7,0x80,4,0x80,1);
register __m128i mask2 = _mm_set_epi8 (0x80,0x80,0x80,0x80,0x80,0x80,12,0x80,10,0x80,7,0x80,4,0x80,1,0x80);
__m128i temp1_upper = _mm_or_si128(_mm_shuffle_epi8(upper,mask1),_mm_shuffle_epi8(upper,mask2));

Although the vtbl1_u8 command (uint8x8_t, uint8x8_t) creates a lookup table that can be used to assign values ​​to the destination register, it only works with 64-bit registers. Also, the shuffle operation performs a comparison at the beginning, which should be done in NEON, and I do not know how to do this efficiently.

r0 = (mask0 and 0x80)? 0: SELECT (a, mask0 and 0x0f) // SELECT (a, n) extracts the nth 8-bit parameter from.

r1 = (mask1 and 0x80)? 0: SELECT (a, mask1 and 0x0f)

...

, , 4- . , , 4 , . , - .

,

!

+5
2

VTBL 0, .

Q , :

  • Q (, Q8)
  • vtbl.8 d0, {q8}, d0 ( d0 )

.

, 4 ~ 6 , vtbl.

, VBIC 8 .

, , .

  • vmov.u8, d1, # ​​0x70
  • Q (, Q8)
  • vbic.i8 d0, d0, d1
  • vtbl.8 d0, {q8}, d0 ( d0 )
+2

vtbl2_u8 , :

#define uint8x16_to_8x8x2(v) ((uint8x8x2_t) { vget_low_u8(v), vget_high_u8(v) })

uint8x16_t a = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff };
uint8x16_t b = { 0x80, 0x0f, 0x01, 0x0e, 0x02, 0x0d, 0x03, 0x0c, 0x04, 0x0b, 0x05, 0x0a, 0x06, 0x09, 0x07, 0x08 };
uint8x16_t c = vcombine_u8(vtbl2_u8(uint8x16_to_8x8x2(a), vget_low_u8(b)), vtbl2_u8(uint8x16_to_8x8x2(a), vget_high_u8(b)));
// c = 00 ff 11 ee 22 dd 33 cc 44 bb 55 aa 66 99 77 88

, vtbl 0 , , 0x80.

+3

All Articles