__builtin_pextd

Purpose

Copies some bits from one input argument as specified by a mask in another input argument into the rightmost bits of the target variable.

Note: This built-in function is valid only when both of the following conditions are met:
  • The -mcpu option is set to target Power10 processors.
  • The compiler mode is 64-bit.

Syntax

d=__builtin_pextd(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
unsigned long long unsigned long long unsigned long long

Result value

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

Here is an example for doubleword inputs:
Argument Value
a 0x0088 0080 0008 0000
b 0x 8888 8888 8888 8888
d 0x 0000 0000 0000 3210
In the above table, since 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.