SSE 内在函数:如何将值存储到寄存器?
SSE intrinsics: How to store values to the register?
我对 SSE 内部函数还很陌生,遇到了一个小问题。我需要帮助将整数值加载到 __m128i
这是我已有的:
__m128i a = _mm_set_epi16( 1, 1, 2, 2, 3, 3, 4, 4 );
__m128i b = _mm_set_epi16( 5, 5, 6, 6, 7, 7, 8, 8 );
//some magic
__m128i c // = (1,2,3,4,5,6,7,8);
如果您不想动态加载值,则可以使用 set intrinsics:
intrinsics for loading data to the sse registers
例如:
__m128i c = _mm_set_epi16(1,2,3,4,5,6,7,8); //load 8 16-bit integers to the register
我自己找到了解决方案
__m128i a = _mm_set_epi16( 1, 1, 2, 2, 3, 3, 4, 4 );
__m128i b = _mm_set_epi16( 5, 5, 6, 6, 7, 7, 8, 8 );
//some magic
__m128i mmShufflerVo = _mm_set_epi8(-1, -1, -1, -1, -1, -1, -1, -1, 13, 12, 9, 8,5, 4,1, 0);
__m128i mmShufflerHi = _mm_set_epi8(13, 12, 9, 8, 5, 4, 1, 0, -1, -1, -1,
-1, -1, -1, -1, -1);
__m128i mmResult0_3 = _mm_shuffle_epi8(mmResult0_3, mmShufflerVo);
__m128i mmResult4_7 = _mm_shuffle_epi8(mmResult4_7, mmShufflerHi);
__m128i c = _mm_or_si128(mmResult0_3, mmResult4_7);
我对 SSE 内部函数还很陌生,遇到了一个小问题。我需要帮助将整数值加载到 __m128i
这是我已有的:
__m128i a = _mm_set_epi16( 1, 1, 2, 2, 3, 3, 4, 4 );
__m128i b = _mm_set_epi16( 5, 5, 6, 6, 7, 7, 8, 8 );
//some magic
__m128i c // = (1,2,3,4,5,6,7,8);
如果您不想动态加载值,则可以使用 set intrinsics:
intrinsics for loading data to the sse registers
例如:
__m128i c = _mm_set_epi16(1,2,3,4,5,6,7,8); //load 8 16-bit integers to the register
我自己找到了解决方案
__m128i a = _mm_set_epi16( 1, 1, 2, 2, 3, 3, 4, 4 );
__m128i b = _mm_set_epi16( 5, 5, 6, 6, 7, 7, 8, 8 );
//some magic
__m128i mmShufflerVo = _mm_set_epi8(-1, -1, -1, -1, -1, -1, -1, -1, 13, 12, 9, 8,5, 4,1, 0);
__m128i mmShufflerHi = _mm_set_epi8(13, 12, 9, 8, 5, 4, 1, 0, -1, -1, -1,
-1, -1, -1, -1, -1);
__m128i mmResult0_3 = _mm_shuffle_epi8(mmResult0_3, mmShufflerVo);
__m128i mmResult4_7 = _mm_shuffle_epi8(mmResult4_7, mmShufflerHi);
__m128i c = _mm_or_si128(mmResult0_3, mmResult4_7);