Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fastest way to move higher or lower 64 bits in integer SSE register

What's the fastest way to move only the higher or lower 64 bits from an integer SSE register to another? With SSE 4.1, it can be done with a single pblendw instruction (_mm_blend_epi16). But what about older SSE versions? Shift and unpack? AND and OR? movsd despite of the bypass delay?

Closely related question: Best way to shuffle 64-bit portions of two __m128i's

like image 324
nwellnhof Avatar asked Dec 10 '22 22:12

nwellnhof


1 Answers

To move the low 64 bits from src to dst, preserving the high 64 bits of dst:

movsd dst, src

To move the high 64 bits from src to dst, preserving the low 64 bits of dst:

shufps dst, src, E4h

Bypass delays generally only add latency, not dispatch or execute or retirement resources, so they are usually only a concern when comparing otherwise equivalent sequences (i.e. if there were a single-instruction equivalent that stayed in the integer domain, you'd prefer to use it for integer arithmetic).

like image 72
Stephen Canon Avatar answered May 10 '23 10:05

Stephen Canon