From dc215785635e91c391118cf773f5ba1f6d26acb1 Mon Sep 17 00:00:00 2001 From: Ulrich Weigand <uweigand@de.ibm.com> Date: Wed, 11 Mar 2009 15:24:00 +0000 Subject: [PATCH] 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 --- gcc/ChangeLog | 5 ++ gcc/fold-const.c | 3 +- gcc/testsuite/ChangeLog | 5 ++ .../gcc.c-torture/execute/ieee/inf-2.c | 2 +- .../gcc.c-torture/execute/ieee/inf-3.c | 79 +++++++++++++++++++ 5 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/execute/ieee/inf-3.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 069a96cae7d6..1241708f095b 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 97331f34d24e..e38850fd5df4 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 d76bc03855c8..3760728fa444 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 1823b35ff0ff..dafd95835c8a 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 000000000000..f2ee4806265f --- /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; +} + -- GitLab