]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
fold-const.c (fold_comparison): Only call fold_inf_compare if the mode supports infin...
authorUlrich Weigand <uweigand@de.ibm.com>
Wed, 11 Mar 2009 15:24:00 +0000 (15:24 +0000)
committerUlrich Weigand <uweigand@gcc.gnu.org>
Wed, 11 Mar 2009 15:24:00 +0000 (15:24 +0000)
ChangeLog:

* fold-const.c (fold_comparison): Only call fold_inf_compare
if the mode supports infinities.

testsuite/ChangeLog:

* gcc.c-torture/execute/ieee/inf-3.c: New test.
* gcc.c-torture/execute/ieee/inf-2.c: Fix typo.

From-SVN: r144779

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/ieee/inf-2.c
gcc/testsuite/gcc.c-torture/execute/ieee/inf-3.c [new file with mode: 0644]

index 069a96cae7d658aa86bb5c997d76a7744e7d0df6..1241708f095b9577b4dbf8dd76e7a728abaf63d4 100644 (file)
@@ -1,3 +1,8 @@
+2009-03-11  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
+
+       * fold-const.c (fold_comparison): Only call fold_inf_compare
+       if the mode supports infinities.
+
 2009-03-11  Jason Merrill  <jason@redhat.com>
 
        PR debug/39086
index 97331f34d24e039357923e98da50ae5dc2db681f..e38850fd5df467cec544b3d235e54216f6d750cc 100644 (file)
@@ -9292,7 +9292,8 @@ fold_comparison (enum tree_code code, tree type, tree op0, tree op1)
            }
 
          /* Fold comparisons against infinity.  */
-         if (REAL_VALUE_ISINF (cst))
+         if (REAL_VALUE_ISINF (cst)
+             && MODE_HAS_INFINITIES (TYPE_MODE (TREE_TYPE (arg1))))
            {
              tem = fold_inf_compare (code, type, arg0, arg1);
              if (tem != NULL_TREE)
index d76bc03855c8ca37864987207afad9f8ec295bed..3760728fa4447f21253f68d73b3c4a962f7d591b 100644 (file)
@@ -1,3 +1,8 @@
+2009-03-11  Ulrich Weigand  <Ulrich.Weigand@de.ibm.com>
+
+       * gcc.c-torture/execute/ieee/inf-3.c: New test.
+       * gcc.c-torture/execute/ieee/inf-2.c: Fix typo.
+
 2009-03-11  Olivier Hainque  <hainque@adacore.com>
 
        * gnat.dg/slice_enum.adb: New test.
index 1823b35ff0ff18a9ba0368b31157ebc5d39a8a02..dafd95835c8a6cfbd4dd1be65aec10373041439e 100644 (file)
@@ -77,7 +77,7 @@ int main()
 {
   test (34.0, __builtin_inf());
   testf (34.0f, __builtin_inff());
-  testf (34.0l, __builtin_infl());
+  testl (34.0l, __builtin_infl());
   return 0;
 }
 
diff --git a/gcc/testsuite/gcc.c-torture/execute/ieee/inf-3.c b/gcc/testsuite/gcc.c-torture/execute/ieee/inf-3.c
new file mode 100644 (file)
index 0000000..f2ee480
--- /dev/null
@@ -0,0 +1,79 @@
+extern void abort (void);
+
+void test(double f, double i)
+{
+  if (f == __builtin_huge_val())
+    abort ();
+  if (f == -__builtin_huge_val())
+    abort ();
+  if (i == -__builtin_huge_val())
+    abort ();
+  if (i != __builtin_huge_val())
+    abort ();
+
+  if (f >= __builtin_huge_val())
+    abort ();
+  if (f > __builtin_huge_val())
+    abort ();
+  if (i > __builtin_huge_val())
+    abort ();
+  if (f <= -__builtin_huge_val())
+    abort ();
+  if (f < -__builtin_huge_val())
+    abort ();
+}
+
+void testf(float f, float i)
+{
+  if (f == __builtin_huge_valf())
+    abort ();
+  if (f == -__builtin_huge_valf())
+    abort ();
+  if (i == -__builtin_huge_valf())
+    abort ();
+  if (i != __builtin_huge_valf())
+    abort ();
+
+  if (f >= __builtin_huge_valf())
+    abort ();
+  if (f > __builtin_huge_valf())
+    abort ();
+  if (i > __builtin_huge_valf())
+    abort ();
+  if (f <= -__builtin_huge_valf())
+    abort ();
+  if (f < -__builtin_huge_valf())
+    abort ();
+}
+
+void testl(long double f, long double i)
+{
+  if (f == __builtin_huge_vall())
+    abort ();
+  if (f == -__builtin_huge_vall())
+    abort ();
+  if (i == -__builtin_huge_vall())
+    abort ();
+  if (i != __builtin_huge_vall())
+    abort ();
+
+  if (f >= __builtin_huge_vall())
+    abort ();
+  if (f > __builtin_huge_vall())
+    abort ();
+  if (i > __builtin_huge_vall())
+    abort ();
+  if (f <= -__builtin_huge_vall())
+    abort ();
+  if (f < -__builtin_huge_vall())
+    abort ();
+}
+
+int main()
+{
+  test (34.0, __builtin_huge_val());
+  testf (34.0f, __builtin_huge_valf());
+  testl (34.0l, __builtin_huge_vall());
+  return 0;
+}
+