vec_perm: Vector Permute

d = vec_perm(a, b, c)
Returns a vector that contains some elements of two vectors, in the order specified by a third vector.
Figure 1. Permute 16 integer elements (8-bit)
graphic
Each byte of the result is selected by using the least significant 5 bits of the corresponding byte of c as an index into the concatenated bytes of a and b.
Note: The vector generate mask built-in functions could help generate the mask c.
Table 1. Vector Permute
d a b c
vector signed char vector signed char vector signed char vector unsigned char
vector bool char vector bool char vector bool char
vector unsigned char vector unsigned char vector unsigned char
vector signed short vector signed short vector signed short
vector bool short vector bool short vector bool short
vector unsigned short vector unsigned short vector unsigned short
vector signed int vector signed int vector signed int
vector bool int vector bool int vector bool int
vector unsigned int vector unsigned int vector unsigned int
vector signed long long vector signed long long vector signed long long
vector bool long long vector bool long long vector bool long long
vector unsigned long long vector unsigned long long vector unsigned long long
vector double vector double vector signed double