SSE: convert __m128 and __m128i to two __m128d

Two related questions.

This is what my code should do with a fairly large amount of data. This is done inside the inner loops, and performance is important.

  • Convert and __int32 array to double (or convert __m128i to two __m128d).
  • Convert and array floats to double (or convert __m128 to two __m128d).

Basically, I need a function with the following signatures:

void convert_int_to_double(__int32 const * input, double * output);
void convert_float_to_double(float const * input, double * output);

The input and output pointers are aligned, and the number of elements is a multiple of 4. The main problem is how to quickly unzip __m128 into two __m128d.

+3
source share
1 answer

_ mm_cvtepi32_pd _ mm_cvtps_pd .

:

__m128i* base_addr = ...;
for( int i = 0; i < cnt; ++i )
{
    __m128i epi32 = _mm_load_si128( base_addr + i );
    __m128d v0 = _mm_cvtepi32_pd( epi32 );
    epi32 = _mm_srli_si128( epi32, 8 );
    __m128d v1 = _mm_cvtepi32_pd( epi32 );
    ....
}
+6

Source: https://habr.com/ru/post/1780039/


All Articles