Vol. 2A 3-131
INSTRUCTION SET REFERENCE, A-M
CMPPS—Compare Packed Single-Precision Floating-Point Values
CMPPS—Compare Packed Single-Precision Floating-Point Values
Description
Performs a SIMD compare of the four packed single-precision floating-point values in
the source operand (second operand) and the destination operand (first operand)
and returns the results of the comparison to the destination operand. The compar-
ison predicate operand (third operand) specifies the type of comparison performed
on each of the pairs of packed values. The result of each comparison is a doubleword
mask of all 1s (comparison true) or all 0s (comparison false).
The source operand can be an XMM register or a 128-bit memory location. The desti-
nation operand is an XMM register. The comparison predicate operand is an 8-bit
immediate, the first 3 bits of which define the type of comparison to be made (see
Table 3-7). Bits 4 through 7 of the immediate are reserved.
The unordered relationship is true when at least one of the two source operands
being compared is a NaN; the ordered relationship is true when neither source
operand is a NaN.
A subsequent computational instruction that uses the mask result in the destination
operand as an input operand will not generate a fault, because a mask of all 0s corre-
sponds to a floating-point value of +0.0 and a mask of all 1s corresponds to a QNaN.
Some of the comparisons listed in Table 3-7 (such as the greater-than, greater-than-
or-equal, not-greater-than, and not-greater-than-or-equal relations) can be made
only through software emulation. For these comparisons the program must swap the
operands (copying registers when necessary to protect the data that will now be in
the destination), and then perform the compare using a different predicate. The
predicate to be used for these emulations is listed in Table 3-7 under the heading
Emulation.
Compilers and assemblers may implement the following two-operand pseudo-ops in
addition to the three-operand CMPPS instruction. See Table 3-9.
In 64-bit mode, use of the REX.R prefix permits this instruction to access additional
registers (XMM8-XMM15).
Opcode Instruction 64-Bit
Mode
Compat/
Leg Mode
Description
0F C2 /r ib CMPPS xmm1,
xmm2/m128, imm8
Valid Valid Compare packed single-
precision floating-point values
in xmm2/mem and xmm1
using imm8 as comparison
predicate.