https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88556
Bug ID: 88556
Summary: Inline built-in sinh, cosh, tanh for -ffast-math
Product: gcc
Version: 9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: jsm28 at gcc dot gnu.org
Target Milestone: ---
Target: i?86-*-*
GCC should support inline code generation for sinh, cosh, tanh functions, under
appropriate fast-math conditions.
glibc's bits/mathinline.h, for 32-bit non-SSE fast-math x86 only, has:
/* The argument range of the inline version of sinhl is slightly reduced. */
__inline_mathcodeNP (sinh, __x, \
register long double __exm1 = __expm1l (__fabsl (__x)); \
return 0.5 * (__exm1 / (__exm1 + 1.0) + __exm1) * __sgn1l (__x))
__inline_mathcodeNP (cosh, __x, \
register long double __ex = __expl (__x); \
return 0.5 * (__ex + 1.0 / __ex))
__inline_mathcodeNP (tanh, __x, \
register long double __exm1 = __expm1l (-__fabsl (__x + __x)); \
return __exm1 / (__exm1 + 2.0) * __sgn1l (-__x))
We're moving away from such inlines in glibc, preferring to leave it to the
compiler to inline standard functions under appropriate conditions. This
inlining probably only makes sense when expm1l / expl are themselves expanded
inline (but in principle it's otherwise generic; note this x86 code uses long
double, so avoiding reducing the argument range for built-in functions for
narrower types).
flag_unsafe_math_optimizations should be required for all these expansions; the
sinh one is specifically unsafe for infinite arguments so should also require
flag_finite_math_only.