fold-const.c (fold): Add constant folding for unordered comparison tree nodes.
authorRoger Sayle <roger@eyesopen.com>
Sat, 19 Jun 2004 00:17:33 +0000 (00:17 +0000)
committerRoger Sayle <sayle@gcc.gnu.org>
Sat, 19 Jun 2004 00:17:33 +0000 (00:17 +0000)
commitee8db92b391a602cb93f4ba227b152bcf81cb054
tree9819bd8cdb1d4003c3909100c418617db3fb2944
parent1c37e0b6e8b036fc3dce3765d195cf57919bed02
fold-const.c (fold): Add constant folding for unordered comparison tree nodes.

* fold-const.c (fold) <UNORDERED_EXPR, ORDERED_EXPR, UNLT_EXPR,
UNLE_EXPR, UNGT_EXPR, UNGE_EXPR, UNEQ_EXPR, LTGT_EXPR>: Add
constant folding for unordered comparison tree nodes.  If both
operands are real constants, call fold_relational_const.  If either
operand is a NaN, evaluate the other for side-effects and return a
constant.  Optimize (double)float1 CMP (double)float2 into the
equivalent float1 CMP float2.
(nondestructive_fold_binary_to_constant) <UNORDERED_EXPR,
ORDERED_EXPR, UNLT_EXPR, UNLE_EXPR, UNGT_EXPR, UNGE_EXPR, UNEQ_EXPR,
LTGT_EXPR>: Call fold_relational_const for constant operands.
(fold_relational_const): Add support for unordered comparison tree
nodes.  Don't constant fold "ordered" floating point comparisons
against NaN if when flag_trapping_math is set.

* gcc.dg/unordered-2.c: New test case.
* gcc.dg/unordered-3.c: New test case.

From-SVN: r83379
gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/unordered-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/unordered-3.c [new file with mode: 0644]