I'm trying to learn shuffling using this example in C from the GCC manual
typedef int v4si __attribute__ ((vector_size (16)));
v4si a = {1,2,3,4};
v4si b = {5,6,7,8};
v4si mask = {0,4,2,5};
v4si res = __builtin_shuffle (a, b, mask); /* res is {1,5,3,6} */
I don't understand what the mask
does exactly? All I can find online is similar to this:
The shuffle mask operand specifies, for each element of the result vector, which element of the two input vectors the result element gets
But it doesn't explain how? is there AND, OR
going on? what do the numbers in mask mean?