gccint: Comparisons
1
1 14.10 Comparison Operations
1 ===========================
1
1 Comparison operators test a relation on two operands and are considered
1 to represent a machine-dependent nonzero value described by, but not
1 necessarily equal to, 'STORE_FLAG_VALUE' (⇒Misc) if the relation
1 holds, or zero if it does not, for comparison operators whose results
1 have a 'MODE_INT' mode, 'FLOAT_STORE_FLAG_VALUE' (⇒Misc) if the
1 relation holds, or zero if it does not, for comparison operators that
1 return floating-point values, and a vector of either
1 'VECTOR_STORE_FLAG_VALUE' (⇒Misc) if the relation holds, or of
1 zeros if it does not, for comparison operators that return vector
1 results. The mode of the comparison operation is independent of the
1 mode of the data being compared. If the comparison operation is being
1 tested (e.g., the first operand of an 'if_then_else'), the mode must be
1 'VOIDmode'.
1
1 There are two ways that comparison operations may be used. The
1 comparison operators may be used to compare the condition codes '(cc0)'
1 against zero, as in '(eq (cc0) (const_int 0))'. Such a construct
1 actually refers to the result of the preceding instruction in which the
1 condition codes were set. The instruction setting the condition code
1 must be adjacent to the instruction using the condition code; only
1 'note' insns may separate them.
1
1 Alternatively, a comparison operation may directly compare two data
1 objects. The mode of the comparison is determined by the operands; they
1 must both be valid for a common machine mode. A comparison with both
1 operands constant would be invalid as the machine mode could not be
1 deduced from it, but such a comparison should never exist in RTL due to
1 constant folding.
1
1 In the example above, if '(cc0)' were last set to '(compare X Y)', the
1 comparison operation is identical to '(eq X Y)'. Usually only one style
1 of comparisons is supported on a particular machine, but the combine
1 pass will try to merge the operations to produce the 'eq' shown in case
1 it exists in the context of the particular insn involved.
1
1 Inequality comparisons come in two flavors, signed and unsigned. Thus,
1 there are distinct expression codes 'gt' and 'gtu' for signed and
1 unsigned greater-than. These can produce different results for the same
1 pair of integer values: for example, 1 is signed greater-than -1 but not
1 unsigned greater-than, because -1 when regarded as unsigned is actually
1 '0xffffffff' which is greater than 1.
1
1 The signed comparisons are also used for floating point values.
1 Floating point comparisons are distinguished by the machine modes of the
1 operands.
1
1 '(eq:M X Y)'
1 'STORE_FLAG_VALUE' if the values represented by X and Y are equal,
1 otherwise 0.
1
1 '(ne:M X Y)'
1 'STORE_FLAG_VALUE' if the values represented by X and Y are not
1 equal, otherwise 0.
1
1 '(gt:M X Y)'
1 'STORE_FLAG_VALUE' if the X is greater than Y. If they are
1 fixed-point, the comparison is done in a signed sense.
1
1 '(gtu:M X Y)'
1 Like 'gt' but does unsigned comparison, on fixed-point numbers
1 only.
1
1 '(lt:M X Y)'
1 '(ltu:M X Y)'
1 Like 'gt' and 'gtu' but test for "less than".
1
1 '(ge:M X Y)'
1 '(geu:M X Y)'
1 Like 'gt' and 'gtu' but test for "greater than or equal".
1
1 '(le:M X Y)'
1 '(leu:M X Y)'
1 Like 'gt' and 'gtu' but test for "less than or equal".
1
1 '(if_then_else COND THEN ELSE)'
1 This is not a comparison operation but is listed here because it is
1 always used in conjunction with a comparison operation. To be
1 precise, COND is a comparison expression. This expression
1 represents a choice, according to COND, between the value
1 represented by THEN and the one represented by ELSE.
1
1 On most machines, 'if_then_else' expressions are valid only to
1 express conditional jumps.
1
1 '(cond [TEST1 VALUE1 TEST2 VALUE2 ...] DEFAULT)'
1 Similar to 'if_then_else', but more general. Each of TEST1, TEST2,
1 ... is performed in turn. The result of this expression is the
1 VALUE corresponding to the first nonzero test, or DEFAULT if none
1 of the tests are nonzero expressions.
1
1 This is currently not valid for instruction patterns and is
1 supported only for insn attributes. ⇒Insn Attributes.
1