SSE:将短整数转换为浮点数 [英] SSE: convert short integer to float
本文介绍了SSE:将短整数转换为浮点数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用 SSE 将一组无符号短数转换为浮点数.说吧
I want to convert an array of unsigned short numbers to float using SSE. Let's say
__m128i xVal; // Has 8 16-bit unsigned integers
__m128 y1, y2; // 2 xmm registers for 8 float values
我想要 y1 中的前 4 个 uint16 &y2 中的下一个 4 uint16.需要知道使用哪个 sse 内在的.
I want first 4 uint16 in y1 & next 4 uint16 in y2. Need to know which sse intrinsic to use.
推荐答案
您需要先将 8 x 16 位无符号短整型向量解包为两个 32 位无符号整数向量,然后将这些向量中的每一个都转换为浮点型:
You need to first unpack your vector of 8 x 16 bit unsigned shorts into two vectors of 32 bit unsigned ints, then convert each of these vectors to float:
__m128i xlo = _mm_unpacklo_epi16(x, _mm_set1_epi16(0));
__m128i xhi = _mm_unpackhi_epi16(x, _mm_set1_epi16(0));
__m128 ylo = _mm_cvtepi32_ps(xlo);
__m128 yhi = _mm_cvtepi32_ps(xhi);
这篇关于SSE:将短整数转换为浮点数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文