Storing two x86 32 bit registers into 128 bit xmm register

后端 未结 2 1818
無奈伤痛
無奈伤痛 2020-12-30 10:31

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           


        
相关标签:
2条回答
  • 2020-12-30 10:53

    I don't know much about MMX, but perhaps you want the PACKSSDW instruction.

    The PACKSSDW instruction takes the two double words in the source operand and the two double words in the destination operand and converts these to four signed words via saturation. The instruction packs these four words together and stores the result in the destination MMX register.

    (from http://webster.cs.ucr.edu/AoA/Windows/HTML/TheMMXInstructionSeta2.html)

    Edit: I just realized that those were SSE registers. Oh well.

    Edit: I'm going to shut up now.

    0 讨论(0)
  • 2020-12-30 11:09

    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
    
    0 讨论(0)
提交回复
热议问题