1 # exp(x) = 2^hi + 2^hi (2^lo - 1)
2 # where hi+lo = log2e*x with 128bit precision
3 # exact log2e*x calculation depends on nearest rounding mode
4 # using the exact multiplication method of Dekker and Veltkamp
11 # special cases: 2*x is +-inf, nan or |x| < 0x1p-32
12 # check (exponent|0x8000)+2 < 0xbfff+2-32
21 # if |x|<0x1p-32 return 1+x
26 # if 2*x == -inf,-nan return -0/x
31 # if 2*x == inf,nan return 2*x
36 # should be 0x1.71547652b82fe178p0 == 0x3fff b8aa3b29 5c17f0bc
37 # it will be wrong on non-nearest rounding mode
48 # if 2^hi == inf return 2^hi
55 # fpu stack: 2^hi x hi
59 movq $0x41f0000000100000,%rax
70 # yh = log2e_hi - c*log2e_hi + c*log2e_hi
71 movq $0x3ff7154765200000,%rax
74 # fpu stack: 2^hi x hi xh xl yh
75 # lo = hi - xh*yh + xl*yh
82 movq $0x3de705fc2f000000,%rax
85 # fpu stack: 2^hi x lo xh xl yl
95 movq $0x82f0025f2dc582ee,%rax
99 # fpu stack: 2^hi x lo log2e_lo
101 # return 2^hi + 2^hi (2^lo - 1)