9.7.1.2. Integer Arithmetic Instructions: sub
sub
Subtract one value from another.
Syntax
ptx
sub.type1 d, a, b;
sub{.sat}.type2 d, a, b;
.type1 = { .u16, .u32, .u64,
.s16, .s64 };
.type2 = { .s32, .u8x4, .s8x4 };Description
Performs subtraction and writes the resulting value into a destination register.
For .u8x4, .s8x4 instruction types, forms input vectors by quarter word values from source operands. Quarter-word operands are then subtracted in parallel to produce .u8x4, .s8x4 result in destination.
For instruction types .u8x4, .s8x4 operands d, a and b have type .b32.
Semantics
ptx
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.s32,.u8x4,.s8x4types.
PTX ISA Notes
Introduced in PTX ISA version 1.0.
sub.u8x4, sub.s8x4 introduced in PTX ISA version 9.2.
Target ISA Notes
Supported on all target architectures.
sub.u8x4, sub.s8x4 are supported on following family-specific architectures:
sm_107for higher in the same familysm_120for higher in the same family
Examples
ptx
sub.s32 c,a,b;
sub.u8x4 p, q, r;