How to split a 128-bit XMM register into two 64-bit integer registers?

How to split a 128-bit register xmminto two 64-bit quadrants?

I have a very large number in xmm1and you want to get a higher square in r9and a lower square before r10, or RAXand RDX.

movlpdor movhpdonly works with a register in memory or vice versa.

+4
source share
1 answer

SSE2 ( x86-64) XMM ( ). : MOVD MOVQ. , , , .

SSE4.1 / , 16- (, PEXTRQ). , , movq , , tmp.

#SSE4.1
movq    rax, xmm0       # low qword
pextrq  rdx,  xmm0, 1   # high qword
# 128b result in rdx:rax, ready for use with div r64 for example.
# (But watch out for #DE on overflow)
# also ready for returning as a __int128_t in the SystemV x86-64 ABI

#SSE2
movq       r10, xmm0
punpckhqdq xmm0, xmm0    # broadcast the high half of xmm0 to both halves
movq       r9,  xmm0

PUNPCKHQDQ - . 64 , 65 Core2 (Merom/Conroe). . . PUNPCKHQDQ SSE2, 4 .

xmm0, pshufd . - .


movlpd movhpd...

. movlps/movhps, , CPU float double.

movhlps xmm1, xmm0, xmm0 , FP- ( , Intel Nehalem). xmm1, .

pshufd . movhlps, , Core2, movhlps , pshufd .

+4

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


All Articles