9.7.7.1. Comparison and Selection Instructions: set
set
Compare two numeric values with a relational operator, and optionally combine this result with a predicate value by applying a Boolean operator.
Syntax
set.CmpOp{.ftz}.dtype.stype d, a, b;
set.CmpOp.BoolOp{.ftz}.dtype.stype d, a, b, {!}c;
.CmpOp = { eq, ne, lt, le, gt, ge, lo, ls, hi, hs,
equ, neu, ltu, leu, gtu, geu, num, nan };
.BoolOp = { and, or, xor };
.dtype = { .u32, .s32, .f32 };
.stype = { .b16, .b32, .b64,
.u16, .u32, .u64,
.s16, .s32, .s64,
.f32, .f64 };
set.CmpOp.type d, a, b;
.CmpOp = { eq, ne, lt, le, gt, ge, lo, ls, hi, hs};
.type = { .u8x4, .s8x4, .u16x2, .s16x2 };Description
Compares two numeric values and optionally combines the result with another predicate value by applying a Boolean operator. If this result is True, 1.0f is written for floating-point destination types, and 0xffffffff is written for integer destination types. Otherwise, 0x00000000 is written.
For .u16x2, .s16x2 instruction types, forms input vectors by half word values from source operands. Half-word operands are then compared in parallel. If the result is True, 0xffff is written to the destination register at a bit-position corresponding to input half word values. Otherwise, 0x0000 is written. In this case, all operands must be of type .b32.
For .u8x4, .s8x4 instruction types, forms input vectors by quarter word values from source operands. Quarter-word operands are then compared in parallel. If the result is True, 0xff is written to the destination register at a bit-position corresponding to input quarter word values. Otherwise, 0x00 is written. In this case, all operands must be of type .b32.
Operand d has type .dtype; operands a and b have type .stype; operand c has type .pred.
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] CmpOp iB[i]) ? 0xffff : 0x0000;
}
} 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] CmpOp iB[i]) ? 0xff : 0x00;
}
} else {
t = (a CmpOp b) ? 1 : 0;
if (isFloat(dtype))
d = BoolOp(t, c) ? 1.0f : 0x00000000;
else
d = BoolOp(t, c) ? 0xffffffff : 0x00000000;
}Integer Notes
The signed and unsigned comparison operators are eq, ne, lt, le, gt, ge.
For unsigned values, the comparison operators lo, ls, hi, and hs for lower, lower-or-same, higher, and higher-or-same may be used instead of lt, le, gt, ge, respectively.
The untyped, bit-size comparisons are eq and ne.
Floating Point Notes
The ordered comparisons are eq, ne, lt, le, gt, ge. If either operand is NaN, the result is False.
To aid comparison operations in the presence of NaN values, unordered versions are included: equ, neu, ltu, leu, gtu, geu. If both operands are numeric values (not NaN), then these comparisons have the same result as their ordered counterparts. If either operand is NaN, then the result of these comparisons is True.
num returns True if both operands are numeric values (not NaN), and nan returns True if either operand is NaN.
Subnormal numbers:
sm_20+- By default, subnormal numbers are supported.
set.ftz.dtype.f32flushes subnormal inputs to sign-preserving zero.sm_1xset.dtype.f64supports subnormal numbers.set.dtype.f32flushes subnormal inputs to sign-preserving zero.
Modifier .ftz applies only to .f32 comparisons.
PTX ISA Notes
Introduced in PTX ISA version 1.0.
set with .u8x4, .s8x4, .u16x2, .s16x2 introduced in PTX ISA version 9.4.
Target ISA Notes
set with .f64 source type requires sm_13 or higher.
Support for set with .u8x4, .s8x4, .u16x2, .s16x2 supported on following family-specific architectures:
sm_107for higher in the same family
Examples
@p set.lt.and.f32.s32 d,a,b,r;
set.eq.u32.u32 d,i,n;
set.ge.s16x2 bd, ba, bb;