#include <stdint.h>
#include <stdbool.h>
#ifdef CORE_MATH_SUPPORT_ERRNO
#include <errno.h>
#endif
#include "expl_tables.h"
#include "tint.h"
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
#endif
#pragma STDC FENV_ACCESS ON
typedef union {
long double f;
struct __attribute__((packed)) {uint64_t m;uint32_t e:16;uint32_t empty:16;};
} b96u96_u;
typedef union {
double f;
struct __attribute__((packed)) {uint64_t m:52;uint32_t e:11;uint32_t s:1;};
uint64_t u;
} b64u64_u;
static inline void a_mul(double *hi, double *lo, double a, double b) {
*hi = a * b;
*lo = __builtin_fma (a, b, -*hi);
}
static inline void
fast_two_sum(double *s, double *t, double a, double b)
{
*s = a + b;
double e = *s - a;
*t = b - e;
}
static inline void d_mul(double *hi, double *lo, double ah, double al,
double bh, double bl) {
double s, t;
a_mul (hi, &s, ah, bh);
t = __builtin_fma (al, bh, s);
*lo = __builtin_fma (ah, bl, t);
}
typedef struct {
int32_t extra_exponent;
uint64_t fracpart;
double xs;
} redinfo;
static inline long double
fastpath(long double x, redinfo* ri, bool* need_accurate) {
b96u96_u cvt_x; cvt_x.f = x;
b64u64_u cvt_w, cvt_aux;
cvt_w.u = ((cvt_x.e&0x8000ull) << (63 - 15)) | (((cvt_x.e&0x7ffful) + (1023ul - 16383ul)) << (64 - 12)) |
((cvt_x.m >> 11) & ~(1ull << 52)); double xh0 = cvt_w.f;
cvt_w.u = ((cvt_x.e&0x8000ull) << (63 - 15)) | (((cvt_x.e&0x7ffful) + (1023ul - 16383ul - 11)) << (64 - 12)) |
(cvt_x.m & ((1ul << 11) - 1ul));
cvt_aux.u = ((cvt_x.e&0x8000ul) << (63 - 15)) | (((cvt_x.e&0x7ffful) + (1023ul - 16383ul - 11)) << (64 - 12));
double xl0 = cvt_w.f - cvt_aux.f;
static const double ln2invh = 0x1.71547652b82fep+0;
static const double ln2invl = 0x1.777d0ffda0d24p-56;
static const double C = 0x1.8p+32;
double xh, xl;
b64u64_u y = {.f = __builtin_fma (xh0, ln2invh, C)};
d_mul (&xh, &xl, ln2invh, ln2invl, xh0, xl0);
b64u64_u cvt = {.f = xh};
bool do_red = cvt.e >= -20 + 0x3ff;
if (__builtin_expect (do_red, 1)) { double remaining = xh - (y.f - C);
fast_two_sum (&xh, &xl, remaining, xl);
}
uint64_t fracpart = y.u;
int16_t extra_exponent = y.u >> 20;
int i0 = fracpart & 0x1f;
int i1 = (fracpart >> 5) & 0x1f;
int i2 = (fracpart >> 10) & 0x1f;
int i3 = (fracpart >> 15) & 0x1f;
double frcp_acc0_l, frcp_acc0_h, frcp_acc2_h, frcp_acc2_l;
double xs_pow2_h, xs_pow2_l;
d_mul(&frcp_acc0_h, &frcp_acc0_l,
t0[i0][0], t0[i0][1], t1[i1][0], t1[i1][1]);
d_mul(&frcp_acc2_h, &frcp_acc2_l,
t2[i2][0], t2[i2][1], t3[i3][0], t3[i3][1]);
d_mul(&xs_pow2_h, &xs_pow2_l, frcp_acc0_h, frcp_acc0_l,
frcp_acc2_h, frcp_acc2_l);
double xsq = xh * xh;
double orders23 = xsq * __builtin_fma (xh, 0x1.c6b08d704a1cdp-5,
0x1.ebfbdff82c696p-3);
double order1h, order1l;
static const double coeff1h = 0x1.62e42fefa39efp-1;
static const double coeff1l = 0x1.abc9e3b369936p-56;
d_mul (&order1h, &order1l, coeff1h, coeff1l, xh, xl);
double finalh, finall;
fast_two_sum (&finalh, &finall, 1, orders23);
double tmp;
fast_two_sum(&finalh, &tmp, finalh, order1h);
finall = tmp + (finall + order1l);
int64_t err; if(__builtin_expect(do_red,1)) {
d_mul(&finalh, &finall, finalh, finall, xs_pow2_h, xs_pow2_l);
err = -87;
} else {
extra_exponent = 0;
err = -89;
}
fast_two_sum(&finalh, &finall, finalh, finall);
b64u64_u th = {.f = finalh}, tl = {.f = finall};
long eh = th.u>>52, el = (tl.u>>52) & 0x3ff, de = eh - el;
int64_t ml = (tl.u & ~(0xfffull<<52)) | (1ll<<52), sgnl = -(tl.u >> 63);
ml = (ml ^ sgnl) - sgnl;
int64_t mlt;
long sh = de - 11;
if(__builtin_expect(sh>63,0)){ mlt = sgnl;
if(__builtin_expect(sh-64>63,0)) ml = sgnl;
else
ml >>= sh - 64;
} else {
mlt = ml>>sh; ml = (uint64_t)ml<<(64-sh); }
uint64_t mh = (th.u<<11) | (1ull<<63);
int64_t eps = (mh >> (-err - 64));
mh += mlt; if(__builtin_expect(!(mh>>63),0)){
mh = (mh << 1) | ((uint64_t)ml >> 63);
ml = (uint64_t)ml<<1;
extra_exponent--;
eps <<= 1;
}
int wanted_exponent = extra_exponent + 0x3c00 + eh;
if(__builtin_expect(wanted_exponent <= 0, 0)) {
int shiftby = 1 - wanted_exponent;
if(__builtin_expect(shiftby >= 64, 0)) {
ml = mh >> (shiftby-64);
eps = 1;
mh = 0;
if(__builtin_expect(shiftby > 65, 0)) {
return 0x1p-16445L * .25L;
}
} else {
ml = (uint64_t)ml >> shiftby;
ml |= mh << (64 - shiftby);
mh >>= shiftby;
eps >>= shiftby;
}
wanted_exponent = 0;
}
uint64_t oldmh = mh;
float op = 1.0f + 0x1p-25f, om = 1.0f - 0x1p-25f;
if(op==om){ // round to nearest
mh += (uint64_t)ml>>63;
ml ^= (1ull << 63);
} else if(op>1.0f) { // round to +inf
mh += 1;
}
/* Notice that having modified the high bit of ml suitably (which is the
rounding bit) we have that ml, as a signed integer, has as (scaled)
absolute value the distance between m and the rounding boundary.
This will be used for the rounding test.
*/
// This branch can only be taken if wanted_exponent != 0
// Else we simply cannot have an overflow
if(__builtin_expect(mh < oldmh, 0)) {
ml = ml/2; // Signed semantics matter
eps >>= 1;
mh = 1ull << 63;
wanted_exponent++;
}
// We had a denormal but rounding made it into the smallest normal
if(__builtin_expect((mh>>63) && !wanted_exponent, 0)) {
wanted_exponent = 1;
}
b96u96_u v;
v.m = mh; // mantissa
v.e = wanted_exponent; //extra_exponent + 0x3c00 + eh; // exponent
// Given the signedness, this test expresses that ml >= -eps and that
// ml <= eps. This holds true because eps fits in 128-87=41 bits.
bool b1 = (uint64_t)ml + eps <= (uint64_t)(2*eps);
// Denormals *inside* the computation don't seem to pause a problem
// given the error analysis (we used absolute bounds mostly)
// rounding test
*need_accurate = b1;
if(__builtin_expect(b1 != 0, 0)) {
ri->fracpart = fracpart;
ri->xs = y.f - C;
/* y.f - C = r (see above). Since we have
xh + xl = x / log(2) + eps1 with |eps1| < 2^-123.3,
|r - xh| < 2^-20 and |xl| < 2^-37, we have:
|xs - x/log(2)| < 2^-20 + 2^-37 + 2^-123.3 < 2^-19.999 */
ri->extra_exponent = extra_exponent;
}
// Infinity output case
if(__builtin_expect(wanted_exponent >= 32767, 0)) {
#ifdef CORE_MATH_SUPPORT_ERRNO
errno = ERANGE; // overflow
#endif
return 0x1p16383L + 0x1p16383L;
}
return v.f;
}
typedef struct {
double h,l;
} dd;
// r has value a * 2^exp
static inline
void tint_mul2exp(tint_t* r, int64_t a, int64_t exp) {
r->sgn = (uint64_t)a >> 63;
if(r->sgn) {a = -a;}
if(__builtin_expect(!a, 0)) {
cp_tint(r, &ZERO);
}
int clz = (a) ? __builtin_clzll(a) : 0;
r->ex = exp - clz + 64;
r->h = (uint64_t)a << clz;
r->m = r->l = 0;
}
/*
Convert a double double into tint_t representation.
This is minimalistic : it assumes toload->h is nonzero,
that toload->h + toload->l has the binade of toload->h,
and that the exponent difference is less than 75.
Under those assumptions (which are satisfied by the
lookup tables t0...t3) the operation is exact.
*/
static inline void
load_dd (tint_t *a, const dd* toload) {
b64u64_u u = {.f = toload->h};
a->sgn = u.u >> 63;
uint64_t ax = u.u & (-1l ^ (1ull << 63));
u.f = toload->l;
uint64_t bx = u.u & (-1l ^ (1ull << 63));
// We assume toload->h is not 0
int64_t exp = (ax >> 52) - 1023;
a->ex = exp + 1;
unsigned __int128 mantissa = (1ull << 63) | (ax << 11);
mantissa <<= 64;
a->_h = mantissa;
a->l = 0;
if(__builtin_expect(bx >> 52 != 0, 1)) { // toload->l != 0
int de = (ax >> 52) - (bx >> 52);
unsigned __int128 mantissa_b = (1ull << 52) | (bx & ((1ull << 52) - 1));
mantissa_b <<= 75 - de; // If de was 0, we would shift 12+63
if((u.u>>63) ^ a->sgn) { // We do *not* handle underflows/overflows
mantissa_b = -mantissa_b;
}
mantissa += mantissa_b;
}
a->_h = mantissa;
a->l = 0;
}
// load x into a tint assuming it is not a denormal (exact).
static inline void
load_ld(tint_t *t, long double x) {
b96u96_u cvt = {.f = x};
// for tints, a number with exponent 0 is in [1/2, 1)
// for long double, a a number with (unbiased) exponent 0 is in [1, 2)
// thus we have to add 1 to the unbiased exponent
t->ex = 1 + ((cvt.e & 0x7fff) - 16383);
t->h = cvt.m;
t->m = t->l = 0;
t->sgn = cvt.e >> 15;
}
/*
pow2_xs(x, fracpart, &corr) puts a value c in corr
such that 2^fracpart * exp(c/2^168) = x * (1 + e) with
|e| < 2^-167.026, where by "fracpart" we mean the low 20 bits
of fracpart, divided by 2^20.
*/
static inline void
pow2_xs (tint_t *x, uint64_t fracpart, int64_t* corr) {
// Decompose fracpart as i0/2^20 + i1/2^15 + i2/2^10 + i3/2^5
int i0 = fracpart & 0x1f;
int i1 = (fracpart >> 5) & 0x1f;
int i2 = (fracpart >> 10) & 0x1f;
int i3 = (fracpart >> 15) & 0x1f;
/*
By construction, we have for all k, 0 <= k < 4,
2^(ik/2^(20 - 5k)) * exp(tk_corr[ik]/2^168 + errk) = tmpk
with |err0| < 2^-169.005, |err1| < 2^-169.049, |err2| < 2^-169.031,
and |err3| < 2^-169.024.
Therefore, discounting rounding,
2^fracpart * exp(corr0 + ... + corr3) = tmp0 * ... * tmp3 * exp(-t)
for some t with |t| < 2^-169.005 + 2^-169.049 + 2^-169.031 + 2^-169.024
< 2^-167.027.
tint_t tmp0[1], tmp1[1], tmp2[1], tmp3[1];
load_dd (tmp0, (dd*)(&t0[i0])); int64_t corr0 = t0_corr[i0];
load_dd (tmp1, (dd*)(&t1[i1])); int64_t corr1 = t1_corr[i1];
load_dd (tmp2, (dd*)(&t2[i2])); int64_t corr2 = t2_corr[i2];
load_dd (tmp3, (dd*)(&t3[i3])); int64_t corr3 = t3_corr[i3];
tint_t acc0[1], acc1[1];
mul_tint(acc0, tmp0, tmp1);
mul_tint(acc1, tmp2, tmp3);
mul_tint(x, acc0, acc1);
*corr = corr0 + corr1 + corr2 + corr3;
}
static inline void
compute_reducted(tint_t *xred,
const tint_t* x, double xs, int64_t correction) {
static const tint_t logeff2 = {
.h = 0xb17217f7d1cf79abULL,
.m = 0xc9e3b39803f2f6afULL,
.l = 0x40f343267298b62eULL,
.ex = 0, .sgn = 0};
tint_t t_xs;
tint_fromd(&t_xs, -xs);
mul_tint(xred, &logeff2, &t_xs);
add_tint(xred, xred, x);
tint_t corr;
tint_mul2exp(&corr, correction, -168); corr.sgn ^= 1;
add_tint(xred, xred, &corr);
}
struct fint {
int ex;
int64_t m; };
static inline void
evaluate_polynomial(tint_t *y, const tint_t* x) {
tint_t x2[1]; mul_tint(x2, x, x);
tint_t x4[1]; mul_tint(x4, x2, x2);
static const tint_t c2 = {.h = 0x8000000000000000ull,
.m = 0x0000000000000000ull,
.l = 0x0000000000000000ull,
.ex = 0, .sgn = 0};
static const tint_t c3 = {.h = 0xaaaaaaaaaaaaaaaaull,
.m = 0xaaaaaaaaaaaaaaaaull,
.l = 0xaaaaaaaaaaaaaaabull,
.ex = -2, .sgn = 0};
tint_t order23[1];
mul_tint(order23, &c3, x);
add_tint(order23, order23, &c2);
mul_tint(order23, order23, x2);
static const tint_t c4 = {.h = 0xaaaaaaaaaaaaaaaaull,
.m = 0xaaaaaaaaaaaaaaaaull,
.l = 0xaaaaaaaaaaaaaaabull,
.ex = -4, .sgn = 0};
static const tint_t c5 = {.h = 0x8888888888888888ull,
.m = 0x8888888888888888ull,
.l = 0x8888888888888889ull,
.ex = -6, .sgn = 0};
static const tint_t c6 = {.h = 0xb60b60b60b60b60bull,
.m = 0x60b60b60b60b60b6ull,
.l = 0x0b60b60b60b60b61ull,
.ex = -9, .sgn = 0};
static const tint_t c7 = {.h = 0xd00d00d00d00d00dull,
.m = 0x00d00d00d00d00d0ull,
.l = 0x0d00d00d00d00d01ull,
.ex = -12, .sgn = 0};
tint_t order45[1];
mul_tint(order45, &c5, x);
add_tint(order45, order45, &c4);
tint_t order67[1];
mul_tint(order67, &c7, x);
add_tint(order67, order67, &c6);
mul_tint(order67, order67, x2);
tint_t order4567[1];
add_tint(order4567, order45, order67);
mul_tint(order4567, order4567, x4);
add_tint(y, &ONE, x);
add_tint(y, y, order23);
add_tint(y, y, order4567);
}
__attribute__((cold))
static
long double accurate_path(long double x, const redinfo* ri) {
tint_t tx[1];
load_ld(tx, x); tint_t final[1];
if(tx->ex > -20) { int64_t correction;
tint_t p2_xs[1];
pow2_xs (p2_xs, ri->fracpart, &correction);
tint_t xred[1];
compute_reducted (xred, tx, ri->xs, correction);
tint_t poly[1];
evaluate_polynomial (poly, xred);
mul_tint(final, poly, p2_xs);
final->ex += ri->extra_exponent;
} else { evaluate_polynomial (final, tx);
}
final->ex += 16383 - 1; if(final->ex <= 0) {
int shiftby = 1 - final->ex;
if(__builtin_expect(shiftby == 64, 0)) {
return 0x1p-16445L * .75L;
}
if(__builtin_expect(shiftby > 64, 0)) {
return 0x1p-16445L * .25L;
}
rshift (final, final, shiftby);
final->ex = 0;
}
float op = 1.0f + 0x1p-25f, om = 1.0f - 0x1p-25f;
if(op == om) {
final->h += final->m >> 63;
final->m ^= 1ull << 63;
} else if(op > 1.0f) {
final->h += 1;
}
if(__builtin_expect(!final->h, 0)) {
final->h = 1ull << 63;
final->l >>= 1;
final->l |= (final->m & 1) << 63;
final->m /= 2; // Signed semantics matter
final->ex++;
}
if(__builtin_expect((final->h>>63) && !final->ex, 0)) {
final->ex = 1;
}
if(__builtin_expect(final->ex >= 32767, 0)) {
return 0x1p16383L + 0x1p16383L;
}
/* The search for hard-to-round cases is done, thus at this point
we are sure that all values are correctly rounded. */
b96u96_u retval;
retval.e = final->ex;
retval.m = final->h;
return retval.f;
};
__attribute__((cold))
static
long double catch_exceptions(long double x, bool* caught) {
/* upper_except holds pairs (x, y) where exp(x) is rounded down to y
when rounding to nearest (the real value is a bit above y).
lower_except holds pairs where exp(x) is rounded up to y when rounding
to nearest (the real value is a bit below y).
We do not expect a lot of exceptions; if they become too numerous
binary search would be more efficient.
*/
#define UPPER_EXCEPT 21
static const long double upper_except[UPPER_EXCEPT][2] = {
{-0x1.0000000000000002p-62L,0x1.fffffffffffffff8p-1L},
{-0x1.0000000000000004p-61L,0x1.fffffffffffffffp-1L},
{-0x1.8000000000000012p-60L,0x1.ffffffffffffffdp-1L},
{-0x1.0000000000000008p-60L,0x1.ffffffffffffffep-1L},
{-0x1.8000000000000024p-59L,0x1.ffffffffffffffap-1L},
{-0x1.000000000000001p-59L,0x1.ffffffffffffffcp-1L},
{-0x1.c000000000000062p-58L,0x1.ffffffffffffff2p-1L},
{-0x1.8000000000000048p-58L,0x1.ffffffffffffff4p-1L},
{-0x1.4000000000000032p-58L,0x1.ffffffffffffff6p-1L},
{-0x1.000000000000002p-58L,0x1.ffffffffffffff8p-1L},
{-0x1.c0000000000000c4p-57L,0x1.fffffffffffffe4p-1L},
{-0x1.800000000000009p-57L,0x1.fffffffffffffe8p-1L},
{-0x1.4000000000000064p-57L,0x1.fffffffffffffecp-1L},
{-0x1.000000000000004p-57L,0x1.ffffffffffffffp-1L},
{-0x1.c000000000000188p-56L,0x1.fffffffffffffc8p-1L},
{-0x1.a000000000000152p-56L,0x1.fffffffffffffccp-1L},
{-0x1.800000000000012p-56L,0x1.fffffffffffffdp-1L},
{-0x1.60000000000000f2p-56L,0x1.fffffffffffffd4p-1L},
{-0x1.40000000000000c8p-56L,0x1.fffffffffffffd8p-1L},
{-0x1.20000000000000a2p-56L,0x1.fffffffffffffdcp-1L},
{-0x1.000000000000008p-56L,0x1.fffffffffffffep-1L},
};
#define LOWER_EXCEPT 22
static const long double lower_except[LOWER_EXCEPT][2] = {
{0x1.1fffffffffffff5ep-56L,0x1.000000000000012p+0L},
{0x1.3fffffffffffff38p-56L,0x1.000000000000014p+0L},
{0x1.5fffffffffffff0ep-56L,0x1.000000000000016p+0L},
{0x1.7ffffffffffffeep-56L,0x1.000000000000018p+0L},
{0x1.9ffffffffffffeaep-56L,0x1.00000000000001ap+0L},
{0x1.bffffffffffffe78p-56L,0x1.00000000000001cp+0L},
{0x1.3fffffffffffff9cp-57L,0x1.00000000000000ap+0L},
{0x1.7fffffffffffff7p-57L,0x1.00000000000000cp+0L},
{0x1.bfffffffffffff3cp-57L,0x1.00000000000000ep+0L},
{0x1.ffffffffffffffp-57L,0x1.00000000000001p+0L},
{0x1.ffffffffffffff8p-58L,0x1.000000000000008p+0L},
{0x1.bfffffffffffff9ep-58L,0x1.000000000000007p+0L},
{0x1.fffffffffffffffep-64L,0x1.0000000000000002p+0L},
{0x1.3fffffffffffffcep-58L,0x1.000000000000005p+0L},
{0x1.7fffffffffffffb8p-58L,0x1.000000000000006p+0L},
{0x1.7fffffffffffffdcp-59L,0x1.000000000000003p+0L},
{0x1.ffffffffffffffcp-59L,0x1.000000000000004p+0L},
{0x1.7fffffffffffffeep-60L,0x1.0000000000000018p+0L},
{0x1.ffffffffffffffep-60L,0x1.000000000000002p+0L},
{0x1.fffffffffffffffp-61L,0x1.000000000000001p+0L},
{0x1.fffffffffffffff8p-62L,0x1.0000000000000008p+0L},
{0x1.fffffffffffffffcp-63L,0x1.0000000000000004p+0L},
};
for(unsigned i = 0; i < UPPER_EXCEPT; ++i) {
if(__builtin_expect(x == upper_except[i][0], 0)) {
long double y = upper_except[i][1];
*caught = true;
return y + 0x1.p-16445L;
}
}
for(unsigned i = 0; i < LOWER_EXCEPT; ++i) {
if(__builtin_expect(x == lower_except[i][0], 0)) {
long double y = lower_except[i][1];
*caught = true;
return y - 0x1.p-16445L;
}
}
*caught = false;
return x;
}
long double cr_expl(long double x) {
b96u96_u cvt_x = {.f = x};
int e = cvt_x.e & 0x7fff;
if (__builtin_expect(e >= 14 + 16383, 0)) { // |x| >= 2^14
if(__builtin_expect(e == 0x7fff, 0)) {
if (cvt_x.e == 0xffff && cvt_x.m == 0x8000000000000000ull) // -Inf
return 0x0p0L;
return x+x; // Nan or +Inf.
/* Makes signalling NaNs raise the invalid exception
Note that qNaN+qNaN does not raise it, and +Inf + (+Inf) does not
raise overflow. */
}
// Note that exp(2^14) > 2^16384 and that exp(-2^14) < 2^-16446.
if(cvt_x.e&0x8000) {
#ifdef CORE_MATH_SUPPORT_ERRNO
errno = ERANGE; // underflow
#endif
return 0x1p-16445L * 0.25L;
} else {
#ifdef CORE_MATH_SUPPORT_ERRNO
errno = ERANGE; // overflow
#endif
return 0x1p16383L + 0x1p16383L;
}
}
if(__builtin_expect(e <= -65 + 16383, 0)) { // |x| < 2^-64
if(__builtin_expect(!cvt_x.m && !e, 0)) return 1.L;
return 1.L + x;
/* If x = 0, we have 1 = 1 + x = exp(x) so we get a correct result.
Assume 0 < x < 2^-64. Let u = ulp(1) = 2^-63. Then we have
1 < 1 + x < exp(x) < 1 + u. If the rounding mode is directed
this ensures that 1 + x and exp(x) round to the same value.
If the rounding mode is to nearest, 1 + x rounds to 1 and we
need to show that exp(x) <= 1 + u/2.
Since x < 2^-64, in fact x <= x0 := 2^-64 - 2^-128. We check with
Sage that exp(x0) <= 1 + u/2, which ensures returning 1 + x
is correct.
Assume -2^-64 < x < 0. By the alternating series, we have
1 - u/2 < 1 + x < exp(x) < 1. Again, if the rounding mode is
directed, 1 + x and exp(x) round to the same value.
If x >= -u/4, then 1 + x and exp(x) also round to the same value
(namely 1) when rounding to nearest.
We therefore only have to check that when -u/2 < x < -u/4,
exp(x) < 1 - u/4.
If x < -2^-65, then x <= x1 := -2^-65 - 2^-128. With Sage we
again check that exp(x1) < 1 - u/4.
*/
}
// now |x| < 2^14
redinfo ri;
bool do_accurate = false;
long double fp_expx = fastpath(x, &ri, &do_accurate);
if(__builtin_expect(!do_accurate, 1)) {
return fp_expx;
} else {
bool is_exception;
fp_expx = catch_exceptions(x, &is_exception);
if(__builtin_expect(is_exception, 0)) {return fp_expx;}
else {return accurate_path(x, &ri);}
}
}