https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77269

--- Comment #3 from Joseph S. Myers <jsm28 at gcc dot gnu.org> ---
Author: jsm28
Date: Mon Aug 22 18:03:59 2016
New Revision: 239665

URL: https://gcc.gnu.org/viewcvs?rev=239665&root=gcc&view=rev
Log:
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.

Added:
    trunk/gcc/testsuite/gcc.dg/torture/float128-tg-2.c
    trunk/gcc/testsuite/gcc.dg/torture/float128x-tg-2.c
    trunk/gcc/testsuite/gcc.dg/torture/float16-tg-2.c
    trunk/gcc/testsuite/gcc.dg/torture/float32-tg-2.c
    trunk/gcc/testsuite/gcc.dg/torture/float32x-tg-2.c
    trunk/gcc/testsuite/gcc.dg/torture/float64-tg-2.c
    trunk/gcc/testsuite/gcc.dg/torture/float64x-tg-2.c
    trunk/gcc/testsuite/gcc.dg/torture/floatn-tg-2.h
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/builtins.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.dg/torture/builtin-isinf_sign-1.c

Reply via email to