OSDN Git Service

2006-10-24 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 24 Oct 2006 09:15:07 +0000 (09:15 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 24 Oct 2006 09:15:07 +0000 (09:15 +0000)
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@118001 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/builtins.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr28796-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/pr28796-2.c [new file with mode: 0644]

index ac9dcf7..811fd4c 100644 (file)
@@ -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
index 78fc11f..f77f8b2 100644 (file)
@@ -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));
 }
index 98445d5..e5533b0 100644 (file)
@@ -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 (file)
index 0000000..a762bec
--- /dev/null
@@ -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 (file)
index 0000000..8847d78
--- /dev/null
@@ -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;
+}