Fix powerpc-nofpu complex long double functions spurious "invalid" exception (bug 22687).

For soft-float powerpc, various _Complex long double functions
generate spurious "invalid" exceptions, even with a compiler with GCC
bug 64811 fixed.

The problem is GCC's built-in fabsl expansion.  Various files are
already built with -fno-builtin-fabsl because in this case (IBM long
double, for soft-float or e500v1) a fallback fabsl expansion based on
comparisons is used, which can produce the wrong sign of a zero
result.  Those comparisons can also produce spurious exceptions for
NaN arguments.  Furthermore, __builtin_fpclassify implemently uses
__builtin_fabsl, and is unaffected by -fno-builtin-fabsl, and the
fpclassify macro uses __builtin_fpclassify in the absence of
-fsignaling-nans.  Thus, this patch arranges for the problem files
using fpclassify to be built with -fsignaling-nans in this case, to
avoid spurious exceptions from fpclassify.

Tested for powerpc (soft-float).

	[BZ #22687]
	* sysdeps/powerpc/nofpu/Makefile (CFLAGS-s_cacosl.c): New
	variable.
	(CFLAGS-s_cacoshl.c): Likewise.
	(CFLAGS-s_casinhl.c): Likewise.
	(CFLAGS-s_catanl.c): Likewise.
	(CFLAGS-s_catanhl.c): Likewise.
	(CFLAGS-s_cexpl.c): Likewise.
	(CFLAGS-s_ccoshl.c): Add -fsignaling-nans.
	(CFLAGS-s_csinhl.c): Likewise.
	(CFLAGS-s_clogl.c): Likewise.
	(CFLAGS-s_clog10l.c): Likewise.
	(CFLAGS-s_csinl.c): Likewise.
	(CFLAGS-s_csqrtl.c): Likewise.
This commit is contained in:
Joseph Myers 2018-01-09 22:34:35 +00:00
parent 311ba8dc44
commit e134ca1753
2 changed files with 37 additions and 6 deletions

View File

@ -1,3 +1,20 @@
2018-01-09 Joseph Myers <joseph@codesourcery.com>
[BZ #22687]
* sysdeps/powerpc/nofpu/Makefile (CFLAGS-s_cacosl.c): New
variable.
(CFLAGS-s_cacoshl.c): Likewise.
(CFLAGS-s_casinhl.c): Likewise.
(CFLAGS-s_catanl.c): Likewise.
(CFLAGS-s_catanhl.c): Likewise.
(CFLAGS-s_cexpl.c): Likewise.
(CFLAGS-s_ccoshl.c): Add -fsignaling-nans.
(CFLAGS-s_csinhl.c): Likewise.
(CFLAGS-s_clogl.c): Likewise.
(CFLAGS-s_clog10l.c): Likewise.
(CFLAGS-s_csinl.c): Likewise.
(CFLAGS-s_csqrtl.c): Likewise.
2010-08-04 Emilio Pozuelo Monfort <pochu27@gmail.com>
2017-09-26 Svante Signell <svante.signell@gmail.com>

View File

@ -15,15 +15,29 @@ CPPFLAGS += -I../soft-fp/
# gcc-4.1.1 and may be too late for gcc-4.2. So we need these flags
# until the fix in a gcc release and glibc drops support for earlier
# versions of gcc.
#
# This bug can cause wrong signs of zero results from fabsl, and
# spurious "invalid" exceptions from comparisons with NaN in the
# default code sequence generated. The fpclassify expansion used by
# __builtin_fpclassify, which is used in the absence of
# -fsignaling-nans, uses __builtin_fabsl, and is not affected by
# -fno-builtin-fabsl, so requiring -fsignaling-nans for some affected
# source files.
CFLAGS-e_atan2l.c += -fno-builtin-fabsl
CFLAGS-e_hypotl.c += -fno-builtin-fabsl
CFLAGS-e_powl.c += -fno-builtin-fabsl
CFLAGS-s_ccoshl.c += -fno-builtin-fabsl
CFLAGS-s_csinhl.c += -fno-builtin-fabsl
CFLAGS-s_clogl.c += -fno-builtin-fabsl
CFLAGS-s_clog10l.c += -fno-builtin-fabsl
CFLAGS-s_csinl.c += -fno-builtin-fabsl
CFLAGS-s_csqrtl.c += -fno-builtin-fabsl
CFLAGS-s_cacosl.c += -fsignaling-nans
CFLAGS-s_cacoshl.c += -fsignaling-nans
CFLAGS-s_casinhl.c += -fsignaling-nans
CFLAGS-s_catanl.c += -fsignaling-nans
CFLAGS-s_catanhl.c += -fsignaling-nans
CFLAGS-s_ccoshl.c += -fno-builtin-fabsl -fsignaling-nans
CFLAGS-s_cexpl.c += -fsignaling-nans
CFLAGS-s_csinhl.c += -fno-builtin-fabsl -fsignaling-nans
CFLAGS-s_clogl.c += -fno-builtin-fabsl -fsignaling-nans
CFLAGS-s_clog10l.c += -fno-builtin-fabsl -fsignaling-nans
CFLAGS-s_csinl.c += -fno-builtin-fabsl -fsignaling-nans
CFLAGS-s_csqrtl.c += -fno-builtin-fabsl -fsignaling-nans
CFLAGS-w_acosl_compat.c += -fno-builtin-fabsl
CFLAGS-w_asinl_compat.c += -fno-builtin-fabsl
CFLAGS-w_atanhl_compat.c += -fno-builtin-fabsl