Can I move 256-bit from memory location immediately to YMM registers?

1.8k views Asked by At

Can I move 256-bit from memory location immediately to YMM registers? If I want to fill an xmm register, I use in inline asm in gcc:

          "movlpd mytest_1(%rip),%xmm1 \n\t"
          "movhpd mytest_1+8(%rip),%xmm1 \n\t"

Can this be made easier I guess?

Furthermore: The same procedure move aligned or not 4 quadwords in 1 step to Ymm0? I look for the reverse of Vmovdqa ymm1, mem256 source -> destination.

1

There are 1 answers

1
zx485 On
"movlpd mytest_1(%rip),%xmm1 \n\t"
"movhpd mytest_1+8(%rip),%xmm1 \n\t"

These two instructions can be combined to one movdqu/movdqa, because x86 is a Little Endian architecture

"movdqu mytest_1(%rip),%xmm1 \n\t"    // 16-byte unaligned or
"movdqa mytest_1(%rip),%xmm1 \n\t"    // for 16-byte aligned 'mytest_1'

Both can also be used for AVX 32-bit memory transfer (vmovdqu/vmovdqa):

"vmovdqu mytest_1(%rip),%ymm1 \n\t"   // 32-byte unaligned or
"vmovdqa mytest_1(%rip),%ymm1 \n\t"   // for 32-byte aligned 'mytest_1'

Regarding the second part of your question:

I look for the reverse of Vmovdqa ymm1, mem256 source -> destination.

This does work in both directions, e.g. the possible instructions for vmovdqa:

VMOVDQA ymm1, ymm2/m256   RM   V/V   AVX   Move aligned packed integer values from ymm2/mem to ymm1.
VMOVDQA ymm2/m256, ymm1   MR   V/V   AVX   Move aligned packed integer values from ymm1 to ymm2/mem.