Are there any better way to load unsigned char
array to short
using SSE? Like
unsigned char foo1[16];
__m128i foo2 = _mm_loadu_si128((__m128i*)foo1);
I want foo2
to store elements in the short int
data type.
Are there any better way to load unsigned char
array to short
using SSE? Like
unsigned char foo1[16];
__m128i foo2 = _mm_loadu_si128((__m128i*)foo1);
I want foo2
to store elements in the short int
data type.
Not completely clear what you want.
But if you want SSE register with one short value per each input byte, then you probably need this (untested):
__declspec( align( 16 ) ) unsigned char foo1[ 16 ];
// Fill your array with data
const __m128i src = _mm_load_si128( ( __m128i* )foo1 );
const __m128i zero = _mm_setzero_si128();
const __m128i lower = _mm_unpacklo_epi8( src, zero ); // First 8 short values
const __m128i higher = _mm_unpackhi_epi8( src, zero ); // Last 8 short values