Intel® ISA Extensions
Use hardware-based isolation and memory encryption to provide more code protection in your solutions.

Rotate shift in AVX and SSE

Pourya_Shirazian
Beginner
1,422 Views
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.
0 Kudos
2 Replies
sirrida
Beginner
1,422 Views
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.
0 Kudos
jimdempseyatthecove
Honored Contributor III
1,422 Views
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.


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

0 Kudos
Reply