vec_pext
Purpose
Copies some bits from each element of one vector as specified by a mask in another vector into the rightmost bits of the target vector.
Syntax
d=vec_pext(a,b)
Result and argument types
The following table describes the types of the returned value and the function arguments.
| d | a | b |
|---|---|---|
| vector unsigned long long | vector unsigned long long | vector unsigned long long |
Result value
The bit of each element of a, for which the corresponding bit of that element of b is the rightmost 1-bit, is copied into the rightmost
bit position of the corresponding element of d. The bit of each element of a, for which the corresponding bit of that element of
b is the next-rightmost 1-bit,
is copied into the next-rightmost bit position of the corresponding element of d, and so forth until the element of
b contains no more 1-bits. All
bits in each element of d
that are not copied from the corresponding element of a are set to zero.
| Argument | Element 0 | Element 1 |
|---|---|---|
| a | 0x 0088 0080 0008 0000 | 0x 4c48 4440 0c08 0400 |
| b | 0x 8888 8888 8888 8888 | 0x cccc cccc cccc cccc |
| d | 0x 0000 0000 0000 3210 | 0x 0000 0000 7654 3210 |
b contains 16 bits that are set to 1, all bits except the rightmost 16
bits of d are set to
zero. The rightmost 16 bits are set by extracting the bits of a at the positions of the 1-bits in b. Those bits are 0011 0010 0001 0000,
providing the result shown in the previous table.