From 2f64c4305f43bd0d2970af561b59bd3915c1f121 Mon Sep 17 00:00:00 2001 From: sayle Date: Sat, 19 Jun 2004 00:17:33 +0000 Subject: * fold-const.c (fold) : 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) : 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@83379 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/testsuite/gcc.dg/unordered-3.c | 79 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/unordered-3.c (limited to 'gcc/testsuite/gcc.dg/unordered-3.c') diff --git a/gcc/testsuite/gcc.dg/unordered-3.c b/gcc/testsuite/gcc.dg/unordered-3.c new file mode 100644 index 00000000000..4a11a6d48d8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/unordered-3.c @@ -0,0 +1,79 @@ +/* { dg-do link } */ + +void link_error (); + +void test1() +{ + if (__builtin_isgreater(1.0,__builtin_nan("")) != 0) + link_error (); + if (__builtin_isgreater(__builtin_nan(""),1.0) != 0) + link_error (); + + if (__builtin_isgreaterequal(1.0,__builtin_nan("")) != 0) + link_error (); + if (__builtin_isgreaterequal(__builtin_nan(""),1.0) != 0) + link_error (); + + if (__builtin_isless(1.0,__builtin_nan("")) != 0) + link_error (); + if (__builtin_isless(__builtin_nan(""),1.0) != 0) + link_error (); + + if (__builtin_islessequal(1.0,__builtin_nan("")) != 0) + link_error (); + if (__builtin_islessequal(__builtin_nan(""),1.0) != 0) + link_error (); + + if (__builtin_islessgreater(1.0,__builtin_nan("")) != 0) + link_error (); + if (__builtin_islessgreater(__builtin_nan(""),1.0) != 0) + link_error (); + + if (__builtin_isunordered(1.0,__builtin_nan("")) == 0) + link_error (); + if (__builtin_isunordered(__builtin_nan(""),1.0) == 0) + link_error (); +} + + +void test2(double x) +{ + if (__builtin_isgreater(x,__builtin_nan("")) != 0) + link_error (); + if (__builtin_isgreater(__builtin_nan(""),x) != 0) + link_error (); + + if (__builtin_isgreaterequal(x,__builtin_nan("")) != 0) + link_error (); + if (__builtin_isgreaterequal(__builtin_nan(""),x) != 0) + link_error (); + + if (__builtin_isless(x,__builtin_nan("")) != 0) + link_error (); + if (__builtin_isless(__builtin_nan(""),x) != 0) + link_error (); + + if (__builtin_islessequal(x,__builtin_nan("")) != 0) + link_error (); + if (__builtin_islessequal(__builtin_nan(""),x) != 0) + link_error (); + + if (__builtin_islessgreater(x,__builtin_nan("")) != 0) + link_error (); + if (__builtin_islessgreater(__builtin_nan(""),x) != 0) + link_error (); + + if (__builtin_isunordered(x,__builtin_nan("")) == 0) + link_error (); + if (__builtin_isunordered(__builtin_nan(""),x) == 0) + link_error (); +} + + +int main() +{ + test1 (); + test2 (1.0); + return 0; +} + -- cgit v1.2.1