Itanium(R) processor topicCompare Instruction

cmp

Operation Font Conventions

Instruction Type A

Format

(qp) cmp.crel.ctype p1, p2 = r2, r3 register_form

(qp) cmp.crel.ctype p1, p2 = imm8, r3 imm8_form

(qp) cmp.crel.ctype p1, p2 = r0, r3 parallel_inequality_form

(qp) cmp.crel.ctype p1, p2 = r3, r0 pseudo-op


Description

The two source operands are compared for one of ten relations specified by crel. This produces a boolean result which is 1 if the comparison condition is true, and 0 otherwise. This result is written to the two predicate register destinations, p1 and p2. The way the result is written to the destinations is determined by the compare type specified by ctype.

The compare types describe how the predicate targets are updated based on the result of the comparison. The normal type simply writes the compare result to one target, and the complement to the other. The parallel types update the targets only for a particular comparison result. This allows multiple simultaneous OR-type or multiple simultaneous AND-type compares to target the same predicate register.

The unc is special in that it first initializes both predicate targets to 0, independent of the qualifying predicate. It then operates the same as the normal type. The behavior of the compare types is described in the Comparison Types table. A blank entry indicates the predicate target is left unchanged.

In the register_form the first operand is GR (general registers) r2; in the imm8_form the first operand is taken from the sign extended imm8 encoding field; and in the parallel_inequality_form the first operand must be GR 0. The parallel_inequality_form is only used when the compare type is one of the parallel types, and the relation is an inequality (>, >=, <, <=). See below.

If the two predicate register destinations are the same (p1 and p2 specify the same predicate register), the instruction will take an Illegal Operation fault, if the qualifying predicate is set, or if the compare type is unc.

Of the ten relations, not all are directly implemented in hardware. Some are actually pseudo-ops. For these, the assembler simply switches the source operand specifiers and/or switches the predicate target specifiers and uses an implemented relation. For some of the pseudo-op compares in the imm8_form, the assembler subtracts 1 from the immediate value, making the allowed immediate range slightly different. Of the six parallel compare types, three of the types are actually pseudo-ops. The assembler simply uses the negative relation with an implemented type. The implemented relations and how the pseudo-ops map onto them are shown in 64-bit Comparison Relations for Normal and UNC Type Compares, and 64-bit Comparison Relations for parallel type compares.

The parallel compare types can be used only with a restricted set of relations and operands. They can be used with equal and not-equal comparisons between two registers or between a register and an immediate, or they can be used with inequality comparisons between a register and GR 0. Unsigned relations are not provided, since they are not of much use when one of the operands is zero. For the parallel inequality comparisons, hardware only directly implements the ones where the first operand (GR r2) is GR 0. Comparisons where the second operand is GR 0 are pseudo-ops for which the assembler switches the register specifiers and uses the opposite relation..


Related Topics:

cmp4 - Compare Word Instruction

cmpxchg - Compare and Exchange Instruction

Compare Instructions

fcmp - Floating-point Compare Instruction

fpcmp - Floating-point Parallel Compare Instruction

pcmp - Parallel Compare Instruction

pmax - Parallel Maximum Instruction

pmin - Parallel Minimum Instruction