+2016-08-22 Joseph Myers <joseph@codesourcery.com>
+
+ PR middle-end/77269
+ * builtins.c (fold_builtin_classify): Use builtin_decl_explicit
+ (BUILT_IN_SIGNBIT) to expand __builtin_isinf_sign.
+
2016-08-22 Patrick Palka <ppalka@gcc.gnu.org>
* print-tree.c (print_node) [VECTOR_CST]: Coalesce the output of
/* In a boolean context, GCC will fold the inner COND_EXPR to
1. So e.g. "if (isinf_sign(x))" would be folded to just
"if (isinf(x) ? 1 : 0)" which becomes "if (isinf(x))". */
- tree signbit_fn = mathfn_built_in_1
- (TREE_TYPE (arg), CFN_BUILT_IN_SIGNBIT, 0);
+ tree signbit_fn = builtin_decl_explicit (BUILT_IN_SIGNBIT);
tree isinf_fn = builtin_decl_explicit (BUILT_IN_ISINF);
tree tmp = NULL_TREE;
+2016-08-22 Joseph Myers <joseph@codesourcery.com>
+
+ PR middle-end/77269
+ * 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.
+
2016-08-22 Joseph Myers <joseph@codesourcery.com>
* gcc.dg/torture/float128-builtin.c,
/* 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__
--- /dev/null
+/* 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"
--- /dev/null
+/* 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"
--- /dev/null
+/* 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"
--- /dev/null
+/* 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"
--- /dev/null
+/* 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"
--- /dev/null
+/* 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"
--- /dev/null
+/* 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"
--- /dev/null
+/* 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);
+}