aboutsummaryrefslogtreecommitdiff
path: root/gcc/builtins.c
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/builtins.c
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/builtins.c')
-rw-r--r--gcc/builtins.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c
index cf0cfc7..b981bcd 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -7881,8 +7881,7 @@ fold_builtin_classify (location_t loc, tree fndecl, tree arg, int builtin_index)
/* 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;