PTX ISA v9.4

9.7.1.12. Integer Arithmetic Instructions: neg

neg

Arithmetic negate.

Syntax

ptx
neg.type  d, a;

.type = { .s8x4, .s16, .s32, .s64 };

Description

Negate the sign of a and store the result in d.

For .s8x4 instruction types, forms input vectors by quarter word values from source operands. Quarter-word operands are then negated in parallel to produce .s8x4 result in destination.

Operands d and a have the same type as the instruction type. For instruction type .s8x4, operands d and a have type .b32.

Semantics

ptx
if (type == s8x4) {
    iA[0] = a[0:7];
    iA[1] = a[8:15];
    iA[2] = a[16:23];
    iA[3] = a[24:31];
    for (i = 0; i < 4; i++) {
         d[i] = -iA[i];
    }
} else {
    d = -a;
}

Notes

Only for signed integers.

PTX ISA Notes

Introduced in PTX ISA version 1.0.

neg.s8x4 introduced in PTX ISA version 9.2.

Target ISA Notes

Supported on all target architectures.

neg.s8x4 is supported on following family-specific architectures:

  • sm_107f or higher in the same family
  • sm_120f or higher in the same family

Examples

ptx
neg.s32  r0,a;
neg.s8x4 p, q, r;
esc
Type to search across all documentation