Commit Graph

5 Commits

Author SHA1 Message Date
Joseph Myers bfff8b1bec Update copyright dates with scripts/update-copyrights. 2017-01-01 00:14:16 +00:00
Joseph Myers e886c36771 Clean up some complex functions raising FE_INVALID.
Some of the complex arithmetic functions have the following pattern:
in some piece of code, one part of the input (real or imaginary,
depending on the function) is either infinite or NaN.  Part of the
result is to be set to NaN in either case, and FE_INVALID raised only
if the relevant part of the input was infinite.

In such a case, there is no actual need for the conditional on the
type of the input, since subtracting the relevant part of the input
from itself will produce a NaN, with FE_INVALID only if the relevant
part of the input was infinite.  This simplifies the code, and as a
quality-of-implementation matter also improves things by propagating
NaN payloads.  (Right now these functions always raise FE_INVALID for
signaling NaN arguments because of the call to fpclassify - at least
unless glibc is built with -Os - but if fpclassify moves to using
integer arithmetic in future, doing arithmetic on the NaN argument
also ensures an exception for sNaNs.)

Tested for x86_64 and x86.

	* math/s_ccosh_template.c (M_DECL_FUNC (__ccosh)): Instead of
	raising FE_INVALID with feraisexcept in case where part of
	argument is infinite, subtract that part of argument from itself.
	* math/s_cexp_template.c (M_DECL_FUNC (__cexp)): Likewise.
	* math/s_csin_template.c (M_DECL_FUNC (__csin)): Likewise.
	* math/s_csinh_template.c (M_DECL_FUNC (__csinh)): Likewise.
2016-10-14 00:12:56 +00:00
Joseph Myers 4d5940f015 Avoid M_NAN + M_NAN in complex functions.
Some libm complex functions have code that computes M_NAN + M_NAN.
This is nonsensical; it's just equivalent to M_NAN, since it's a quiet
NaN (and the comments suggesting this raises an exception are
similarly wrong).  This patch changes the code just to use M_NAN (and
removes the bogus comments).  (Preferably, code should either
propagate an input NaN or do a computation that raises "invalid" and
generates a default NaN at the same time.  There are various cases,
however, that currently raise "invalid" even for NaN inputs; I think
those are cases where "invalid" is optional in ISO C so a change to
whether it's raised would be OK, but they would still need more
careful consideration than the cases where such issues do not arise.)

Tested for x86_64 and x86 (testsuite, and that installed stripped
shared libraries are unchanged by the patch).

	* math/s_ccosh_template.c (M_DECL_FUNC (__ccosh)): Use M_NAN
	instead of M_NAN + M_NAN.
	* math/s_csinh_template.c (M_DECL_FUNC (__csinh)): Likewise.
2016-10-11 00:50:43 +00:00
Paul E. Murphy c50eee19c4 Convert _Complex sine functions to generated code
Refactor s_c{,a}sin{,h}{f,,l} into a single templated
macro.
2016-08-19 16:46:41 -05:00
Paul E. Murphy ffb84f5e19 Prepare to convert _Complex sine functions
This patch has no function changes, except to
ensure the git history correctly tracks the
changes to convert the double version of these
functions into a templated version.
2016-08-19 16:12:36 -05:00