Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Storing two x86 32 bit registers into 128 bit xmm register

Is there any faster method to store two x86 32 bit registers in one 128 bit xmm register?

movd  xmm0, edx
movd  xmm1, eax
pshufd xmm0, xmm0, $1
por   xmm0, xmm1 

So if EAX is 0x12345678 and EDX is 0x87654321, the result in xmm0 must be 0x8765432112345678.

like image 900
GJ. Avatar asked Feb 09 '10 19:02

GJ.


1 Answers

With SSE 4.1 you can use movd xmm0, eax / pinsrd xmm0, edx, 1 and do it in 2 instructions.

For older CPUs you can use 2 x movd and then punpckldq for a total of 3 instructions:

movd xmm0, edx
movd xmm1, eax
punpckldq xmm0, xmm1
like image 128
Paul R Avatar answered Oct 21 '22 04:10

Paul R



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!