Support __builtin_isinf_sign for new floating-point types (PR middle-end/77269).
commit72f52f3081af48ddddcb9e541c33fbbddfb4215d
authorJoseph Myers <joseph@codesourcery.com>
Mon, 22 Aug 2016 18:03:59 +0000 (22 19:03 +0100)
committerJoseph Myers <jsm28@gcc.gnu.org>
Mon, 22 Aug 2016 18:03:59 +0000 (22 19:03 +0100)
tree92790e144d0acb87113da7350151c0896d7f9232
parent27abac26489e547861904edf53ce1f9d3358a20d
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
12 files changed:
gcc/ChangeLog
gcc/builtins.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/builtin-isinf_sign-1.c
gcc/testsuite/gcc.dg/torture/float128-tg-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/float128x-tg-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/float16-tg-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/float32-tg-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/float32x-tg-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/float64-tg-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/float64x-tg-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/floatn-tg-2.h [new file with mode: 0644]