Reputation: 576
I'm interested in copying the data of a __m256i datatype (used in Intel Intrinsics for AVX instructions) to a new __m256i.
I'm aware that I can store the data from the AVX register to memory and then from memory, I can load the data into a new register. However, is there a more simple way (i.e. a dedicated instruction for it), where I can directly "clone" the register without first using operations for storing it to memory and then loading it again?
I guess, I could add an empty register to my register, and then get a new __m256i type back that can be loaded into a register... This seems as a bit of a hack, however, and requires I use some operations to create a new empty __m256i dummy at some point.
Sorry if it is a simple question (it is a simple problem). I just haven't been able to find a single intrinsic function that could do this for me.
Upvotes: 1
Views: 761
Reputation: 29022
You can easily copy a YMM register in x86 assembly to another one using MOVDQA
vmovdqa ymm0, ymm1
The corresponding intrinsic of this is
_mm256_store_si256(_m256i *p, __m256i a);
The compiler should optimize away any variable references.
Upvotes: 1
Reputation: 212979
You can just do assignment in the usual way, e.g.
__m256i v1 = _mm256_set1_epi32(42);
__m256i v2 = v1;
The compiler will typically generate a vmovdqa
instruction (or it may even just optimise away the register copy).
Upvotes: 4