NEON vs Intel SSE -某些操作的等价性

NEON vs Intel SSE - equivalence of certain operations

本文关键字:操作 vs Intel SSE NEON      更新时间:2023-10-16

我在计算几个英特尔SSE操作的NEON等效时遇到了一些麻烦。似乎NEON不能一次处理整个Q寄存器(128位值数据类型)。我没有在arm_neon.h头文件或NEON intrinsic引用中找到任何内容。

我想做的是:

// Intel SSE
// shift the entire 128 bit value with 2 bytes to the right; this is done 
// without sign extension by shifting in zeros
__m128i val = _mm_srli_si128(vector_of_8_s16, 2);
// insert the least significant 16 bits of "some_16_bit_val"
// the whole thing in this case, into the selected 16 bit 
// integer of vector "val"(the 16 bit element with index 7 in this case)
val = _mm_insert_epi16(val, some_16_bit_val, 7);

我已经看过NEON提供的移位操作,但是没有找到一个等价的方法来完成上面的操作(我对NEON没有太多的经验)。有可能做到以上(我想我只是不知道怎么做)?

您需要VEXT指令。您的示例看起来像这样:

int16x8_t val = vextq_s16(vector_of_8_s16, another_vector_s16, 1);

之后,val的0-111位将包含vector_of_8_s16的16-127位,val的112-127位将包含another_vector_s16的0-15位。