Next:Bit-Fields, Previous:RTL Expressions for Arithmetic, Up:RTL Representation [Contents][Index]
Comparison operators test a relation on two operands and are consideredto represent a machine-dependent nonzero value described by, but notnecessarily equal to,STORE_FLAG_VALUE (seeMiscellaneous Parameters)if the relation holds, or zero if it does not, for comparison operatorswhose results have a ‘MODE_INT’ mode,FLOAT_STORE_FLAG_VALUE (seeMiscellaneous Parameters) if the relation holds, orzero if it does not, for comparison operators that return floating-pointvalues, and a vector of eitherVECTOR_STORE_FLAG_VALUE (seeMiscellaneous Parameters)if the relation holds, or of zeros if it does not, for comparison operatorsthat return vector results.The mode of the comparison operation is independent of the modeof the data being compared. If the comparison operation is being tested(e.g., the first operand of anif_then_else), the mode must beVOIDmode.
A comparison operation compares two dataobjects. The mode of the comparison is determined by the operands; theymust both be valid for a common machine mode. A comparison with bothoperands constant would be invalid as the machine mode could not bededuced from it, but such a comparison should never exist in RTL due toconstant folding.
Usually only one styleof comparisons is supported on a particular machine, but the combinepass will try to merge operations to produce code like(eqxy),in case it exists in the context of the particular insn involved.
Inequality comparisons come in two flavors, signed and unsigned. Thus,there are distinct expression codesgt andgtu for signed andunsigned greater-than. These can produce different results for the samepair of integer values: for example, 1 is signed greater-than −1 but notunsigned greater-than, because −1 when regarded as unsigned is actually0xffffffff which is greater than 1.
The signed comparisons are also used for floating point values. Floatingpoint comparisons are distinguished by the machine modes of the operands.
(eq:mxy) ¶STORE_FLAG_VALUE if the values represented byx andyare equal, otherwise 0.
(ne:mxy) ¶STORE_FLAG_VALUE if the values represented byx andyare not equal, otherwise 0.
(gt:mxy) ¶STORE_FLAG_VALUE if thex is greater thany. If theyare fixed-point, the comparison is done in a signed sense.
(gtu:mxy) ¶Likegt but does unsigned comparison, on fixed-point numbers only.
(lt:mxy) ¶(ltu:mxy)Likegt andgtu but test for “less than”.
(ge:mxy) ¶(geu:mxy)Likegt andgtu but test for “greater than or equal”.
(le:mxy) ¶(leu:mxy)Likegt andgtu but test for “less than or equal”.
(if_then_elsecondthenelse) ¶This is not a comparison operation but is listed here because it isalways used in conjunction with a comparison operation. To beprecise,cond is a comparison expression. This expressionrepresents a choice, according tocond, between the valuerepresented bythen and the one represented byelse.
On most machines,if_then_else expressions are valid onlyto express conditional jumps.
(cond [test1value1test2value2 …]default) ¶Similar toif_then_else, but more general. Each oftest1,test2, … is performed in turn. The result of this expression isthevalue corresponding to the first nonzero test, ordefault ifnone of the tests are nonzero expressions.
This is currently not valid for instruction patterns and is supported onlyfor insn attributes. SeeInstruction Attributes.
Next:Bit-Fields, Previous:RTL Expressions for Arithmetic, Up:RTL Representation [Contents][Index]