aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorUlrich Weigand <uweigand@de.ibm.com>2009-03-11 15:24:00 +0000
committerUlrich Weigand <uweigand@gcc.gnu.org>2009-03-11 15:24:00 +0000
commitdc215785635e91c391118cf773f5ba1f6d26acb1 (patch)
treee99dab3450b2f3d8752625e45a2e5345cd593a8c /gcc
parent32fdf2f406a4db93a66ec808812c5843c601e9b4 (diff)
downloadgcc-dc215785635e91c391118cf773f5ba1f6d26acb1.zip
gcc-dc215785635e91c391118cf773f5ba1f6d26acb1.tar.gz
gcc-dc215785635e91c391118cf773f5ba1f6d26acb1.tar.bz2
fold-const.c (fold_comparison): Only call fold_inf_compare if the mode supports infinities.
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/fold-const.c3
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/ieee/inf-2.c2
-rw-r--r--gcc/testsuite/gcc.c-torture/execute/ieee/inf-3.c79
5 files changed, 92 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 069a96c..1241708 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 97331f3..e38850f 100644
--- a/gcc/fold-const.c
+++ b/gcc/fold-const.c
@@ -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)
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index d76bc03..3760728 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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.
diff --git a/gcc/testsuite/gcc.c-torture/execute/ieee/inf-2.c b/gcc/testsuite/gcc.c-torture/execute/ieee/inf-2.c
index 1823b35..dafd958 100644
--- a/gcc/testsuite/gcc.c-torture/execute/ieee/inf-2.c
+++ b/gcc/testsuite/gcc.c-torture/execute/ieee/inf-2.c
@@ -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
index 0000000..f2ee480
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/ieee/inf-3.c
@@ -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;
+}
+