aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2016-09-21 18:52:47 +0100
committerJoseph Myers <jsm28@gcc.gnu.org>2016-09-21 18:52:47 +0100
commit5f84cee259d615b36a673aa6d712ebaf9fb90fd9 (patch)
tree3d573af5255cfad98a1ba8a9dc2513466fd3d5f0
parent18e15e303af1184973bbe35547602567303fa6fe (diff)
downloadgcc-5f84cee259d615b36a673aa6d712ebaf9fb90fd9.zip
gcc-5f84cee259d615b36a673aa6d712ebaf9fb90fd9.tar.gz
gcc-5f84cee259d615b36a673aa6d712ebaf9fb90fd9.tar.bz2
Add _FloatN, _FloatNx tests for __builtin_fpclassify.
This patch adds tests for _FloatN and _FloatNx arguments to the __builtin_fpclassify type-generic built-in function, omitted from the original tests for type-generic functions on these types. Tested for x86_64-pc-linux-gnu; all the supported new tests pass. * gcc.dg/torture/float128-tg-3.c, gcc.dg/torture/float128x-tg-3.c, gcc.dg/torture/float16-tg-3.c, gcc.dg/torture/float32-tg-3.c, gcc.dg/torture/float32x-tg-3.c, gcc.dg/torture/float64-tg-3.c, gcc.dg/torture/float64x-tg-3.c, gcc.dg/torture/floatn-tg-3.h: New tests. From-SVN: r240328
-rw-r--r--gcc/testsuite/ChangeLog8
-rw-r--r--gcc/testsuite/gcc.dg/torture/float128-tg-3.c10
-rw-r--r--gcc/testsuite/gcc.dg/torture/float128x-tg-3.c10
-rw-r--r--gcc/testsuite/gcc.dg/torture/float16-tg-3.c10
-rw-r--r--gcc/testsuite/gcc.dg/torture/float32-tg-3.c10
-rw-r--r--gcc/testsuite/gcc.dg/torture/float32x-tg-3.c10
-rw-r--r--gcc/testsuite/gcc.dg/torture/float64-tg-3.c10
-rw-r--r--gcc/testsuite/gcc.dg/torture/float64x-tg-3.c10
-rw-r--r--gcc/testsuite/gcc.dg/torture/floatn-tg-3.h79
9 files changed, 157 insertions, 0 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index d1fa9f2..28e974b 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2016-09-21 Joseph Myers <joseph@codesourcery.com>
+
+ * gcc.dg/torture/float128-tg-3.c, gcc.dg/torture/float128x-tg-3.c,
+ gcc.dg/torture/float16-tg-3.c, gcc.dg/torture/float32-tg-3.c,
+ gcc.dg/torture/float32x-tg-3.c, gcc.dg/torture/float64-tg-3.c,
+ gcc.dg/torture/float64x-tg-3.c, gcc.dg/torture/floatn-tg-3.h: New
+ tests.
+
2016-09-21 Uros Bizjak <ubizjak@gmail.com>
* gcc.c-torture/unsorted/dump-noaddr.x: Remove debug statements.
diff --git a/gcc/testsuite/gcc.dg/torture/float128-tg-3.c b/gcc/testsuite/gcc.dg/torture/float128-tg-3.c
new file mode 100644
index 0000000..c358187
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/float128-tg-3.c
@@ -0,0 +1,10 @@
+/* Test _Float128 type-generic built-in functions: __builtin_fpclassify. */
+/* { dg-do run } */
+/* { dg-options "" } */
+/* { dg-add-options float128 } */
+/* { dg-add-options ieee } */
+/* { dg-require-effective-target float128_runtime } */
+
+#define WIDTH 128
+#define EXT 0
+#include "floatn-tg-3.h"
diff --git a/gcc/testsuite/gcc.dg/torture/float128x-tg-3.c b/gcc/testsuite/gcc.dg/torture/float128x-tg-3.c
new file mode 100644
index 0000000..afb42d3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/float128x-tg-3.c
@@ -0,0 +1,10 @@
+/* Test _Float128x type-generic built-in functions: __builtin_fpclassify. */
+/* { dg-do run } */
+/* { dg-options "" } */
+/* { dg-add-options float128x } */
+/* { dg-add-options ieee } */
+/* { dg-require-effective-target float128x_runtime } */
+
+#define WIDTH 128
+#define EXT 1
+#include "floatn-tg-3.h"
diff --git a/gcc/testsuite/gcc.dg/torture/float16-tg-3.c b/gcc/testsuite/gcc.dg/torture/float16-tg-3.c
new file mode 100644
index 0000000..9587ec1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/float16-tg-3.c
@@ -0,0 +1,10 @@
+/* Test _Float16 type-generic built-in functions: __builtin_fpclassify. */
+/* { dg-do run } */
+/* { dg-options "" } */
+/* { dg-add-options float16 } */
+/* { dg-add-options ieee } */
+/* { dg-require-effective-target float16_runtime } */
+
+#define WIDTH 16
+#define EXT 0
+#include "floatn-tg-3.h"
diff --git a/gcc/testsuite/gcc.dg/torture/float32-tg-3.c b/gcc/testsuite/gcc.dg/torture/float32-tg-3.c
new file mode 100644
index 0000000..b07c07a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/float32-tg-3.c
@@ -0,0 +1,10 @@
+/* Test _Float32 type-generic built-in functions: __builtin_fpclassify. */
+/* { dg-do run } */
+/* { dg-options "" } */
+/* { dg-add-options float32 } */
+/* { dg-add-options ieee } */
+/* { dg-require-effective-target float32_runtime } */
+
+#define WIDTH 32
+#define EXT 0
+#include "floatn-tg-3.h"
diff --git a/gcc/testsuite/gcc.dg/torture/float32x-tg-3.c b/gcc/testsuite/gcc.dg/torture/float32x-tg-3.c
new file mode 100644
index 0000000..9f9f982
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/float32x-tg-3.c
@@ -0,0 +1,10 @@
+/* Test _Float32x type-generic built-in functions: __builtin_fpclassify. */
+/* { dg-do run } */
+/* { dg-options "" } */
+/* { dg-add-options float32x } */
+/* { dg-add-options ieee } */
+/* { dg-require-effective-target float32x_runtime } */
+
+#define WIDTH 32
+#define EXT 1
+#include "floatn-tg-3.h"
diff --git a/gcc/testsuite/gcc.dg/torture/float64-tg-3.c b/gcc/testsuite/gcc.dg/torture/float64-tg-3.c
new file mode 100644
index 0000000..a83e781
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/float64-tg-3.c
@@ -0,0 +1,10 @@
+/* Test _Float64 type-generic built-in functions: __builtin_fpclassify. */
+/* { dg-do run } */
+/* { dg-options "" } */
+/* { dg-add-options float64 } */
+/* { dg-add-options ieee } */
+/* { dg-require-effective-target float64_runtime } */
+
+#define WIDTH 64
+#define EXT 0
+#include "floatn-tg-3.h"
diff --git a/gcc/testsuite/gcc.dg/torture/float64x-tg-3.c b/gcc/testsuite/gcc.dg/torture/float64x-tg-3.c
new file mode 100644
index 0000000..195c4fd
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/float64x-tg-3.c
@@ -0,0 +1,10 @@
+/* Test _Float64x type-generic built-in functions: __builtin_fpclassify. */
+/* { dg-do run } */
+/* { dg-options "" } */
+/* { dg-add-options float64x } */
+/* { dg-add-options ieee } */
+/* { dg-require-effective-target float64x_runtime } */
+
+#define WIDTH 64
+#define EXT 1
+#include "floatn-tg-3.h"
diff --git a/gcc/testsuite/gcc.dg/torture/floatn-tg-3.h b/gcc/testsuite/gcc.dg/torture/floatn-tg-3.h
new file mode 100644
index 0000000..322e957
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/floatn-tg-3.h
@@ -0,0 +1,79 @@
+/* Tests for _FloatN / _FloatNx types: compile and execution tests for
+ type-generic built-in functions: __builtin_fpclassify. Before
+ including this file, define WIDTH as the value N; define EXT to 1
+ for _FloatNx and 0 for _FloatN. */
+
+#define __STDC_WANT_IEC_60559_TYPES_EXT__
+#include <float.h>
+
+#define CONCATX(X, Y) X ## Y
+#define CONCAT(X, Y) CONCATX (X, Y)
+#define CONCAT3(X, Y, Z) CONCAT (CONCAT (X, Y), Z)
+#define CONCAT4(W, X, Y, Z) CONCAT (CONCAT (CONCAT (W, X), Y), Z)
+
+#if EXT
+# define TYPE CONCAT3 (_Float, WIDTH, x)
+# define CST(C) CONCAT4 (C, f, WIDTH, x)
+# define MAX CONCAT3 (FLT, WIDTH, X_MAX)
+# define MIN CONCAT3 (FLT, WIDTH, X_MIN)
+# define TRUE_MIN CONCAT3 (FLT, WIDTH, X_TRUE_MIN)
+#else
+# define TYPE CONCAT (_Float, WIDTH)
+# define CST(C) CONCAT3 (C, f, WIDTH)
+# define MAX CONCAT3 (FLT, WIDTH, _MAX)
+# define MIN CONCAT3 (FLT, WIDTH, _MIN)
+# define TRUE_MIN CONCAT3 (FLT, WIDTH, _TRUE_MIN)
+#endif
+
+extern void exit (int);
+extern void abort (void);
+
+#define FP_NAN 0
+#define FP_INFINITE 1
+#define FP_ZERO 2
+#define FP_SUBNORMAL 3
+#define FP_NORMAL 4
+
+#define fpclassify(X) __builtin_fpclassify (FP_NAN, FP_INFINITE, \
+ FP_NORMAL, FP_SUBNORMAL, \
+ FP_ZERO, (X))
+
+volatile TYPE inf = __builtin_inf (), nanval = __builtin_nan ("");
+volatile TYPE neginf = -__builtin_inf (), negnanval = -__builtin_nan ("");
+volatile TYPE zero = CST (0.0), negzero = -CST (0.0), one = CST (1.0);
+volatile TYPE max = MAX, negmax = -MAX, min = MIN, negmin = -MIN;
+volatile TYPE true_min = TRUE_MIN, negtrue_min = -TRUE_MIN;
+
+/* Allow for any optimizations of comparisons involving the result of
+ fpclassify by also testing case where result is stored in a
+ volatile variable and so the comparison cannot be optimized. */
+#define CHECK_FPCLASSIFY(VAL, EXP) \
+ do \
+ { \
+ volatile int c; \
+ if (fpclassify (VAL) != (EXP)) \
+ abort (); \
+ c = fpclassify (VAL); \
+ if (c != (EXP)) \
+ abort (); \
+ } \
+ while (0)
+
+int
+main (void)
+{
+ CHECK_FPCLASSIFY (inf, FP_INFINITE);
+ CHECK_FPCLASSIFY (neginf, FP_INFINITE);
+ CHECK_FPCLASSIFY (nanval, FP_NAN);
+ CHECK_FPCLASSIFY (negnanval, FP_NAN);
+ CHECK_FPCLASSIFY (zero, FP_ZERO);
+ CHECK_FPCLASSIFY (negzero, FP_ZERO);
+ CHECK_FPCLASSIFY (one, FP_NORMAL);
+ CHECK_FPCLASSIFY (max, FP_NORMAL);
+ CHECK_FPCLASSIFY (negmax, FP_NORMAL);
+ CHECK_FPCLASSIFY (min, FP_NORMAL);
+ CHECK_FPCLASSIFY (negmin, FP_NORMAL);
+ CHECK_FPCLASSIFY (true_min, FP_SUBNORMAL);
+ CHECK_FPCLASSIFY (negtrue_min, FP_SUBNORMAL);
+ exit (0);
+}