Minor math tweaks + ipow32f/ipow64f (#428)

This commit is contained in:
Max Graey 2019-01-25 00:17:44 +02:00 committed by Daniel Wirtz
parent 9a3763df32
commit c7441066dc
13 changed files with 3440 additions and 2280 deletions

View File

@ -343,8 +343,7 @@ export namespace NativeMath {
t = reinterpret<f64>((reinterpret<u64>(t) + 0x80000000) & 0xFFFFFFFFC0000000);
var s = t * t;
r = x / s;
var w = t + t;
r = (r - t) / (w + r);
r = (r - t) / (2 * t + r);
t = t + t * r;
return t;
}
@ -402,10 +401,7 @@ export namespace NativeMath {
hx &= 0x7FFFFFFF;
if (hx >= 0x4086232B) {
if (isNaN(x)) return x;
if (x > overflow) {
x *= Ox1p1023;
return x;
}
if (x > overflow) return x * Ox1p1023;
if (x < underflow) return 0;
}
var hi: f64, lo: f64 = 0;
@ -819,8 +815,9 @@ export namespace NativeMath {
if (iy >= 0x43400000) yisint = 2;
else if (iy >= 0x3FF00000) {
k = (iy >> 20) - 0x3FF;
let offset = select<i32>(52, 20, k > 20) - k;
let Ly = select<i32>(ly, iy, k > 20);
let kcond = k > 20;
let offset = select<i32>(52, 20, kcond) - k;
let Ly = select<i32>(ly, iy, kcond);
let jj = Ly >> offset;
if ((jj << offset) == Ly) yisint = 2 - (jj & 1);
}
@ -842,19 +839,24 @@ export namespace NativeMath {
}
var ax = builtin_abs<f64>(x), z: f64;
if (lx == 0) {
if (ix == 0x7FF00000 || ix == 0 || ix == 0x3FF00000) {
if (ix == 0 || ix == 0x7FF00000 || ix == 0x3FF00000) {
z = ax;
if (hy < 0) z = 1.0 / z;
if (hx < 0) {
if (((ix - 0x3FF00000) | yisint) == 0) z = (z - z) / (z - z);
else if (yisint == 1) z = -z;
if (((ix - 0x3FF00000) | yisint) == 0) {
let d = z - z;
z = d / d;
} else if (yisint == 1) z = -z;
}
return z;
}
}
var s = 1.0;
if (hx < 0) {
if (yisint == 0) return (x - x) / (x - x);
if (yisint == 0) {
let d = x - x;
return d / d;
}
if (yisint == 1) s = -1.0;
}
var t1: f64, t2: f64, p_h: f64, p_l: f64, r: f64, t: f64, u: f64, v: f64, w: f64;
@ -1105,7 +1107,10 @@ export namespace NativeMath {
var ey = <i64>(uy >> 52 & 0x7FF);
var sx = ux >> 63;
var uy1 = uy << 1;
if (uy1 == 0 || ex == 0x7FF || isNaN<f64>(y)) return (x * y) / (x * y);
if (uy1 == 0 || ex == 0x7FF || isNaN<f64>(y)) {
let m = x * y;
return m / m;
}
var ux1 = ux << 1;
if (ux1 <= uy1) {
if (ux1 == uy1) return 0 * x;
@ -1157,7 +1162,10 @@ export namespace NativeMath {
var ex = <i64>(ux >> 52 & 0x7FF);
var ey = <i64>(uy >> 52 & 0x7FF);
var sx = <i32>(ux >> 63);
if (uy << 1 == 0 || ex == 0x7FF || isNaN(y)) return (x * y) / (x * y);
if (uy << 1 == 0 || ex == 0x7FF || isNaN(y)) {
let m = x * y;
return m / m;
}
if (ux << 1 == 0) return x;
var uxi = ux;
if (!ex) {
@ -1236,7 +1244,7 @@ function expo2f(x: f32): f32 { // exp(x)/2 for x >= log(DBL_MAX)
const // see: musl/src/math/__expo2f.c
k = <u32>235,
kln2 = reinterpret<f32>(0x4322E3BC); // 0x1.45c778p+7f
var scale = reinterpret<f32>(<u32>(0x7F + k / 2) << 23);
var scale = reinterpret<f32>(<u32>(0x7F + (k >> 1)) << 23);
return NativeMathf.exp(x - kln2) * scale * scale;
}
@ -1538,12 +1546,8 @@ export namespace NativeMathf {
hx &= 0x7FFFFFFF;
if (hx >= 0x42AEAC50) {
if (hx >= 0x42B17218) {
if (!sign_) {
x *= Ox1p127f;
return x;
} else {
if (hx >= 0x42CFF1B5) return 0;
}
if (!sign_) return x * Ox1p127f;
else if (hx >= 0x42CFF1B5) return 0;
}
}
var hi: f32, lo: f32;
@ -1889,8 +1893,9 @@ export namespace NativeMathf {
if (iy >= 0x4B800000) yisint = 2;
else if (iy >= 0x3F800000) {
k = (iy >> 23) - 0x7F;
j = iy >> (23 - k);
if ((j << (23 - k)) == iy) yisint = 2 - (j & 1);
let ki = 23 - k;
j = iy >> ki;
if ((j << ki) == iy) yisint = 2 - (j & 1);
}
}
if (iy == 0x7F800000) { // y is +-inf
@ -1909,14 +1914,20 @@ export namespace NativeMathf {
z = ax;
if (hy < 0) z = 1.0 / z;
if (hx < 0) {
if (((ix - 0x3F800000) | yisint) == 0) z = (z - z) / (z - z);
if (((ix - 0x3F800000) | yisint) == 0) {
let d = z - z;
z = d / d;
}
else if (yisint == 1) z = -z;
}
return z;
}
var sn = <f32>1.0;
if (hx < 0) {
if (yisint == 0) return (x - x) / (x - x);
if (yisint == 0) {
let d = x - x;
return d / d;
}
if (yisint == 1) sn = -1.0;
}
var t1: f32, t2: f32, r: f32, s: f32, t: f32, u: f32, v: f32, w: f32, p_h: f32, p_l: f32;
@ -2159,7 +2170,10 @@ export namespace NativeMathf {
var ey = <i32>(uy >> 23 & 0xFF);
var sx = ux & 0x80000000;
var uy1 = uy << 1;
if (uy1 == 0 || ex == 0xFF || isNaN<f32>(y)) return (x * y) / (x * y);
if (uy1 == 0 || ex == 0xFF || isNaN<f32>(y)) {
let m = x * y;
return m / m;
}
var ux1 = ux << 1;
if (ux1 <= uy1) {
if (ux1 == uy1) return 0 * x;
@ -2380,3 +2394,27 @@ export function ipow64(x: i64, e: i32): i64 {
}
return out;
}
export function ipow32f(x: f32, e: i32): f32 {
var sign = e >> 31;
e = (e + sign) ^ sign; // abs(e)
var out: f32 = 1;
while (e) {
out *= select<f32>(x, 1.0, e & 1);
e >>= 1;
x *= x;
}
return sign ? <f32>1.0 / out : out;
}
export function ipow64f(x: f64, e: i32): f64 {
var sign = e >> 31;
e = (e + sign) ^ sign; // abs(e)
var out = 1.0;
while (e) {
out *= select(x, 1.0, e & 1);
e >>= 1;
x *= x;
}
return sign ? 1.0 / out : out;
}

File diff suppressed because it is too large Load Diff

View File

@ -3813,7 +3813,7 @@
if
i32.const 0
i32.const 2816
i32.const 970
i32.const 972
i32.const 4
call $~lib/env/abort
unreachable
@ -5479,7 +5479,7 @@
if
i32.const 0
i32.const 2816
i32.const 979
i32.const 981
i32.const 24
call $~lib/env/abort
unreachable

View File

@ -5225,7 +5225,7 @@
if
i32.const 0
i32.const 2816
i32.const 970
i32.const 972
i32.const 4
call $~lib/env/abort
unreachable
@ -8241,7 +8241,7 @@
if
i32.const 0
i32.const 2816
i32.const 979
i32.const 981
i32.const 24
call $~lib/env/abort
unreachable

View File

@ -1506,6 +1506,7 @@
f64.div
f64.mul
set_local $2
get_local $0
get_local $1
f64.const 1.87595182427177
get_local $2
@ -1538,18 +1539,16 @@
tee_local $1
get_local $1
f64.mul
f64.div
set_local $2
get_local $1
get_local $1
get_local $0
get_local $2
f64.div
tee_local $2
get_local $1
f64.sub
f64.const 2
get_local $1
get_local $1
f64.add
f64.mul
get_local $2
f64.add
f64.div
@ -2840,19 +2839,20 @@
(local $5 i32)
(local $6 f64)
(local $7 i32)
(local $8 i32)
(local $9 f64)
(local $10 i32)
(local $11 f64)
(local $8 f64)
(local $9 i32)
(local $10 f64)
(local $11 i32)
(local $12 i32)
(local $13 i32)
(local $14 i32)
(local $15 f64)
(local $14 f64)
(local $15 i32)
(local $16 f64)
(local $17 i64)
(local $18 i32)
(local $19 f64)
(local $20 i32)
(local $21 i32)
get_local $0
i64.reinterpret/f64
tee_local $17
@ -2866,7 +2866,7 @@
get_local $18
i32.const 2147483647
i32.and
set_local $4
set_local $5
get_local $1
i64.reinterpret/f64
tee_local $17
@ -2876,57 +2876,57 @@
tee_local $13
i32.const 2147483647
i32.and
set_local $12
get_local $12
set_local $11
get_local $11
get_local $17
i32.wrap/i64
tee_local $7
tee_local $21
i32.or
i32.eqz
if
f64.const 1
return
end
get_local $4
get_local $5
i32.const 2146435072
i32.gt_s
tee_local $8
tee_local $4
i32.eqz
if
get_local $4
get_local $5
i32.const 2146435072
i32.eq
tee_local $8
tee_local $4
if
get_local $20
i32.const 0
i32.ne
set_local $8
set_local $4
end
end
get_local $8
get_local $4
i32.eqz
if
get_local $12
get_local $11
i32.const 2146435072
i32.gt_s
set_local $8
set_local $4
end
get_local $8
get_local $4
i32.eqz
if
get_local $12
get_local $11
i32.const 2146435072
i32.eq
tee_local $8
tee_local $4
if
get_local $7
get_local $21
i32.const 0
i32.ne
set_local $8
set_local $4
end
end
get_local $8
get_local $4
if
get_local $0
get_local $1
@ -2937,71 +2937,70 @@
i32.const 0
i32.lt_s
if
get_local $12
get_local $11
i32.const 1128267776
i32.ge_s
if (result i32)
i32.const 2
else
get_local $12
get_local $11
i32.const 1072693248
i32.ge_s
if (result i32)
i32.const 52
i32.const 20
get_local $12
get_local $21
get_local $11
get_local $11
i32.const 20
i32.shr_s
i32.const 1023
i32.sub
tee_local $10
tee_local $12
i32.const 20
i32.gt_s
tee_local $5
tee_local $4
select
tee_local $7
i32.const 52
i32.const 20
get_local $4
select
get_local $10
i32.sub
set_local $8
get_local $7
get_local $12
get_local $5
select
tee_local $10
get_local $8
i32.sub
tee_local $9
i32.shr_s
set_local $5
set_local $4
i32.const 2
get_local $5
get_local $4
i32.const 1
i32.and
i32.sub
i32.const 0
get_local $5
get_local $8
get_local $4
get_local $9
i32.shl
get_local $10
get_local $7
i32.eq
select
else
i32.const 0
end
end
set_local $14
set_local $15
end
get_local $7
get_local $21
i32.eqz
if
get_local $12
get_local $11
i32.const 2146435072
i32.eq
if
get_local $4
get_local $5
i32.const 1072693248
i32.sub
get_local $20
i32.or
if
get_local $4
get_local $5
i32.const 1072693248
i32.ge_s
if
@ -3031,7 +3030,7 @@
end
unreachable
end
get_local $12
get_local $11
i32.const 1072693248
i32.eq
if
@ -3076,25 +3075,25 @@
get_local $20
i32.eqz
if
get_local $4
get_local $5
i32.eqz
tee_local $4
i32.eqz
if
get_local $5
i32.const 2146435072
i32.eq
tee_local $5
i32.eqz
if
get_local $4
i32.eqz
set_local $5
set_local $4
end
get_local $5
get_local $4
i32.eqz
if
get_local $4
get_local $5
i32.const 1072693248
i32.eq
set_local $5
set_local $4
end
get_local $5
get_local $4
if
f64.const 1
get_local $2
@ -3109,16 +3108,16 @@
i32.const 0
i32.lt_s
if (result f64)
get_local $4
get_local $5
i32.const 1072693248
i32.sub
get_local $14
get_local $15
i32.or
if (result f64)
get_local $2
f64.neg
get_local $2
get_local $14
get_local $15
i32.const 1
i32.eq
select
@ -3126,8 +3125,8 @@
get_local $2
get_local $2
f64.sub
tee_local $0
get_local $0
tee_local $14
get_local $14
f64.div
end
else
@ -3137,39 +3136,39 @@
end
end
f64.const 1
set_local $11
set_local $10
get_local $18
i32.const 0
i32.lt_s
if
get_local $14
get_local $15
i32.eqz
if
get_local $0
get_local $0
f64.sub
tee_local $0
get_local $0
tee_local $14
get_local $14
f64.div
return
end
f64.const -1
f64.const 1
get_local $14
get_local $15
i32.const 1
i32.eq
select
set_local $11
set_local $10
end
get_local $12
get_local $11
i32.const 1105199104
i32.gt_s
if (result f64)
get_local $12
get_local $11
i32.const 1139802112
i32.gt_s
if
get_local $4
get_local $5
i32.const 1072693247
i32.le_s
if
@ -3181,7 +3180,7 @@
select
return
end
get_local $4
get_local $5
i32.const 1072693248
i32.ge_s
if
@ -3194,7 +3193,7 @@
return
end
end
get_local $4
get_local $5
i32.const 1072693247
i32.lt_s
if
@ -3202,13 +3201,13 @@
i32.const 0
i32.lt_s
if (result f64)
get_local $11
get_local $10
f64.const 1.e+300
f64.mul
f64.const 1.e+300
f64.mul
else
get_local $11
get_local $10
f64.const 1e-300
f64.mul
f64.const 1e-300
@ -3216,7 +3215,7 @@
end
return
end
get_local $4
get_local $5
i32.const 1072693248
i32.gt_s
if
@ -3224,13 +3223,13 @@
i32.const 0
i32.gt_s
if (result f64)
get_local $11
get_local $10
f64.const 1.e+300
f64.mul
f64.const 1.e+300
f64.mul
else
get_local $11
get_local $10
f64.const 1e-300
f64.mul
f64.const 1e-300
@ -3268,21 +3267,21 @@
f64.sub
tee_local $6
f64.add
set_local $9
set_local $8
get_local $6
get_local $9
get_local $8
i64.reinterpret/f64
i64.const -4294967296
i64.and
f64.reinterpret/i64
tee_local $9
tee_local $8
get_local $16
f64.sub
f64.sub
else
i32.const 0
set_local $7
get_local $4
get_local $5
i32.const 1048576
i32.lt_s
if (result i32)
@ -3294,32 +3293,32 @@
i64.const 32
i64.shr_u
i32.wrap/i64
set_local $4
set_local $5
i32.const -53
else
i32.const 0
end
get_local $4
get_local $5
i32.const 20
i32.shr_s
i32.const 1023
i32.sub
i32.add
set_local $7
get_local $4
get_local $5
i32.const 1048575
i32.and
tee_local $5
tee_local $9
i32.const 1072693248
i32.or
set_local $4
get_local $5
set_local $5
get_local $9
i32.const 235662
i32.le_s
if (result i32)
i32.const 0
else
get_local $5
get_local $9
i32.const 767610
i32.lt_s
if (result i32)
@ -3329,19 +3328,19 @@
i32.const 1
i32.add
set_local $7
get_local $4
get_local $5
i32.const -1048576
i32.add
set_local $4
set_local $5
i32.const 0
end
end
set_local $10
set_local $12
get_local $2
i64.reinterpret/f64
i64.const 4294967295
i64.and
get_local $4
get_local $5
i64.extend_s/i32
i64.const 32
i64.shl
@ -3350,7 +3349,7 @@
tee_local $2
f64.const 1.5
f64.const 1
get_local $10
get_local $12
select
tee_local $0
f64.sub
@ -3362,16 +3361,16 @@
f64.div
tee_local $6
f64.mul
set_local $9
set_local $14
get_local $2
get_local $4
get_local $5
i32.const 1
i32.shr_s
i32.const 536870912
i32.or
i32.const 524288
i32.add
get_local $10
get_local $12
i32.const 18
i32.shl
i32.add
@ -3379,27 +3378,27 @@
i64.const 32
i64.shl
f64.reinterpret/i64
tee_local $3
tee_local $8
get_local $0
f64.sub
f64.sub
set_local $2
get_local $9
get_local $9
get_local $14
get_local $14
f64.mul
tee_local $15
get_local $15
tee_local $3
get_local $3
f64.mul
f64.const 0.5999999999999946
get_local $15
get_local $3
f64.const 0.4285714285785502
get_local $15
get_local $3
f64.const 0.33333332981837743
get_local $15
get_local $3
f64.const 0.272728123808534
get_local $15
get_local $3
f64.const 0.23066074577556175
get_local $15
get_local $3
f64.const 0.20697501780033842
f64.mul
f64.add
@ -3415,13 +3414,13 @@
set_local $19
get_local $6
get_local $16
get_local $9
get_local $14
i64.reinterpret/f64
i64.const -4294967296
i64.and
f64.reinterpret/i64
tee_local $6
get_local $3
get_local $8
f64.mul
f64.sub
get_local $6
@ -3434,40 +3433,40 @@
get_local $6
get_local $6
f64.mul
tee_local $15
tee_local $3
f64.add
get_local $19
get_local $0
get_local $6
get_local $9
get_local $14
f64.add
f64.mul
f64.add
tee_local $19
f64.add
set_local $3
set_local $8
get_local $19
get_local $3
get_local $8
i64.reinterpret/f64
i64.const -4294967296
i64.and
f64.reinterpret/i64
tee_local $3
tee_local $8
f64.const 3
f64.sub
get_local $15
get_local $3
f64.sub
f64.sub
set_local $2
get_local $6
get_local $3
get_local $8
f64.mul
tee_local $16
get_local $0
get_local $3
get_local $8
f64.mul
get_local $2
get_local $9
get_local $14
f64.mul
f64.add
tee_local $6
@ -3497,14 +3496,14 @@
f64.add
f64.const 1.350039202129749e-08
f64.const 0
get_local $10
get_local $12
select
f64.add
tee_local $2
f64.add
f64.const 0.5849624872207642
f64.const 0
get_local $10
get_local $12
select
tee_local $0
f64.add
@ -3512,14 +3511,14 @@
f64.convert_s/i32
tee_local $3
f64.add
set_local $9
set_local $8
get_local $2
get_local $9
get_local $8
i64.reinterpret/f64
i64.const -4294967296
i64.and
f64.reinterpret/i64
tee_local $9
tee_local $8
get_local $3
f64.sub
get_local $0
@ -3537,7 +3536,7 @@
f64.reinterpret/i64
tee_local $0
f64.sub
get_local $9
get_local $8
f64.mul
get_local $1
get_local $2
@ -3545,7 +3544,7 @@
f64.add
tee_local $6
get_local $0
get_local $9
get_local $8
f64.mul
tee_local $0
f64.add
@ -3553,21 +3552,21 @@
i64.reinterpret/f64
tee_local $17
i32.wrap/i64
set_local $8
set_local $4
block $folding-inner1
block $folding-inner0
get_local $17
i64.const 32
i64.shr_u
i32.wrap/i64
tee_local $5
tee_local $9
i32.const 1083179008
i32.ge_s
if
get_local $5
get_local $9
i32.const 1083179008
i32.sub
get_local $8
get_local $4
i32.or
br_if $folding-inner0
get_local $6
@ -3579,16 +3578,16 @@
f64.gt
br_if $folding-inner0
else
get_local $5
get_local $9
i32.const 2147483647
i32.and
i32.const 1083231232
i32.ge_s
if
get_local $5
get_local $9
i32.const -1064252416
i32.sub
get_local $8
get_local $4
i32.or
br_if $folding-inner1
get_local $6
@ -3599,27 +3598,27 @@
br_if $folding-inner1
end
end
get_local $5
get_local $9
i32.const 2147483647
i32.and
tee_local $8
tee_local $4
i32.const 20
i32.shr_s
i32.const 1023
i32.sub
set_local $10
set_local $12
i32.const 0
set_local $7
get_local $8
get_local $4
i32.const 1071644672
i32.gt_s
if
i32.const 1048576
get_local $10
get_local $12
i32.const 1
i32.add
i32.shr_s
get_local $5
get_local $9
i32.add
tee_local $7
i32.const 2147483647
@ -3628,9 +3627,9 @@
i32.shr_s
i32.const 1023
i32.sub
set_local $10
set_local $12
i32.const 1048575
get_local $10
get_local $12
i32.shr_s
i32.const -1
i32.xor
@ -3647,7 +3646,7 @@
i32.const 1048576
i32.or
i32.const 20
get_local $10
get_local $12
i32.sub
i32.shr_s
set_local $7
@ -3655,7 +3654,7 @@
get_local $7
i32.sub
get_local $7
get_local $5
get_local $9
i32.const 0
i32.lt_s
select
@ -3693,7 +3692,7 @@
get_local $2
f64.mul
set_local $3
get_local $11
get_local $10
f64.const 1
get_local $2
get_local $2
@ -3717,9 +3716,9 @@
f64.add
f64.mul
f64.sub
tee_local $9
tee_local $8
f64.mul
get_local $9
get_local $8
f64.const 2
f64.sub
f64.div
@ -3746,7 +3745,7 @@
i32.const 20
i32.shl
i32.add
tee_local $5
tee_local $9
i32.const 20
i32.shr_s
i32.const 0
@ -3760,7 +3759,7 @@
i64.reinterpret/f64
i64.const 4294967295
i64.and
get_local $5
get_local $9
i64.extend_s/i32
i64.const 32
i64.shl
@ -3770,14 +3769,14 @@
f64.mul
return
end
get_local $11
get_local $10
f64.const 1.e+300
f64.mul
f64.const 1.e+300
f64.mul
return
end
get_local $11
get_local $10
f64.const 1e-300
f64.mul
f64.const 1e-300

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -3320,3 +3320,41 @@ assert(ipow64(3, 64) == 8733086111712066817); // should overflow
assert(ipow64(3, 128) == -9204772141784466943); // should overflow
assert(ipow64(57055, 3) + ipow64(339590, 3) == 39347712995520375); // add Buterin's twit example
// ipow32f /////////////////////////////////////////////////////////////////////////////////////
assert(ipow32f(0, 0) == <f32>1.0);
assert(ipow32f(<f32>NaN, 0) == <f32>1.0);
assert(isNaN<f32>(ipow32f(<f32>NaN, 1)));
assert(isNaN<f32>(ipow32f(<f32>NaN, -1)));
assert(isNaN<f32>(ipow32f(<f32>NaN, 2)));
assert(ipow32f(<f32>Infinity, 0) == <f32>1.0);
assert(ipow32f(<f32>Infinity, 1) == <f32>Infinity);
assert(ipow32f(<f32>-Infinity, 0) == <f32>1.0);
assert(ipow32f(<f32>-Infinity, 1) == <f32>-Infinity);
assert(ipow32f(<f32>-Infinity, 2) == <f32>Infinity);
assert(ipow32f(<f32>1.0, 0) == <f32>1.0);
assert(ipow32f(f32.MAX_VALUE, 2) == <f32>Infinity);
assert(ipow32f(f32.MIN_VALUE, 2) == <f32>0.0);
assert(ipow32f(f32.MAX_VALUE, -1) == <f32>2.938735877055719e-39);
assert(ipow32f(<f32>10.0, 36) == <f32>1.0000000409184788e+36);
assert(ipow32f(<f32>10.0,-36) == <f32>9.999999462560281e-37);
// ipow64f /////////////////////////////////////////////////////////////////////////////////////
assert(ipow64f(0, 0) == 1.0);
assert(ipow64f(NaN, 0) == 1.0);
assert(isNaN(ipow64f(NaN, 1)));
assert(isNaN(ipow64f(NaN, -1)));
assert(isNaN(ipow64f(NaN, 2)));
assert(ipow64f(Infinity, 0) == 1.0);
assert(ipow64f(Infinity, 1) == Infinity);
assert(ipow64f(-Infinity, 0) == 1.0);
assert(ipow64f(-Infinity, 1) == -Infinity);
assert(ipow64f(-Infinity, 2) == Infinity);
assert(ipow64f(1.0, 0) == 1.0);
assert(ipow64f(f64.MAX_VALUE, 2) == Infinity);
assert(ipow64f(f64.MIN_VALUE, 2) == 0.0);
assert(ipow64f(f64.MAX_VALUE, -1) == 5.562684646268003e-309);
assert(ipow64f(10.0, 127) == 1.0000000000000002e+127);
assert(ipow64f(10.0,-127) == 9.999999999999998e-128);

File diff suppressed because it is too large Load Diff

View File

@ -31,8 +31,9 @@
(local $6 i64)
(local $7 i64)
(local $8 i32)
(local $9 i64)
(local $9 f64)
(local $10 i64)
(local $11 i64)
get_local $0
i64.reinterpret/f64
set_local $2
@ -84,21 +85,21 @@
get_local $0
get_local $1
f64.mul
get_local $0
get_local $1
f64.mul
set_local $9
get_local $9
get_local $9
f64.div
return
end
get_local $2
i64.const 1
i64.shl
set_local $9
get_local $9
set_local $10
get_local $10
get_local $7
i64.le_u
if
get_local $9
get_local $10
get_local $7
i64.eq
if
@ -234,13 +235,13 @@
i64.const 11
i64.shl
i64.clz
set_local $10
set_local $11
get_local $4
get_local $10
get_local $11
i64.sub
set_local $4
get_local $2
get_local $10
get_local $11
i64.shl
set_local $2
get_local $4
@ -342,8 +343,9 @@
(local $6 i32)
(local $7 i32)
(local $8 i32)
(local $9 i32)
(local $9 f32)
(local $10 i32)
(local $11 i32)
get_local $0
i32.reinterpret/f32
set_local $2
@ -395,21 +397,21 @@
get_local $0
get_local $1
f32.mul
get_local $0
get_local $1
f32.mul
set_local $9
get_local $9
get_local $9
f32.div
return
end
get_local $2
i32.const 1
i32.shl
set_local $9
get_local $9
set_local $10
get_local $10
get_local $7
i32.le_u
if
get_local $9
get_local $10
get_local $7
i32.eq
if
@ -545,13 +547,13 @@
i32.const 8
i32.shl
i32.clz
set_local $10
set_local $11
get_local $4
get_local $10
get_local $11
i32.sub
set_local $4
get_local $2
get_local $10
get_local $11
i32.shl
set_local $2
get_local $4

View File

@ -240,19 +240,20 @@
(local $5 i32)
(local $6 f64)
(local $7 i32)
(local $8 i32)
(local $9 f64)
(local $10 i32)
(local $11 f64)
(local $8 f64)
(local $9 i32)
(local $10 f64)
(local $11 i32)
(local $12 i32)
(local $13 i32)
(local $14 i32)
(local $15 f64)
(local $14 f64)
(local $15 i32)
(local $16 f64)
(local $17 i64)
(local $18 i32)
(local $19 f64)
(local $20 i32)
(local $21 i32)
get_local $0
i64.reinterpret/f64
tee_local $17
@ -266,7 +267,7 @@
get_local $18
i32.const 2147483647
i32.and
set_local $4
set_local $5
get_local $1
i64.reinterpret/f64
tee_local $17
@ -276,57 +277,57 @@
tee_local $13
i32.const 2147483647
i32.and
set_local $12
get_local $12
set_local $11
get_local $11
get_local $17
i32.wrap/i64
tee_local $7
tee_local $21
i32.or
i32.eqz
if
f64.const 1
return
end
get_local $4
get_local $5
i32.const 2146435072
i32.gt_s
tee_local $8
tee_local $4
i32.eqz
if
get_local $4
get_local $5
i32.const 2146435072
i32.eq
tee_local $8
tee_local $4
if
get_local $20
i32.const 0
i32.ne
set_local $8
set_local $4
end
end
get_local $8
get_local $4
i32.eqz
if
get_local $12
get_local $11
i32.const 2146435072
i32.gt_s
set_local $8
set_local $4
end
get_local $8
get_local $4
i32.eqz
if
get_local $12
get_local $11
i32.const 2146435072
i32.eq
tee_local $8
tee_local $4
if
get_local $7
get_local $21
i32.const 0
i32.ne
set_local $8
set_local $4
end
end
get_local $8
get_local $4
if
get_local $0
get_local $1
@ -337,71 +338,70 @@
i32.const 0
i32.lt_s
if
get_local $12
get_local $11
i32.const 1128267776
i32.ge_s
if (result i32)
i32.const 2
else
get_local $12
get_local $11
i32.const 1072693248
i32.ge_s
if (result i32)
i32.const 52
i32.const 20
get_local $12
get_local $21
get_local $11
get_local $11
i32.const 20
i32.shr_s
i32.const 1023
i32.sub
tee_local $10
tee_local $12
i32.const 20
i32.gt_s
tee_local $5
tee_local $4
select
tee_local $7
i32.const 52
i32.const 20
get_local $4
select
get_local $10
i32.sub
set_local $8
get_local $7
get_local $12
get_local $5
select
tee_local $10
get_local $8
i32.sub
tee_local $9
i32.shr_s
set_local $5
set_local $4
i32.const 2
get_local $5
get_local $4
i32.const 1
i32.and
i32.sub
i32.const 0
get_local $5
get_local $8
get_local $4
get_local $9
i32.shl
get_local $10
get_local $7
i32.eq
select
else
i32.const 0
end
end
set_local $14
set_local $15
end
get_local $7
get_local $21
i32.eqz
if
get_local $12
get_local $11
i32.const 2146435072
i32.eq
if
get_local $4
get_local $5
i32.const 1072693248
i32.sub
get_local $20
i32.or
if
get_local $4
get_local $5
i32.const 1072693248
i32.ge_s
if
@ -431,7 +431,7 @@
end
unreachable
end
get_local $12
get_local $11
i32.const 1072693248
i32.eq
if
@ -476,25 +476,25 @@
get_local $20
i32.eqz
if
get_local $4
get_local $5
i32.eqz
tee_local $4
i32.eqz
if
get_local $5
i32.const 2146435072
i32.eq
tee_local $5
i32.eqz
if
get_local $4
i32.eqz
set_local $5
set_local $4
end
get_local $5
get_local $4
i32.eqz
if
get_local $4
get_local $5
i32.const 1072693248
i32.eq
set_local $5
set_local $4
end
get_local $5
get_local $4
if
f64.const 1
get_local $2
@ -509,16 +509,16 @@
i32.const 0
i32.lt_s
if (result f64)
get_local $4
get_local $5
i32.const 1072693248
i32.sub
get_local $14
get_local $15
i32.or
if (result f64)
get_local $2
f64.neg
get_local $2
get_local $14
get_local $15
i32.const 1
i32.eq
select
@ -526,8 +526,8 @@
get_local $2
get_local $2
f64.sub
tee_local $0
get_local $0
tee_local $14
get_local $14
f64.div
end
else
@ -537,39 +537,39 @@
end
end
f64.const 1
set_local $11
set_local $10
get_local $18
i32.const 0
i32.lt_s
if
get_local $14
get_local $15
i32.eqz
if
get_local $0
get_local $0
f64.sub
tee_local $0
get_local $0
tee_local $14
get_local $14
f64.div
return
end
f64.const -1
f64.const 1
get_local $14
get_local $15
i32.const 1
i32.eq
select
set_local $11
set_local $10
end
get_local $12
get_local $11
i32.const 1105199104
i32.gt_s
if (result f64)
get_local $12
get_local $11
i32.const 1139802112
i32.gt_s
if
get_local $4
get_local $5
i32.const 1072693247
i32.le_s
if
@ -581,7 +581,7 @@
select
return
end
get_local $4
get_local $5
i32.const 1072693248
i32.ge_s
if
@ -594,7 +594,7 @@
return
end
end
get_local $4
get_local $5
i32.const 1072693247
i32.lt_s
if
@ -602,13 +602,13 @@
i32.const 0
i32.lt_s
if (result f64)
get_local $11
get_local $10
f64.const 1.e+300
f64.mul
f64.const 1.e+300
f64.mul
else
get_local $11
get_local $10
f64.const 1e-300
f64.mul
f64.const 1e-300
@ -616,7 +616,7 @@
end
return
end
get_local $4
get_local $5
i32.const 1072693248
i32.gt_s
if
@ -624,13 +624,13 @@
i32.const 0
i32.gt_s
if (result f64)
get_local $11
get_local $10
f64.const 1.e+300
f64.mul
f64.const 1.e+300
f64.mul
else
get_local $11
get_local $10
f64.const 1e-300
f64.mul
f64.const 1e-300
@ -668,21 +668,21 @@
f64.sub
tee_local $6
f64.add
set_local $9
set_local $8
get_local $6
get_local $9
get_local $8
i64.reinterpret/f64
i64.const -4294967296
i64.and
f64.reinterpret/i64
tee_local $9
tee_local $8
get_local $16
f64.sub
f64.sub
else
i32.const 0
set_local $7
get_local $4
get_local $5
i32.const 1048576
i32.lt_s
if (result i32)
@ -694,32 +694,32 @@
i64.const 32
i64.shr_u
i32.wrap/i64
set_local $4
set_local $5
i32.const -53
else
i32.const 0
end
get_local $4
get_local $5
i32.const 20
i32.shr_s
i32.const 1023
i32.sub
i32.add
set_local $7
get_local $4
get_local $5
i32.const 1048575
i32.and
tee_local $5
tee_local $9
i32.const 1072693248
i32.or
set_local $4
get_local $5
set_local $5
get_local $9
i32.const 235662
i32.le_s
if (result i32)
i32.const 0
else
get_local $5
get_local $9
i32.const 767610
i32.lt_s
if (result i32)
@ -729,19 +729,19 @@
i32.const 1
i32.add
set_local $7
get_local $4
get_local $5
i32.const -1048576
i32.add
set_local $4
set_local $5
i32.const 0
end
end
set_local $10
set_local $12
get_local $2
i64.reinterpret/f64
i64.const 4294967295
i64.and
get_local $4
get_local $5
i64.extend_s/i32
i64.const 32
i64.shl
@ -750,7 +750,7 @@
tee_local $2
f64.const 1.5
f64.const 1
get_local $10
get_local $12
select
tee_local $0
f64.sub
@ -762,16 +762,16 @@
f64.div
tee_local $6
f64.mul
set_local $9
set_local $14
get_local $2
get_local $4
get_local $5
i32.const 1
i32.shr_s
i32.const 536870912
i32.or
i32.const 524288
i32.add
get_local $10
get_local $12
i32.const 18
i32.shl
i32.add
@ -779,27 +779,27 @@
i64.const 32
i64.shl
f64.reinterpret/i64
tee_local $3
tee_local $8
get_local $0
f64.sub
f64.sub
set_local $2
get_local $9
get_local $9
get_local $14
get_local $14
f64.mul
tee_local $15
get_local $15
tee_local $3
get_local $3
f64.mul
f64.const 0.5999999999999946
get_local $15
get_local $3
f64.const 0.4285714285785502
get_local $15
get_local $3
f64.const 0.33333332981837743
get_local $15
get_local $3
f64.const 0.272728123808534
get_local $15
get_local $3
f64.const 0.23066074577556175
get_local $15
get_local $3
f64.const 0.20697501780033842
f64.mul
f64.add
@ -815,13 +815,13 @@
set_local $19
get_local $6
get_local $16
get_local $9
get_local $14
i64.reinterpret/f64
i64.const -4294967296
i64.and
f64.reinterpret/i64
tee_local $6
get_local $3
get_local $8
f64.mul
f64.sub
get_local $6
@ -834,40 +834,40 @@
get_local $6
get_local $6
f64.mul
tee_local $15
tee_local $3
f64.add
get_local $19
get_local $0
get_local $6
get_local $9
get_local $14
f64.add
f64.mul
f64.add
tee_local $19
f64.add
set_local $3
set_local $8
get_local $19
get_local $3
get_local $8
i64.reinterpret/f64
i64.const -4294967296
i64.and
f64.reinterpret/i64
tee_local $3
tee_local $8
f64.const 3
f64.sub
get_local $15
get_local $3
f64.sub
f64.sub
set_local $2
get_local $6
get_local $3
get_local $8
f64.mul
tee_local $16
get_local $0
get_local $3
get_local $8
f64.mul
get_local $2
get_local $9
get_local $14
f64.mul
f64.add
tee_local $6
@ -897,14 +897,14 @@
f64.add
f64.const 1.350039202129749e-08
f64.const 0
get_local $10
get_local $12
select
f64.add
tee_local $2
f64.add
f64.const 0.5849624872207642
f64.const 0
get_local $10
get_local $12
select
tee_local $0
f64.add
@ -912,14 +912,14 @@
f64.convert_s/i32
tee_local $3
f64.add
set_local $9
set_local $8
get_local $2
get_local $9
get_local $8
i64.reinterpret/f64
i64.const -4294967296
i64.and
f64.reinterpret/i64
tee_local $9
tee_local $8
get_local $3
f64.sub
get_local $0
@ -937,7 +937,7 @@
f64.reinterpret/i64
tee_local $0
f64.sub
get_local $9
get_local $8
f64.mul
get_local $1
get_local $2
@ -945,7 +945,7 @@
f64.add
tee_local $6
get_local $0
get_local $9
get_local $8
f64.mul
tee_local $0
f64.add
@ -953,21 +953,21 @@
i64.reinterpret/f64
tee_local $17
i32.wrap/i64
set_local $8
set_local $4
block $folding-inner1
block $folding-inner0
get_local $17
i64.const 32
i64.shr_u
i32.wrap/i64
tee_local $5
tee_local $9
i32.const 1083179008
i32.ge_s
if
get_local $5
get_local $9
i32.const 1083179008
i32.sub
get_local $8
get_local $4
i32.or
br_if $folding-inner0
get_local $6
@ -979,16 +979,16 @@
f64.gt
br_if $folding-inner0
else
get_local $5
get_local $9
i32.const 2147483647
i32.and
i32.const 1083231232
i32.ge_s
if
get_local $5
get_local $9
i32.const -1064252416
i32.sub
get_local $8
get_local $4
i32.or
br_if $folding-inner1
get_local $6
@ -999,27 +999,27 @@
br_if $folding-inner1
end
end
get_local $5
get_local $9
i32.const 2147483647
i32.and
tee_local $8
tee_local $4
i32.const 20
i32.shr_s
i32.const 1023
i32.sub
set_local $10
set_local $12
i32.const 0
set_local $7
get_local $8
get_local $4
i32.const 1071644672
i32.gt_s
if
i32.const 1048576
get_local $10
get_local $12
i32.const 1
i32.add
i32.shr_s
get_local $5
get_local $9
i32.add
tee_local $7
i32.const 2147483647
@ -1028,9 +1028,9 @@
i32.shr_s
i32.const 1023
i32.sub
set_local $10
set_local $12
i32.const 1048575
get_local $10
get_local $12
i32.shr_s
i32.const -1
i32.xor
@ -1047,7 +1047,7 @@
i32.const 1048576
i32.or
i32.const 20
get_local $10
get_local $12
i32.sub
i32.shr_s
set_local $7
@ -1055,7 +1055,7 @@
get_local $7
i32.sub
get_local $7
get_local $5
get_local $9
i32.const 0
i32.lt_s
select
@ -1093,7 +1093,7 @@
get_local $2
f64.mul
set_local $3
get_local $11
get_local $10
f64.const 1
get_local $2
get_local $2
@ -1117,9 +1117,9 @@
f64.add
f64.mul
f64.sub
tee_local $9
tee_local $8
f64.mul
get_local $9
get_local $8
f64.const 2
f64.sub
f64.div
@ -1146,7 +1146,7 @@
i32.const 20
i32.shl
i32.add
tee_local $5
tee_local $9
i32.const 20
i32.shr_s
i32.const 0
@ -1160,7 +1160,7 @@
i64.reinterpret/f64
i64.const 4294967295
i64.and
get_local $5
get_local $9
i64.extend_s/i32
i64.const 32
i64.shl
@ -1170,14 +1170,14 @@
f64.mul
return
end
get_local $11
get_local $10
f64.const 1.e+300
f64.mul
f64.const 1.e+300
f64.mul
return
end
get_local $11
get_local $10
f64.const 1e-300
f64.mul
f64.const 1e-300

File diff suppressed because it is too large Load Diff

View File

@ -11738,8 +11738,9 @@
(local $6 i32)
(local $7 i32)
(local $8 i32)
(local $9 i32)
(local $9 f32)
(local $10 i32)
(local $11 i32)
get_local $0
i32.reinterpret/f32
set_local $2
@ -11791,21 +11792,21 @@
get_local $0
get_local $1
f32.mul
get_local $0
get_local $1
f32.mul
set_local $9
get_local $9
get_local $9
f32.div
return
end
get_local $2
i32.const 1
i32.shl
set_local $9
get_local $9
set_local $10
get_local $10
get_local $7
i32.le_u
if
get_local $9
get_local $10
get_local $7
i32.eq
if
@ -11941,13 +11942,13 @@
i32.const 8
i32.shl
i32.clz
set_local $10
set_local $11
get_local $4
get_local $10
get_local $11
i32.sub
set_local $4
get_local $2
get_local $10
get_local $11
i32.shl
set_local $2
get_local $4
@ -12128,8 +12129,9 @@
(local $6 i64)
(local $7 i64)
(local $8 i32)
(local $9 i64)
(local $9 f64)
(local $10 i64)
(local $11 i64)
get_local $0
i64.reinterpret/f64
set_local $2
@ -12181,21 +12183,21 @@
get_local $0
get_local $1
f64.mul
get_local $0
get_local $1
f64.mul
set_local $9
get_local $9
get_local $9
f64.div
return
end
get_local $2
i64.const 1
i64.shl
set_local $9
get_local $9
set_local $10
get_local $10
get_local $7
i64.le_u
if
get_local $9
get_local $10
get_local $7
i64.eq
if
@ -12331,13 +12333,13 @@
i64.const 11
i64.shl
i64.clz
set_local $10
set_local $11
get_local $4
get_local $10
get_local $11
i64.sub
set_local $4
get_local $2
get_local $10
get_local $11
i64.shl
set_local $2
get_local $4