Developer Guide and Reference

ID 767253
Date 10/31/2024
Public
Document Table of Contents

Basic Integer Arithmetic Operations

brev

Description: Reverses the bit order of a 32-bit unsigned int value.

Calling Interface:

unsigned brev(unsigned x)

brevll

Description: Reverses the bit order of a 64-bit unsigned long long value

Calling Interface:

unsigned long long brevll(unsigned long long x)

byte_perm

Description: Returns a 32-bit unsigned int whose bytes are selected from 2 input parameters according to a selector value. The process is:

uint64_t y_x = ((uint64_t)y << 32) | x;
s0 = z & 0x7;
s1 = (z >> 4) & 0x7;
s2 = (z >> 8) & 0x7;
s3 = (z >> 12) & 0x7;

The value res is an unsigned int. The bits representations is:

res[bit_7...bit_0] = y_x[s0];
res[bit_15...bit_8] = y_x[s1];
res[bit_23...bit_16] = y_x[s2];
res[bit_31...bit_24] = y_x[s3];

Calling Interface:

unsigned int byte_perm(unsigned int x, unsigned int y, unsigned int z)

clz

Description: Returns the number of consecutive high-order zero bits in a 32-bit integer.

Calling Interface:

int clz(int x)

clzll

Description: Returns the number of consecutive high-order zero bits in a 64-bit integer.

Calling Interface:

int clzll(long long x)

ffs

Description: Returns the position of the least significant bit set to 1 in a 32-bit integer.

Calling Interface:

int ffs(int x)

ffsll

Description: Finds the position of the least significant bit set to 1 in a 64-bit integer.

Calling Interface:

int ffsll(long long x)

hadd

Description: Returns (x + y) >> 1 for a signed integer, avoid overflow in intermediate sum.

Calling Interface:

int hadd(int x, int y)

rhadd

Description: Returns (x + y + 1) >> 1 for a signed integer, avoid overflow in intermediate sum.

Calling Interface:

int rhadd(int x, int y)

uhadd

Description: Returns (x + y) >> 1 for an unsigned integer, avoid overflow in intermediate sum.

Calling Interface:

unsigned int uhadd(unsigned int x, unsigned int y)

urhadd

Description: Returns (x + y + 1) >> 1 for an unsigned integer, avoid overflow in intermediate sum.

Calling Interface:

unsigned int urhadd(unsigned int x, unsigned int y)

mul24

Description: Multiply two 24-bit integer values x and y. x and y are 32-bit signed integers, but only the low 24-bits are used to perform the multiplication, the high order 8 bits are ignored.

Calling Interface:

int mul24(int x, int y)

umul24

Description: Multiply two 24-bit integer values x and y. x and y are 32-bit unsigned integers, but only the low 24-bits are used to perform the multiplication, the high order 8 bits are ignored.

Calling Interface:

unsigned int umul24(unsigned int x, unsigned int y)

mul64hi

Description: Multiply two 64-bit signed integer to get a 128-bit product x * y, Returns the most significant 64-bit of the 128-bit product.

Calling Interface:

long long mul64hi(long long x, long long y)

umul64hi

Description: Multiply two 64-bit unsigned integer to get a 128-bit product x * y, Returns the most significant 64-bit of the 128-bit product.

Calling Interface:

unsigned long long umul64hi(unsigned long long x, unsigned long long)

mulhi

Description: Multiply two 32-bit signed integer to get a 64-bit product x * y, Returns the most significant 32-bit of the 128-bit product.

Calling Interface:

int mulhi(int x, int y)

umulhi

Description: Multiply two 32-bit unsigned integer to get a 64-bit product x * y, Returns the most significant 32-bit of the 128-bit product.

Calling Interface:

unsigned int umulhi(unsigned int x, unsigned int y)

popc

Description: Returns the number of bits that are set to 1 in a 32-bit integer.

Calling Interface:

int popc(unsigned int x)

popcll

Description: Returns the number of bits that are set to 1 in a 64-bit integer.

Calling Interface:

int popcll(unsigned long long x)

sad

Description: Returns |x - y| + z.

Calling Interface:

unsigned int sad(int x, int y, unsigned int z)

usad

Description: Returns |x - y| + z.

Calling Interface:

unsigned int usad(unsigned int x, unsigned int y, unsigned int z)