aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2016-08-22 19:03:59 +0100
committerJoseph Myers <jsm28@gcc.gnu.org>2016-08-22 19:03:59 +0100
commit72f52f3081af48ddddcb9e541c33fbbddfb4215d (patch)
tree92790e144d0acb87113da7350151c0896d7f9232 /gcc/testsuite/gcc.dg
parent27abac26489e547861904edf53ce1f9d3358a20d (diff)
downloadgcc-72f52f3081af48ddddcb9e541c33fbbddfb4215d.zip
gcc-72f52f3081af48ddddcb9e541c33fbbddfb4215d.tar.gz
gcc-72f52f3081af48ddddcb9e541c33fbbddfb4215d.tar.bz2
Support __builtin_isinf_sign for new floating-point types (PR middle-end/77269).
The __builtin_isinf_sign folding uses a type-specific signbit built-in function, meaning it only works for the types float, double and long double, not for types such as _FloatN, _FloatNx, __float128. Since the signbit built-in function is now type-generic, that can be used unconditionally, much as the code uses the type-generic isinf built-in function unconditionally, and this patch makes it do so, thereby enabling __builtin_isinf_sign (which glibc uses to expand the isinf macro since that macro in glibc traditionally provided the stronger guarantees about the return value given by __builtin_isinf_sign) to work for all floating-point types. The test gcc.dg/torture/builtin-isinf_sign-1.c needs updating because it tests that comparisons of calls to __builtin_isinf_sign to conditional expressions involving __builtin_isinf and __builtin_signbit* get optimized away, and with a change of what particular built-in function for signbit is used, GCC doesn't notice the expressions with type-generic and non-type-generic built-in functions are equivalent at -O0 or -O1 (it does optimize away the original test at -O2). Bootstrapped with no regressions on x86_64-pc-linux-gnu. PR middle-end/77269 gcc: * builtins.c (fold_builtin_classify): Use builtin_decl_explicit (BUILT_IN_SIGNBIT) to expand __builtin_isinf_sign. gcc/testsuite: * gcc.dg/torture/builtin-isinf_sign-1.c: Use __builtin_signbit not __builtin_signbitf and __builtin_signbitl in expected generic expansion. * gcc.dg/torture/float128-tg-2.c, gcc.dg/torture/float128x-tg-2.c, gcc.dg/torture/float16-tg-2.c, gcc.dg/torture/float32-tg-2.c, gcc.dg/torture/float32x-tg-2.c, gcc.dg/torture/float64-tg-2.c, gcc.dg/torture/float64x-tg-2.c, gcc.dg/torture/floatn-tg-2.h: New tests. From-SVN: r239665
Diffstat (limited to 'gcc/testsuite/gcc.dg')
-rw-r--r--gcc/testsuite/gcc.dg/torture/builtin-isinf_sign-1.c4
-rw-r--r--gcc/testsuite/gcc.dg/torture/float128-tg-2.c9
-rw-r--r--gcc/testsuite/gcc.dg/torture/float128x-tg-2.c9
-rw-r--r--gcc/testsuite/gcc.dg/torture/float16-tg-2.c9
-rw-r--r--gcc/testsuite/gcc.dg/torture/float32-tg-2.c9
-rw-r--r--gcc/testsuite/gcc.dg/torture/float32x-tg-2.c9
-rw-r--r--gcc/testsuite/gcc.dg/torture/float64-tg-2.c9
-rw-r--r--gcc/testsuite/gcc.dg/torture/float64x-tg-2.c9
-rw-r--r--gcc/testsuite/gcc.dg/torture/floatn-tg-2.h54
9 files changed, 119 insertions, 2 deletions
diff --git a/gcc/testsuite/gcc.dg/torture/builtin-isinf_sign-1.c b/gcc/testsuite/gcc.dg/torture/builtin-isinf_sign-1.c
index adfffcd..2579c68 100644
--- a/gcc/testsuite/gcc.dg/torture/builtin-isinf_sign-1.c
+++ b/gcc/testsuite/gcc.dg/torture/builtin-isinf_sign-1.c
@@ -15,13 +15,13 @@ foo (float f, double d, long double ld)
/* Test the generic expansion of isinf_sign. */
if (__builtin_isinf_sign(f)
- != (__builtin_isinf(f) ? (__builtin_signbitf(f) ? -1 : 1) : 0))
+ != (__builtin_isinf(f) ? (__builtin_signbit(f) ? -1 : 1) : 0))
link_error (__LINE__);
if (__builtin_isinf_sign(d)
!= (__builtin_isinf(d) ? (__builtin_signbit(d) ? -1 : 1) : 0))
link_error (__LINE__);
if (__builtin_isinf_sign(ld)
- != (__builtin_isinf(ld) ? (__builtin_signbitl(ld) ? -1 : 1) : 0))
+ != (__builtin_isinf(ld) ? (__builtin_signbit(ld) ? -1 : 1) : 0))
link_error (__LINE__);
#ifdef __OPTIMIZE__
diff --git a/gcc/testsuite/gcc.dg/torture/float128-tg-2.c b/gcc/testsuite/gcc.dg/torture/float128-tg-2.c
new file mode 100644
index 0000000..c7a32b1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/float128-tg-2.c
@@ -0,0 +1,9 @@
+/* Test _Float128 type-generic built-in functions: __builtin_isinf_sign. */
+/* { dg-do run } */
+/* { dg-options "" } */
+/* { dg-add-options float128 } */
+/* { dg-require-effective-target float128_runtime } */
+
+#define WIDTH 128
+#define EXT 0
+#include "floatn-tg-2.h"
diff --git a/gcc/testsuite/gcc.dg/torture/float128x-tg-2.c b/gcc/testsuite/gcc.dg/torture/float128x-tg-2.c
new file mode 100644
index 0000000..e5c1b0c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/float128x-tg-2.c
@@ -0,0 +1,9 @@
+/* Test _Float128x type-generic built-in functions: __builtin_isinf_sign. */
+/* { dg-do run } */
+/* { dg-options "" } */
+/* { dg-add-options float128x } */
+/* { dg-require-effective-target float128x_runtime } */
+
+#define WIDTH 128
+#define EXT 1
+#include "floatn-tg-2.h"
diff --git a/gcc/testsuite/gcc.dg/torture/float16-tg-2.c b/gcc/testsuite/gcc.dg/torture/float16-tg-2.c
new file mode 100644
index 0000000..4236018
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/float16-tg-2.c
@@ -0,0 +1,9 @@
+/* Test _Float16 type-generic built-in functions: __builtin_isinf_sign. */
+/* { dg-do run } */
+/* { dg-options "" } */
+/* { dg-add-options float16 } */
+/* { dg-require-effective-target float16_runtime } */
+
+#define WIDTH 16
+#define EXT 0
+#include "floatn-tg-2.h"
diff --git a/gcc/testsuite/gcc.dg/torture/float32-tg-2.c b/gcc/testsuite/gcc.dg/torture/float32-tg-2.c
new file mode 100644
index 0000000..80441d7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/float32-tg-2.c
@@ -0,0 +1,9 @@
+/* Test _Float32 type-generic built-in functions: __builtin_isinf_sign. */
+/* { dg-do run } */
+/* { dg-options "" } */
+/* { dg-add-options float32 } */
+/* { dg-require-effective-target float32_runtime } */
+
+#define WIDTH 32
+#define EXT 0
+#include "floatn-tg-2.h"
diff --git a/gcc/testsuite/gcc.dg/torture/float32x-tg-2.c b/gcc/testsuite/gcc.dg/torture/float32x-tg-2.c
new file mode 100644
index 0000000..897130a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/float32x-tg-2.c
@@ -0,0 +1,9 @@
+/* Test _Float32x type-generic built-in functions: __builtin_isinf_sign. */
+/* { dg-do run } */
+/* { dg-options "" } */
+/* { dg-add-options float32x } */
+/* { dg-require-effective-target float32x_runtime } */
+
+#define WIDTH 32
+#define EXT 1
+#include "floatn-tg-2.h"
diff --git a/gcc/testsuite/gcc.dg/torture/float64-tg-2.c b/gcc/testsuite/gcc.dg/torture/float64-tg-2.c
new file mode 100644
index 0000000..dddaa82
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/float64-tg-2.c
@@ -0,0 +1,9 @@
+/* Test _Float64 type-generic built-in functions: __builtin_isinf_sign. */
+/* { dg-do run } */
+/* { dg-options "" } */
+/* { dg-add-options float64 } */
+/* { dg-require-effective-target float64_runtime } */
+
+#define WIDTH 64
+#define EXT 0
+#include "floatn-tg-2.h"
diff --git a/gcc/testsuite/gcc.dg/torture/float64x-tg-2.c b/gcc/testsuite/gcc.dg/torture/float64x-tg-2.c
new file mode 100644
index 0000000..647d104
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/float64x-tg-2.c
@@ -0,0 +1,9 @@
+/* Test _Float64x type-generic built-in functions: __builtin_isinf_sign. */
+/* { dg-do run } */
+/* { dg-options "" } */
+/* { dg-add-options float64x } */
+/* { dg-require-effective-target float64x_runtime } */
+
+#define WIDTH 64
+#define EXT 1
+#include "floatn-tg-2.h"
diff --git a/gcc/testsuite/gcc.dg/torture/floatn-tg-2.h b/gcc/testsuite/gcc.dg/torture/floatn-tg-2.h
new file mode 100644
index 0000000..1060da6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/floatn-tg-2.h
@@ -0,0 +1,54 @@
+/* Tests for _FloatN / _FloatNx types: compile and execution tests for
+ type-generic built-in functions: __builtin_isinf_sign. 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)
+#else
+# define TYPE CONCAT (_Float, WIDTH)
+# define CST(C) CONCAT3 (C, f, WIDTH)
+# define MAX CONCAT3 (FLT, WIDTH, _MAX)
+#endif
+
+extern void exit (int);
+extern void abort (void);
+
+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;
+
+int
+main (void)
+{
+ if (__builtin_isinf_sign (inf) != 1)
+ abort ();
+ if (__builtin_isinf_sign (neginf) != -1)
+ abort ();
+ if (__builtin_isinf_sign (nanval) != 0)
+ abort ();
+ if (__builtin_isinf_sign (negnanval) != 0)
+ abort ();
+ if (__builtin_isinf_sign (zero) != 0)
+ abort ();
+ if (__builtin_isinf_sign (negzero) != 0)
+ abort ();
+ if (__builtin_isinf_sign (one) != 0)
+ abort ();
+ if (__builtin_isinf_sign (max) != 0)
+ abort ();
+ if (__builtin_isinf_sign (negmax) != 0)
+ abort ();
+ exit (0);
+}