Intel® C++ Compiler Classic Developer Guide and Reference

ID 767249
Date 12/16/2022
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

_addcarryx_u32(), _addcarryx_u64()

Computes sum of two 32/64 bit wide unsigned integer values and a carry-in and returns the value of carry-out produced by the sum. The corresponding 4th Generation Intel® Core™ Processor extension instructions are ADCX and ADOX.

Syntax

extern unsigned char _addcarryx_u32(unsigned char c_in, unsigned int src1, unsigned int src2, unsigned int *sum_out);

extern unsigned char _addcarryx_u64(unsigned char c_in, unsigned __int64 src1, unsigned __int64 src2, unsigned __int64 *sum_out);

Parameters

c_in

Value used for determining carry-in value

src1

32/64 bit source integer

src2

32/64 bit source integer

*sum_out

Pointer to memory location where result is stored

Description

Computes the sum of two 32/64 bit wide integer values (src1, src2) and a carry-in value. The carry-in value is considered '1' for any non-zero c_in input value, or '0' otherwise. The sum is stored to a memory location referenced by sum_out argument:

*sum_out = src1 + src2 + (c_in !=0 ? 1 : 0)

NOTE:

This intrinsic does not perform validity checking of the memory address pointed to by sum_out, thus it cannot be used to find out if the sum produces carry-out without storing result of the sum.

The intrinsic is translated to either ADCX/ADOX instruction, chosen by the compiler. By design, these instructions allow running of two interleaved add-with-carry instruction sequences in parallel via using ADCX and ADOX instructions for these sequences respectively.

Returns

Returns carry-out value generated by the sum. The sum result is stored into memory location pointed by sum_out argument.