Extract data from the xmm register into "standard" variables, internal

How can I extract 2 bytes or any number of bytes from the xmm register?

I am currently using an array to flush the entire register, and then I am accessing the bytes I want. However, this does not seem as effective as it could be. Is there a way to effectively get only the bytes that interest me?

(I work on C on Linux 64bit)

+4
source share
3 answers

The mnemonics for the instructions that you probably want are MOVD and MOVQ , and the corresponding information is _mm_cvtsi128_si32 and _mm_cvtsi128_si64 .

+3
source

INSERTPS was introduced in SSE4.1 and PINS instructions read 8, 16 or 32 bits from the x86 memory and insert it into the field in the XMM register of the destination specified by the immediate operand.

EXTRACTS and PEXTR read the field from the XMM source and paste it into the x86 register or memory location.

+1
source

In SSE2, you can find the _mm_extract_epi16 and _mm_insert_epi16 in the <emmintrin.h> header.

SSE4.1 adds the _mm_extract_epi8, _mm_extract_epi32, _mm_insert_epi8 and _mm_insert_epi32 to the <smmintrin.h> header.

You can search for any of them to find the exact syntax and semantics, but in general, the extract forms take two arguments: A __m128i and a constant integer representing the index. Insert forms take the value __m128i, a value, and an index.

+1
source

All Articles