2015-05-29 46 views

回答

6

假設要的16×8位整數的向量轉換爲4×32位整數四個矢量,則可以通過首先打開包裝到16位做到這一點,然後再次以32位:

// load 8 bit vector 
uint8x16_t v = vld1q_u8(p); // load vector of 16 x 8 bits ints from p 

// unpack to 16 bits 
int16x8_t vl = vreinterpretq_s16_u16(vmovl_u8(vget_low_u8(v))); // 0..7 
int16x8_t vh = vreinterpretq_s16_u16(vmovl_u8(vget_high_u8(v))); // 8..15 

// unpack to 32 bits 
int32x4_t vll = vmovl_s16(vget_low_s16(vl));   // 0..3 
int32x4_t vlh = vmovl_s16(vget_high_s16(vl));   // 4..7 
int32x4_t vhl = vmovl_s16(vget_low_s16(vh));   // 8..11 
int32x4_t vhh = vmovl_s16(vget_high_s16(vh));   // 12..15 
+4

NEON矢量類型不能保證可以通過轉換來轉換,因此對於大多數可移植性,您應該編寫'vreinterpretq_s16_u16(vmovl_u8(vget_low_u8(v)))' –

+0

@CharlesBaylis:謝謝 - 我沒有意識到這一點 - gcc似乎很滿意原始演員,但我已根據您的建議更新了答案。 –

相關問題