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 # interesting case: 0x1p-32 <= |x| < 16384
12 # check if (exponent|0x8000) is in [0xbfff-32, 0xbfff+13]
21 # if |x|>=0x1p14 or nan return 2^trunc(x)
25 # if |x|<0x1p-32 return 1+x
29 # should be 0x1.71547652b82fe178p0L == 0x3fff b8aa3b29 5c17f0bc
30 # it will be wrong on non-nearest rounding mode
41 # if 2^hi == inf return 2^hi
48 # fpu stack: 2^hi x hi
52 movq $
0x41f0000000100000,%rax
63 # yh = log2e_hi - c*log2e_hi + c*log2e_hi
64 movq $
0x3ff7154765200000,%rax
67 # fpu stack: 2^hi x hi xh xl yh
68 # lo = hi - xh*yh + xl*yh
75 movq $
0x3de705fc2f000000,%rax
78 # fpu stack: 2^hi x lo xh xl yl
88 movq $
0x82f0025f2dc582ee,%rax
92 # fpu stack: 2^hi x lo log2e_lo
94 # return 2^hi + 2^hi (2^lo - 1)