9.7.1.1. Integer Arithmetic Instructions: add
add
Add two values.
Syntax
add.type1 d, a, b;
add{.sat}.type2 d, a, b;
.type1 = { .u16, .u64,
.s16, .s64 };
.type2 = { .u32, .u16x2, .u8x4,
.s32, .s16x2, .s8x4 };Description
Performs addition and writes the resulting value into a destination register.
For .u16x2, .s16x2 instruction types, forms input vectors by half word values from source operands. Half-word operands are then added in parallel to produce .u16x2, .s16x2 result in destination.
For .u8x4, .s8x4 instruction types, forms input vectors by quarter word values from source operands. Quarter-word operands are then added in parallel to produce .u8x4, .s8x4 result in destination.
Operands d, a and b have the same type as the instruction type. For instruction types .u16x2, .s16x2, .u8x4, .s8x4, operands d, a and b have type .b32.
Semantics
if (type == u16x2 || type == s16x2) {
iA[0] = a[0:15];
iA[1] = a[16:31];
iB[0] = b[0:15];
iB[1] = b[16:31];
for (i = 0; i < 2; i++) {
d[i] = iA[i] + iB[i];
}
} else if (type == u8x4 || type == s8x4) {
iA[0] = a[0:7];
iA[1] = a[8:15];
iA[2] = a[16:23];
iA[3] = a[24:31];
iB[0] = b[0:7];
iB[1] = b[8:15];
iB[2] = b[16:23];
iB[3] = b[24:31];
for (i = 0; i < 4; i++) {
d[i] = iA[i] + iB[i];
}
} else {
d = a + b;
}Notes
Saturation modifier:
.sat— limits result to MININT..MAXINT (no overflow) for the size and signedness of the operation. Applies only to.u32,.s32,.u16x2,.s16x2,.u8x4,.s8x4types.
PTX ISA Notes
Introduced in PTX ISA version 1.0.
add.u16x2 and add.s16x2 introduced in PTX ISA version 8.0.
add{.sat}.u8x4, add{.sat}.s8x4, add.sat.u16x2, add.sat.s16x2 and add.sat.u32 introduced in PTX ISA version 9.2.
Target ISA Notes
Supported on all target architectures.
add.u16x2 and add.s16x2 require sm_90 or higher.
add{.sat}.u8x4, add{.sat}.s8x4, add.sat.u16x2, add.sat.s16x2 and add.sat.u32 are supported on following family-specific architectures:
sm_107for higher in the same familysm_120for higher in the same family
Examples
@p add.u32 x,y,z;
add.sat.s32 c,c,1;
add.u16x2 u,v,w;
add.s8x4.sat p, q, r;