Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I exchange the middle two 64 bits in a 256 bit AVX(YMM) register

Tags:

x86

avx

simd

Is there any way to exchange the middle two 64 bits in a 256 bit AVX(YMM) register?

I know we can leverage VPERM2F128 to swap the low 128 and high 128 bits, and vshufps seems could only work inside both high and low 128 bits.

So I am wondering is there any efficient instructions to work for this typical situation?

Thanks in advance!

like image 855
Sean Yang Avatar asked Jan 28 '13 07:01

Sean Yang


1 Answers

Thank you all! I found AVX2 vpermq may well work for this.

like image 199
Sean Yang Avatar answered Sep 27 '22 16:09

Sean Yang