vec_pdep

Purpose

Copies some bits from each element of one vector into positions of the target vector specified by a mask in another vector.

Note: This built-in function is valid only when the -mcpu option is set to target Power10 processors.

Syntax

d=vec_pdep(a,b)

Result and argument types

The following table describes the types of the returned value and the function arguments.

Table 1. Types of the returned value and function arguments
d a b
vector unsigned long long vector unsigned long long vector unsigned long long

Result value

The rightmost bit of each element of a is copied into the bit position of the corresponding element of d in which the rightmost 1-bit appears in the corresponding element of b. The next rightmost bit of each element of a is copied into the bit position of the corresponding element of d in which the next-rightmost 1-bit appears in the corresponding element of b, and so forth until the element of b contains no more 1-bits. All bits of the element of d that correspond to 0-bits in the corresponding element of b are set to zero.

Here is an example for doubleword inputs:
Argument Element 0 Element 1
a 0x fedc ba98 7654 3210 0x fedc ba98 7654 3210
b 0x 8888 8888 8888 8888 0x cccc cccc cccc cccc
d 0x 0088 0080 0008 0000 0x 4c48 4440 0c08 0400
Consider element 0 in the previous table. Since b contains 16 bits that are set to 1, only the rightmost 16 bits of a are pertinent to the result. These bits are 0011 0010 0001 0000. These bits are distributed into d at the bit positions that are set in b, providing the result shown in the previous table. You can get element 1 of d using the same method.