From: Paolo Bonzini Date: Fri, 4 Jun 2004 18:34:22 +0000 (+0000) Subject: re PR target/15822 (Several alpha testsuite regressions: gcc.c-torture/execute/ieee... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=28af2467e40311bbddd132788d0dcd7fe02f72d4;p=gcc.git re PR target/15822 (Several alpha testsuite regressions: gcc.c-torture/execute/ieee/fp-cmp-[458].c) 2004-06-04 Paolo Bonzini PR target/15822 * gcc.c-torture/execute/compare-fp-1.c, gcc.c-torture/execute/compare-fp-2.c, gcc.c-torture/execute/compare-fp-3.c, gcc.c-torture/execute/compare-fp-4.c, gcc.c-torture/execute/compare-fp-3.x, gcc.c-torture/execute/compare-fp-4.x: Moved... * gcc.c-torture/execute/ieee/compare-fp-1.c, gcc.c-torture/execute/ieee/compare-fp-2.c, gcc.c-torture/execute/ieee/compare-fp-3.c, gcc.c-torture/execute/ieee/compare-fp-4.c, gcc.c-torture/execute/ieee/compare-fp-3.x, gcc.c-torture/execute/ieee/compare-fp-4.x: ...here. From-SVN: r82631 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 96f85355649..d316dfc6151 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,19 @@ +2004-06-04 Paolo Bonzini + + PR target/15822 + * gcc.c-torture/execute/compare-fp-1.c, + gcc.c-torture/execute/compare-fp-2.c, + gcc.c-torture/execute/compare-fp-3.c, + gcc.c-torture/execute/compare-fp-4.c, + gcc.c-torture/execute/compare-fp-3.x, + gcc.c-torture/execute/compare-fp-4.x: Moved... + * gcc.c-torture/execute/ieee/compare-fp-1.c, + gcc.c-torture/execute/ieee/compare-fp-2.c, + gcc.c-torture/execute/ieee/compare-fp-3.c, + gcc.c-torture/execute/ieee/compare-fp-4.c, + gcc.c-torture/execute/ieee/compare-fp-3.x, + gcc.c-torture/execute/ieee/compare-fp-4.x: ...here. + 2004-06-04 David Ayers * objc/execute/protocol-isEqual-4.m: New testcase. @@ -133,10 +149,13 @@ 2004-05-28 Paolo Bonzini - * gcc.c-torture/compare-fp-1.c, gcc.c-torture/compare-fp-2.c, - gcc.c-torture/compare-fp-3.c, gcc.c-torture/compare-fp-4.c, - gcc.c-torture/compare-fp-3.x, gcc.c-torture/compare-fp-4.x, - gcc.c-torture/pr15649-1.c: New. + * gcc.c-torture/execute/compare-fp-1.c, + gcc.c-torture/execute/compare-fp-2.c, + gcc.c-torture/execute/compare-fp-3.c, + gcc.c-torture/execute/compare-fp-4.c, + gcc.c-torture/execute/compare-fp-3.x, + gcc.c-torture/execute/compare-fp-4.x, + gcc.dg/pr15649-1.c: New. 2004-05-27 Adam Nemet diff --git a/gcc/testsuite/gcc.c-torture/execute/compare-fp-1.c b/gcc/testsuite/gcc.c-torture/execute/compare-fp-1.c deleted file mode 100644 index 81642534cc3..00000000000 --- a/gcc/testsuite/gcc.c-torture/execute/compare-fp-1.c +++ /dev/null @@ -1,189 +0,0 @@ -/* Copyright (C) 2004 Free Software Foundation. - - Test for correctness of composite floating-point comparisons. - - Written by Paolo Bonzini, 26th May 2004. */ - -extern void abort (void); - -#define TEST(c) if ((c) != ok) abort (); -#define ORD(a, b) (!__builtin_isunordered ((a), (b))) -#define UNORD(a, b) (__builtin_isunordered ((a), (b))) -#define UNEQ(a, b) (__builtin_isunordered ((a), (b)) || ((a) == (b))) -#define UNLT(a, b) (__builtin_isunordered ((a), (b)) || ((a) < (b))) -#define UNLE(a, b) (__builtin_isunordered ((a), (b)) || ((a) <= (b))) -#define UNGT(a, b) (__builtin_isunordered ((a), (b)) || ((a) > (b))) -#define UNGE(a, b) (__builtin_isunordered ((a), (b)) || ((a) >= (b))) -#define LTGT(a, b) (__builtin_islessgreater ((a), (b))) - -float pinf; -float ninf; -float NaN; - -int iuneq (float x, float y, int ok) -{ - TEST (UNEQ (x, y)); - TEST (!LTGT (x, y)); - TEST (UNLE (x, y) && UNGE (x,y)); -} - -int ieq (float x, float y, int ok) -{ - TEST (ORD (x, y) && UNEQ (x, y)); -} - -int iltgt (float x, float y, int ok) -{ - TEST (!UNEQ (x, y)); /* Not optimizable. */ - TEST (LTGT (x, y)); /* Same, __builtin_islessgreater does not trap. */ - TEST (ORD (x, y) && (UNLT (x, y) || UNGT (x,y))); -} - -int ine (float x, float y, int ok) -{ - TEST (UNLT (x, y) || UNGT (x, y)); -} - -int iunlt (float x, float y, int ok) -{ - TEST (UNLT (x, y)); - TEST (UNORD (x, y) || (x < y)); -} - -int ilt (float x, float y, int ok) -{ - TEST (ORD (x, y) && UNLT (x, y)); /* Not optimized */ - TEST ((x <= y) && (x != y)); - TEST ((x <= y) && (y != x)); - TEST ((x != y) && (x <= y)); /* Not optimized */ - TEST ((y != x) && (x <= y)); /* Not optimized */ -} - -int iunle (float x, float y, int ok) -{ - TEST (UNLE (x, y)); - TEST (UNORD (x, y) || (x <= y)); -} - -int ile (float x, float y, int ok) -{ - TEST (ORD (x, y) && UNLE (x, y)); /* Not optimized */ - TEST ((x < y) || (x == y)); - TEST ((y > x) || (x == y)); - TEST ((x == y) || (x < y)); /* Not optimized */ - TEST ((y == x) || (x < y)); /* Not optimized */ -} - -int iungt (float x, float y, int ok) -{ - TEST (UNGT (x, y)); - TEST (UNORD (x, y) || (x > y)); -} - -int igt (float x, float y, int ok) -{ - TEST (ORD (x, y) && UNGT (x, y)); /* Not optimized */ - TEST ((x >= y) && (x != y)); - TEST ((x >= y) && (y != x)); - TEST ((x != y) && (x >= y)); /* Not optimized */ - TEST ((y != x) && (x >= y)); /* Not optimized */ -} - -int iunge (float x, float y, int ok) -{ - TEST (UNGE (x, y)); - TEST (UNORD (x, y) || (x >= y)); -} - -int ige (float x, float y, int ok) -{ - TEST (ORD (x, y) && UNGE (x, y)); /* Not optimized */ - TEST ((x > y) || (x == y)); - TEST ((y < x) || (x == y)); - TEST ((x == y) || (x > y)); /* Not optimized */ - TEST ((y == x) || (x > y)); /* Not optimized */ -} - -int -main () -{ - pinf = __builtin_inf (); - ninf = -__builtin_inf (); - NaN = __builtin_nan (""); - - iuneq (ninf, pinf, 0); - iuneq (NaN, NaN, 1); - iuneq (pinf, ninf, 0); - iuneq (1, 4, 0); - iuneq (3, 3, 1); - iuneq (5, 2, 0); - - ieq (1, 4, 0); - ieq (3, 3, 1); - ieq (5, 2, 0); - - iltgt (ninf, pinf, 1); - iltgt (NaN, NaN, 0); - iltgt (pinf, ninf, 1); - iltgt (1, 4, 1); - iltgt (3, 3, 0); - iltgt (5, 2, 1); - - ine (1, 4, 1); - ine (3, 3, 0); - ine (5, 2, 1); - - iunlt (NaN, ninf, 1); - iunlt (pinf, NaN, 1); - iunlt (pinf, ninf, 0); - iunlt (pinf, pinf, 0); - iunlt (ninf, ninf, 0); - iunlt (1, 4, 1); - iunlt (3, 3, 0); - iunlt (5, 2, 0); - - ilt (1, 4, 1); - ilt (3, 3, 0); - ilt (5, 2, 0); - - iunle (NaN, ninf, 1); - iunle (pinf, NaN, 1); - iunle (pinf, ninf, 0); - iunle (pinf, pinf, 1); - iunle (ninf, ninf, 1); - iunle (1, 4, 1); - iunle (3, 3, 1); - iunle (5, 2, 0); - - ile (1, 4, 1); - ile (3, 3, 1); - ile (5, 2, 0); - - iungt (NaN, ninf, 1); - iungt (pinf, NaN, 1); - iungt (pinf, ninf, 1); - iungt (pinf, pinf, 0); - iungt (ninf, ninf, 0); - iungt (1, 4, 0); - iungt (3, 3, 0); - iungt (5, 2, 1); - - igt (1, 4, 0); - igt (3, 3, 0); - igt (5, 2, 1); - - iunge (NaN, ninf, 1); - iunge (pinf, NaN, 1); - iunge (ninf, pinf, 0); - iunge (pinf, pinf, 1); - iunge (ninf, ninf, 1); - iunge (1, 4, 0); - iunge (3, 3, 1); - iunge (5, 2, 1); - - ige (1, 4, 0); - ige (3, 3, 1); - ige (5, 2, 1); - - return 0; -} diff --git a/gcc/testsuite/gcc.c-torture/execute/compare-fp-2.c b/gcc/testsuite/gcc.c-torture/execute/compare-fp-2.c deleted file mode 100644 index 1f78a435a92..00000000000 --- a/gcc/testsuite/gcc.c-torture/execute/compare-fp-2.c +++ /dev/null @@ -1,24 +0,0 @@ -/* Copyright (C) 2004 Free Software Foundation. - - Ensure that the composite comparison optimization doesn't misfire - and attempt to combine an integer comparison with a floating-point one. - - Written by Paolo Bonzini, 26th May 2004. */ - -extern void abort (void); - -int -foo (double x, double y) -{ - /* If miscompiled the following may become false. */ - return (x > y) && ((int)x == (int)y); -} - -int -main () -{ - if (! foo (1.3,1.0)) - abort (); - return 0; -} - diff --git a/gcc/testsuite/gcc.c-torture/execute/compare-fp-3.c b/gcc/testsuite/gcc.c-torture/execute/compare-fp-3.c deleted file mode 100644 index 03e6ff2c506..00000000000 --- a/gcc/testsuite/gcc.c-torture/execute/compare-fp-3.c +++ /dev/null @@ -1,97 +0,0 @@ -/* Copyright (C) 2004 Free Software Foundation. - - Test for composite comparison always true/false optimization. - - Written by Paolo Bonzini, 26th May 2004. */ - -extern void link_error0 (); -extern void link_error1 (); - -void -test1 (float x, float y) -{ - if ((x==y) && (x!=y)) - link_error0(); -} - -void -test2 (float x, float y) -{ - if ((xy)) - link_error0(); -} - -void -test3 (float x, float y) -{ - if ((x=y) || (x= (b)) -#define UNORD(a, b) (!ORD ((a), (b))) -#define UNEQ(a, b) (!LTGT ((a), (b))) -#define UNLT(a, b) (((a) < (b)) || __builtin_isunordered ((a), (b))) -#define UNLE(a, b) (((a) <= (b)) || __builtin_isunordered ((a), (b))) -#define UNGT(a, b) (((a) > (b)) || __builtin_isunordered ((a), (b))) -#define UNGE(a, b) (((a) >= (b)) || __builtin_isunordered ((a), (b))) -#define LTGT(a, b) (((a) < (b)) || (a) > (b)) - -float pinf; -float ninf; -float NaN; - -int iuneq (float x, float y, int ok) -{ - TEST (UNEQ (x, y)); - TEST (!LTGT (x, y)); - TEST (UNLE (x, y) && UNGE (x,y)); -} - -int ieq (float x, float y, int ok) -{ - TEST (ORD (x, y) && UNEQ (x, y)); -} - -int iltgt (float x, float y, int ok) -{ - TEST (!UNEQ (x, y)); - TEST (LTGT (x, y)); - TEST (ORD (x, y) && (UNLT (x, y) || UNGT (x,y))); -} - -int ine (float x, float y, int ok) -{ - TEST (UNLT (x, y) || UNGT (x, y)); - TEST ((x < y) || (x > y) || UNORD (x, y)); -} - -int iunlt (float x, float y, int ok) -{ - TEST (UNLT (x, y)); - TEST (UNORD (x, y) || (x < y)); -} - -int ilt (float x, float y, int ok) -{ - TEST (ORD (x, y) && UNLT (x, y)); - TEST ((x <= y) && (x != y)); - TEST ((x <= y) && (y != x)); - TEST ((x != y) && (x <= y)); - TEST ((y != x) && (x <= y)); -} - -int iunle (float x, float y, int ok) -{ - TEST (UNLE (x, y)); - TEST (UNORD (x, y) || (x <= y)); -} - -int ile (float x, float y, int ok) -{ - TEST (ORD (x, y) && UNLE (x, y)); - TEST ((x < y) || (x == y)); - TEST ((y > x) || (x == y)); - TEST ((x == y) || (x < y)); - TEST ((y == x) || (x < y)); -} - -int iungt (float x, float y, int ok) -{ - TEST (UNGT (x, y)); - TEST (UNORD (x, y) || (x > y)); -} - -int igt (float x, float y, int ok) -{ - TEST (ORD (x, y) && UNGT (x, y)); - TEST ((x >= y) && (x != y)); - TEST ((x >= y) && (y != x)); - TEST ((x != y) && (x >= y)); - TEST ((y != x) && (x >= y)); -} - -int iunge (float x, float y, int ok) -{ - TEST (UNGE (x, y)); - TEST (UNORD (x, y) || (x >= y)); -} - -int ige (float x, float y, int ok) -{ - TEST (ORD (x, y) && UNGE (x, y)); - TEST ((x > y) || (x == y)); - TEST ((y < x) || (x == y)); - TEST ((x == y) || (x > y)); - TEST ((y == x) || (x > y)); -} - -int -main () -{ - pinf = __builtin_inf (); - ninf = -__builtin_inf (); - NaN = __builtin_nan (""); - - iuneq (ninf, pinf, 0); - iuneq (NaN, NaN, 1); - iuneq (pinf, ninf, 0); - iuneq (1, 4, 0); - iuneq (3, 3, 1); - iuneq (5, 2, 0); - - ieq (1, 4, 0); - ieq (3, 3, 1); - ieq (5, 2, 0); - - iltgt (ninf, pinf, 1); - iltgt (NaN, NaN, 0); - iltgt (pinf, ninf, 1); - iltgt (1, 4, 1); - iltgt (3, 3, 0); - iltgt (5, 2, 1); - - ine (1, 4, 1); - ine (3, 3, 0); - ine (5, 2, 1); - - iunlt (NaN, ninf, 1); - iunlt (pinf, NaN, 1); - iunlt (pinf, ninf, 0); - iunlt (pinf, pinf, 0); - iunlt (ninf, ninf, 0); - iunlt (1, 4, 1); - iunlt (3, 3, 0); - iunlt (5, 2, 0); - - ilt (1, 4, 1); - ilt (3, 3, 0); - ilt (5, 2, 0); - - iunle (NaN, ninf, 1); - iunle (pinf, NaN, 1); - iunle (pinf, ninf, 0); - iunle (pinf, pinf, 1); - iunle (ninf, ninf, 1); - iunle (1, 4, 1); - iunle (3, 3, 1); - iunle (5, 2, 0); - - ile (1, 4, 1); - ile (3, 3, 1); - ile (5, 2, 0); - - iungt (NaN, ninf, 1); - iungt (pinf, NaN, 1); - iungt (pinf, ninf, 1); - iungt (pinf, pinf, 0); - iungt (ninf, ninf, 0); - iungt (1, 4, 0); - iungt (3, 3, 0); - iungt (5, 2, 1); - - igt (1, 4, 0); - igt (3, 3, 0); - igt (5, 2, 1); - - iunge (NaN, ninf, 1); - iunge (pinf, NaN, 1); - iunge (ninf, pinf, 0); - iunge (pinf, pinf, 1); - iunge (ninf, ninf, 1); - iunge (1, 4, 0); - iunge (3, 3, 1); - iunge (5, 2, 1); - - ige (1, 4, 0); - ige (3, 3, 1); - ige (5, 2, 1); - - return 0; -} diff --git a/gcc/testsuite/gcc.c-torture/execute/compare-fp-4.x b/gcc/testsuite/gcc.c-torture/execute/compare-fp-4.x deleted file mode 100644 index 3fc750e85af..00000000000 --- a/gcc/testsuite/gcc.c-torture/execute/compare-fp-4.x +++ /dev/null @@ -1,2 +0,0 @@ -set options "-fno-trapping-math" -return 0 diff --git a/gcc/testsuite/gcc.c-torture/execute/ieee/compare-fp-1.c b/gcc/testsuite/gcc.c-torture/execute/ieee/compare-fp-1.c new file mode 100644 index 00000000000..81642534cc3 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/ieee/compare-fp-1.c @@ -0,0 +1,189 @@ +/* Copyright (C) 2004 Free Software Foundation. + + Test for correctness of composite floating-point comparisons. + + Written by Paolo Bonzini, 26th May 2004. */ + +extern void abort (void); + +#define TEST(c) if ((c) != ok) abort (); +#define ORD(a, b) (!__builtin_isunordered ((a), (b))) +#define UNORD(a, b) (__builtin_isunordered ((a), (b))) +#define UNEQ(a, b) (__builtin_isunordered ((a), (b)) || ((a) == (b))) +#define UNLT(a, b) (__builtin_isunordered ((a), (b)) || ((a) < (b))) +#define UNLE(a, b) (__builtin_isunordered ((a), (b)) || ((a) <= (b))) +#define UNGT(a, b) (__builtin_isunordered ((a), (b)) || ((a) > (b))) +#define UNGE(a, b) (__builtin_isunordered ((a), (b)) || ((a) >= (b))) +#define LTGT(a, b) (__builtin_islessgreater ((a), (b))) + +float pinf; +float ninf; +float NaN; + +int iuneq (float x, float y, int ok) +{ + TEST (UNEQ (x, y)); + TEST (!LTGT (x, y)); + TEST (UNLE (x, y) && UNGE (x,y)); +} + +int ieq (float x, float y, int ok) +{ + TEST (ORD (x, y) && UNEQ (x, y)); +} + +int iltgt (float x, float y, int ok) +{ + TEST (!UNEQ (x, y)); /* Not optimizable. */ + TEST (LTGT (x, y)); /* Same, __builtin_islessgreater does not trap. */ + TEST (ORD (x, y) && (UNLT (x, y) || UNGT (x,y))); +} + +int ine (float x, float y, int ok) +{ + TEST (UNLT (x, y) || UNGT (x, y)); +} + +int iunlt (float x, float y, int ok) +{ + TEST (UNLT (x, y)); + TEST (UNORD (x, y) || (x < y)); +} + +int ilt (float x, float y, int ok) +{ + TEST (ORD (x, y) && UNLT (x, y)); /* Not optimized */ + TEST ((x <= y) && (x != y)); + TEST ((x <= y) && (y != x)); + TEST ((x != y) && (x <= y)); /* Not optimized */ + TEST ((y != x) && (x <= y)); /* Not optimized */ +} + +int iunle (float x, float y, int ok) +{ + TEST (UNLE (x, y)); + TEST (UNORD (x, y) || (x <= y)); +} + +int ile (float x, float y, int ok) +{ + TEST (ORD (x, y) && UNLE (x, y)); /* Not optimized */ + TEST ((x < y) || (x == y)); + TEST ((y > x) || (x == y)); + TEST ((x == y) || (x < y)); /* Not optimized */ + TEST ((y == x) || (x < y)); /* Not optimized */ +} + +int iungt (float x, float y, int ok) +{ + TEST (UNGT (x, y)); + TEST (UNORD (x, y) || (x > y)); +} + +int igt (float x, float y, int ok) +{ + TEST (ORD (x, y) && UNGT (x, y)); /* Not optimized */ + TEST ((x >= y) && (x != y)); + TEST ((x >= y) && (y != x)); + TEST ((x != y) && (x >= y)); /* Not optimized */ + TEST ((y != x) && (x >= y)); /* Not optimized */ +} + +int iunge (float x, float y, int ok) +{ + TEST (UNGE (x, y)); + TEST (UNORD (x, y) || (x >= y)); +} + +int ige (float x, float y, int ok) +{ + TEST (ORD (x, y) && UNGE (x, y)); /* Not optimized */ + TEST ((x > y) || (x == y)); + TEST ((y < x) || (x == y)); + TEST ((x == y) || (x > y)); /* Not optimized */ + TEST ((y == x) || (x > y)); /* Not optimized */ +} + +int +main () +{ + pinf = __builtin_inf (); + ninf = -__builtin_inf (); + NaN = __builtin_nan (""); + + iuneq (ninf, pinf, 0); + iuneq (NaN, NaN, 1); + iuneq (pinf, ninf, 0); + iuneq (1, 4, 0); + iuneq (3, 3, 1); + iuneq (5, 2, 0); + + ieq (1, 4, 0); + ieq (3, 3, 1); + ieq (5, 2, 0); + + iltgt (ninf, pinf, 1); + iltgt (NaN, NaN, 0); + iltgt (pinf, ninf, 1); + iltgt (1, 4, 1); + iltgt (3, 3, 0); + iltgt (5, 2, 1); + + ine (1, 4, 1); + ine (3, 3, 0); + ine (5, 2, 1); + + iunlt (NaN, ninf, 1); + iunlt (pinf, NaN, 1); + iunlt (pinf, ninf, 0); + iunlt (pinf, pinf, 0); + iunlt (ninf, ninf, 0); + iunlt (1, 4, 1); + iunlt (3, 3, 0); + iunlt (5, 2, 0); + + ilt (1, 4, 1); + ilt (3, 3, 0); + ilt (5, 2, 0); + + iunle (NaN, ninf, 1); + iunle (pinf, NaN, 1); + iunle (pinf, ninf, 0); + iunle (pinf, pinf, 1); + iunle (ninf, ninf, 1); + iunle (1, 4, 1); + iunle (3, 3, 1); + iunle (5, 2, 0); + + ile (1, 4, 1); + ile (3, 3, 1); + ile (5, 2, 0); + + iungt (NaN, ninf, 1); + iungt (pinf, NaN, 1); + iungt (pinf, ninf, 1); + iungt (pinf, pinf, 0); + iungt (ninf, ninf, 0); + iungt (1, 4, 0); + iungt (3, 3, 0); + iungt (5, 2, 1); + + igt (1, 4, 0); + igt (3, 3, 0); + igt (5, 2, 1); + + iunge (NaN, ninf, 1); + iunge (pinf, NaN, 1); + iunge (ninf, pinf, 0); + iunge (pinf, pinf, 1); + iunge (ninf, ninf, 1); + iunge (1, 4, 0); + iunge (3, 3, 1); + iunge (5, 2, 1); + + ige (1, 4, 0); + ige (3, 3, 1); + ige (5, 2, 1); + + return 0; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/ieee/compare-fp-2.c b/gcc/testsuite/gcc.c-torture/execute/ieee/compare-fp-2.c new file mode 100644 index 00000000000..1f78a435a92 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/ieee/compare-fp-2.c @@ -0,0 +1,24 @@ +/* Copyright (C) 2004 Free Software Foundation. + + Ensure that the composite comparison optimization doesn't misfire + and attempt to combine an integer comparison with a floating-point one. + + Written by Paolo Bonzini, 26th May 2004. */ + +extern void abort (void); + +int +foo (double x, double y) +{ + /* If miscompiled the following may become false. */ + return (x > y) && ((int)x == (int)y); +} + +int +main () +{ + if (! foo (1.3,1.0)) + abort (); + return 0; +} + diff --git a/gcc/testsuite/gcc.c-torture/execute/ieee/compare-fp-3.c b/gcc/testsuite/gcc.c-torture/execute/ieee/compare-fp-3.c new file mode 100644 index 00000000000..03e6ff2c506 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/ieee/compare-fp-3.c @@ -0,0 +1,97 @@ +/* Copyright (C) 2004 Free Software Foundation. + + Test for composite comparison always true/false optimization. + + Written by Paolo Bonzini, 26th May 2004. */ + +extern void link_error0 (); +extern void link_error1 (); + +void +test1 (float x, float y) +{ + if ((x==y) && (x!=y)) + link_error0(); +} + +void +test2 (float x, float y) +{ + if ((xy)) + link_error0(); +} + +void +test3 (float x, float y) +{ + if ((x=y) || (x= (b)) +#define UNORD(a, b) (!ORD ((a), (b))) +#define UNEQ(a, b) (!LTGT ((a), (b))) +#define UNLT(a, b) (((a) < (b)) || __builtin_isunordered ((a), (b))) +#define UNLE(a, b) (((a) <= (b)) || __builtin_isunordered ((a), (b))) +#define UNGT(a, b) (((a) > (b)) || __builtin_isunordered ((a), (b))) +#define UNGE(a, b) (((a) >= (b)) || __builtin_isunordered ((a), (b))) +#define LTGT(a, b) (((a) < (b)) || (a) > (b)) + +float pinf; +float ninf; +float NaN; + +int iuneq (float x, float y, int ok) +{ + TEST (UNEQ (x, y)); + TEST (!LTGT (x, y)); + TEST (UNLE (x, y) && UNGE (x,y)); +} + +int ieq (float x, float y, int ok) +{ + TEST (ORD (x, y) && UNEQ (x, y)); +} + +int iltgt (float x, float y, int ok) +{ + TEST (!UNEQ (x, y)); + TEST (LTGT (x, y)); + TEST (ORD (x, y) && (UNLT (x, y) || UNGT (x,y))); +} + +int ine (float x, float y, int ok) +{ + TEST (UNLT (x, y) || UNGT (x, y)); + TEST ((x < y) || (x > y) || UNORD (x, y)); +} + +int iunlt (float x, float y, int ok) +{ + TEST (UNLT (x, y)); + TEST (UNORD (x, y) || (x < y)); +} + +int ilt (float x, float y, int ok) +{ + TEST (ORD (x, y) && UNLT (x, y)); + TEST ((x <= y) && (x != y)); + TEST ((x <= y) && (y != x)); + TEST ((x != y) && (x <= y)); + TEST ((y != x) && (x <= y)); +} + +int iunle (float x, float y, int ok) +{ + TEST (UNLE (x, y)); + TEST (UNORD (x, y) || (x <= y)); +} + +int ile (float x, float y, int ok) +{ + TEST (ORD (x, y) && UNLE (x, y)); + TEST ((x < y) || (x == y)); + TEST ((y > x) || (x == y)); + TEST ((x == y) || (x < y)); + TEST ((y == x) || (x < y)); +} + +int iungt (float x, float y, int ok) +{ + TEST (UNGT (x, y)); + TEST (UNORD (x, y) || (x > y)); +} + +int igt (float x, float y, int ok) +{ + TEST (ORD (x, y) && UNGT (x, y)); + TEST ((x >= y) && (x != y)); + TEST ((x >= y) && (y != x)); + TEST ((x != y) && (x >= y)); + TEST ((y != x) && (x >= y)); +} + +int iunge (float x, float y, int ok) +{ + TEST (UNGE (x, y)); + TEST (UNORD (x, y) || (x >= y)); +} + +int ige (float x, float y, int ok) +{ + TEST (ORD (x, y) && UNGE (x, y)); + TEST ((x > y) || (x == y)); + TEST ((y < x) || (x == y)); + TEST ((x == y) || (x > y)); + TEST ((y == x) || (x > y)); +} + +int +main () +{ + pinf = __builtin_inf (); + ninf = -__builtin_inf (); + NaN = __builtin_nan (""); + + iuneq (ninf, pinf, 0); + iuneq (NaN, NaN, 1); + iuneq (pinf, ninf, 0); + iuneq (1, 4, 0); + iuneq (3, 3, 1); + iuneq (5, 2, 0); + + ieq (1, 4, 0); + ieq (3, 3, 1); + ieq (5, 2, 0); + + iltgt (ninf, pinf, 1); + iltgt (NaN, NaN, 0); + iltgt (pinf, ninf, 1); + iltgt (1, 4, 1); + iltgt (3, 3, 0); + iltgt (5, 2, 1); + + ine (1, 4, 1); + ine (3, 3, 0); + ine (5, 2, 1); + + iunlt (NaN, ninf, 1); + iunlt (pinf, NaN, 1); + iunlt (pinf, ninf, 0); + iunlt (pinf, pinf, 0); + iunlt (ninf, ninf, 0); + iunlt (1, 4, 1); + iunlt (3, 3, 0); + iunlt (5, 2, 0); + + ilt (1, 4, 1); + ilt (3, 3, 0); + ilt (5, 2, 0); + + iunle (NaN, ninf, 1); + iunle (pinf, NaN, 1); + iunle (pinf, ninf, 0); + iunle (pinf, pinf, 1); + iunle (ninf, ninf, 1); + iunle (1, 4, 1); + iunle (3, 3, 1); + iunle (5, 2, 0); + + ile (1, 4, 1); + ile (3, 3, 1); + ile (5, 2, 0); + + iungt (NaN, ninf, 1); + iungt (pinf, NaN, 1); + iungt (pinf, ninf, 1); + iungt (pinf, pinf, 0); + iungt (ninf, ninf, 0); + iungt (1, 4, 0); + iungt (3, 3, 0); + iungt (5, 2, 1); + + igt (1, 4, 0); + igt (3, 3, 0); + igt (5, 2, 1); + + iunge (NaN, ninf, 1); + iunge (pinf, NaN, 1); + iunge (ninf, pinf, 0); + iunge (pinf, pinf, 1); + iunge (ninf, ninf, 1); + iunge (1, 4, 0); + iunge (3, 3, 1); + iunge (5, 2, 1); + + ige (1, 4, 0); + ige (3, 3, 1); + ige (5, 2, 1); + + return 0; +} diff --git a/gcc/testsuite/gcc.c-torture/execute/ieee/compare-fp-4.x b/gcc/testsuite/gcc.c-torture/execute/ieee/compare-fp-4.x new file mode 100644 index 00000000000..3fc750e85af --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/ieee/compare-fp-4.x @@ -0,0 +1,2 @@ +set options "-fno-trapping-math" +return 0