Rotate shift in AVX and SSE

Rotate shift in AVX and SSE

imagem de Pourya Shirazian

I need to shift values in a simd register and replace from left or right. Basically I have an array like {4,5,4,5} in SSE or {4,5,4,5,4,5,4,5} in AVX and need to convert them to {5,4,5,4} or {5,4,5,4,5,4,5,4}. I need the solution to work with both SSE and AVX instruction sets.

Pourya Shirazian
3 posts / novo 0
Último post
Para obter mais informações sobre otimizações de compiladores, consulte Aviso sobre otimizações.
imagem de sirrida

Do you mean data dependent rotation (i.e. different rotation of each subword) or a cyclically exchange of the subwords?
A solution of the first problem is sketched on my site or with AVX2 (Intel proposal: 2 times VPSLLV* or VPSRLV* and one POR) or XOP (AMD Bulldozer: VPROT*) commands.
The second problem is easily solved by the commands SHUFPS, SHUFPD, PSHUFD, PSHUFB and PALIGNR; unfortunately these commands are somewhat limited for YMM usage because of their missing cross-lane operations.

imagem de jimdempseyatthecove

Quoting Pourya_ShirazianI need to shift values in a simd register and replace from left or right. Basically I have an array like {4,5,4,5} in SSE or {4,5,4,5,4,5,4,5} in AVX and need to convert them to {5,4,5,4} or {5,4,5,4,5,4,5,4}. I need the solution to work with both SSE and AVX instruction sets.

If I take you literally that the only numbers are:

{4,5,4,5} in SSE or {4,5,4,5,4,5,4,5} in AVX, then pxor with
{1,1,1,1} in SSE or {1,1,1,1,1,1,1,1} in AVX, to convert to
{5,4,5,4} in SSE or{5,4,5,4,5,4,5,4} in AVX.

xor again with same number sequence to convert back from
{5,4,5,4} in SSE or{5,4,5,4,5,4,5,4} in AVX to
{4,5,4,5} in SSE or {4,5,4,5,4,5,4,5} in AVX.

Jim Dempsey

www.quickthreadprogramming.com

Faça login para deixar um comentário.