diff options
author | Richard Guenther <rguenther@suse.de> | 2006-10-24 09:15:07 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2006-10-24 09:15:07 +0000 |
commit | 27d7d0422ce932e1f531fec5de9b81bced2f369b (patch) | |
tree | 7a70218041825ef460b80274878b0b9a76fd0182 | |
parent | e1502f6e2de6e37603adb0e415a5d9847bfaf990 (diff) | |
download | gcc-27d7d0422ce932e1f531fec5de9b81bced2f369b.zip gcc-27d7d0422ce932e1f531fec5de9b81bced2f369b.tar.gz gcc-27d7d0422ce932e1f531fec5de9b81bced2f369b.tar.bz2 |
re PR middle-end/28796 (__builtin_nan() and __builtin_unordered() inconsistent)
2006-10-24 Richard Guenther <rguenther@suse.de>
PR middle-end/28796
* builtins.c (fold_builtin_classify): Use HONOR_INFINITIES
and HONOR_NANS instead of MODE_HAS_INFINITIES and MODE_HAS_NANS
for deciding optimizations in consistency with fold-const.c
(fold_builtin_unordered_cmp): Likewise.
* gcc.dg/pr28796-1.c: New testcase.
* gcc.dg/pr28796-1.c: Likewise.
From-SVN: r118001
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/builtins.c | 14 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr28796-1.c | 17 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr28796-2.c | 21 |
5 files changed, 59 insertions, 7 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ac9dcf7..811fd4c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,13 @@ 2006-10-24 Richard Guenther <rguenther@suse.de> + PR middle-end/28796 + * builtins.c (fold_builtin_classify): Use HONOR_INFINITIES + and HONOR_NANS instead of MODE_HAS_INFINITIES and MODE_HAS_NANS + for deciding optimizations in consistency with fold-const.c + (fold_builtin_unordered_cmp): Likewise. + +2006-10-24 Richard Guenther <rguenther@suse.de> + * builtins.c (fold_builtin_floor): Fold floor (x) where x is nonnegative to trunc (x). (fold_builtin_int_roundingfn): Fold lfloor (x) where x is diff --git a/gcc/builtins.c b/gcc/builtins.c index 78fc11f..f77f8b2 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -8776,7 +8776,7 @@ fold_builtin_classify (tree fndecl, tree arglist, int builtin_index) switch (builtin_index) { case BUILT_IN_ISINF: - if (!MODE_HAS_INFINITIES (TYPE_MODE (TREE_TYPE (arg)))) + if (!HONOR_INFINITIES (TYPE_MODE (TREE_TYPE (arg)))) return omit_one_operand (type, integer_zero_node, arg); if (TREE_CODE (arg) == REAL_CST) @@ -8792,8 +8792,8 @@ fold_builtin_classify (tree fndecl, tree arglist, int builtin_index) return NULL_TREE; case BUILT_IN_FINITE: - if (!MODE_HAS_NANS (TYPE_MODE (TREE_TYPE (arg))) - && !MODE_HAS_INFINITIES (TYPE_MODE (TREE_TYPE (arg)))) + if (!HONOR_NANS (TYPE_MODE (TREE_TYPE (arg))) + && !HONOR_INFINITIES (TYPE_MODE (TREE_TYPE (arg)))) return omit_one_operand (type, integer_one_node, arg); if (TREE_CODE (arg) == REAL_CST) @@ -8806,7 +8806,7 @@ fold_builtin_classify (tree fndecl, tree arglist, int builtin_index) return NULL_TREE; case BUILT_IN_ISNAN: - if (!MODE_HAS_NANS (TYPE_MODE (TREE_TYPE (arg)))) + if (!HONOR_NANS (TYPE_MODE (TREE_TYPE (arg)))) return omit_one_operand (type, integer_zero_node, arg); if (TREE_CODE (arg) == REAL_CST) @@ -8889,13 +8889,13 @@ fold_builtin_unordered_cmp (tree fndecl, tree arglist, if (unordered_code == UNORDERED_EXPR) { - if (!MODE_HAS_NANS (TYPE_MODE (TREE_TYPE (arg0)))) + if (!HONOR_NANS (TYPE_MODE (TREE_TYPE (arg0)))) return omit_two_operands (type, integer_zero_node, arg0, arg1); return fold_build2 (UNORDERED_EXPR, type, arg0, arg1); } - code = MODE_HAS_NANS (TYPE_MODE (TREE_TYPE (arg0))) ? unordered_code - : ordered_code; + code = HONOR_NANS (TYPE_MODE (TREE_TYPE (arg0))) ? unordered_code + : ordered_code; return fold_build1 (TRUTH_NOT_EXPR, type, fold_build2 (code, type, arg0, arg1)); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 98445d5..e5533b0 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,11 @@ 2006-10-24 Richard Guenther <rguenther@suse.de> + PR middle-end/28796 + * gcc.dg/pr28796-1.c: New testcase. + * gcc.dg/pr28796-2.c: Likewise. + +2006-10-24 Richard Guenther <rguenther@suse.de> + * gcc.dg/builtins-57.c: New testcase. 2006-10-24 Richard Guenther <rguenther@suse.de> diff --git a/gcc/testsuite/gcc.dg/pr28796-1.c b/gcc/testsuite/gcc.dg/pr28796-1.c new file mode 100644 index 0000000..a762bec --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr28796-1.c @@ -0,0 +1,17 @@ +/* { dg-do link } */ +/* { dg-options "-ffinite-math-only" } */ + +float f; + +int main() +{ + if (__builtin_isunordered (f, f) != 0) + link_error (); + if (__builtin_isnan (f) != 0) + link_error (); + if (__builtin_finite (f) != 1) + link_error (); + if (f != f) + link_error (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/pr28796-2.c b/gcc/testsuite/gcc.dg/pr28796-2.c new file mode 100644 index 0000000..8847d78 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr28796-2.c @@ -0,0 +1,21 @@ +/* { dg-do run } */ +/* { dg-options "-O2 -funsafe-math-optimizations" } */ + +extern void abort (void); + +void foo(float f) +{ + if (__builtin_isunordered (f, f) != 1) + abort (); + if (__builtin_isnan (f) != 1) + abort (); + if (__builtin_finite (f) != 0) + abort (); +} + +int main() +{ + float f = __builtin_nanf(""); + foo(f); + return 0; +} |