如何加载16个8位数据并将它们连接到4个无符号整数?
有没有什么优雅的方法来加载 16 个 8 位数据并将它们连接到 4 个 unsigned int ?
如下所示:
通过 _mm_load_si128() 将以下数组(16 epi8)加载到 __m128i
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee,0xff
,然后进行一些操作,使寄存器(__m128i)变成4 epi32,0x33221100,0x77665544,0xbbaa8899,0xffeeddcc
,
谢谢!
Is there any elegant way to load 16 8-bits data and concatenate them to 4 unsigned int ?
like follows:
load the following array(16 epi8) by _mm_load_si128() to an __m128i
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff
and then do some manipulation such that the register(__m128i) becomes 4 epi32,
0x33221100, 0x77665544, 0xbbaa8899, 0xffeeddcc
thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的:什么也不做。加载后,寄存器已经处于您想要的状态。 (假设
0xbbaa8899
是一个拼写错误,而您实际上的意思是0xbbaa9988
)。Yes: do nothing. After loading, the register is already in your desired state. (Assuming that
0xbbaa8899
is a typo, and you actually meant0xbbaa9988
, anyway).只需创建 4 个 int 指针并将 m128 存储在这些指针所针对的顺序内存中。
或者有一个 int[4] 数组并将您的 m128 存储到该数组所在的内存中,然后 array[0..3] 是您的 4 个整数。
或者,如果您已经拥有 16 字节数组,只需将内存转换为索引 0、4、8、12 处的整数。
Just create 4 int pointers and store your m128 in the sequential memory those pointers are targeted at.
Or have a int[4] array and store your m128 into the memory where the array is located then array[0..3] are your 4 integers.
Or if you already have the 16 byte array just cast the memory to integers at indices 0, 4, 8, 12.