Currently, the code is written:
````
static _Ty asinh(_Ty _Left) {
constexpr _Ty _Ln2 = 0.69314718055994530941723212145817658L;
bool _Neg = _Left < 0;
_Ty _Ans;
if (_Neg) {
_Left = -_Left;
}
if (_Left < 2 / _Flt_eps()) {
_Ans = log1p(_Left + _Left * _Left / (1 + sqrt(_Left * _Left + 1)));
} else {
_Ans = log(_Left) + _Ln2;
}
return static_cast<_Ty>(_Neg ? -_Ans : _Ans);
}
````
I tried the following in compiler explorer and it appeared to generate slightly better assembly.
````
static _Ty asinh(_Ty _Left) {
constexpr _Ty _Ln2 = 0.69314718055994530941723212145817658L;
constexpr _Ty boundary = 2 / std::numeric_limits<_Ty>::epsilon();
bool _Neg = _Left < 0;
double _Ans;
if (_Neg) {
_Left = -_Left;
}
if (_Left < boundary) {
_Ans = log1p(_Left + _Left * _Left / (1 + sqrt(_Left * _Left + 1)));
} else {
_Ans = log(_Left) + _Ln2;
}
return static_cast<double>(_Neg ? -_Ans : _Ans);
}
````
Since you鈥檙e proposing a specific code change, please submit this as a pull request so you can sign our CLA. Thanks!
Closing this for now, but we're still open to reviewing a PR.
Most helpful comment
Since you鈥檙e proposing a specific code change, please submit this as a pull request so you can sign our CLA. Thanks!