From c6159df1d5afad15722ea7fb8012d7046f8c3d38 Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Sun, 10 Feb 2019 22:22:28 +0200 Subject: [PATCH 01/22] init --- std/assembly/math.ts | 95 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/std/assembly/math.ts b/std/assembly/math.ts index 6eb9479564..0cc3a97bd4 100644 --- a/std/assembly/math.ts +++ b/std/assembly/math.ts @@ -2287,6 +2287,101 @@ export namespace NativeMathf { } } +export namespace SafeMath { + + @inline + export function clz(x: T): T { + if (isInteger()) { + return builtin_clz(x); + } + throw new Error("Unexpected generic type"); + } + + @inline + export function clz32(x: T): T { + if (isInteger() && sizeof() <= 4) { + return builtin_clz(x); + } + throw new Error("Unexpected generic type"); + } + + @inline + export function min(x: T, y: T): T { + if (isInteger()) { + return builtin_min(x, y); + } + throw new Error("Unexpected generic type"); + } + + @inline + export function max(x: T, y: T): T { + if (isInteger()) { + return builtin_max(x, y); + } + throw new Error("Unexpected generic type"); + } + + @inline + export function abs(x: T): T { + if (isInteger()) { + return builtin_abs(x); + } + throw new Error("Unexpected generic type"); + } + + @inline + export function imul(x: T, y: T): T { + if (isInteger()) { + return x * y; + } + throw new Error("Unexpected generic type"); + } + + @inline + export function pow(x: T, y: i32): T { + if (isInteger()) { + if (sizeof() == 8) return ipow64(x, y); + if (sizeof() <= 4) return ipow32(x, y); + } + throw new Error("Unexpected generic type"); + } + + @inline + export function sign(x: T): T { + if (isInteger()) { + if (!x) return 0; + if (isSigned()) { + return 1 - (x >> (sizeof() * 4 - 1) << 1); + } else { + return 1; + } + } + throw new Error("Unexpected generic type"); + } + + @inline + export function sqrt(x: T): T { + if (isInteger()) { + if (x <= 1) return x; + if (x <= 3) return 1; + + let res = 0; + let add = 1 << (sizeof() * 4 - 1) + let tmp: T; + for (let i = 0; i < sizeof() * 4; ++i) { + tmp = res | add; + let sqr = tmp * tmp; + if (x >= sqr) { + res = tmp; + } + add >>= 1; + } + return res; + } + throw new Error("Unexpected generic type"); + } +} + export function ipow32(x: i32, e: i32): i32 { var out = 1; if (ASC_SHRINK_LEVEL < 1) { From d0888fbde7d419b0103e348c5645762559941b7d Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Sun, 10 Feb 2019 22:29:27 +0200 Subject: [PATCH 02/22] fix sqrt --- std/assembly/math.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/std/assembly/math.ts b/std/assembly/math.ts index 0cc3a97bd4..c28fb08826 100644 --- a/std/assembly/math.ts +++ b/std/assembly/math.ts @@ -2366,7 +2366,7 @@ export namespace SafeMath { if (x <= 3) return 1; let res = 0; - let add = 1 << (sizeof() * 4 - 1) + let add = 1 << (sizeof() * 4 / 2 - 1); let tmp: T; for (let i = 0; i < sizeof() * 4; ++i) { tmp = res | add; From 0777331c51707dfee9ecefa270839d7a4a98cd1d Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Sun, 10 Feb 2019 22:33:09 +0200 Subject: [PATCH 03/22] add signbit [skip ci] --- std/assembly/math.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/std/assembly/math.ts b/std/assembly/math.ts index c28fb08826..67e0aeb780 100644 --- a/std/assembly/math.ts +++ b/std/assembly/math.ts @@ -2359,6 +2359,19 @@ export namespace SafeMath { throw new Error("Unexpected generic type"); } + @inline + export function signbit(x: T): bool { + if (isInteger()) { + if (!x) return 0; + if (isSigned()) { + return (x >> (sizeof() * 4 - 1)); + } else { + return 1; + } + } + throw new Error("Unexpected generic type"); + } + @inline export function sqrt(x: T): T { if (isInteger()) { From e49f97da09cc8a14f22df6da3a23241555c5fa38 Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Tue, 12 Feb 2019 00:46:21 +0200 Subject: [PATCH 04/22] fixes [skip ci] --- std/assembly/math.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/std/assembly/math.ts b/std/assembly/math.ts index 67e0aeb780..b19883e59f 100644 --- a/std/assembly/math.ts +++ b/std/assembly/math.ts @@ -2347,13 +2347,13 @@ export namespace SafeMath { } @inline - export function sign(x: T): T { + export function sign(x: T): i32 { if (isInteger()) { - if (!x) return 0; + if (!x) return 0; if (isSigned()) { - return 1 - (x >> (sizeof() * 4 - 1) << 1); + return 1 - (x >>> (sizeof() * 4 - 1) << 1); } else { - return 1; + return 1; } } throw new Error("Unexpected generic type"); @@ -2362,11 +2362,10 @@ export namespace SafeMath { @inline export function signbit(x: T): bool { if (isInteger()) { - if (!x) return 0; if (isSigned()) { - return (x >> (sizeof() * 4 - 1)); + return (x >>> (sizeof() * 4 - 1)); } else { - return 1; + return true; } } throw new Error("Unexpected generic type"); From 09a29d343f79e0676a17168db6d7a74ef0ac4fec Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Tue, 12 Feb 2019 00:53:58 +0200 Subject: [PATCH 05/22] add log2 [skip ci] --- std/assembly/math.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/std/assembly/math.ts b/std/assembly/math.ts index b19883e59f..d023a8d871 100644 --- a/std/assembly/math.ts +++ b/std/assembly/math.ts @@ -2392,6 +2392,12 @@ export namespace SafeMath { } throw new Error("Unexpected generic type"); } + + // floor(log2(x)) + @inline + export function log2(x: T): T { + return (sizeof() * 4 - 1) - builtin_clz(x); + } } export function ipow32(x: i32, e: i32): i32 { From 89219dc7b9d83f628683695e2f72b31ac6bd6d58 Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Tue, 12 Feb 2019 00:59:33 +0200 Subject: [PATCH 06/22] add more checks for log2 [skip ci] --- std/assembly/math.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/std/assembly/math.ts b/std/assembly/math.ts index d023a8d871..f37a2a8a62 100644 --- a/std/assembly/math.ts +++ b/std/assembly/math.ts @@ -2396,7 +2396,13 @@ export namespace SafeMath { // floor(log2(x)) @inline export function log2(x: T): T { - return (sizeof() * 4 - 1) - builtin_clz(x); + if (isInteger()) { + if (isSigned()) { + if (x <= 0) return -1; + } + return (sizeof() * 4 - 1) - builtin_clz(x); + } + throw new Error("Unexpected generic type"); } } From 78bab558ada3717cbe8f9682ee214a1ddc63a176 Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Tue, 12 Feb 2019 01:25:50 +0200 Subject: [PATCH 07/22] fixes [skip ci] --- std/assembly/math.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/std/assembly/math.ts b/std/assembly/math.ts index f37a2a8a62..c1c6ef2298 100644 --- a/std/assembly/math.ts +++ b/std/assembly/math.ts @@ -2351,7 +2351,7 @@ export namespace SafeMath { if (isInteger()) { if (!x) return 0; if (isSigned()) { - return 1 - (x >>> (sizeof() * 4 - 1) << 1); + return 1 - (x >>> (sizeof() * 8 - 1) << 1); } else { return 1; } @@ -2363,7 +2363,7 @@ export namespace SafeMath { export function signbit(x: T): bool { if (isInteger()) { if (isSigned()) { - return (x >>> (sizeof() * 4 - 1)); + return (x >>> (sizeof() * 8 - 1)); } else { return true; } @@ -2378,9 +2378,9 @@ export namespace SafeMath { if (x <= 3) return 1; let res = 0; - let add = 1 << (sizeof() * 4 / 2 - 1); + let add = 1 << (sizeof() * 8 / 2 - 1); let tmp: T; - for (let i = 0; i < sizeof() * 4; ++i) { + for (let i = 0; i < sizeof() * 8; ++i) { tmp = res | add; let sqr = tmp * tmp; if (x >= sqr) { @@ -2400,7 +2400,7 @@ export namespace SafeMath { if (isSigned()) { if (x <= 0) return -1; } - return (sizeof() * 4 - 1) - builtin_clz(x); + return (sizeof() * 8 - 1) - builtin_clz(x); } throw new Error("Unexpected generic type"); } From 24d966c04f50a7d86fec2cf50c4ea0fe35483b0c Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Tue, 12 Feb 2019 03:46:18 +0200 Subject: [PATCH 08/22] minor fixes [skip ci] --- std/assembly/math.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/std/assembly/math.ts b/std/assembly/math.ts index c1c6ef2298..007427d885 100644 --- a/std/assembly/math.ts +++ b/std/assembly/math.ts @@ -2349,11 +2349,11 @@ export namespace SafeMath { @inline export function sign(x: T): i32 { if (isInteger()) { - if (!x) return 0; if (isSigned()) { + if (!x) return 0; return 1 - (x >>> (sizeof() * 8 - 1) << 1); } else { - return 1; + return (x != 0); } } throw new Error("Unexpected generic type"); @@ -2365,7 +2365,7 @@ export namespace SafeMath { if (isSigned()) { return (x >>> (sizeof() * 8 - 1)); } else { - return true; + return false; } } throw new Error("Unexpected generic type"); @@ -2374,9 +2374,7 @@ export namespace SafeMath { @inline export function sqrt(x: T): T { if (isInteger()) { - if (x <= 1) return x; - if (x <= 3) return 1; - + if (x <= 0) return 0; let res = 0; let add = 1 << (sizeof() * 8 / 2 - 1); let tmp: T; @@ -2386,7 +2384,7 @@ export namespace SafeMath { if (x >= sqr) { res = tmp; } - add >>= 1; + add >>>= 1; } return res; } From 7257558ddf3135639fdceb9a8518ff39d43f2f2b Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Tue, 12 Feb 2019 20:57:55 +0200 Subject: [PATCH 09/22] improve error handling [skip ci] --- std/assembly/math.ts | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/std/assembly/math.ts b/std/assembly/math.ts index 007427d885..1f4c7c885f 100644 --- a/std/assembly/math.ts +++ b/std/assembly/math.ts @@ -2294,7 +2294,7 @@ export namespace SafeMath { if (isInteger()) { return builtin_clz(x); } - throw new Error("Unexpected generic type"); + throw new TypeError("Unexpected generic type"); } @inline @@ -2302,7 +2302,7 @@ export namespace SafeMath { if (isInteger() && sizeof() <= 4) { return builtin_clz(x); } - throw new Error("Unexpected generic type"); + throw new TypeError("Unexpected generic type"); } @inline @@ -2310,7 +2310,7 @@ export namespace SafeMath { if (isInteger()) { return builtin_min(x, y); } - throw new Error("Unexpected generic type"); + throw new TypeError("Unexpected generic type"); } @inline @@ -2318,7 +2318,7 @@ export namespace SafeMath { if (isInteger()) { return builtin_max(x, y); } - throw new Error("Unexpected generic type"); + throw new TypeError("Unexpected generic type"); } @inline @@ -2326,7 +2326,7 @@ export namespace SafeMath { if (isInteger()) { return builtin_abs(x); } - throw new Error("Unexpected generic type"); + throw new TypeError("Unexpected generic type"); } @inline @@ -2334,7 +2334,7 @@ export namespace SafeMath { if (isInteger()) { return x * y; } - throw new Error("Unexpected generic type"); + throw new TypeError("Unexpected generic type"); } @inline @@ -2343,7 +2343,7 @@ export namespace SafeMath { if (sizeof() == 8) return ipow64(x, y); if (sizeof() <= 4) return ipow32(x, y); } - throw new Error("Unexpected generic type"); + throw new TypeError("Unexpected generic type"); } @inline @@ -2356,7 +2356,7 @@ export namespace SafeMath { return (x != 0); } } - throw new Error("Unexpected generic type"); + throw new TypeError("Unexpected generic type"); } @inline @@ -2368,13 +2368,16 @@ export namespace SafeMath { return false; } } - throw new Error("Unexpected generic type"); + throw new TypeError("Unexpected generic type"); } @inline export function sqrt(x: T): T { if (isInteger()) { - if (x <= 0) return 0; + if (isSigned()) { + if (x < 0) throw new RangeError("Math.sqrt received negative argument"); + } + if (!x) return 0; let res = 0; let add = 1 << (sizeof() * 8 / 2 - 1); let tmp: T; @@ -2388,7 +2391,7 @@ export namespace SafeMath { } return res; } - throw new Error("Unexpected generic type"); + throw new TypeError("Unexpected generic type"); } // floor(log2(x)) @@ -2396,11 +2399,13 @@ export namespace SafeMath { export function log2(x: T): T { if (isInteger()) { if (isSigned()) { - if (x <= 0) return -1; + if (x <= 0) throw new RangeError("Math.log2 received negative or zero argument"); + } else { + if (!x) throw new RangeError("Math.log2 received zero argument"); } return (sizeof() * 8 - 1) - builtin_clz(x); } - throw new Error("Unexpected generic type"); + throw new TypeError("Unexpected generic type"); } } From 6cdf9cd1972b3ef12b411248cabf9cf60cd5da34 Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Tue, 12 Feb 2019 21:33:53 +0200 Subject: [PATCH 10/22] refactoring [skip ci] --- std/assembly/math.ts | 57 +++++++++++++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 19 deletions(-) diff --git a/std/assembly/math.ts b/std/assembly/math.ts index 1f4c7c885f..d6edc5a100 100644 --- a/std/assembly/math.ts +++ b/std/assembly/math.ts @@ -2299,8 +2299,8 @@ export namespace SafeMath { @inline export function clz32(x: T): T { - if (isInteger() && sizeof() <= 4) { - return builtin_clz(x); + if (isInteger()) { + return builtin_clz(x); } throw new TypeError("Unexpected generic type"); } @@ -2329,10 +2329,30 @@ export namespace SafeMath { throw new TypeError("Unexpected generic type"); } + @inline + export function ceil(x: T): T { + return x; + } + + @inline + export function floor(x: T): T { + return x; + } + + @inline + export function round(x: T): T { + return x; + } + + @inline + export function trunc(x: T): T { + return x; + } + @inline export function imul(x: T, y: T): T { if (isInteger()) { - return x * y; + return (x * y); } throw new TypeError("Unexpected generic type"); } @@ -2346,12 +2366,25 @@ export namespace SafeMath { throw new TypeError("Unexpected generic type"); } + // floor(log2(x)) + @inline + export function log2(x: T): T { + if (isInteger()) { + if (isSigned()) { + if (x <= 0) throw new RangeError("Math.log2 received negative or zero argument"); + } else { + if (!x) throw new RangeError("Math.log2 received zero argument"); + } + return (sizeof() * 8 - 1) - builtin_clz(x); + } + throw new TypeError("Unexpected generic type"); + } + @inline export function sign(x: T): i32 { if (isInteger()) { if (isSigned()) { - if (!x) return 0; - return 1 - (x >>> (sizeof() * 8 - 1) << 1); + return select(0, 1 - (x >>> (sizeof() * 8 - 1) << 1), !x); } else { return (x != 0); } @@ -2393,20 +2426,6 @@ export namespace SafeMath { } throw new TypeError("Unexpected generic type"); } - - // floor(log2(x)) - @inline - export function log2(x: T): T { - if (isInteger()) { - if (isSigned()) { - if (x <= 0) throw new RangeError("Math.log2 received negative or zero argument"); - } else { - if (!x) throw new RangeError("Math.log2 received zero argument"); - } - return (sizeof() * 8 - 1) - builtin_clz(x); - } - throw new TypeError("Unexpected generic type"); - } } export function ipow32(x: i32, e: i32): i32 { From 1b040d011a6f91a28f0e992c25a3c6341807c5d3 Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Tue, 12 Feb 2019 21:42:03 +0200 Subject: [PATCH 11/22] simpilfy sign & signbit [skip ci] --- std/assembly/math.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/std/assembly/math.ts b/std/assembly/math.ts index d6edc5a100..2f0c257376 100644 --- a/std/assembly/math.ts +++ b/std/assembly/math.ts @@ -2289,6 +2289,14 @@ export namespace NativeMathf { export namespace SafeMath { + @inline + export function abs(x: T): T { + if (isInteger()) { + return builtin_abs(x); + } + throw new TypeError("Unexpected generic type"); + } + @inline export function clz(x: T): T { if (isInteger()) { @@ -2321,14 +2329,6 @@ export namespace SafeMath { throw new TypeError("Unexpected generic type"); } - @inline - export function abs(x: T): T { - if (isInteger()) { - return builtin_abs(x); - } - throw new TypeError("Unexpected generic type"); - } - @inline export function ceil(x: T): T { return x; @@ -2384,7 +2384,7 @@ export namespace SafeMath { export function sign(x: T): i32 { if (isInteger()) { if (isSigned()) { - return select(0, 1 - (x >>> (sizeof() * 8 - 1) << 1), !x); + return (x > 0) - (x < 0); } else { return (x != 0); } @@ -2396,7 +2396,7 @@ export namespace SafeMath { export function signbit(x: T): bool { if (isInteger()) { if (isSigned()) { - return (x >>> (sizeof() * 8 - 1)); + return x < 0; } else { return false; } From 464feb72679837bcc76e5cffee029fbaa5cd3f4f Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Sun, 17 Feb 2019 01:05:20 +0200 Subject: [PATCH 12/22] rename SafeMath -> IntegerMath --- std/assembly/math.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/std/assembly/math.ts b/std/assembly/math.ts index 2f0c257376..a34e4e3998 100644 --- a/std/assembly/math.ts +++ b/std/assembly/math.ts @@ -2287,7 +2287,7 @@ export namespace NativeMathf { } } -export namespace SafeMath { +export namespace IntegerMath { @inline export function abs(x: T): T { From 3771cedc9c4103c6a326af91cac35dae69046b7f Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Sun, 17 Feb 2019 13:18:25 +0200 Subject: [PATCH 13/22] fix tslint --- std/assembly/math.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/std/assembly/math.ts b/std/assembly/math.ts index a34e4e3998..c7f3153f8b 100644 --- a/std/assembly/math.ts +++ b/std/assembly/math.ts @@ -2412,6 +2412,7 @@ export namespace IntegerMath { } if (!x) return 0; let res = 0; + /* tslint:disable-next-line:as-types */ let add = 1 << (sizeof() * 8 / 2 - 1); let tmp: T; for (let i = 0; i < sizeof() * 8; ++i) { From 2b9b34117205e7a22a79b3e1e1880143e260fd5e Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Tue, 19 Feb 2019 10:08:55 +0200 Subject: [PATCH 14/22] add first tests and definitions --- std/assembly/index.d.ts | 35 + std/assembly/math.ts | 6 +- tests/compiler/std/math.optimized.wat | 120 +- tests/compiler/std/math.ts | 61 + tests/compiler/std/math.untouched.wat | 1675 ++++++++++++++++++++++--- 5 files changed, 1652 insertions(+), 245 deletions(-) diff --git a/std/assembly/index.d.ts b/std/assembly/index.d.ts index 635a5b47f5..82c5604ae3 100644 --- a/std/assembly/index.d.ts +++ b/std/assembly/index.d.ts @@ -870,6 +870,39 @@ interface IMath { trunc(x: T): T; } +interface IIntegerMath { + /** Returns the absolute value of `x`. */ + abs(x: T): T; + /** Returns the number of leading zero bits in the 32-bit or 64-bit binary representation of `x`. */ + clz(x: T): T; + /** Returns the number of leading zero bits in the 32-bit binary representation of `x`. */ + clz32(x: T): T; + /** Returns the lowest-valued number of its arguments. */ + min(x: T, y: T): T; + /** Returns the largest-valued number of its arguments. */ + max(x: T, y: T): T; + /** Returns same value as input without changes. */ + ceil(x: T): T; + /** Returns same value as input without changes. */ + floor(x: T): T; + /** Returns same value as input without changes. */ + round(x: T): T; + /** Returns same value as input without changes. */ + trunc(x: T): T; + /** Returns the result of the C-like 32-bit multiplication of `a` and `b`. */ + imul(x: T, y: T): T; + /** Returns `base` to the power of `exponent`. */ + pow(base: T, exponent: T): T; + /** Returns the base 2 logarithm of `x` as `floor(log2(x))` */ + log2(x: T): T; + /** Returns the sign of `x`, indicating whether the number is positive, negative or zero. */ + sign(x: T): i32; + /** Returns whether the sign bit of `x` is set */ + signbit(x: T): bool; + /** Returns the square root of `x` as `floor(sqrt(x))`. */ + sqrt(x: T): T; +} + interface INativeMath extends IMath { /** Seeds the random number generator. */ seedRandom(value: i64): void; @@ -889,6 +922,8 @@ declare const NativeMathf: INativeMath; declare const Math: IMath; /** Alias of {@link NativeMathf} or {@link JSMath} respectively. Defaults to `NativeMathf`. */ declare const Mathf: IMath; +/** Integer math implemented natively. */ +declare const IntegerMath: IIntegerMath; declare class Date { /** Returns the UTC timestamp in milliseconds of the specified date. */ diff --git a/std/assembly/math.ts b/std/assembly/math.ts index c7f3153f8b..553311b07d 100644 --- a/std/assembly/math.ts +++ b/std/assembly/math.ts @@ -2375,7 +2375,11 @@ export namespace IntegerMath { } else { if (!x) throw new RangeError("Math.log2 received zero argument"); } - return (sizeof() * 8 - 1) - builtin_clz(x); + if (sizeof() <= 4) { + return (31 - builtin_clz(x)); + } else { + return (63 - builtin_clz(x)); + } } throw new TypeError("Unexpected generic type"); } diff --git a/tests/compiler/std/math.optimized.wat b/tests/compiler/std/math.optimized.wat index 82f4e659f7..630d351d5e 100644 --- a/tests/compiler/std/math.optimized.wat +++ b/tests/compiler/std/math.optimized.wat @@ -37854,7 +37854,7 @@ if i32.const 0 i32.const 8 - i32.const 3289 + i32.const 3350 i32.const 0 call $~lib/env/abort unreachable @@ -37867,7 +37867,7 @@ if i32.const 0 i32.const 8 - i32.const 3290 + i32.const 3351 i32.const 0 call $~lib/env/abort unreachable @@ -37880,7 +37880,7 @@ if i32.const 0 i32.const 8 - i32.const 3291 + i32.const 3352 i32.const 0 call $~lib/env/abort unreachable @@ -37893,7 +37893,7 @@ if i32.const 0 i32.const 8 - i32.const 3292 + i32.const 3353 i32.const 0 call $~lib/env/abort unreachable @@ -37906,7 +37906,7 @@ if i32.const 0 i32.const 8 - i32.const 3294 + i32.const 3355 i32.const 0 call $~lib/env/abort unreachable @@ -37919,7 +37919,7 @@ if i32.const 0 i32.const 8 - i32.const 3295 + i32.const 3356 i32.const 0 call $~lib/env/abort unreachable @@ -37932,7 +37932,7 @@ if i32.const 0 i32.const 8 - i32.const 3296 + i32.const 3357 i32.const 0 call $~lib/env/abort unreachable @@ -37945,7 +37945,7 @@ if i32.const 0 i32.const 8 - i32.const 3297 + i32.const 3358 i32.const 0 call $~lib/env/abort unreachable @@ -37958,7 +37958,7 @@ if i32.const 0 i32.const 8 - i32.const 3299 + i32.const 3360 i32.const 0 call $~lib/env/abort unreachable @@ -37971,7 +37971,7 @@ if i32.const 0 i32.const 8 - i32.const 3300 + i32.const 3361 i32.const 0 call $~lib/env/abort unreachable @@ -37984,7 +37984,7 @@ if i32.const 0 i32.const 8 - i32.const 3301 + i32.const 3362 i32.const 0 call $~lib/env/abort unreachable @@ -37997,7 +37997,7 @@ if i32.const 0 i32.const 8 - i32.const 3302 + i32.const 3363 i32.const 0 call $~lib/env/abort unreachable @@ -38010,7 +38010,7 @@ if i32.const 0 i32.const 8 - i32.const 3304 + i32.const 3365 i32.const 0 call $~lib/env/abort unreachable @@ -38023,7 +38023,7 @@ if i32.const 0 i32.const 8 - i32.const 3305 + i32.const 3366 i32.const 0 call $~lib/env/abort unreachable @@ -38036,7 +38036,7 @@ if i32.const 0 i32.const 8 - i32.const 3306 + i32.const 3367 i32.const 0 call $~lib/env/abort unreachable @@ -38049,7 +38049,7 @@ if i32.const 0 i32.const 8 - i32.const 3307 + i32.const 3368 i32.const 0 call $~lib/env/abort unreachable @@ -38062,7 +38062,7 @@ if i32.const 0 i32.const 8 - i32.const 3309 + i32.const 3370 i32.const 0 call $~lib/env/abort unreachable @@ -38075,7 +38075,7 @@ if i32.const 0 i32.const 8 - i32.const 3310 + i32.const 3371 i32.const 0 call $~lib/env/abort unreachable @@ -38088,7 +38088,7 @@ if i32.const 0 i32.const 8 - i32.const 3311 + i32.const 3372 i32.const 0 call $~lib/env/abort unreachable @@ -38101,7 +38101,7 @@ if i32.const 0 i32.const 8 - i32.const 3312 + i32.const 3373 i32.const 0 call $~lib/env/abort unreachable @@ -38114,7 +38114,7 @@ if i32.const 0 i32.const 8 - i32.const 3314 + i32.const 3375 i32.const 0 call $~lib/env/abort unreachable @@ -38127,7 +38127,7 @@ if i32.const 0 i32.const 8 - i32.const 3315 + i32.const 3376 i32.const 0 call $~lib/env/abort unreachable @@ -38140,7 +38140,7 @@ if i32.const 0 i32.const 8 - i32.const 3316 + i32.const 3377 i32.const 0 call $~lib/env/abort unreachable @@ -38153,7 +38153,7 @@ if i32.const 0 i32.const 8 - i32.const 3317 + i32.const 3378 i32.const 0 call $~lib/env/abort unreachable @@ -38166,7 +38166,7 @@ if i32.const 0 i32.const 8 - i32.const 3318 + i32.const 3379 i32.const 0 call $~lib/env/abort unreachable @@ -38179,7 +38179,7 @@ if i32.const 0 i32.const 8 - i32.const 3319 + i32.const 3380 i32.const 0 call $~lib/env/abort unreachable @@ -38192,7 +38192,7 @@ if i32.const 0 i32.const 8 - i32.const 3320 + i32.const 3381 i32.const 0 call $~lib/env/abort unreachable @@ -38209,7 +38209,7 @@ if i32.const 0 i32.const 8 - i32.const 3322 + i32.const 3383 i32.const 0 call $~lib/env/abort unreachable @@ -38222,7 +38222,7 @@ if i32.const 0 i32.const 8 - i32.const 3326 + i32.const 3387 i32.const 0 call $~lib/env/abort unreachable @@ -38235,7 +38235,7 @@ if i32.const 0 i32.const 8 - i32.const 3327 + i32.const 3388 i32.const 0 call $~lib/env/abort unreachable @@ -38249,7 +38249,7 @@ if i32.const 0 i32.const 8 - i32.const 3328 + i32.const 3389 i32.const 0 call $~lib/env/abort unreachable @@ -38263,7 +38263,7 @@ if i32.const 0 i32.const 8 - i32.const 3329 + i32.const 3390 i32.const 0 call $~lib/env/abort unreachable @@ -38277,7 +38277,7 @@ if i32.const 0 i32.const 8 - i32.const 3330 + i32.const 3391 i32.const 0 call $~lib/env/abort unreachable @@ -38290,7 +38290,7 @@ if i32.const 0 i32.const 8 - i32.const 3331 + i32.const 3392 i32.const 0 call $~lib/env/abort unreachable @@ -38303,7 +38303,7 @@ if i32.const 0 i32.const 8 - i32.const 3332 + i32.const 3393 i32.const 0 call $~lib/env/abort unreachable @@ -38316,7 +38316,7 @@ if i32.const 0 i32.const 8 - i32.const 3333 + i32.const 3394 i32.const 0 call $~lib/env/abort unreachable @@ -38329,7 +38329,7 @@ if i32.const 0 i32.const 8 - i32.const 3334 + i32.const 3395 i32.const 0 call $~lib/env/abort unreachable @@ -38342,7 +38342,7 @@ if i32.const 0 i32.const 8 - i32.const 3335 + i32.const 3396 i32.const 0 call $~lib/env/abort unreachable @@ -38355,7 +38355,7 @@ if i32.const 0 i32.const 8 - i32.const 3336 + i32.const 3397 i32.const 0 call $~lib/env/abort unreachable @@ -38368,7 +38368,7 @@ if i32.const 0 i32.const 8 - i32.const 3337 + i32.const 3398 i32.const 0 call $~lib/env/abort unreachable @@ -38381,7 +38381,7 @@ if i32.const 0 i32.const 8 - i32.const 3338 + i32.const 3399 i32.const 0 call $~lib/env/abort unreachable @@ -38394,7 +38394,7 @@ if i32.const 0 i32.const 8 - i32.const 3339 + i32.const 3400 i32.const 0 call $~lib/env/abort unreachable @@ -38407,7 +38407,7 @@ if i32.const 0 i32.const 8 - i32.const 3340 + i32.const 3401 i32.const 0 call $~lib/env/abort unreachable @@ -38420,7 +38420,7 @@ if i32.const 0 i32.const 8 - i32.const 3341 + i32.const 3402 i32.const 0 call $~lib/env/abort unreachable @@ -38433,7 +38433,7 @@ if i32.const 0 i32.const 8 - i32.const 3345 + i32.const 3406 i32.const 0 call $~lib/env/abort unreachable @@ -38446,7 +38446,7 @@ if i32.const 0 i32.const 8 - i32.const 3346 + i32.const 3407 i32.const 0 call $~lib/env/abort unreachable @@ -38460,7 +38460,7 @@ if i32.const 0 i32.const 8 - i32.const 3347 + i32.const 3408 i32.const 0 call $~lib/env/abort unreachable @@ -38474,7 +38474,7 @@ if i32.const 0 i32.const 8 - i32.const 3348 + i32.const 3409 i32.const 0 call $~lib/env/abort unreachable @@ -38488,7 +38488,7 @@ if i32.const 0 i32.const 8 - i32.const 3349 + i32.const 3410 i32.const 0 call $~lib/env/abort unreachable @@ -38501,7 +38501,7 @@ if i32.const 0 i32.const 8 - i32.const 3350 + i32.const 3411 i32.const 0 call $~lib/env/abort unreachable @@ -38514,7 +38514,7 @@ if i32.const 0 i32.const 8 - i32.const 3351 + i32.const 3412 i32.const 0 call $~lib/env/abort unreachable @@ -38527,7 +38527,7 @@ if i32.const 0 i32.const 8 - i32.const 3352 + i32.const 3413 i32.const 0 call $~lib/env/abort unreachable @@ -38540,7 +38540,7 @@ if i32.const 0 i32.const 8 - i32.const 3353 + i32.const 3414 i32.const 0 call $~lib/env/abort unreachable @@ -38553,7 +38553,7 @@ if i32.const 0 i32.const 8 - i32.const 3354 + i32.const 3415 i32.const 0 call $~lib/env/abort unreachable @@ -38566,7 +38566,7 @@ if i32.const 0 i32.const 8 - i32.const 3355 + i32.const 3416 i32.const 0 call $~lib/env/abort unreachable @@ -38579,7 +38579,7 @@ if i32.const 0 i32.const 8 - i32.const 3356 + i32.const 3417 i32.const 0 call $~lib/env/abort unreachable @@ -38592,7 +38592,7 @@ if i32.const 0 i32.const 8 - i32.const 3357 + i32.const 3418 i32.const 0 call $~lib/env/abort unreachable @@ -38605,7 +38605,7 @@ if i32.const 0 i32.const 8 - i32.const 3358 + i32.const 3419 i32.const 0 call $~lib/env/abort unreachable @@ -38618,7 +38618,7 @@ if i32.const 0 i32.const 8 - i32.const 3359 + i32.const 3420 i32.const 0 call $~lib/env/abort unreachable @@ -38631,7 +38631,7 @@ if i32.const 0 i32.const 8 - i32.const 3360 + i32.const 3421 i32.const 0 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/math.ts b/tests/compiler/std/math.ts index 5d10bbbda7..db0d55575e 100644 --- a/tests/compiler/std/math.ts +++ b/tests/compiler/std/math.ts @@ -3284,6 +3284,67 @@ assert(NativeMath.imul(NaN, 1) == 0); assert(NativeMath.imul(1, Infinity) == 0); assert(NativeMath.imul(f64.MAX_VALUE, f64.MAX_VALUE) == 0); +// IntegerMath.sign /////////////////////////////////////////////////////////////////////////// + +assert(IntegerMath.sign(0) == 0); +assert(IntegerMath.sign(0) == 0); +assert(IntegerMath.sign(0) == 0); +assert(IntegerMath.sign(0) == 0); +assert(IntegerMath.sign(0) == 0); +assert(IntegerMath.sign(0) == 0); +assert(IntegerMath.sign(2) == 1); +assert(IntegerMath.sign(2) == 1); +assert(IntegerMath.sign(2) == 1); +assert(IntegerMath.sign(2) == 1); +assert(IntegerMath.sign(-2) == -1); +assert(IntegerMath.sign(-2) == -1); +assert(IntegerMath.sign(-2) == 1); +assert(IntegerMath.sign(-2) == 1); +assert(IntegerMath.sign(-2 as i16) == -1); +assert(IntegerMath.sign(-2 as u16) == 1); + +// IntegerMath.signbit /////////////////////////////////////////////////////////////////////////// + +assert(IntegerMath.signbit(0) == false); +assert(IntegerMath.signbit(0) == false); +assert(IntegerMath.signbit(0) == false); +assert(IntegerMath.signbit(0) == false); +assert(IntegerMath.signbit(0) == false); +assert(IntegerMath.signbit(0) == false); +assert(IntegerMath.signbit(2) == false); +assert(IntegerMath.signbit(2) == false); +assert(IntegerMath.signbit(2) == false); +assert(IntegerMath.signbit(2) == false); +assert(IntegerMath.signbit(-2) == true); +assert(IntegerMath.signbit(-2) == true); +assert(IntegerMath.signbit(-2) == false); +assert(IntegerMath.signbit(-2) == false); +assert(IntegerMath.signbit(-2 as i16) == true); +assert(IntegerMath.signbit(-2 as u16) == false); + +// IntegerMath.log2 /////////////////////////////////////////////////////////////////////////// + +assert(IntegerMath.log2(1) == 0); +assert(IntegerMath.log2(1) == 0); +assert(IntegerMath.log2(1) == 0); +assert(IntegerMath.log2(1) == 0); +assert(IntegerMath.log2(1) == 0); +assert(IntegerMath.log2(2) == 1); +assert(IntegerMath.log2(2) == 1); +assert(IntegerMath.log2(2) == 1); +assert(IntegerMath.log2(2) == 1); +assert(IntegerMath.log2(2) == 1); +assert(IntegerMath.log2(3) == 1); +assert(IntegerMath.log2(3) == 1); +assert(IntegerMath.log2(3) == 1); +assert(IntegerMath.log2(3) == 1); +assert(IntegerMath.log2(3) == 1); +assert(IntegerMath.log2(i16.MAX_VALUE) == 14); +assert(IntegerMath.log2(i32.MAX_VALUE) == 30); +assert(IntegerMath.log2(u32.MAX_VALUE) == 31); +assert(IntegerMath.log2(i64.MAX_VALUE) == 62); +assert(IntegerMath.log2(u64.MAX_VALUE) == 63); + // ipow64 ///////////////////////////////////////////////////////////////////////////////////// assert(ipow64(0, 0) == 1); diff --git a/tests/compiler/std/math.untouched.wat b/tests/compiler/std/math.untouched.wat index 9a41b37b41..f5d193e401 100644 --- a/tests/compiler/std/math.untouched.wat +++ b/tests/compiler/std/math.untouched.wat @@ -95,6 +95,11 @@ (global $~lib/math/random_state1_32 (mut i32) (i32.const 0)) (global $ASC_SHRINK_LEVEL i32 (i32.const 0)) (global $~lib/builtins/f64.MAX_VALUE f64 (f64.const 1797693134862315708145274e284)) + (global $~lib/builtins/i16.MAX_VALUE i32 (i32.const 32767)) + (global $~lib/builtins/i32.MAX_VALUE i32 (i32.const 2147483647)) + (global $~lib/builtins/u32.MAX_VALUE i32 (i32.const -1)) + (global $~lib/builtins/i64.MAX_VALUE i64 (i64.const 9223372036854775807)) + (global $~lib/builtins/u64.MAX_VALUE i64 (i64.const -1)) (global $~lib/builtins/f32.MAX_VALUE f32 (f32.const 3402823466385288598117041e14)) (global $~lib/builtins/f32.MIN_VALUE f32 (f32.const 1.401298464324817e-45)) (global $HEAP_BASE i32 (i32.const 68)) @@ -11247,7 +11252,143 @@ i32.mul f64.convert_i32_s ) - (func $~lib/math/ipow64 (; 154 ;) (type $IiI) (param $0 i64) (param $1 i32) (result i64) + (func $~lib/math/IntegerMath.sign (; 154 ;) (type $ii) (param $0 i32) (result i32) + local.get $0 + i32.const 16 + i32.shl + i32.const 16 + i32.shr_s + i32.const 0 + i32.gt_s + local.get $0 + i32.const 16 + i32.shl + i32.const 16 + i32.shr_s + i32.const 0 + i32.lt_s + i32.sub + return + ) + (func $~lib/math/IntegerMath.sign (; 155 ;) (type $ii) (param $0 i32) (result i32) + local.get $0 + i32.const 65535 + i32.and + i32.const 0 + i32.ne + return + ) + (func $~lib/math/IntegerMath.signbit (; 156 ;) (type $ii) (param $0 i32) (result i32) + local.get $0 + i32.const 16 + i32.shl + i32.const 16 + i32.shr_s + i32.const 0 + i32.lt_s + return + ) + (func $~lib/math/IntegerMath.signbit (; 157 ;) (type $ii) (param $0 i32) (result i32) + i32.const 0 + return + ) + (func $~lib/math/IntegerMath.log2 (; 158 ;) (type $ii) (param $0 i32) (result i32) + local.get $0 + i32.const 16 + i32.shl + i32.const 16 + i32.shr_s + i32.const 0 + i32.le_s + if + i32.const 0 + i32.const 40 + i32.const 2374 + i32.const 20 + call $~lib/env/abort + unreachable + end + i32.const 31 + local.get $0 + i32.const 16 + i32.shl + i32.const 16 + i32.shr_s + i32.clz + i32.sub + return + ) + (func $~lib/math/IntegerMath.log2 (; 159 ;) (type $ii) (param $0 i32) (result i32) + local.get $0 + i32.const 0 + i32.le_s + if + i32.const 0 + i32.const 40 + i32.const 2374 + i32.const 20 + call $~lib/env/abort + unreachable + end + i32.const 31 + local.get $0 + i32.clz + i32.sub + return + ) + (func $~lib/math/IntegerMath.log2 (; 160 ;) (type $ii) (param $0 i32) (result i32) + local.get $0 + i32.eqz + if + i32.const 0 + i32.const 40 + i32.const 2376 + i32.const 16 + call $~lib/env/abort + unreachable + end + i32.const 31 + local.get $0 + i32.clz + i32.sub + return + ) + (func $~lib/math/IntegerMath.log2 (; 161 ;) (type $II) (param $0 i64) (result i64) + local.get $0 + i64.const 0 + i64.le_s + if + i32.const 0 + i32.const 40 + i32.const 2374 + i32.const 20 + call $~lib/env/abort + unreachable + end + i64.const 63 + local.get $0 + i64.clz + i64.sub + return + ) + (func $~lib/math/IntegerMath.log2 (; 162 ;) (type $II) (param $0 i64) (result i64) + local.get $0 + i64.eqz + if + i32.const 0 + i32.const 40 + i32.const 2376 + i32.const 16 + call $~lib/env/abort + unreachable + end + i64.const 63 + local.get $0 + i64.clz + i64.sub + return + ) + (func $~lib/math/ipow64 (; 163 ;) (type $IiI) (param $0 i64) (param $1 i32) (result i64) (local $2 i64) (local $3 i32) (local $4 i32) @@ -11479,7 +11620,7 @@ end local.get $2 ) - (func $~lib/math/ipow32f (; 155 ;) (type $fif) (param $0 f32) (param $1 i32) (result f32) + (func $~lib/math/ipow32f (; 164 ;) (type $fif) (param $0 f32) (param $1 i32) (result f32) (local $2 i32) (local $3 f32) local.get $1 @@ -11530,7 +11671,7 @@ local.get $3 end ) - (func $~lib/math/ipow64f (; 156 ;) (type $FiF) (param $0 f64) (param $1 i32) (result f64) + (func $~lib/math/ipow64f (; 165 ;) (type $FiF) (param $0 f64) (param $1 i32) (result f64) (local $2 i32) (local $3 f64) local.get $1 @@ -11581,7 +11722,7 @@ local.get $3 end ) - (func $start (; 157 ;) (type $_) + (func $start (; 166 ;) (type $_) (local $0 i32) (local $1 f64) (local $2 i32) @@ -42120,11 +42261,20 @@ call $~lib/env/abort unreachable end - i64.const 0 + block $~lib/math/IntegerMath.sign|inlined.0 (result i32) + i32.const 0 + local.set $0 + local.get $0 + i32.const 0 + i32.gt_s + local.get $0 + i32.const 0 + i32.lt_s + i32.sub + br $~lib/math/IntegerMath.sign|inlined.0 + end i32.const 0 - call $~lib/math/ipow64 - i64.const 1 - i64.eq + i32.eq i32.eqz if i32.const 0 @@ -42134,11 +42284,16 @@ call $~lib/env/abort unreachable end - i64.const 0 - i32.const 1 - call $~lib/math/ipow64 - i64.const 0 - i64.eq + block $~lib/math/IntegerMath.sign|inlined.0 (result i32) + i32.const 0 + local.set $0 + local.get $0 + i32.const 0 + i32.ne + br $~lib/math/IntegerMath.sign|inlined.0 + end + i32.const 0 + i32.eq i32.eqz if i32.const 0 @@ -42148,11 +42303,20 @@ call $~lib/env/abort unreachable end - i64.const 0 - i32.const 2 - call $~lib/math/ipow64 - i64.const 0 - i64.eq + block $~lib/math/IntegerMath.sign|inlined.0 (result i32) + i32.const 0 + local.set $0 + local.get $0 + i32.const 0 + i32.gt_s + local.get $0 + i32.const 0 + i32.lt_s + i32.sub + br $~lib/math/IntegerMath.sign|inlined.0 + end + i32.const 0 + i32.eq i32.eqz if i32.const 0 @@ -42162,11 +42326,16 @@ call $~lib/env/abort unreachable end - i64.const 0 - i32.const 3 - call $~lib/math/ipow64 - i64.const 0 - i64.eq + block $~lib/math/IntegerMath.sign|inlined.0 (result i32) + i32.const 0 + local.set $0 + local.get $0 + i32.const 0 + i32.ne + br $~lib/math/IntegerMath.sign|inlined.0 + end + i32.const 0 + i32.eq i32.eqz if i32.const 0 @@ -42176,11 +42345,39 @@ call $~lib/env/abort unreachable end - i64.const 1 + block $~lib/math/IntegerMath.sign|inlined.0 (result i32) + i64.const 0 + local.set $3 + local.get $3 + i64.const 0 + i64.gt_s + local.get $3 + i64.const 0 + i64.lt_s + i32.sub + br $~lib/math/IntegerMath.sign|inlined.0 + end i32.const 0 - call $~lib/math/ipow64 - i64.const 1 - i64.eq + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3293 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.sign|inlined.0 (result i32) + i64.const 0 + local.set $3 + local.get $3 + i64.const 0 + i64.ne + br $~lib/math/IntegerMath.sign|inlined.0 + end + i32.const 0 + i32.eq i32.eqz if i32.const 0 @@ -42190,11 +42387,20 @@ call $~lib/env/abort unreachable end - i64.const 1 + block $~lib/math/IntegerMath.sign|inlined.1 (result i32) + i32.const 2 + local.set $0 + local.get $0 + i32.const 0 + i32.gt_s + local.get $0 + i32.const 0 + i32.lt_s + i32.sub + br $~lib/math/IntegerMath.sign|inlined.1 + end i32.const 1 - call $~lib/math/ipow64 - i64.const 1 - i64.eq + i32.eq i32.eqz if i32.const 0 @@ -42204,11 +42410,16 @@ call $~lib/env/abort unreachable end - i64.const 1 - i32.const 2 - call $~lib/math/ipow64 - i64.const 1 - i64.eq + block $~lib/math/IntegerMath.sign|inlined.1 (result i32) + i32.const 2 + local.set $0 + local.get $0 + i32.const 0 + i32.ne + br $~lib/math/IntegerMath.sign|inlined.1 + end + i32.const 1 + i32.eq i32.eqz if i32.const 0 @@ -42218,11 +42429,20 @@ call $~lib/env/abort unreachable end - i64.const 1 - i32.const 3 - call $~lib/math/ipow64 - i64.const 1 - i64.eq + block $~lib/math/IntegerMath.sign|inlined.1 (result i32) + i64.const 2 + local.set $3 + local.get $3 + i64.const 0 + i64.gt_s + local.get $3 + i64.const 0 + i64.lt_s + i32.sub + br $~lib/math/IntegerMath.sign|inlined.1 + end + i32.const 1 + i32.eq i32.eqz if i32.const 0 @@ -42232,11 +42452,39 @@ call $~lib/env/abort unreachable end - i64.const 2 - i32.const 0 - call $~lib/math/ipow64 - i64.const 1 - i64.eq + block $~lib/math/IntegerMath.sign|inlined.1 (result i32) + i64.const 2 + local.set $3 + local.get $3 + i64.const 0 + i64.ne + br $~lib/math/IntegerMath.sign|inlined.1 + end + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3298 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.sign|inlined.2 (result i32) + i32.const -2 + local.set $0 + local.get $0 + i32.const 0 + i32.gt_s + local.get $0 + i32.const 0 + i32.lt_s + i32.sub + br $~lib/math/IntegerMath.sign|inlined.2 + end + i32.const -1 + i32.eq i32.eqz if i32.const 0 @@ -42246,11 +42494,20 @@ call $~lib/env/abort unreachable end - i64.const 2 - i32.const 1 - call $~lib/math/ipow64 - i64.const 2 - i64.eq + block $~lib/math/IntegerMath.sign|inlined.2 (result i32) + i64.const -2 + local.set $3 + local.get $3 + i64.const 0 + i64.gt_s + local.get $3 + i64.const 0 + i64.lt_s + i32.sub + br $~lib/math/IntegerMath.sign|inlined.2 + end + i32.const -1 + i32.eq i32.eqz if i32.const 0 @@ -42260,11 +42517,16 @@ call $~lib/env/abort unreachable end - i64.const 2 - i32.const 2 - call $~lib/math/ipow64 - i64.const 4 - i64.eq + block $~lib/math/IntegerMath.sign|inlined.2 (result i32) + i32.const -2 + local.set $0 + local.get $0 + i32.const 0 + i32.ne + br $~lib/math/IntegerMath.sign|inlined.2 + end + i32.const 1 + i32.eq i32.eqz if i32.const 0 @@ -42274,11 +42536,16 @@ call $~lib/env/abort unreachable end - i64.const 2 - i32.const 3 - call $~lib/math/ipow64 - i64.const 8 - i64.eq + block $~lib/math/IntegerMath.sign|inlined.2 (result i32) + i64.const -2 + local.set $3 + local.get $3 + i64.const 0 + i64.ne + br $~lib/math/IntegerMath.sign|inlined.2 + end + i32.const 1 + i32.eq i32.eqz if i32.const 0 @@ -42288,123 +42555,164 @@ call $~lib/env/abort unreachable end - i64.const -1 - i32.const 0 - call $~lib/math/ipow64 - i64.const 1 - i64.eq + i32.const -2 + call $~lib/math/IntegerMath.sign + i32.const -1 + i32.eq i32.eqz if i32.const 0 i32.const 8 - i32.const 3304 + i32.const 3303 i32.const 0 call $~lib/env/abort unreachable end - i64.const -1 + i32.const -2 + call $~lib/math/IntegerMath.sign i32.const 1 - call $~lib/math/ipow64 - i64.const -1 - i64.eq + i32.eq i32.eqz if i32.const 0 i32.const 8 - i32.const 3305 + i32.const 3304 i32.const 0 call $~lib/env/abort unreachable end - i64.const -1 - i32.const 2 - call $~lib/math/ipow64 - i64.const 1 - i64.eq + block $~lib/math/IntegerMath.signbit|inlined.0 (result i32) + i32.const 0 + local.set $0 + local.get $0 + i32.const 0 + i32.lt_s + br $~lib/math/IntegerMath.signbit|inlined.0 + end + i32.const 0 + i32.ne + i32.const 0 + i32.eq i32.eqz if i32.const 0 i32.const 8 - i32.const 3306 + i32.const 3308 i32.const 0 call $~lib/env/abort unreachable end - i64.const -1 - i32.const 3 - call $~lib/math/ipow64 - i64.const -1 - i64.eq + block $~lib/math/IntegerMath.signbit|inlined.0 (result i32) + i32.const 0 + local.set $0 + i32.const 0 + br $~lib/math/IntegerMath.signbit|inlined.0 + end + i32.const 0 + i32.ne + i32.const 0 + i32.eq i32.eqz if i32.const 0 i32.const 8 - i32.const 3307 + i32.const 3309 i32.const 0 call $~lib/env/abort unreachable end - i64.const -2 + block $~lib/math/IntegerMath.signbit|inlined.0 (result i32) + i32.const 0 + local.set $0 + local.get $0 + i32.const 0 + i32.lt_s + br $~lib/math/IntegerMath.signbit|inlined.0 + end i32.const 0 - call $~lib/math/ipow64 - i64.const 1 - i64.eq + i32.ne + i32.const 0 + i32.eq i32.eqz if i32.const 0 i32.const 8 - i32.const 3309 + i32.const 3310 i32.const 0 call $~lib/env/abort unreachable end - i64.const -2 - i32.const 1 - call $~lib/math/ipow64 - i64.const -2 - i64.eq + block $~lib/math/IntegerMath.signbit|inlined.0 (result i32) + i32.const 0 + local.set $0 + i32.const 0 + br $~lib/math/IntegerMath.signbit|inlined.0 + end + i32.const 0 + i32.ne + i32.const 0 + i32.eq i32.eqz if i32.const 0 i32.const 8 - i32.const 3310 + i32.const 3311 i32.const 0 call $~lib/env/abort unreachable end - i64.const -2 - i32.const 2 - call $~lib/math/ipow64 - i64.const 4 - i64.eq + block $~lib/math/IntegerMath.signbit|inlined.0 (result i32) + i64.const 0 + local.set $3 + local.get $3 + i64.const 0 + i64.lt_s + br $~lib/math/IntegerMath.signbit|inlined.0 + end + i32.const 0 + i32.ne + i32.const 0 + i32.eq i32.eqz if i32.const 0 i32.const 8 - i32.const 3311 + i32.const 3312 i32.const 0 call $~lib/env/abort unreachable end - i64.const -2 - i32.const 3 - call $~lib/math/ipow64 - i64.const -8 - i64.eq + block $~lib/math/IntegerMath.signbit|inlined.0 (result i32) + i64.const 0 + local.set $3 + i32.const 0 + br $~lib/math/IntegerMath.signbit|inlined.0 + end + i32.const 0 + i32.ne + i32.const 0 + i32.eq i32.eqz if i32.const 0 i32.const 8 - i32.const 3312 + i32.const 3313 i32.const 0 call $~lib/env/abort unreachable end - i64.const 3 - i32.const 40 - call $~lib/math/ipow64 - i64.const -6289078614652622815 - i64.eq + block $~lib/math/IntegerMath.signbit|inlined.1 (result i32) + i32.const 2 + local.set $0 + local.get $0 + i32.const 0 + i32.lt_s + br $~lib/math/IntegerMath.signbit|inlined.1 + end + i32.const 0 + i32.ne + i32.const 0 + i32.eq i32.eqz if i32.const 0 @@ -42414,11 +42722,16 @@ call $~lib/env/abort unreachable end - i64.const 3 - i32.const 41 - call $~lib/math/ipow64 - i64.const -420491770248316829 - i64.eq + block $~lib/math/IntegerMath.signbit|inlined.1 (result i32) + i32.const 2 + local.set $0 + i32.const 0 + br $~lib/math/IntegerMath.signbit|inlined.1 + end + i32.const 0 + i32.ne + i32.const 0 + i32.eq i32.eqz if i32.const 0 @@ -42428,11 +42741,18 @@ call $~lib/env/abort unreachable end - i64.const 3 - i32.const 42 - call $~lib/math/ipow64 - i64.const -1261475310744950487 - i64.eq + block $~lib/math/IntegerMath.signbit|inlined.1 (result i32) + i64.const 2 + local.set $3 + local.get $3 + i64.const 0 + i64.lt_s + br $~lib/math/IntegerMath.signbit|inlined.1 + end + i32.const 0 + i32.ne + i32.const 0 + i32.eq i32.eqz if i32.const 0 @@ -42442,11 +42762,16 @@ call $~lib/env/abort unreachable end - i64.const 3 - i32.const 43 - call $~lib/math/ipow64 - i64.const -3784425932234851461 - i64.eq + block $~lib/math/IntegerMath.signbit|inlined.1 (result i32) + i64.const 2 + local.set $3 + i32.const 0 + br $~lib/math/IntegerMath.signbit|inlined.1 + end + i32.const 0 + i32.ne + i32.const 0 + i32.eq i32.eqz if i32.const 0 @@ -42456,11 +42781,18 @@ call $~lib/env/abort unreachable end - i64.const 3 - i32.const 63 - call $~lib/math/ipow64 - i64.const -3237885987332494933 - i64.eq + block $~lib/math/IntegerMath.signbit|inlined.2 (result i32) + i32.const -2 + local.set $0 + local.get $0 + i32.const 0 + i32.lt_s + br $~lib/math/IntegerMath.signbit|inlined.2 + end + i32.const 0 + i32.ne + i32.const 1 + i32.eq i32.eqz if i32.const 0 @@ -42470,11 +42802,18 @@ call $~lib/env/abort unreachable end - i64.const 3 - i32.const 64 - call $~lib/math/ipow64 - i64.const 8733086111712066817 - i64.eq + block $~lib/math/IntegerMath.signbit|inlined.2 (result i32) + i64.const -2 + local.set $3 + local.get $3 + i64.const 0 + i64.lt_s + br $~lib/math/IntegerMath.signbit|inlined.2 + end + i32.const 0 + i32.ne + i32.const 1 + i32.eq i32.eqz if i32.const 0 @@ -42484,11 +42823,16 @@ call $~lib/env/abort unreachable end - i64.const 3 - i32.const 128 - call $~lib/math/ipow64 - i64.const -9204772141784466943 - i64.eq + block $~lib/math/IntegerMath.signbit|inlined.2 (result i32) + i32.const -2 + local.set $0 + i32.const 0 + br $~lib/math/IntegerMath.signbit|inlined.2 + end + i32.const 0 + i32.ne + i32.const 0 + i32.eq i32.eqz if i32.const 0 @@ -42498,15 +42842,29 @@ call $~lib/env/abort unreachable end - i64.const 57055 - i32.const 3 - call $~lib/math/ipow64 - i64.const 339590 - i32.const 3 - call $~lib/math/ipow64 - i64.add - i64.const 39347712995520375 - i64.eq + block $~lib/math/IntegerMath.signbit|inlined.2 (result i32) + i64.const -2 + local.set $3 + i32.const 0 + br $~lib/math/IntegerMath.signbit|inlined.2 + end + i32.const 0 + i32.ne + i32.const 0 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3321 + i32.const 0 + call $~lib/env/abort + unreachable + end + i32.const -2 + call $~lib/math/IntegerMath.signbit + i32.const 1 + i32.eq i32.eqz if i32.const 0 @@ -42516,6 +42874,955 @@ call $~lib/env/abort unreachable end + i32.const -2 + call $~lib/math/IntegerMath.signbit + i32.const 0 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3323 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.log2|inlined.0 (result i32) + i32.const 1 + local.set $0 + local.get $0 + i32.const 0 + i32.le_s + if + i32.const 0 + i32.const 40 + i32.const 2374 + i32.const 20 + call $~lib/env/abort + unreachable + end + i32.const 31 + local.get $0 + i32.clz + i32.sub + br $~lib/math/IntegerMath.log2|inlined.0 + end + i32.const 16 + i32.shl + i32.const 16 + i32.shr_s + i32.const 0 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3327 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.log2|inlined.0 (result i32) + i32.const 1 + local.set $0 + local.get $0 + i32.const 0 + i32.le_s + if + i32.const 0 + i32.const 40 + i32.const 2374 + i32.const 20 + call $~lib/env/abort + unreachable + end + i32.const 31 + local.get $0 + i32.clz + i32.sub + br $~lib/math/IntegerMath.log2|inlined.0 + end + i32.const 0 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3328 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.log2|inlined.0 (result i32) + i32.const 1 + local.set $0 + local.get $0 + i32.eqz + if + i32.const 0 + i32.const 40 + i32.const 2376 + i32.const 16 + call $~lib/env/abort + unreachable + end + i32.const 31 + local.get $0 + i32.clz + i32.sub + br $~lib/math/IntegerMath.log2|inlined.0 + end + i32.const 0 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3329 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.log2|inlined.0 (result i64) + i64.const 1 + local.set $3 + local.get $3 + i64.const 0 + i64.le_s + if + i32.const 0 + i32.const 40 + i32.const 2374 + i32.const 20 + call $~lib/env/abort + unreachable + end + i64.const 63 + local.get $3 + i64.clz + i64.sub + br $~lib/math/IntegerMath.log2|inlined.0 + end + i64.const 0 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3330 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.log2|inlined.0 (result i64) + i64.const 1 + local.set $3 + local.get $3 + i64.eqz + if + i32.const 0 + i32.const 40 + i32.const 2376 + i32.const 16 + call $~lib/env/abort + unreachable + end + i64.const 63 + local.get $3 + i64.clz + i64.sub + br $~lib/math/IntegerMath.log2|inlined.0 + end + i64.const 0 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3331 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.log2|inlined.1 (result i32) + i32.const 2 + local.set $0 + local.get $0 + i32.const 0 + i32.le_s + if + i32.const 0 + i32.const 40 + i32.const 2374 + i32.const 20 + call $~lib/env/abort + unreachable + end + i32.const 31 + local.get $0 + i32.clz + i32.sub + br $~lib/math/IntegerMath.log2|inlined.1 + end + i32.const 16 + i32.shl + i32.const 16 + i32.shr_s + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3332 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.log2|inlined.1 (result i32) + i32.const 2 + local.set $0 + local.get $0 + i32.const 0 + i32.le_s + if + i32.const 0 + i32.const 40 + i32.const 2374 + i32.const 20 + call $~lib/env/abort + unreachable + end + i32.const 31 + local.get $0 + i32.clz + i32.sub + br $~lib/math/IntegerMath.log2|inlined.1 + end + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3333 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.log2|inlined.1 (result i32) + i32.const 2 + local.set $0 + local.get $0 + i32.eqz + if + i32.const 0 + i32.const 40 + i32.const 2376 + i32.const 16 + call $~lib/env/abort + unreachable + end + i32.const 31 + local.get $0 + i32.clz + i32.sub + br $~lib/math/IntegerMath.log2|inlined.1 + end + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3334 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.log2|inlined.1 (result i64) + i64.const 2 + local.set $3 + local.get $3 + i64.const 0 + i64.le_s + if + i32.const 0 + i32.const 40 + i32.const 2374 + i32.const 20 + call $~lib/env/abort + unreachable + end + i64.const 63 + local.get $3 + i64.clz + i64.sub + br $~lib/math/IntegerMath.log2|inlined.1 + end + i64.const 1 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3335 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.log2|inlined.1 (result i64) + i64.const 2 + local.set $3 + local.get $3 + i64.eqz + if + i32.const 0 + i32.const 40 + i32.const 2376 + i32.const 16 + call $~lib/env/abort + unreachable + end + i64.const 63 + local.get $3 + i64.clz + i64.sub + br $~lib/math/IntegerMath.log2|inlined.1 + end + i64.const 1 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3336 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.log2|inlined.2 (result i32) + i32.const 3 + local.set $0 + local.get $0 + i32.const 0 + i32.le_s + if + i32.const 0 + i32.const 40 + i32.const 2374 + i32.const 20 + call $~lib/env/abort + unreachable + end + i32.const 31 + local.get $0 + i32.clz + i32.sub + br $~lib/math/IntegerMath.log2|inlined.2 + end + i32.const 16 + i32.shl + i32.const 16 + i32.shr_s + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3337 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.log2|inlined.2 (result i32) + i32.const 3 + local.set $0 + local.get $0 + i32.const 0 + i32.le_s + if + i32.const 0 + i32.const 40 + i32.const 2374 + i32.const 20 + call $~lib/env/abort + unreachable + end + i32.const 31 + local.get $0 + i32.clz + i32.sub + br $~lib/math/IntegerMath.log2|inlined.2 + end + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3338 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.log2|inlined.2 (result i32) + i32.const 3 + local.set $0 + local.get $0 + i32.eqz + if + i32.const 0 + i32.const 40 + i32.const 2376 + i32.const 16 + call $~lib/env/abort + unreachable + end + i32.const 31 + local.get $0 + i32.clz + i32.sub + br $~lib/math/IntegerMath.log2|inlined.2 + end + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3339 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.log2|inlined.2 (result i64) + i64.const 3 + local.set $3 + local.get $3 + i64.const 0 + i64.le_s + if + i32.const 0 + i32.const 40 + i32.const 2374 + i32.const 20 + call $~lib/env/abort + unreachable + end + i64.const 63 + local.get $3 + i64.clz + i64.sub + br $~lib/math/IntegerMath.log2|inlined.2 + end + i64.const 1 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3340 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.log2|inlined.2 (result i64) + i64.const 3 + local.set $3 + local.get $3 + i64.eqz + if + i32.const 0 + i32.const 40 + i32.const 2376 + i32.const 16 + call $~lib/env/abort + unreachable + end + i64.const 63 + local.get $3 + i64.clz + i64.sub + br $~lib/math/IntegerMath.log2|inlined.2 + end + i64.const 1 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3341 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $~lib/builtins/i16.MAX_VALUE + call $~lib/math/IntegerMath.log2 + i32.const 16 + i32.shl + i32.const 16 + i32.shr_s + i32.const 14 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3342 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $~lib/builtins/i32.MAX_VALUE + call $~lib/math/IntegerMath.log2 + i32.const 30 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3343 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $~lib/builtins/u32.MAX_VALUE + call $~lib/math/IntegerMath.log2 + i32.const 31 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3344 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $~lib/builtins/i64.MAX_VALUE + call $~lib/math/IntegerMath.log2 + i64.const 62 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3345 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $~lib/builtins/u64.MAX_VALUE + call $~lib/math/IntegerMath.log2 + i64.const 63 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3346 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 0 + i32.const 0 + call $~lib/math/ipow64 + i64.const 1 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3350 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 0 + i32.const 1 + call $~lib/math/ipow64 + i64.const 0 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3351 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 0 + i32.const 2 + call $~lib/math/ipow64 + i64.const 0 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3352 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 0 + i32.const 3 + call $~lib/math/ipow64 + i64.const 0 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3353 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 1 + i32.const 0 + call $~lib/math/ipow64 + i64.const 1 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3355 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 1 + i32.const 1 + call $~lib/math/ipow64 + i64.const 1 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3356 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 1 + i32.const 2 + call $~lib/math/ipow64 + i64.const 1 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3357 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 1 + i32.const 3 + call $~lib/math/ipow64 + i64.const 1 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3358 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 2 + i32.const 0 + call $~lib/math/ipow64 + i64.const 1 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3360 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 2 + i32.const 1 + call $~lib/math/ipow64 + i64.const 2 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3361 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 2 + i32.const 2 + call $~lib/math/ipow64 + i64.const 4 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3362 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 2 + i32.const 3 + call $~lib/math/ipow64 + i64.const 8 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3363 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const -1 + i32.const 0 + call $~lib/math/ipow64 + i64.const 1 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3365 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const -1 + i32.const 1 + call $~lib/math/ipow64 + i64.const -1 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3366 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const -1 + i32.const 2 + call $~lib/math/ipow64 + i64.const 1 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3367 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const -1 + i32.const 3 + call $~lib/math/ipow64 + i64.const -1 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3368 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const -2 + i32.const 0 + call $~lib/math/ipow64 + i64.const 1 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3370 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const -2 + i32.const 1 + call $~lib/math/ipow64 + i64.const -2 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3371 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const -2 + i32.const 2 + call $~lib/math/ipow64 + i64.const 4 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3372 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const -2 + i32.const 3 + call $~lib/math/ipow64 + i64.const -8 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3373 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 3 + i32.const 40 + call $~lib/math/ipow64 + i64.const -6289078614652622815 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3375 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 3 + i32.const 41 + call $~lib/math/ipow64 + i64.const -420491770248316829 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3376 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 3 + i32.const 42 + call $~lib/math/ipow64 + i64.const -1261475310744950487 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3377 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 3 + i32.const 43 + call $~lib/math/ipow64 + i64.const -3784425932234851461 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3378 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 3 + i32.const 63 + call $~lib/math/ipow64 + i64.const -3237885987332494933 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3379 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 3 + i32.const 64 + call $~lib/math/ipow64 + i64.const 8733086111712066817 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3380 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 3 + i32.const 128 + call $~lib/math/ipow64 + i64.const -9204772141784466943 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3381 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 57055 + i32.const 3 + call $~lib/math/ipow64 + i64.const 339590 + i32.const 3 + call $~lib/math/ipow64 + i64.add + i64.const 39347712995520375 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3383 + i32.const 0 + call $~lib/env/abort + unreachable + end f32.const 0 i32.const 0 call $~lib/math/ipow32f @@ -42525,7 +43832,7 @@ if i32.const 0 i32.const 8 - i32.const 3326 + i32.const 3387 i32.const 0 call $~lib/env/abort unreachable @@ -42539,7 +43846,7 @@ if i32.const 0 i32.const 8 - i32.const 3327 + i32.const 3388 i32.const 0 call $~lib/env/abort unreachable @@ -42559,7 +43866,7 @@ if i32.const 0 i32.const 8 - i32.const 3328 + i32.const 3389 i32.const 0 call $~lib/env/abort unreachable @@ -42579,7 +43886,7 @@ if i32.const 0 i32.const 8 - i32.const 3329 + i32.const 3390 i32.const 0 call $~lib/env/abort unreachable @@ -42599,7 +43906,7 @@ if i32.const 0 i32.const 8 - i32.const 3330 + i32.const 3391 i32.const 0 call $~lib/env/abort unreachable @@ -42613,7 +43920,7 @@ if i32.const 0 i32.const 8 - i32.const 3331 + i32.const 3392 i32.const 0 call $~lib/env/abort unreachable @@ -42627,7 +43934,7 @@ if i32.const 0 i32.const 8 - i32.const 3332 + i32.const 3393 i32.const 0 call $~lib/env/abort unreachable @@ -42642,7 +43949,7 @@ if i32.const 0 i32.const 8 - i32.const 3333 + i32.const 3394 i32.const 0 call $~lib/env/abort unreachable @@ -42658,7 +43965,7 @@ if i32.const 0 i32.const 8 - i32.const 3334 + i32.const 3395 i32.const 0 call $~lib/env/abort unreachable @@ -42673,7 +43980,7 @@ if i32.const 0 i32.const 8 - i32.const 3335 + i32.const 3396 i32.const 0 call $~lib/env/abort unreachable @@ -42687,7 +43994,7 @@ if i32.const 0 i32.const 8 - i32.const 3336 + i32.const 3397 i32.const 0 call $~lib/env/abort unreachable @@ -42701,7 +44008,7 @@ if i32.const 0 i32.const 8 - i32.const 3337 + i32.const 3398 i32.const 0 call $~lib/env/abort unreachable @@ -42715,7 +44022,7 @@ if i32.const 0 i32.const 8 - i32.const 3338 + i32.const 3399 i32.const 0 call $~lib/env/abort unreachable @@ -42729,7 +44036,7 @@ if i32.const 0 i32.const 8 - i32.const 3339 + i32.const 3400 i32.const 0 call $~lib/env/abort unreachable @@ -42743,7 +44050,7 @@ if i32.const 0 i32.const 8 - i32.const 3340 + i32.const 3401 i32.const 0 call $~lib/env/abort unreachable @@ -42757,7 +44064,7 @@ if i32.const 0 i32.const 8 - i32.const 3341 + i32.const 3402 i32.const 0 call $~lib/env/abort unreachable @@ -42771,7 +44078,7 @@ if i32.const 0 i32.const 8 - i32.const 3345 + i32.const 3406 i32.const 0 call $~lib/env/abort unreachable @@ -42785,7 +44092,7 @@ if i32.const 0 i32.const 8 - i32.const 3346 + i32.const 3407 i32.const 0 call $~lib/env/abort unreachable @@ -42798,7 +44105,7 @@ if i32.const 0 i32.const 8 - i32.const 3347 + i32.const 3408 i32.const 0 call $~lib/env/abort unreachable @@ -42811,7 +44118,7 @@ if i32.const 0 i32.const 8 - i32.const 3348 + i32.const 3409 i32.const 0 call $~lib/env/abort unreachable @@ -42824,7 +44131,7 @@ if i32.const 0 i32.const 8 - i32.const 3349 + i32.const 3410 i32.const 0 call $~lib/env/abort unreachable @@ -42838,7 +44145,7 @@ if i32.const 0 i32.const 8 - i32.const 3350 + i32.const 3411 i32.const 0 call $~lib/env/abort unreachable @@ -42852,7 +44159,7 @@ if i32.const 0 i32.const 8 - i32.const 3351 + i32.const 3412 i32.const 0 call $~lib/env/abort unreachable @@ -42867,7 +44174,7 @@ if i32.const 0 i32.const 8 - i32.const 3352 + i32.const 3413 i32.const 0 call $~lib/env/abort unreachable @@ -42883,7 +44190,7 @@ if i32.const 0 i32.const 8 - i32.const 3353 + i32.const 3414 i32.const 0 call $~lib/env/abort unreachable @@ -42898,7 +44205,7 @@ if i32.const 0 i32.const 8 - i32.const 3354 + i32.const 3415 i32.const 0 call $~lib/env/abort unreachable @@ -42912,7 +44219,7 @@ if i32.const 0 i32.const 8 - i32.const 3355 + i32.const 3416 i32.const 0 call $~lib/env/abort unreachable @@ -42926,7 +44233,7 @@ if i32.const 0 i32.const 8 - i32.const 3356 + i32.const 3417 i32.const 0 call $~lib/env/abort unreachable @@ -42940,7 +44247,7 @@ if i32.const 0 i32.const 8 - i32.const 3357 + i32.const 3418 i32.const 0 call $~lib/env/abort unreachable @@ -42954,7 +44261,7 @@ if i32.const 0 i32.const 8 - i32.const 3358 + i32.const 3419 i32.const 0 call $~lib/env/abort unreachable @@ -42968,7 +44275,7 @@ if i32.const 0 i32.const 8 - i32.const 3359 + i32.const 3420 i32.const 0 call $~lib/env/abort unreachable @@ -42982,12 +44289,12 @@ if i32.const 0 i32.const 8 - i32.const 3360 + i32.const 3421 i32.const 0 call $~lib/env/abort unreachable end ) - (func $null (; 158 ;) (type $_) + (func $null (; 167 ;) (type $_) ) ) From 05818536e17406303ea0f6e666eef6bfb62ad507 Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Tue, 19 Feb 2019 19:53:48 +0200 Subject: [PATCH 15/22] use ather int sqrt implementation --- std/assembly/math.ts | 46 +- tests/compiler/std/math.optimized.wat | 2193 ++++++++++++- tests/compiler/std/math.ts | 39 + tests/compiler/std/math.untouched.wat | 4182 ++++++++++++++++++++++++- 4 files changed, 6147 insertions(+), 313 deletions(-) diff --git a/std/assembly/math.ts b/std/assembly/math.ts index 553311b07d..47984d9f49 100644 --- a/std/assembly/math.ts +++ b/std/assembly/math.ts @@ -2414,20 +2414,42 @@ export namespace IntegerMath { if (isSigned()) { if (x < 0) throw new RangeError("Math.sqrt received negative argument"); } - if (!x) return 0; - let res = 0; - /* tslint:disable-next-line:as-types */ - let add = 1 << (sizeof() * 8 / 2 - 1); - let tmp: T; - for (let i = 0; i < sizeof() * 8; ++i) { - tmp = res | add; - let sqr = tmp * tmp; - if (x >= sqr) { - res = tmp; + // Complexity: O(log n) + // Iterative version of approach described in this article: + // https://www.cs.uni-potsdam.de/ti/kreitz/PDF/03cucs-intsqrt.pdf + if (x < 2) return x; + let s = 2; + let xs = x >> 2; + while (xs && xs != x) { + s += 2; + xs = x >> s; + } + s -= 2; + if (sizeof() <= 4) { + let ux = x; + let res: u32 = 0; + while (s >= 0) { + res <<= 1; + let m = res + 1; + if (m * m <= (ux >> s)) { + res = m; + } + s -= 2; + } + return res; + } else { + let ux = x; + let res: u64 = 0; + while (s >= 0) { + res <<= 1; + let m = res + 1; + if (m * m <= (ux >> s)) { + res = m; + } + s -= 2; } - add >>>= 1; + return res; } - return res; } throw new TypeError("Unexpected generic type"); } diff --git a/tests/compiler/std/math.optimized.wat b/tests/compiler/std/math.optimized.wat index 630d351d5e..55252343ff 100644 --- a/tests/compiler/std/math.optimized.wat +++ b/tests/compiler/std/math.optimized.wat @@ -28,6 +28,7 @@ (type $FUNCSIG$iffi (func (param f32 f32 i32) (result i32))) (type $FUNCSIG$idddi (func (param f64 f64 f64 i32) (result i32))) (type $FUNCSIG$ifffi (func (param f32 f32 f32 i32) (result i32))) + (type $FUNCSIG$j (func (result i64))) (import "Math" "E" (global $~lib/bindings/Math/E f64)) (import "Math" "LN2" (global $~lib/bindings/Math/LN2 f64)) (import "Math" "LN10" (global $~lib/bindings/Math/LN10 f64)) @@ -9222,7 +9223,75 @@ i32.mul f64.convert_i32_s ) - (func $~lib/math/ipow64 (; 146 ;) (type $IiI) (param $0 i64) (param $1 i32) (result i64) + (func $~lib/math/IntegerMath.sqrt (; 146 ;) (type $FUNCSIG$j) (result i64) + (local $0 i32) + (local $1 i64) + (local $2 i64) + i32.const 2 + local.set $0 + i64.const 4611686018427387903 + local.set $1 + loop $continue|0 + local.get $1 + i64.const -1 + i64.ne + i64.extend_i32_u + local.get $1 + local.get $1 + i64.const 0 + i64.ne + select + i64.const 0 + i64.ne + if + i64.const -1 + local.get $0 + i32.const 2 + i32.add + local.tee $0 + i64.extend_i32_s + i64.shr_u + local.set $1 + br $continue|0 + end + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 + loop $continue|1 + local.get $0 + i32.const 0 + i32.ge_s + if + local.get $2 + i64.const 1 + i64.shl + local.tee $2 + i64.const 1 + i64.add + local.tee $1 + local.get $1 + i64.mul + i64.const -1 + local.get $0 + i64.extend_i32_s + i64.shr_u + i64.le_u + if + local.get $1 + local.set $2 + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 + br $continue|1 + end + end + local.get $2 + ) + (func $~lib/math/ipow64 (; 147 ;) (type $IiI) (param $0 i64) (param $1 i32) (result i64) (local $2 i64) (local $3 i32) i64.const 1 @@ -9418,7 +9487,7 @@ end local.get $2 ) - (func $~lib/math/ipow32f (; 147 ;) (type $fif) (param $0 f32) (param $1 i32) (result f32) + (func $~lib/math/ipow32f (; 148 ;) (type $fif) (param $0 f32) (param $1 i32) (result f32) (local $2 f32) (local $3 i32) local.get $1 @@ -9464,7 +9533,7 @@ end local.get $2 ) - (func $~lib/math/ipow64f (; 148 ;) (type $FiF) (param $0 f64) (param $1 i32) (result f64) + (func $~lib/math/ipow64f (; 149 ;) (type $FiF) (param $0 f64) (param $1 i32) (result f64) (local $2 f64) (local $3 i32) local.get $1 @@ -9510,11 +9579,14 @@ end local.get $2 ) - (func $start (; 149 ;) (type $_) - (local $0 f64) - (local $1 f32) + (func $start (; 150 ;) (type $_) + (local $0 i32) + (local $1 i32) (local $2 i32) - (local $3 i32) + (local $3 i64) + (local $4 i64) + (local $5 f64) + (local $6 f32) f64.const 2.718281828459045 global.get $~lib/bindings/Math/E f64.const 0 @@ -31434,16 +31506,16 @@ f64.lt if call $~lib/math/NativeMath.random - local.tee $0 + local.tee $5 f64.const 0 f64.ge - local.tee $3 + local.tee $0 if (result i32) - local.get $0 + local.get $5 f64.const 1 f64.lt else - local.get $3 + local.get $0 end if local.get $2 @@ -31474,16 +31546,16 @@ f64.lt if call $~lib/math/NativeMathf.random - local.tee $1 + local.tee $6 f32.const 0 f32.ge - local.tee $3 + local.tee $0 if (result i32) - local.get $1 + local.get $6 f32.const 1 f32.lt else - local.get $3 + local.get $0 end if local.get $2 @@ -37846,171 +37918,1964 @@ call $~lib/env/abort unreachable end - i64.const 0 + i32.const 2 + local.set $0 + loop $continue|22 + local.get $1 + i32.const 2 + i32.ne + local.get $1 + local.get $1 + select + if + i32.const 2 + local.get $0 + i32.const 2 + i32.add + local.tee $0 + i32.const 16 + i32.shl + i32.const 16 + i32.shr_s + i32.shr_s + local.set $1 + br $continue|22 + end + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 i32.const 0 - call $~lib/math/ipow64 - i64.const 1 - i64.ne - if - i32.const 0 - i32.const 8 - i32.const 3350 + local.set $1 + loop $continue|23 + local.get $0 i32.const 0 - call $~lib/env/abort - unreachable + i32.ge_s + if + local.get $1 + i32.const 1 + i32.shl + local.tee $1 + i32.const 1 + i32.add + local.tee $2 + local.get $2 + i32.mul + i32.const 2 + local.get $0 + i32.shr_u + i32.le_u + if + local.get $2 + local.set $1 + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 + br $continue|23 + end end - i64.const 0 + local.get $1 + i32.const 65535 + i32.and i32.const 1 - call $~lib/math/ipow64 - i64.const 0 - i64.ne + i32.ne if i32.const 0 i32.const 8 - i32.const 3351 + i32.const 3360 i32.const 0 call $~lib/env/abort unreachable end - i64.const 0 i32.const 2 - call $~lib/math/ipow64 - i64.const 0 - i64.ne - if - i32.const 0 - i32.const 8 - i32.const 3352 + local.set $1 + i32.const 0 + local.set $0 + loop $continue|24 + local.get $0 + i32.const 2 + i32.ne + local.get $0 + local.get $0 + select + if + i32.const 2 + local.get $1 + i32.const 2 + i32.add + local.tee $1 + i32.shr_s + local.set $0 + br $continue|24 + end + end + local.get $1 + i32.const 2 + i32.sub + local.set $1 + i32.const 0 + local.set $0 + loop $continue|25 + local.get $1 i32.const 0 - call $~lib/env/abort - unreachable + i32.ge_s + if + local.get $0 + i32.const 1 + i32.shl + local.tee $0 + i32.const 1 + i32.add + local.tee $2 + local.get $2 + i32.mul + i32.const 2 + local.get $1 + i32.shr_u + i32.le_u + if + local.get $2 + local.set $0 + end + local.get $1 + i32.const 2 + i32.sub + local.set $1 + br $continue|25 + end end - i64.const 0 - i32.const 3 - call $~lib/math/ipow64 - i64.const 0 - i64.ne + local.get $0 + i32.const 1 + i32.ne if i32.const 0 i32.const 8 - i32.const 3353 + i32.const 3361 i32.const 0 call $~lib/env/abort unreachable end - i64.const 1 + i32.const 2 + local.set $0 i32.const 0 - call $~lib/math/ipow64 - i64.const 1 - i64.ne - if - i32.const 0 - i32.const 8 - i32.const 3355 + local.set $1 + loop $continue|26 + local.get $1 + i32.const 2 + i32.ne + local.get $1 + local.get $1 + select + if + i32.const 2 + local.get $0 + i32.const 2 + i32.add + local.tee $0 + i32.shr_u + local.set $1 + br $continue|26 + end + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 + i32.const 0 + local.set $1 + loop $continue|27 + local.get $0 i32.const 0 - call $~lib/env/abort - unreachable + i32.ge_s + if + local.get $1 + i32.const 1 + i32.shl + local.tee $1 + i32.const 1 + i32.add + local.tee $2 + local.get $2 + i32.mul + i32.const 2 + local.get $0 + i32.shr_u + i32.le_u + if + local.get $2 + local.set $1 + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 + br $continue|27 + end end - i64.const 1 + local.get $1 i32.const 1 - call $~lib/math/ipow64 - i64.const 1 - i64.ne + i32.ne if i32.const 0 i32.const 8 - i32.const 3356 + i32.const 3362 i32.const 0 call $~lib/env/abort unreachable end - i64.const 1 i32.const 2 - call $~lib/math/ipow64 + local.set $2 + loop $continue|28 + local.get $3 + i64.const 2 + i64.ne + i64.extend_i32_u + local.get $3 + local.get $3 + i64.const 0 + i64.ne + select + i64.const 0 + i64.ne + if + i64.const 2 + local.get $2 + i32.const 2 + i32.add + local.tee $2 + i64.extend_i32_s + i64.shr_s + local.set $3 + br $continue|28 + end + end + local.get $2 + i32.const 2 + i32.sub + local.set $2 + loop $continue|29 + local.get $2 + i32.const 0 + i32.ge_s + if + local.get $4 + i64.const 1 + i64.shl + local.tee $4 + i64.const 1 + i64.add + local.tee $3 + local.get $3 + i64.mul + i64.const 2 + local.get $2 + i64.extend_i32_s + i64.shr_u + i64.le_u + if + local.get $3 + local.set $4 + end + local.get $2 + i32.const 2 + i32.sub + local.set $2 + br $continue|29 + end + end + local.get $4 i64.const 1 i64.ne if i32.const 0 i32.const 8 - i32.const 3357 + i32.const 3363 i32.const 0 call $~lib/env/abort unreachable end - i64.const 1 - i32.const 3 - call $~lib/math/ipow64 + i32.const 2 + local.set $2 + i64.const 0 + local.set $3 + loop $continue|30 + local.get $3 + i64.const 2 + i64.ne + i64.extend_i32_u + local.get $3 + local.get $3 + i64.const 0 + i64.ne + select + i64.const 0 + i64.ne + if + i64.const 2 + local.get $2 + i32.const 2 + i32.add + local.tee $2 + i64.extend_i32_s + i64.shr_u + local.set $3 + br $continue|30 + end + end + local.get $2 + i32.const 2 + i32.sub + local.set $2 + i64.const 0 + local.set $4 + loop $continue|31 + local.get $2 + i32.const 0 + i32.ge_s + if + local.get $4 + i64.const 1 + i64.shl + local.tee $4 + i64.const 1 + i64.add + local.tee $3 + local.get $3 + i64.mul + i64.const 2 + local.get $2 + i64.extend_i32_s + i64.shr_u + i64.le_u + if + local.get $3 + local.set $4 + end + local.get $2 + i32.const 2 + i32.sub + local.set $2 + br $continue|31 + end + end + local.get $4 i64.const 1 i64.ne if i32.const 0 i32.const 8 - i32.const 3358 + i32.const 3364 i32.const 0 call $~lib/env/abort unreachable end - i64.const 2 + i32.const 2 + local.set $1 i32.const 0 - call $~lib/math/ipow64 - i64.const 1 - i64.ne - if - i32.const 0 - i32.const 8 - i32.const 3360 + local.set $0 + loop $continue|32 + local.get $0 + i32.const 3 + i32.ne + local.get $0 + local.get $0 + select + if + i32.const 3 + local.get $1 + i32.const 2 + i32.add + local.tee $1 + i32.const 16 + i32.shl + i32.const 16 + i32.shr_s + i32.shr_s + local.set $0 + br $continue|32 + end + end + local.get $1 + i32.const 2 + i32.sub + local.set $1 + i32.const 0 + local.set $0 + loop $continue|33 + local.get $1 i32.const 0 - call $~lib/env/abort - unreachable + i32.ge_s + if + local.get $0 + i32.const 1 + i32.shl + local.tee $0 + i32.const 1 + i32.add + local.tee $2 + local.get $2 + i32.mul + i32.const 3 + local.get $1 + i32.shr_u + i32.le_u + if + local.get $2 + local.set $0 + end + local.get $1 + i32.const 2 + i32.sub + local.set $1 + br $continue|33 + end end - i64.const 2 + local.get $0 + i32.const 65535 + i32.and i32.const 1 - call $~lib/math/ipow64 - i64.const 2 - i64.ne + i32.ne if i32.const 0 i32.const 8 - i32.const 3361 + i32.const 3365 i32.const 0 call $~lib/env/abort unreachable end - i64.const 2 i32.const 2 - call $~lib/math/ipow64 - i64.const 4 - i64.ne - if - i32.const 0 - i32.const 8 - i32.const 3362 + local.set $0 + i32.const 0 + local.set $1 + loop $continue|34 + local.get $1 + i32.const 3 + i32.ne + local.get $1 + local.get $1 + select + if + i32.const 3 + local.get $0 + i32.const 2 + i32.add + local.tee $0 + i32.shr_s + local.set $1 + br $continue|34 + end + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 + i32.const 0 + local.set $1 + loop $continue|35 + local.get $0 i32.const 0 - call $~lib/env/abort - unreachable + i32.ge_s + if + local.get $1 + i32.const 1 + i32.shl + local.tee $1 + i32.const 1 + i32.add + local.tee $2 + local.get $2 + i32.mul + i32.const 3 + local.get $0 + i32.shr_u + i32.le_u + if + local.get $2 + local.set $1 + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 + br $continue|35 + end end - i64.const 2 - i32.const 3 - call $~lib/math/ipow64 - i64.const 8 - i64.ne + local.get $1 + i32.const 1 + i32.ne if i32.const 0 i32.const 8 - i32.const 3363 + i32.const 3366 i32.const 0 call $~lib/env/abort unreachable end - i64.const -1 + i32.const 2 + local.set $1 i32.const 0 - call $~lib/math/ipow64 - i64.const 1 - i64.ne + local.set $0 + loop $continue|36 + local.get $0 + i32.const 3 + i32.ne + local.get $0 + local.get $0 + select + if + i32.const 3 + local.get $1 + i32.const 2 + i32.add + local.tee $1 + i32.shr_u + local.set $0 + br $continue|36 + end + end + local.get $1 + i32.const 2 + i32.sub + local.set $1 + i32.const 0 + local.set $0 + loop $continue|37 + local.get $1 + i32.const 0 + i32.ge_s + if + local.get $0 + i32.const 1 + i32.shl + local.tee $0 + i32.const 1 + i32.add + local.tee $2 + local.get $2 + i32.mul + i32.const 3 + local.get $1 + i32.shr_u + i32.le_u + if + local.get $2 + local.set $0 + end + local.get $1 + i32.const 2 + i32.sub + local.set $1 + br $continue|37 + end + end + local.get $0 + i32.const 1 + i32.ne + if + i32.const 0 + i32.const 8 + i32.const 3367 + i32.const 0 + call $~lib/env/abort + unreachable + end + i32.const 2 + local.set $2 + i64.const 0 + local.set $3 + loop $continue|38 + local.get $3 + i64.const 3 + i64.ne + i64.extend_i32_u + local.get $3 + local.get $3 + i64.const 0 + i64.ne + select + i64.const 0 + i64.ne + if + i64.const 3 + local.get $2 + i32.const 2 + i32.add + local.tee $2 + i64.extend_i32_s + i64.shr_s + local.set $3 + br $continue|38 + end + end + local.get $2 + i32.const 2 + i32.sub + local.set $2 + i64.const 0 + local.set $4 + loop $continue|39 + local.get $2 + i32.const 0 + i32.ge_s + if + local.get $4 + i64.const 1 + i64.shl + local.tee $4 + i64.const 1 + i64.add + local.tee $3 + local.get $3 + i64.mul + i64.const 3 + local.get $2 + i64.extend_i32_s + i64.shr_u + i64.le_u + if + local.get $3 + local.set $4 + end + local.get $2 + i32.const 2 + i32.sub + local.set $2 + br $continue|39 + end + end + local.get $4 + i64.const 1 + i64.ne + if + i32.const 0 + i32.const 8 + i32.const 3368 + i32.const 0 + call $~lib/env/abort + unreachable + end + i32.const 2 + local.set $2 + i64.const 0 + local.set $3 + loop $continue|40 + local.get $3 + i64.const 3 + i64.ne + i64.extend_i32_u + local.get $3 + local.get $3 + i64.const 0 + i64.ne + select + i64.const 0 + i64.ne + if + i64.const 3 + local.get $2 + i32.const 2 + i32.add + local.tee $2 + i64.extend_i32_s + i64.shr_u + local.set $3 + br $continue|40 + end + end + local.get $2 + i32.const 2 + i32.sub + local.set $2 + i64.const 0 + local.set $4 + loop $continue|41 + local.get $2 + i32.const 0 + i32.ge_s + if + local.get $4 + i64.const 1 + i64.shl + local.tee $4 + i64.const 1 + i64.add + local.tee $3 + local.get $3 + i64.mul + i64.const 3 + local.get $2 + i64.extend_i32_s + i64.shr_u + i64.le_u + if + local.get $3 + local.set $4 + end + local.get $2 + i32.const 2 + i32.sub + local.set $2 + br $continue|41 + end + end + local.get $4 + i64.const 1 + i64.ne + if + i32.const 0 + i32.const 8 + i32.const 3369 + i32.const 0 + call $~lib/env/abort + unreachable + end + i32.const 2 + local.set $0 + i32.const 1 + local.set $1 + loop $continue|42 + local.get $1 + i32.const 4 + i32.ne + local.get $1 + local.get $1 + select + if + i32.const 4 + local.get $0 + i32.const 2 + i32.add + local.tee $0 + i32.const 16 + i32.shl + i32.const 16 + i32.shr_s + i32.shr_s + local.set $1 + br $continue|42 + end + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 + i32.const 0 + local.set $1 + loop $continue|43 + local.get $0 + i32.const 0 + i32.ge_s + if + local.get $1 + i32.const 1 + i32.shl + local.tee $1 + i32.const 1 + i32.add + local.tee $2 + local.get $2 + i32.mul + i32.const 4 + local.get $0 + i32.shr_u + i32.le_u + if + local.get $2 + local.set $1 + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 + br $continue|43 + end + end + local.get $1 + i32.const 65535 + i32.and + i32.const 2 + i32.ne + if + i32.const 0 + i32.const 8 + i32.const 3370 + i32.const 0 + call $~lib/env/abort + unreachable + end + i32.const 2 + local.set $1 + i32.const 1 + local.set $0 + loop $continue|44 + local.get $0 + i32.const 4 + i32.ne + local.get $0 + local.get $0 + select + if + i32.const 4 + local.get $1 + i32.const 2 + i32.add + local.tee $1 + i32.shr_s + local.set $0 + br $continue|44 + end + end + local.get $1 + i32.const 2 + i32.sub + local.set $1 + i32.const 0 + local.set $0 + loop $continue|45 + local.get $1 + i32.const 0 + i32.ge_s + if + local.get $0 + i32.const 1 + i32.shl + local.tee $0 + i32.const 1 + i32.add + local.tee $2 + local.get $2 + i32.mul + i32.const 4 + local.get $1 + i32.shr_u + i32.le_u + if + local.get $2 + local.set $0 + end + local.get $1 + i32.const 2 + i32.sub + local.set $1 + br $continue|45 + end + end + local.get $0 + i32.const 2 + i32.ne + if + i32.const 0 + i32.const 8 + i32.const 3371 + i32.const 0 + call $~lib/env/abort + unreachable + end + i32.const 2 + local.set $0 + i32.const 1 + local.set $1 + loop $continue|46 + local.get $1 + i32.const 4 + i32.ne + local.get $1 + local.get $1 + select + if + i32.const 4 + local.get $0 + i32.const 2 + i32.add + local.tee $0 + i32.shr_u + local.set $1 + br $continue|46 + end + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 + i32.const 0 + local.set $1 + loop $continue|47 + local.get $0 + i32.const 0 + i32.ge_s + if + local.get $1 + i32.const 1 + i32.shl + local.tee $1 + i32.const 1 + i32.add + local.tee $2 + local.get $2 + i32.mul + i32.const 4 + local.get $0 + i32.shr_u + i32.le_u + if + local.get $2 + local.set $1 + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 + br $continue|47 + end + end + local.get $1 + i32.const 2 + i32.ne + if + i32.const 0 + i32.const 8 + i32.const 3372 + i32.const 0 + call $~lib/env/abort + unreachable + end + i32.const 2 + local.set $2 + i64.const 1 + local.set $3 + loop $continue|48 + local.get $3 + i64.const 4 + i64.ne + i64.extend_i32_u + local.get $3 + local.get $3 + i64.const 0 + i64.ne + select + i64.const 0 + i64.ne + if + i64.const 4 + local.get $2 + i32.const 2 + i32.add + local.tee $2 + i64.extend_i32_s + i64.shr_s + local.set $3 + br $continue|48 + end + end + local.get $2 + i32.const 2 + i32.sub + local.set $2 + i64.const 0 + local.set $4 + loop $continue|49 + local.get $2 + i32.const 0 + i32.ge_s + if + local.get $4 + i64.const 1 + i64.shl + local.tee $4 + i64.const 1 + i64.add + local.tee $3 + local.get $3 + i64.mul + i64.const 4 + local.get $2 + i64.extend_i32_s + i64.shr_u + i64.le_u + if + local.get $3 + local.set $4 + end + local.get $2 + i32.const 2 + i32.sub + local.set $2 + br $continue|49 + end + end + local.get $4 + i64.const 2 + i64.ne + if + i32.const 0 + i32.const 8 + i32.const 3373 + i32.const 0 + call $~lib/env/abort + unreachable + end + i32.const 2 + local.set $2 + i64.const 1 + local.set $3 + loop $continue|50 + local.get $3 + i64.const 4 + i64.ne + i64.extend_i32_u + local.get $3 + local.get $3 + i64.const 0 + i64.ne + select + i64.const 0 + i64.ne + if + i64.const 4 + local.get $2 + i32.const 2 + i32.add + local.tee $2 + i64.extend_i32_s + i64.shr_u + local.set $3 + br $continue|50 + end + end + local.get $2 + i32.const 2 + i32.sub + local.set $2 + i64.const 0 + local.set $4 + loop $continue|51 + local.get $2 + i32.const 0 + i32.ge_s + if + local.get $4 + i64.const 1 + i64.shl + local.tee $4 + i64.const 1 + i64.add + local.tee $3 + local.get $3 + i64.mul + i64.const 4 + local.get $2 + i64.extend_i32_s + i64.shr_u + i64.le_u + if + local.get $3 + local.set $4 + end + local.get $2 + i32.const 2 + i32.sub + local.set $2 + br $continue|51 + end + end + local.get $4 + i64.const 2 + i64.ne + if + i32.const 0 + i32.const 8 + i32.const 3374 + i32.const 0 + call $~lib/env/abort + unreachable + end + i32.const 2 + local.set $1 + i32.const 8191 + local.set $0 + loop $continue|52 + local.get $0 + i32.const 32767 + i32.ne + local.get $0 + local.get $0 + select + if + i32.const 32767 + local.get $1 + i32.const 2 + i32.add + local.tee $1 + i32.const 16 + i32.shl + i32.const 16 + i32.shr_s + i32.shr_s + local.set $0 + br $continue|52 + end + end + local.get $1 + i32.const 2 + i32.sub + local.set $1 + i32.const 0 + local.set $0 + loop $continue|53 + local.get $1 + i32.const 0 + i32.ge_s + if + local.get $0 + i32.const 1 + i32.shl + local.tee $0 + i32.const 1 + i32.add + local.tee $2 + local.get $2 + i32.mul + i32.const 32767 + local.get $1 + i32.shr_u + i32.le_u + if + local.get $2 + local.set $0 + end + local.get $1 + i32.const 2 + i32.sub + local.set $1 + br $continue|53 + end + end + local.get $0 + i32.const 65535 + i32.and + i32.const 181 + i32.ne + if + i32.const 0 + i32.const 8 + i32.const 3375 + i32.const 0 + call $~lib/env/abort + unreachable + end + i32.const 2 + local.set $0 + i32.const 8191 + local.set $1 + loop $continue|54 + local.get $1 + i32.const 32767 + i32.ne + local.get $1 + local.get $1 + select + if + i32.const 32767 + local.get $0 + i32.const 2 + i32.add + local.tee $0 + i32.const 65535 + i32.and + i32.shr_u + local.set $1 + br $continue|54 + end + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 + i32.const 0 + local.set $1 + loop $continue|55 + local.get $0 + i32.const 0 + i32.ge_s + if + local.get $1 + i32.const 1 + i32.shl + local.tee $1 + i32.const 1 + i32.add + local.tee $2 + local.get $2 + i32.mul + i32.const 32767 + local.get $0 + i32.shr_u + i32.le_u + if + local.get $2 + local.set $1 + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 + br $continue|55 + end + end + local.get $1 + i32.const 65535 + i32.and + i32.const 181 + i32.ne + if + i32.const 0 + i32.const 8 + i32.const 3376 + i32.const 0 + call $~lib/env/abort + unreachable + end + i32.const 2 + local.set $1 + i32.const 8191 + local.set $0 + loop $continue|56 + local.get $0 + i32.const 32767 + i32.ne + local.get $0 + local.get $0 + select + if + i32.const 32767 + local.get $1 + i32.const 2 + i32.add + local.tee $1 + i32.shr_s + local.set $0 + br $continue|56 + end + end + local.get $1 + i32.const 2 + i32.sub + local.set $1 + i32.const 0 + local.set $0 + loop $continue|57 + local.get $1 + i32.const 0 + i32.ge_s + if + local.get $0 + i32.const 1 + i32.shl + local.tee $0 + i32.const 1 + i32.add + local.tee $2 + local.get $2 + i32.mul + i32.const 32767 + local.get $1 + i32.shr_u + i32.le_u + if + local.get $2 + local.set $0 + end + local.get $1 + i32.const 2 + i32.sub + local.set $1 + br $continue|57 + end + end + local.get $0 + i32.const 181 + i32.ne + if + i32.const 0 + i32.const 8 + i32.const 3377 + i32.const 0 + call $~lib/env/abort + unreachable + end + i32.const 2 + local.set $0 + i32.const 8191 + local.set $1 + loop $continue|58 + local.get $1 + i32.const 32767 + i32.ne + local.get $1 + local.get $1 + select + if + i32.const 32767 + local.get $0 + i32.const 2 + i32.add + local.tee $0 + i32.shr_u + local.set $1 + br $continue|58 + end + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 + i32.const 0 + local.set $1 + loop $continue|59 + local.get $0 + i32.const 0 + i32.ge_s + if + local.get $1 + i32.const 1 + i32.shl + local.tee $1 + i32.const 1 + i32.add + local.tee $2 + local.get $2 + i32.mul + i32.const 32767 + local.get $0 + i32.shr_u + i32.le_u + if + local.get $2 + local.set $1 + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 + br $continue|59 + end + end + local.get $1 + i32.const 181 + i32.ne + if + i32.const 0 + i32.const 8 + i32.const 3378 + i32.const 0 + call $~lib/env/abort + unreachable + end + i32.const 2 + local.set $1 + i32.const 16383 + local.set $0 + loop $continue|60 + local.get $0 + i32.const 65535 + i32.ne + local.get $0 + local.get $0 + select + if + i32.const 65535 + local.get $1 + i32.const 2 + i32.add + local.tee $1 + i32.const 65535 + i32.and + i32.shr_u + local.set $0 + br $continue|60 + end + end + local.get $1 + i32.const 2 + i32.sub + local.set $1 + i32.const 0 + local.set $0 + loop $continue|61 + local.get $1 + i32.const 0 + i32.ge_s + if + local.get $0 + i32.const 1 + i32.shl + local.tee $0 + i32.const 1 + i32.add + local.tee $2 + local.get $2 + i32.mul + i32.const 65535 + local.get $1 + i32.shr_u + i32.le_u + if + local.get $2 + local.set $0 + end + local.get $1 + i32.const 2 + i32.sub + local.set $1 + br $continue|61 + end + end + local.get $0 + i32.const 65535 + i32.and + i32.const 255 + i32.ne + if + i32.const 0 + i32.const 8 + i32.const 3379 + i32.const 0 + call $~lib/env/abort + unreachable + end + i32.const 2 + local.set $0 + i32.const 536870911 + local.set $1 + loop $continue|62 + local.get $1 + i32.const 2147483647 + i32.ne + local.get $1 + local.get $1 + select + if + i32.const 2147483647 + local.get $0 + i32.const 2 + i32.add + local.tee $0 + i32.shr_s + local.set $1 + br $continue|62 + end + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 + i32.const 0 + local.set $1 + loop $continue|63 + local.get $0 + i32.const 0 + i32.ge_s + if + local.get $1 + i32.const 1 + i32.shl + local.tee $1 + i32.const 1 + i32.add + local.tee $2 + local.get $2 + i32.mul + i32.const 2147483647 + local.get $0 + i32.shr_u + i32.le_u + if + local.get $2 + local.set $1 + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 + br $continue|63 + end + end + local.get $1 + i32.const 46340 + i32.ne if i32.const 0 i32.const 8 - i32.const 3365 + i32.const 3380 + i32.const 0 + call $~lib/env/abort + unreachable + end + i32.const 2 + local.set $1 + i32.const 536870911 + local.set $0 + loop $continue|64 + local.get $0 + i32.const 2147483647 + i32.ne + local.get $0 + local.get $0 + select + if + i32.const 2147483647 + local.get $1 + i32.const 2 + i32.add + local.tee $1 + i32.shr_u + local.set $0 + br $continue|64 + end + end + local.get $1 + i32.const 2 + i32.sub + local.set $1 + i32.const 0 + local.set $0 + loop $continue|65 + local.get $1 + i32.const 0 + i32.ge_s + if + local.get $0 + i32.const 1 + i32.shl + local.tee $0 + i32.const 1 + i32.add + local.tee $2 + local.get $2 + i32.mul + i32.const 2147483647 + local.get $1 + i32.shr_u + i32.le_u + if + local.get $2 + local.set $0 + end + local.get $1 + i32.const 2 + i32.sub + local.set $1 + br $continue|65 + end + end + local.get $0 + i32.const 46340 + i32.ne + if + i32.const 0 + i32.const 8 + i32.const 3381 + i32.const 0 + call $~lib/env/abort + unreachable + end + i32.const 2 + local.set $0 + i32.const 1073741823 + local.set $1 + loop $continue|66 + local.get $1 + i32.const -1 + i32.ne + local.get $1 + local.get $1 + select + if + i32.const -1 + local.get $0 + i32.const 2 + i32.add + local.tee $0 + i32.shr_u + local.set $1 + br $continue|66 + end + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 + i32.const 0 + local.set $1 + loop $continue|67 + local.get $0 + i32.const 0 + i32.ge_s + if + local.get $1 + i32.const 1 + i32.shl + local.tee $1 + i32.const 1 + i32.add + local.tee $2 + local.get $2 + i32.mul + i32.const -1 + local.get $0 + i32.shr_u + i32.le_u + if + local.get $2 + local.set $1 + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 + br $continue|67 + end + end + local.get $1 + i32.const 65535 + i32.ne + if + i32.const 0 + i32.const 8 + i32.const 3382 + i32.const 0 + call $~lib/env/abort + unreachable + end + i32.const 2 + local.set $2 + i64.const 2305843009213693951 + local.set $3 + loop $continue|68 + local.get $3 + i64.const 9223372036854775807 + i64.ne + i64.extend_i32_u + local.get $3 + local.get $3 + i64.const 0 + i64.ne + select + i64.const 0 + i64.ne + if + i64.const 9223372036854775807 + local.get $2 + i32.const 2 + i32.add + local.tee $2 + i64.extend_i32_s + i64.shr_s + local.set $3 + br $continue|68 + end + end + local.get $2 + i32.const 2 + i32.sub + local.set $2 + i64.const 0 + local.set $4 + loop $continue|69 + local.get $2 + i32.const 0 + i32.ge_s + if + local.get $4 + i64.const 1 + i64.shl + local.tee $4 + i64.const 1 + i64.add + local.tee $3 + local.get $3 + i64.mul + i64.const 9223372036854775807 + local.get $2 + i64.extend_i32_s + i64.shr_u + i64.le_u + if + local.get $3 + local.set $4 + end + local.get $2 + i32.const 2 + i32.sub + local.set $2 + br $continue|69 + end + end + local.get $4 + i64.const 3037000499 + i64.ne + if + i32.const 0 + i32.const 8 + i32.const 3383 + i32.const 0 + call $~lib/env/abort + unreachable + end + i32.const 2 + local.set $2 + i64.const 2305843009213693951 + local.set $3 + loop $continue|70 + local.get $3 + i64.const 9223372036854775807 + i64.ne + i64.extend_i32_u + local.get $3 + local.get $3 + i64.const 0 + i64.ne + select + i64.const 0 + i64.ne + if + i64.const 9223372036854775807 + local.get $2 + i32.const 2 + i32.add + local.tee $2 + i64.extend_i32_s + i64.shr_u + local.set $3 + br $continue|70 + end + end + local.get $2 + i32.const 2 + i32.sub + local.set $2 + i64.const 0 + local.set $4 + loop $continue|71 + local.get $2 + i32.const 0 + i32.ge_s + if + local.get $4 + i64.const 1 + i64.shl + local.tee $4 + i64.const 1 + i64.add + local.tee $3 + local.get $3 + i64.mul + i64.const 9223372036854775807 + local.get $2 + i64.extend_i32_s + i64.shr_u + i64.le_u + if + local.get $3 + local.set $4 + end + local.get $2 + i32.const 2 + i32.sub + local.set $2 + br $continue|71 + end + end + local.get $4 + i64.const 3037000499 + i64.ne + if + i32.const 0 + i32.const 8 + i32.const 3384 + i32.const 0 + call $~lib/env/abort + unreachable + end + call $~lib/math/IntegerMath.sqrt + i64.const 4294967295 + i64.ne + if + i32.const 0 + i32.const 8 + i32.const 3385 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 0 + i32.const 0 + call $~lib/math/ipow64 + i64.const 1 + i64.ne + if + i32.const 0 + i32.const 8 + i32.const 3389 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 0 + i32.const 1 + call $~lib/math/ipow64 + i64.const 0 + i64.ne + if + i32.const 0 + i32.const 8 + i32.const 3390 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 0 + i32.const 2 + call $~lib/math/ipow64 + i64.const 0 + i64.ne + if + i32.const 0 + i32.const 8 + i32.const 3391 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 0 + i32.const 3 + call $~lib/math/ipow64 + i64.const 0 + i64.ne + if + i32.const 0 + i32.const 8 + i32.const 3392 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 1 + i32.const 0 + call $~lib/math/ipow64 + i64.const 1 + i64.ne + if + i32.const 0 + i32.const 8 + i32.const 3394 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 1 + i32.const 1 + call $~lib/math/ipow64 + i64.const 1 + i64.ne + if + i32.const 0 + i32.const 8 + i32.const 3395 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 1 + i32.const 2 + call $~lib/math/ipow64 + i64.const 1 + i64.ne + if + i32.const 0 + i32.const 8 + i32.const 3396 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 1 + i32.const 3 + call $~lib/math/ipow64 + i64.const 1 + i64.ne + if + i32.const 0 + i32.const 8 + i32.const 3397 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 2 + i32.const 0 + call $~lib/math/ipow64 + i64.const 1 + i64.ne + if + i32.const 0 + i32.const 8 + i32.const 3399 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 2 + i32.const 1 + call $~lib/math/ipow64 + i64.const 2 + i64.ne + if + i32.const 0 + i32.const 8 + i32.const 3400 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 2 + i32.const 2 + call $~lib/math/ipow64 + i64.const 4 + i64.ne + if + i32.const 0 + i32.const 8 + i32.const 3401 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 2 + i32.const 3 + call $~lib/math/ipow64 + i64.const 8 + i64.ne + if + i32.const 0 + i32.const 8 + i32.const 3402 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const -1 + i32.const 0 + call $~lib/math/ipow64 + i64.const 1 + i64.ne + if + i32.const 0 + i32.const 8 + i32.const 3404 i32.const 0 call $~lib/env/abort unreachable @@ -38023,7 +39888,7 @@ if i32.const 0 i32.const 8 - i32.const 3366 + i32.const 3405 i32.const 0 call $~lib/env/abort unreachable @@ -38036,7 +39901,7 @@ if i32.const 0 i32.const 8 - i32.const 3367 + i32.const 3406 i32.const 0 call $~lib/env/abort unreachable @@ -38049,7 +39914,7 @@ if i32.const 0 i32.const 8 - i32.const 3368 + i32.const 3407 i32.const 0 call $~lib/env/abort unreachable @@ -38062,7 +39927,7 @@ if i32.const 0 i32.const 8 - i32.const 3370 + i32.const 3409 i32.const 0 call $~lib/env/abort unreachable @@ -38075,7 +39940,7 @@ if i32.const 0 i32.const 8 - i32.const 3371 + i32.const 3410 i32.const 0 call $~lib/env/abort unreachable @@ -38088,7 +39953,7 @@ if i32.const 0 i32.const 8 - i32.const 3372 + i32.const 3411 i32.const 0 call $~lib/env/abort unreachable @@ -38101,7 +39966,7 @@ if i32.const 0 i32.const 8 - i32.const 3373 + i32.const 3412 i32.const 0 call $~lib/env/abort unreachable @@ -38114,7 +39979,7 @@ if i32.const 0 i32.const 8 - i32.const 3375 + i32.const 3414 i32.const 0 call $~lib/env/abort unreachable @@ -38127,7 +39992,7 @@ if i32.const 0 i32.const 8 - i32.const 3376 + i32.const 3415 i32.const 0 call $~lib/env/abort unreachable @@ -38140,7 +40005,7 @@ if i32.const 0 i32.const 8 - i32.const 3377 + i32.const 3416 i32.const 0 call $~lib/env/abort unreachable @@ -38153,7 +40018,7 @@ if i32.const 0 i32.const 8 - i32.const 3378 + i32.const 3417 i32.const 0 call $~lib/env/abort unreachable @@ -38166,7 +40031,7 @@ if i32.const 0 i32.const 8 - i32.const 3379 + i32.const 3418 i32.const 0 call $~lib/env/abort unreachable @@ -38179,7 +40044,7 @@ if i32.const 0 i32.const 8 - i32.const 3380 + i32.const 3419 i32.const 0 call $~lib/env/abort unreachable @@ -38192,7 +40057,7 @@ if i32.const 0 i32.const 8 - i32.const 3381 + i32.const 3420 i32.const 0 call $~lib/env/abort unreachable @@ -38209,7 +40074,7 @@ if i32.const 0 i32.const 8 - i32.const 3383 + i32.const 3422 i32.const 0 call $~lib/env/abort unreachable @@ -38222,7 +40087,7 @@ if i32.const 0 i32.const 8 - i32.const 3387 + i32.const 3426 i32.const 0 call $~lib/env/abort unreachable @@ -38235,7 +40100,7 @@ if i32.const 0 i32.const 8 - i32.const 3388 + i32.const 3427 i32.const 0 call $~lib/env/abort unreachable @@ -38243,13 +40108,13 @@ f32.const nan:0x400000 i32.const 1 call $~lib/math/ipow32f - local.tee $1 - local.get $1 + local.tee $6 + local.get $6 f32.eq if i32.const 0 i32.const 8 - i32.const 3389 + i32.const 3428 i32.const 0 call $~lib/env/abort unreachable @@ -38257,13 +40122,13 @@ f32.const nan:0x400000 i32.const -1 call $~lib/math/ipow32f - local.tee $1 - local.get $1 + local.tee $6 + local.get $6 f32.eq if i32.const 0 i32.const 8 - i32.const 3390 + i32.const 3429 i32.const 0 call $~lib/env/abort unreachable @@ -38271,13 +40136,13 @@ f32.const nan:0x400000 i32.const 2 call $~lib/math/ipow32f - local.tee $1 - local.get $1 + local.tee $6 + local.get $6 f32.eq if i32.const 0 i32.const 8 - i32.const 3391 + i32.const 3430 i32.const 0 call $~lib/env/abort unreachable @@ -38290,7 +40155,7 @@ if i32.const 0 i32.const 8 - i32.const 3392 + i32.const 3431 i32.const 0 call $~lib/env/abort unreachable @@ -38303,7 +40168,7 @@ if i32.const 0 i32.const 8 - i32.const 3393 + i32.const 3432 i32.const 0 call $~lib/env/abort unreachable @@ -38316,7 +40181,7 @@ if i32.const 0 i32.const 8 - i32.const 3394 + i32.const 3433 i32.const 0 call $~lib/env/abort unreachable @@ -38329,7 +40194,7 @@ if i32.const 0 i32.const 8 - i32.const 3395 + i32.const 3434 i32.const 0 call $~lib/env/abort unreachable @@ -38342,7 +40207,7 @@ if i32.const 0 i32.const 8 - i32.const 3396 + i32.const 3435 i32.const 0 call $~lib/env/abort unreachable @@ -38355,7 +40220,7 @@ if i32.const 0 i32.const 8 - i32.const 3397 + i32.const 3436 i32.const 0 call $~lib/env/abort unreachable @@ -38368,7 +40233,7 @@ if i32.const 0 i32.const 8 - i32.const 3398 + i32.const 3437 i32.const 0 call $~lib/env/abort unreachable @@ -38381,7 +40246,7 @@ if i32.const 0 i32.const 8 - i32.const 3399 + i32.const 3438 i32.const 0 call $~lib/env/abort unreachable @@ -38394,7 +40259,7 @@ if i32.const 0 i32.const 8 - i32.const 3400 + i32.const 3439 i32.const 0 call $~lib/env/abort unreachable @@ -38407,7 +40272,7 @@ if i32.const 0 i32.const 8 - i32.const 3401 + i32.const 3440 i32.const 0 call $~lib/env/abort unreachable @@ -38420,7 +40285,7 @@ if i32.const 0 i32.const 8 - i32.const 3402 + i32.const 3441 i32.const 0 call $~lib/env/abort unreachable @@ -38433,7 +40298,7 @@ if i32.const 0 i32.const 8 - i32.const 3406 + i32.const 3445 i32.const 0 call $~lib/env/abort unreachable @@ -38446,7 +40311,7 @@ if i32.const 0 i32.const 8 - i32.const 3407 + i32.const 3446 i32.const 0 call $~lib/env/abort unreachable @@ -38454,13 +40319,13 @@ f64.const nan:0x8000000000000 i32.const 1 call $~lib/math/ipow64f - local.tee $0 - local.get $0 + local.tee $5 + local.get $5 f64.eq if i32.const 0 i32.const 8 - i32.const 3408 + i32.const 3447 i32.const 0 call $~lib/env/abort unreachable @@ -38468,13 +40333,13 @@ f64.const nan:0x8000000000000 i32.const -1 call $~lib/math/ipow64f - local.tee $0 - local.get $0 + local.tee $5 + local.get $5 f64.eq if i32.const 0 i32.const 8 - i32.const 3409 + i32.const 3448 i32.const 0 call $~lib/env/abort unreachable @@ -38482,13 +40347,13 @@ f64.const nan:0x8000000000000 i32.const 2 call $~lib/math/ipow64f - local.tee $0 - local.get $0 + local.tee $5 + local.get $5 f64.eq if i32.const 0 i32.const 8 - i32.const 3410 + i32.const 3449 i32.const 0 call $~lib/env/abort unreachable @@ -38501,7 +40366,7 @@ if i32.const 0 i32.const 8 - i32.const 3411 + i32.const 3450 i32.const 0 call $~lib/env/abort unreachable @@ -38514,7 +40379,7 @@ if i32.const 0 i32.const 8 - i32.const 3412 + i32.const 3451 i32.const 0 call $~lib/env/abort unreachable @@ -38527,7 +40392,7 @@ if i32.const 0 i32.const 8 - i32.const 3413 + i32.const 3452 i32.const 0 call $~lib/env/abort unreachable @@ -38540,7 +40405,7 @@ if i32.const 0 i32.const 8 - i32.const 3414 + i32.const 3453 i32.const 0 call $~lib/env/abort unreachable @@ -38553,7 +40418,7 @@ if i32.const 0 i32.const 8 - i32.const 3415 + i32.const 3454 i32.const 0 call $~lib/env/abort unreachable @@ -38566,7 +40431,7 @@ if i32.const 0 i32.const 8 - i32.const 3416 + i32.const 3455 i32.const 0 call $~lib/env/abort unreachable @@ -38579,7 +40444,7 @@ if i32.const 0 i32.const 8 - i32.const 3417 + i32.const 3456 i32.const 0 call $~lib/env/abort unreachable @@ -38592,7 +40457,7 @@ if i32.const 0 i32.const 8 - i32.const 3418 + i32.const 3457 i32.const 0 call $~lib/env/abort unreachable @@ -38605,7 +40470,7 @@ if i32.const 0 i32.const 8 - i32.const 3419 + i32.const 3458 i32.const 0 call $~lib/env/abort unreachable @@ -38618,7 +40483,7 @@ if i32.const 0 i32.const 8 - i32.const 3420 + i32.const 3459 i32.const 0 call $~lib/env/abort unreachable @@ -38631,13 +40496,13 @@ if i32.const 0 i32.const 8 - i32.const 3421 + i32.const 3460 i32.const 0 call $~lib/env/abort unreachable end ) - (func $null (; 150 ;) (type $_) + (func $null (; 151 ;) (type $_) nop ) ) diff --git a/tests/compiler/std/math.ts b/tests/compiler/std/math.ts index db0d55575e..4a662c6a9b 100644 --- a/tests/compiler/std/math.ts +++ b/tests/compiler/std/math.ts @@ -3345,6 +3345,45 @@ assert(IntegerMath.log2(u32.MAX_VALUE) == 31); assert(IntegerMath.log2(i64.MAX_VALUE) == 62); assert(IntegerMath.log2(u64.MAX_VALUE) == 63); +// IntegerMath.sqrt /////////////////////////////////////////////////////////////////////////// + +assert(IntegerMath.sqrt(0) == 0); +assert(IntegerMath.sqrt(0) == 0); +assert(IntegerMath.sqrt(0) == 0); +assert(IntegerMath.sqrt(0) == 0); +assert(IntegerMath.sqrt(0) == 0); +assert(IntegerMath.sqrt(1) == 1); +assert(IntegerMath.sqrt(1) == 1); +assert(IntegerMath.sqrt(1) == 1); +assert(IntegerMath.sqrt(1) == 1); +assert(IntegerMath.sqrt(1) == 1); +assert(IntegerMath.sqrt(2) == 1); +assert(IntegerMath.sqrt(2) == 1); +assert(IntegerMath.sqrt(2) == 1); +assert(IntegerMath.sqrt(2) == 1); +assert(IntegerMath.sqrt(2) == 1); +assert(IntegerMath.sqrt(3) == 1); +assert(IntegerMath.sqrt(3) == 1); +assert(IntegerMath.sqrt(3) == 1); +assert(IntegerMath.sqrt(3) == 1); +assert(IntegerMath.sqrt(3) == 1); +assert(IntegerMath.sqrt(4) == 2); +assert(IntegerMath.sqrt(4) == 2); +assert(IntegerMath.sqrt(4) == 2); +assert(IntegerMath.sqrt(4) == 2); +assert(IntegerMath.sqrt(4) == 2); +assert(IntegerMath.sqrt(i16.MAX_VALUE) == 181); +assert(IntegerMath.sqrt(i16.MAX_VALUE) == 181); +assert(IntegerMath.sqrt(i16.MAX_VALUE) == 181); +assert(IntegerMath.sqrt(i16.MAX_VALUE) == 181); +assert(IntegerMath.sqrt(u16.MAX_VALUE) == 255); +assert(IntegerMath.sqrt(i32.MAX_VALUE) == 46340); +assert(IntegerMath.sqrt(i32.MAX_VALUE) == 46340); +assert(IntegerMath.sqrt(u32.MAX_VALUE) == 65535); +assert(IntegerMath.sqrt(i64.MAX_VALUE) == 3037000499); +assert(IntegerMath.sqrt(i64.MAX_VALUE) == 3037000499); +assert(IntegerMath.sqrt(u64.MAX_VALUE) == 4294967295); + // ipow64 ///////////////////////////////////////////////////////////////////////////////////// assert(ipow64(0, 0) == 1); diff --git a/tests/compiler/std/math.untouched.wat b/tests/compiler/std/math.untouched.wat index f5d193e401..7edf0f04af 100644 --- a/tests/compiler/std/math.untouched.wat +++ b/tests/compiler/std/math.untouched.wat @@ -100,6 +100,7 @@ (global $~lib/builtins/u32.MAX_VALUE i32 (i32.const -1)) (global $~lib/builtins/i64.MAX_VALUE i64 (i64.const 9223372036854775807)) (global $~lib/builtins/u64.MAX_VALUE i64 (i64.const -1)) + (global $~lib/builtins/u16.MAX_VALUE i32 (i32.const 65535)) (global $~lib/builtins/f32.MAX_VALUE f32 (f32.const 3402823466385288598117041e14)) (global $~lib/builtins/f32.MIN_VALUE f32 (f32.const 1.401298464324817e-45)) (global $HEAP_BASE i32 (i32.const 68)) @@ -11388,7 +11389,104 @@ i64.sub return ) - (func $~lib/math/ipow64 (; 163 ;) (type $IiI) (param $0 i64) (param $1 i32) (result i64) + (func $~lib/math/IntegerMath.sqrt (; 163 ;) (type $II) (param $0 i64) (result i64) + (local $1 i32) + (local $2 i64) + (local $3 i64) + (local $4 i64) + (local $5 i64) + local.get $0 + i64.const 2 + i64.lt_u + if + local.get $0 + return + end + i32.const 2 + local.set $1 + local.get $0 + i64.const 2 + i64.shr_u + local.set $2 + block $break|0 + loop $continue|0 + local.get $2 + i64.const 0 + i64.ne + if (result i64) + local.get $2 + local.get $0 + i64.ne + i64.extend_i32_u + else + local.get $2 + end + i64.const 0 + i64.ne + if + block + local.get $1 + i32.const 2 + i32.add + local.set $1 + local.get $0 + local.get $1 + i64.extend_i32_s + i64.shr_u + local.set $2 + end + br $continue|0 + end + end + end + local.get $1 + i32.const 2 + i32.sub + local.set $1 + local.get $0 + local.set $3 + i64.const 0 + local.set $4 + block $break|1 + loop $continue|1 + local.get $1 + i32.const 0 + i32.ge_s + if + block + local.get $4 + i64.const 1 + i64.shl + local.set $4 + local.get $4 + i64.const 1 + i64.add + local.set $5 + local.get $5 + local.get $5 + i64.mul + local.get $3 + local.get $1 + i64.extend_i32_s + i64.shr_u + i64.le_u + if + local.get $5 + local.set $4 + end + local.get $1 + i32.const 2 + i32.sub + local.set $1 + end + br $continue|1 + end + end + end + local.get $4 + return + ) + (func $~lib/math/ipow64 (; 164 ;) (type $IiI) (param $0 i64) (param $1 i32) (result i64) (local $2 i64) (local $3 i32) (local $4 i32) @@ -11620,7 +11718,7 @@ end local.get $2 ) - (func $~lib/math/ipow32f (; 164 ;) (type $fif) (param $0 f32) (param $1 i32) (result f32) + (func $~lib/math/ipow32f (; 165 ;) (type $fif) (param $0 f32) (param $1 i32) (result f32) (local $2 i32) (local $3 f32) local.get $1 @@ -11671,7 +11769,7 @@ local.get $3 end ) - (func $~lib/math/ipow64f (; 165 ;) (type $FiF) (param $0 f64) (param $1 i32) (result f64) + (func $~lib/math/ipow64f (; 166 ;) (type $FiF) (param $0 f64) (param $1 i32) (result f64) (local $2 i32) (local $3 f64) local.get $1 @@ -11722,12 +11820,20 @@ local.get $3 end ) - (func $start (; 166 ;) (type $_) + (func $start (; 167 ;) (type $_) (local $0 i32) (local $1 f64) (local $2 i32) (local $3 i64) (local $4 f32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + (local $8 i32) + (local $9 i64) + (local $10 i64) + (local $11 i64) + (local $12 i64) global.get $~lib/math/NativeMath.E global.get $~lib/math/NativeMath.E f64.eq @@ -43427,142 +43533,3944 @@ call $~lib/env/abort unreachable end - i64.const 0 - i32.const 0 - call $~lib/math/ipow64 - i64.const 1 - i64.eq - i32.eqz - if - i32.const 0 - i32.const 8 - i32.const 3350 + block $~lib/math/IntegerMath.sqrt|inlined.0 (result i32) i32.const 0 - call $~lib/env/abort - unreachable - end - i64.const 0 - i32.const 1 - call $~lib/math/ipow64 - i64.const 0 - i64.eq - i32.eqz - if + local.set $0 + local.get $0 i32.const 0 - i32.const 8 - i32.const 3351 + i32.lt_s + if + i32.const 0 + i32.const 40 + i32.const 2415 + i32.const 19 + call $~lib/env/abort + unreachable + end + local.get $0 + i32.const 2 + i32.lt_s + if + local.get $0 + br $~lib/math/IntegerMath.sqrt|inlined.0 + end + i32.const 2 + local.set $2 + local.get $0 + i32.const 2 + i32.shr_s + local.set $5 + block $break|2 + loop $continue|2 + local.get $5 + if (result i32) + local.get $5 + local.get $0 + i32.ne + else + local.get $5 + end + if + block + local.get $2 + i32.const 2 + i32.add + local.set $2 + local.get $0 + local.get $2 + i32.const 16 + i32.shl + i32.const 16 + i32.shr_s + i32.shr_s + local.set $5 + end + br $continue|2 + end + end + end + local.get $2 + i32.const 2 + i32.sub + local.set $2 + local.get $0 + local.set $6 i32.const 0 - call $~lib/env/abort - unreachable + local.set $7 + block $break|3 + loop $continue|3 + local.get $2 + i32.const 0 + i32.ge_s + if + block + local.get $7 + i32.const 1 + i32.shl + local.set $7 + local.get $7 + i32.const 1 + i32.add + local.set $8 + local.get $8 + local.get $8 + i32.mul + local.get $6 + local.get $2 + i32.shr_u + i32.le_u + if + local.get $8 + local.set $7 + end + local.get $2 + i32.const 2 + i32.sub + local.set $2 + end + br $continue|3 + end + end + end + local.get $7 + br $~lib/math/IntegerMath.sqrt|inlined.0 end - i64.const 0 - i32.const 2 - call $~lib/math/ipow64 - i64.const 0 - i64.eq + i32.const 16 + i32.shl + i32.const 16 + i32.shr_s + i32.const 0 + i32.eq i32.eqz if i32.const 0 i32.const 8 - i32.const 3352 + i32.const 3350 i32.const 0 call $~lib/env/abort unreachable end - i64.const 0 - i32.const 3 - call $~lib/math/ipow64 - i64.const 0 - i64.eq - i32.eqz - if + block $~lib/math/IntegerMath.sqrt|inlined.0 (result i32) i32.const 0 - i32.const 8 - i32.const 3353 + local.set $0 + local.get $0 i32.const 0 - call $~lib/env/abort - unreachable + i32.lt_s + if + i32.const 0 + i32.const 40 + i32.const 2415 + i32.const 19 + call $~lib/env/abort + unreachable + end + local.get $0 + i32.const 2 + i32.lt_s + if + local.get $0 + br $~lib/math/IntegerMath.sqrt|inlined.0 + end + i32.const 2 + local.set $5 + local.get $0 + i32.const 2 + i32.shr_s + local.set $2 + block $break|4 + loop $continue|4 + local.get $2 + if (result i32) + local.get $2 + local.get $0 + i32.ne + else + local.get $2 + end + if + block + local.get $5 + i32.const 2 + i32.add + local.set $5 + local.get $0 + local.get $5 + i32.shr_s + local.set $2 + end + br $continue|4 + end + end + end + local.get $5 + i32.const 2 + i32.sub + local.set $5 + local.get $0 + local.set $7 + i32.const 0 + local.set $6 + block $break|5 + loop $continue|5 + local.get $5 + i32.const 0 + i32.ge_s + if + block + local.get $6 + i32.const 1 + i32.shl + local.set $6 + local.get $6 + i32.const 1 + i32.add + local.set $8 + local.get $8 + local.get $8 + i32.mul + local.get $7 + local.get $5 + i32.shr_u + i32.le_u + if + local.get $8 + local.set $6 + end + local.get $5 + i32.const 2 + i32.sub + local.set $5 + end + br $continue|5 + end + end + end + local.get $6 + br $~lib/math/IntegerMath.sqrt|inlined.0 end - i64.const 1 i32.const 0 - call $~lib/math/ipow64 - i64.const 1 - i64.eq + i32.eq i32.eqz if i32.const 0 i32.const 8 - i32.const 3355 + i32.const 3351 i32.const 0 call $~lib/env/abort unreachable end - i64.const 1 - i32.const 1 - call $~lib/math/ipow64 - i64.const 1 - i64.eq - i32.eqz - if + block $~lib/math/IntegerMath.sqrt|inlined.0 (result i32) i32.const 0 - i32.const 8 - i32.const 3356 + local.set $0 + local.get $0 + i32.const 2 + i32.lt_u + if + local.get $0 + br $~lib/math/IntegerMath.sqrt|inlined.0 + end + i32.const 2 + local.set $2 + local.get $0 + i32.const 2 + i32.shr_u + local.set $5 + block $break|6 + loop $continue|6 + local.get $5 + if (result i32) + local.get $5 + local.get $0 + i32.ne + else + local.get $5 + end + if + block + local.get $2 + i32.const 2 + i32.add + local.set $2 + local.get $0 + local.get $2 + i32.shr_u + local.set $5 + end + br $continue|6 + end + end + end + local.get $2 + i32.const 2 + i32.sub + local.set $2 + local.get $0 + local.set $6 i32.const 0 - call $~lib/env/abort - unreachable + local.set $7 + block $break|7 + loop $continue|7 + local.get $2 + i32.const 0 + i32.ge_s + if + block + local.get $7 + i32.const 1 + i32.shl + local.set $7 + local.get $7 + i32.const 1 + i32.add + local.set $8 + local.get $8 + local.get $8 + i32.mul + local.get $6 + local.get $2 + i32.shr_u + i32.le_u + if + local.get $8 + local.set $7 + end + local.get $2 + i32.const 2 + i32.sub + local.set $2 + end + br $continue|7 + end + end + end + local.get $7 + br $~lib/math/IntegerMath.sqrt|inlined.0 end - i64.const 1 - i32.const 2 - call $~lib/math/ipow64 - i64.const 1 - i64.eq + i32.const 0 + i32.eq i32.eqz if i32.const 0 i32.const 8 - i32.const 3357 + i32.const 3352 i32.const 0 call $~lib/env/abort unreachable end - i64.const 1 - i32.const 3 - call $~lib/math/ipow64 - i64.const 1 + block $~lib/math/IntegerMath.sqrt|inlined.0 (result i64) + i64.const 0 + local.set $3 + local.get $3 + i64.const 0 + i64.lt_s + if + i32.const 0 + i32.const 40 + i32.const 2415 + i32.const 19 + call $~lib/env/abort + unreachable + end + local.get $3 + i64.const 2 + i64.lt_s + if + local.get $3 + br $~lib/math/IntegerMath.sqrt|inlined.0 + end + i32.const 2 + local.set $0 + local.get $3 + i64.const 2 + i64.shr_s + local.set $9 + block $break|8 + loop $continue|8 + local.get $9 + i64.const 0 + i64.ne + if (result i64) + local.get $9 + local.get $3 + i64.ne + i64.extend_i32_u + else + local.get $9 + end + i64.const 0 + i64.ne + if + block + local.get $0 + i32.const 2 + i32.add + local.set $0 + local.get $3 + local.get $0 + i64.extend_i32_s + i64.shr_s + local.set $9 + end + br $continue|8 + end + end + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 + local.get $3 + local.set $10 + i64.const 0 + local.set $11 + block $break|9 + loop $continue|9 + local.get $0 + i32.const 0 + i32.ge_s + if + block + local.get $11 + i64.const 1 + i64.shl + local.set $11 + local.get $11 + i64.const 1 + i64.add + local.set $12 + local.get $12 + local.get $12 + i64.mul + local.get $10 + local.get $0 + i64.extend_i32_s + i64.shr_u + i64.le_u + if + local.get $12 + local.set $11 + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 + end + br $continue|9 + end + end + end + local.get $11 + br $~lib/math/IntegerMath.sqrt|inlined.0 + end + i64.const 0 i64.eq i32.eqz if i32.const 0 i32.const 8 - i32.const 3358 + i32.const 3353 i32.const 0 call $~lib/env/abort unreachable end - i64.const 2 - i32.const 0 - call $~lib/math/ipow64 - i64.const 1 + block $~lib/math/IntegerMath.sqrt|inlined.0 (result i64) + i64.const 0 + local.set $3 + local.get $3 + i64.const 2 + i64.lt_u + if + local.get $3 + br $~lib/math/IntegerMath.sqrt|inlined.0 + end + i32.const 2 + local.set $0 + local.get $3 + i64.const 2 + i64.shr_u + local.set $9 + block $break|10 + loop $continue|10 + local.get $9 + i64.const 0 + i64.ne + if (result i64) + local.get $9 + local.get $3 + i64.ne + i64.extend_i32_u + else + local.get $9 + end + i64.const 0 + i64.ne + if + block + local.get $0 + i32.const 2 + i32.add + local.set $0 + local.get $3 + local.get $0 + i64.extend_i32_s + i64.shr_u + local.set $9 + end + br $continue|10 + end + end + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 + local.get $3 + local.set $11 + i64.const 0 + local.set $10 + block $break|11 + loop $continue|11 + local.get $0 + i32.const 0 + i32.ge_s + if + block + local.get $10 + i64.const 1 + i64.shl + local.set $10 + local.get $10 + i64.const 1 + i64.add + local.set $12 + local.get $12 + local.get $12 + i64.mul + local.get $11 + local.get $0 + i64.extend_i32_s + i64.shr_u + i64.le_u + if + local.get $12 + local.set $10 + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 + end + br $continue|11 + end + end + end + local.get $10 + br $~lib/math/IntegerMath.sqrt|inlined.0 + end + i64.const 0 i64.eq i32.eqz if i32.const 0 i32.const 8 - i32.const 3360 + i32.const 3354 i32.const 0 call $~lib/env/abort unreachable end - i64.const 2 - i32.const 1 - call $~lib/math/ipow64 - i64.const 2 - i64.eq - i32.eqz - if - i32.const 0 + block $~lib/math/IntegerMath.sqrt|inlined.1 (result i32) + i32.const 1 + local.set $0 + local.get $0 + i32.const 0 + i32.lt_s + if + i32.const 0 + i32.const 40 + i32.const 2415 + i32.const 19 + call $~lib/env/abort + unreachable + end + local.get $0 + i32.const 2 + i32.lt_s + if + local.get $0 + br $~lib/math/IntegerMath.sqrt|inlined.1 + end + i32.const 2 + local.set $5 + local.get $0 + i32.const 2 + i32.shr_s + local.set $2 + block $break|12 + loop $continue|12 + local.get $2 + if (result i32) + local.get $2 + local.get $0 + i32.ne + else + local.get $2 + end + if + block + local.get $5 + i32.const 2 + i32.add + local.set $5 + local.get $0 + local.get $5 + i32.const 16 + i32.shl + i32.const 16 + i32.shr_s + i32.shr_s + local.set $2 + end + br $continue|12 + end + end + end + local.get $5 + i32.const 2 + i32.sub + local.set $5 + local.get $0 + local.set $7 + i32.const 0 + local.set $6 + block $break|13 + loop $continue|13 + local.get $5 + i32.const 0 + i32.ge_s + if + block + local.get $6 + i32.const 1 + i32.shl + local.set $6 + local.get $6 + i32.const 1 + i32.add + local.set $8 + local.get $8 + local.get $8 + i32.mul + local.get $7 + local.get $5 + i32.shr_u + i32.le_u + if + local.get $8 + local.set $6 + end + local.get $5 + i32.const 2 + i32.sub + local.set $5 + end + br $continue|13 + end + end + end + local.get $6 + br $~lib/math/IntegerMath.sqrt|inlined.1 + end + i32.const 16 + i32.shl + i32.const 16 + i32.shr_s + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3355 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.sqrt|inlined.1 (result i32) + i32.const 1 + local.set $0 + local.get $0 + i32.const 0 + i32.lt_s + if + i32.const 0 + i32.const 40 + i32.const 2415 + i32.const 19 + call $~lib/env/abort + unreachable + end + local.get $0 + i32.const 2 + i32.lt_s + if + local.get $0 + br $~lib/math/IntegerMath.sqrt|inlined.1 + end + i32.const 2 + local.set $2 + local.get $0 + i32.const 2 + i32.shr_s + local.set $5 + block $break|14 + loop $continue|14 + local.get $5 + if (result i32) + local.get $5 + local.get $0 + i32.ne + else + local.get $5 + end + if + block + local.get $2 + i32.const 2 + i32.add + local.set $2 + local.get $0 + local.get $2 + i32.shr_s + local.set $5 + end + br $continue|14 + end + end + end + local.get $2 + i32.const 2 + i32.sub + local.set $2 + local.get $0 + local.set $6 + i32.const 0 + local.set $7 + block $break|15 + loop $continue|15 + local.get $2 + i32.const 0 + i32.ge_s + if + block + local.get $7 + i32.const 1 + i32.shl + local.set $7 + local.get $7 + i32.const 1 + i32.add + local.set $8 + local.get $8 + local.get $8 + i32.mul + local.get $6 + local.get $2 + i32.shr_u + i32.le_u + if + local.get $8 + local.set $7 + end + local.get $2 + i32.const 2 + i32.sub + local.set $2 + end + br $continue|15 + end + end + end + local.get $7 + br $~lib/math/IntegerMath.sqrt|inlined.1 + end + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3356 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.sqrt|inlined.1 (result i32) + i32.const 1 + local.set $0 + local.get $0 + i32.const 2 + i32.lt_u + if + local.get $0 + br $~lib/math/IntegerMath.sqrt|inlined.1 + end + i32.const 2 + local.set $5 + local.get $0 + i32.const 2 + i32.shr_u + local.set $2 + block $break|16 + loop $continue|16 + local.get $2 + if (result i32) + local.get $2 + local.get $0 + i32.ne + else + local.get $2 + end + if + block + local.get $5 + i32.const 2 + i32.add + local.set $5 + local.get $0 + local.get $5 + i32.shr_u + local.set $2 + end + br $continue|16 + end + end + end + local.get $5 + i32.const 2 + i32.sub + local.set $5 + local.get $0 + local.set $7 + i32.const 0 + local.set $6 + block $break|17 + loop $continue|17 + local.get $5 + i32.const 0 + i32.ge_s + if + block + local.get $6 + i32.const 1 + i32.shl + local.set $6 + local.get $6 + i32.const 1 + i32.add + local.set $8 + local.get $8 + local.get $8 + i32.mul + local.get $7 + local.get $5 + i32.shr_u + i32.le_u + if + local.get $8 + local.set $6 + end + local.get $5 + i32.const 2 + i32.sub + local.set $5 + end + br $continue|17 + end + end + end + local.get $6 + br $~lib/math/IntegerMath.sqrt|inlined.1 + end + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3357 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.sqrt|inlined.1 (result i64) + i64.const 1 + local.set $3 + local.get $3 + i64.const 0 + i64.lt_s + if + i32.const 0 + i32.const 40 + i32.const 2415 + i32.const 19 + call $~lib/env/abort + unreachable + end + local.get $3 + i64.const 2 + i64.lt_s + if + local.get $3 + br $~lib/math/IntegerMath.sqrt|inlined.1 + end + i32.const 2 + local.set $0 + local.get $3 + i64.const 2 + i64.shr_s + local.set $9 + block $break|18 + loop $continue|18 + local.get $9 + i64.const 0 + i64.ne + if (result i64) + local.get $9 + local.get $3 + i64.ne + i64.extend_i32_u + else + local.get $9 + end + i64.const 0 + i64.ne + if + block + local.get $0 + i32.const 2 + i32.add + local.set $0 + local.get $3 + local.get $0 + i64.extend_i32_s + i64.shr_s + local.set $9 + end + br $continue|18 + end + end + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 + local.get $3 + local.set $10 + i64.const 0 + local.set $11 + block $break|19 + loop $continue|19 + local.get $0 + i32.const 0 + i32.ge_s + if + block + local.get $11 + i64.const 1 + i64.shl + local.set $11 + local.get $11 + i64.const 1 + i64.add + local.set $12 + local.get $12 + local.get $12 + i64.mul + local.get $10 + local.get $0 + i64.extend_i32_s + i64.shr_u + i64.le_u + if + local.get $12 + local.set $11 + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 + end + br $continue|19 + end + end + end + local.get $11 + br $~lib/math/IntegerMath.sqrt|inlined.1 + end + i64.const 1 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3358 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.sqrt|inlined.1 (result i64) + i64.const 1 + local.set $3 + local.get $3 + i64.const 2 + i64.lt_u + if + local.get $3 + br $~lib/math/IntegerMath.sqrt|inlined.1 + end + i32.const 2 + local.set $0 + local.get $3 + i64.const 2 + i64.shr_u + local.set $9 + block $break|20 + loop $continue|20 + local.get $9 + i64.const 0 + i64.ne + if (result i64) + local.get $9 + local.get $3 + i64.ne + i64.extend_i32_u + else + local.get $9 + end + i64.const 0 + i64.ne + if + block + local.get $0 + i32.const 2 + i32.add + local.set $0 + local.get $3 + local.get $0 + i64.extend_i32_s + i64.shr_u + local.set $9 + end + br $continue|20 + end + end + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 + local.get $3 + local.set $11 + i64.const 0 + local.set $10 + block $break|21 + loop $continue|21 + local.get $0 + i32.const 0 + i32.ge_s + if + block + local.get $10 + i64.const 1 + i64.shl + local.set $10 + local.get $10 + i64.const 1 + i64.add + local.set $12 + local.get $12 + local.get $12 + i64.mul + local.get $11 + local.get $0 + i64.extend_i32_s + i64.shr_u + i64.le_u + if + local.get $12 + local.set $10 + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 + end + br $continue|21 + end + end + end + local.get $10 + br $~lib/math/IntegerMath.sqrt|inlined.1 + end + i64.const 1 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3359 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.sqrt|inlined.2 (result i32) + i32.const 2 + local.set $0 + local.get $0 + i32.const 0 + i32.lt_s + if + i32.const 0 + i32.const 40 + i32.const 2415 + i32.const 19 + call $~lib/env/abort + unreachable + end + local.get $0 + i32.const 2 + i32.lt_s + if + local.get $0 + br $~lib/math/IntegerMath.sqrt|inlined.2 + end + i32.const 2 + local.set $2 + local.get $0 + i32.const 2 + i32.shr_s + local.set $5 + block $break|22 + loop $continue|22 + local.get $5 + if (result i32) + local.get $5 + local.get $0 + i32.ne + else + local.get $5 + end + if + block + local.get $2 + i32.const 2 + i32.add + local.set $2 + local.get $0 + local.get $2 + i32.const 16 + i32.shl + i32.const 16 + i32.shr_s + i32.shr_s + local.set $5 + end + br $continue|22 + end + end + end + local.get $2 + i32.const 2 + i32.sub + local.set $2 + local.get $0 + local.set $6 + i32.const 0 + local.set $7 + block $break|23 + loop $continue|23 + local.get $2 + i32.const 0 + i32.ge_s + if + block + local.get $7 + i32.const 1 + i32.shl + local.set $7 + local.get $7 + i32.const 1 + i32.add + local.set $8 + local.get $8 + local.get $8 + i32.mul + local.get $6 + local.get $2 + i32.shr_u + i32.le_u + if + local.get $8 + local.set $7 + end + local.get $2 + i32.const 2 + i32.sub + local.set $2 + end + br $continue|23 + end + end + end + local.get $7 + br $~lib/math/IntegerMath.sqrt|inlined.2 + end + i32.const 16 + i32.shl + i32.const 16 + i32.shr_s + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3360 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.sqrt|inlined.2 (result i32) + i32.const 2 + local.set $0 + local.get $0 + i32.const 0 + i32.lt_s + if + i32.const 0 + i32.const 40 + i32.const 2415 + i32.const 19 + call $~lib/env/abort + unreachable + end + local.get $0 + i32.const 2 + i32.lt_s + if + local.get $0 + br $~lib/math/IntegerMath.sqrt|inlined.2 + end + i32.const 2 + local.set $5 + local.get $0 + i32.const 2 + i32.shr_s + local.set $2 + block $break|24 + loop $continue|24 + local.get $2 + if (result i32) + local.get $2 + local.get $0 + i32.ne + else + local.get $2 + end + if + block + local.get $5 + i32.const 2 + i32.add + local.set $5 + local.get $0 + local.get $5 + i32.shr_s + local.set $2 + end + br $continue|24 + end + end + end + local.get $5 + i32.const 2 + i32.sub + local.set $5 + local.get $0 + local.set $7 + i32.const 0 + local.set $6 + block $break|25 + loop $continue|25 + local.get $5 + i32.const 0 + i32.ge_s + if + block + local.get $6 + i32.const 1 + i32.shl + local.set $6 + local.get $6 + i32.const 1 + i32.add + local.set $8 + local.get $8 + local.get $8 + i32.mul + local.get $7 + local.get $5 + i32.shr_u + i32.le_u + if + local.get $8 + local.set $6 + end + local.get $5 + i32.const 2 + i32.sub + local.set $5 + end + br $continue|25 + end + end + end + local.get $6 + br $~lib/math/IntegerMath.sqrt|inlined.2 + end + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3361 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.sqrt|inlined.2 (result i32) + i32.const 2 + local.set $0 + local.get $0 + i32.const 2 + i32.lt_u + if + local.get $0 + br $~lib/math/IntegerMath.sqrt|inlined.2 + end + i32.const 2 + local.set $2 + local.get $0 + i32.const 2 + i32.shr_u + local.set $5 + block $break|26 + loop $continue|26 + local.get $5 + if (result i32) + local.get $5 + local.get $0 + i32.ne + else + local.get $5 + end + if + block + local.get $2 + i32.const 2 + i32.add + local.set $2 + local.get $0 + local.get $2 + i32.shr_u + local.set $5 + end + br $continue|26 + end + end + end + local.get $2 + i32.const 2 + i32.sub + local.set $2 + local.get $0 + local.set $6 + i32.const 0 + local.set $7 + block $break|27 + loop $continue|27 + local.get $2 + i32.const 0 + i32.ge_s + if + block + local.get $7 + i32.const 1 + i32.shl + local.set $7 + local.get $7 + i32.const 1 + i32.add + local.set $8 + local.get $8 + local.get $8 + i32.mul + local.get $6 + local.get $2 + i32.shr_u + i32.le_u + if + local.get $8 + local.set $7 + end + local.get $2 + i32.const 2 + i32.sub + local.set $2 + end + br $continue|27 + end + end + end + local.get $7 + br $~lib/math/IntegerMath.sqrt|inlined.2 + end + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3362 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.sqrt|inlined.2 (result i64) + i64.const 2 + local.set $3 + local.get $3 + i64.const 0 + i64.lt_s + if + i32.const 0 + i32.const 40 + i32.const 2415 + i32.const 19 + call $~lib/env/abort + unreachable + end + local.get $3 + i64.const 2 + i64.lt_s + if + local.get $3 + br $~lib/math/IntegerMath.sqrt|inlined.2 + end + i32.const 2 + local.set $0 + local.get $3 + i64.const 2 + i64.shr_s + local.set $9 + block $break|28 + loop $continue|28 + local.get $9 + i64.const 0 + i64.ne + if (result i64) + local.get $9 + local.get $3 + i64.ne + i64.extend_i32_u + else + local.get $9 + end + i64.const 0 + i64.ne + if + block + local.get $0 + i32.const 2 + i32.add + local.set $0 + local.get $3 + local.get $0 + i64.extend_i32_s + i64.shr_s + local.set $9 + end + br $continue|28 + end + end + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 + local.get $3 + local.set $10 + i64.const 0 + local.set $11 + block $break|29 + loop $continue|29 + local.get $0 + i32.const 0 + i32.ge_s + if + block + local.get $11 + i64.const 1 + i64.shl + local.set $11 + local.get $11 + i64.const 1 + i64.add + local.set $12 + local.get $12 + local.get $12 + i64.mul + local.get $10 + local.get $0 + i64.extend_i32_s + i64.shr_u + i64.le_u + if + local.get $12 + local.set $11 + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 + end + br $continue|29 + end + end + end + local.get $11 + br $~lib/math/IntegerMath.sqrt|inlined.2 + end + i64.const 1 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3363 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.sqrt|inlined.2 (result i64) + i64.const 2 + local.set $3 + local.get $3 + i64.const 2 + i64.lt_u + if + local.get $3 + br $~lib/math/IntegerMath.sqrt|inlined.2 + end + i32.const 2 + local.set $0 + local.get $3 + i64.const 2 + i64.shr_u + local.set $9 + block $break|30 + loop $continue|30 + local.get $9 + i64.const 0 + i64.ne + if (result i64) + local.get $9 + local.get $3 + i64.ne + i64.extend_i32_u + else + local.get $9 + end + i64.const 0 + i64.ne + if + block + local.get $0 + i32.const 2 + i32.add + local.set $0 + local.get $3 + local.get $0 + i64.extend_i32_s + i64.shr_u + local.set $9 + end + br $continue|30 + end + end + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 + local.get $3 + local.set $11 + i64.const 0 + local.set $10 + block $break|31 + loop $continue|31 + local.get $0 + i32.const 0 + i32.ge_s + if + block + local.get $10 + i64.const 1 + i64.shl + local.set $10 + local.get $10 + i64.const 1 + i64.add + local.set $12 + local.get $12 + local.get $12 + i64.mul + local.get $11 + local.get $0 + i64.extend_i32_s + i64.shr_u + i64.le_u + if + local.get $12 + local.set $10 + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 + end + br $continue|31 + end + end + end + local.get $10 + br $~lib/math/IntegerMath.sqrt|inlined.2 + end + i64.const 1 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3364 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.sqrt|inlined.3 (result i32) + i32.const 3 + local.set $0 + local.get $0 + i32.const 0 + i32.lt_s + if + i32.const 0 + i32.const 40 + i32.const 2415 + i32.const 19 + call $~lib/env/abort + unreachable + end + local.get $0 + i32.const 2 + i32.lt_s + if + local.get $0 + br $~lib/math/IntegerMath.sqrt|inlined.3 + end + i32.const 2 + local.set $5 + local.get $0 + i32.const 2 + i32.shr_s + local.set $2 + block $break|32 + loop $continue|32 + local.get $2 + if (result i32) + local.get $2 + local.get $0 + i32.ne + else + local.get $2 + end + if + block + local.get $5 + i32.const 2 + i32.add + local.set $5 + local.get $0 + local.get $5 + i32.const 16 + i32.shl + i32.const 16 + i32.shr_s + i32.shr_s + local.set $2 + end + br $continue|32 + end + end + end + local.get $5 + i32.const 2 + i32.sub + local.set $5 + local.get $0 + local.set $7 + i32.const 0 + local.set $6 + block $break|33 + loop $continue|33 + local.get $5 + i32.const 0 + i32.ge_s + if + block + local.get $6 + i32.const 1 + i32.shl + local.set $6 + local.get $6 + i32.const 1 + i32.add + local.set $8 + local.get $8 + local.get $8 + i32.mul + local.get $7 + local.get $5 + i32.shr_u + i32.le_u + if + local.get $8 + local.set $6 + end + local.get $5 + i32.const 2 + i32.sub + local.set $5 + end + br $continue|33 + end + end + end + local.get $6 + br $~lib/math/IntegerMath.sqrt|inlined.3 + end + i32.const 16 + i32.shl + i32.const 16 + i32.shr_s + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3365 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.sqrt|inlined.3 (result i32) + i32.const 3 + local.set $0 + local.get $0 + i32.const 0 + i32.lt_s + if + i32.const 0 + i32.const 40 + i32.const 2415 + i32.const 19 + call $~lib/env/abort + unreachable + end + local.get $0 + i32.const 2 + i32.lt_s + if + local.get $0 + br $~lib/math/IntegerMath.sqrt|inlined.3 + end + i32.const 2 + local.set $2 + local.get $0 + i32.const 2 + i32.shr_s + local.set $5 + block $break|34 + loop $continue|34 + local.get $5 + if (result i32) + local.get $5 + local.get $0 + i32.ne + else + local.get $5 + end + if + block + local.get $2 + i32.const 2 + i32.add + local.set $2 + local.get $0 + local.get $2 + i32.shr_s + local.set $5 + end + br $continue|34 + end + end + end + local.get $2 + i32.const 2 + i32.sub + local.set $2 + local.get $0 + local.set $6 + i32.const 0 + local.set $7 + block $break|35 + loop $continue|35 + local.get $2 + i32.const 0 + i32.ge_s + if + block + local.get $7 + i32.const 1 + i32.shl + local.set $7 + local.get $7 + i32.const 1 + i32.add + local.set $8 + local.get $8 + local.get $8 + i32.mul + local.get $6 + local.get $2 + i32.shr_u + i32.le_u + if + local.get $8 + local.set $7 + end + local.get $2 + i32.const 2 + i32.sub + local.set $2 + end + br $continue|35 + end + end + end + local.get $7 + br $~lib/math/IntegerMath.sqrt|inlined.3 + end + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3366 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.sqrt|inlined.3 (result i32) + i32.const 3 + local.set $0 + local.get $0 + i32.const 2 + i32.lt_u + if + local.get $0 + br $~lib/math/IntegerMath.sqrt|inlined.3 + end + i32.const 2 + local.set $5 + local.get $0 + i32.const 2 + i32.shr_u + local.set $2 + block $break|36 + loop $continue|36 + local.get $2 + if (result i32) + local.get $2 + local.get $0 + i32.ne + else + local.get $2 + end + if + block + local.get $5 + i32.const 2 + i32.add + local.set $5 + local.get $0 + local.get $5 + i32.shr_u + local.set $2 + end + br $continue|36 + end + end + end + local.get $5 + i32.const 2 + i32.sub + local.set $5 + local.get $0 + local.set $7 + i32.const 0 + local.set $6 + block $break|37 + loop $continue|37 + local.get $5 + i32.const 0 + i32.ge_s + if + block + local.get $6 + i32.const 1 + i32.shl + local.set $6 + local.get $6 + i32.const 1 + i32.add + local.set $8 + local.get $8 + local.get $8 + i32.mul + local.get $7 + local.get $5 + i32.shr_u + i32.le_u + if + local.get $8 + local.set $6 + end + local.get $5 + i32.const 2 + i32.sub + local.set $5 + end + br $continue|37 + end + end + end + local.get $6 + br $~lib/math/IntegerMath.sqrt|inlined.3 + end + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3367 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.sqrt|inlined.3 (result i64) + i64.const 3 + local.set $3 + local.get $3 + i64.const 0 + i64.lt_s + if + i32.const 0 + i32.const 40 + i32.const 2415 + i32.const 19 + call $~lib/env/abort + unreachable + end + local.get $3 + i64.const 2 + i64.lt_s + if + local.get $3 + br $~lib/math/IntegerMath.sqrt|inlined.3 + end + i32.const 2 + local.set $0 + local.get $3 + i64.const 2 + i64.shr_s + local.set $9 + block $break|38 + loop $continue|38 + local.get $9 + i64.const 0 + i64.ne + if (result i64) + local.get $9 + local.get $3 + i64.ne + i64.extend_i32_u + else + local.get $9 + end + i64.const 0 + i64.ne + if + block + local.get $0 + i32.const 2 + i32.add + local.set $0 + local.get $3 + local.get $0 + i64.extend_i32_s + i64.shr_s + local.set $9 + end + br $continue|38 + end + end + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 + local.get $3 + local.set $10 + i64.const 0 + local.set $11 + block $break|39 + loop $continue|39 + local.get $0 + i32.const 0 + i32.ge_s + if + block + local.get $11 + i64.const 1 + i64.shl + local.set $11 + local.get $11 + i64.const 1 + i64.add + local.set $12 + local.get $12 + local.get $12 + i64.mul + local.get $10 + local.get $0 + i64.extend_i32_s + i64.shr_u + i64.le_u + if + local.get $12 + local.set $11 + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 + end + br $continue|39 + end + end + end + local.get $11 + br $~lib/math/IntegerMath.sqrt|inlined.3 + end + i64.const 1 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3368 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.sqrt|inlined.3 (result i64) + i64.const 3 + local.set $3 + local.get $3 + i64.const 2 + i64.lt_u + if + local.get $3 + br $~lib/math/IntegerMath.sqrt|inlined.3 + end + i32.const 2 + local.set $0 + local.get $3 + i64.const 2 + i64.shr_u + local.set $9 + block $break|40 + loop $continue|40 + local.get $9 + i64.const 0 + i64.ne + if (result i64) + local.get $9 + local.get $3 + i64.ne + i64.extend_i32_u + else + local.get $9 + end + i64.const 0 + i64.ne + if + block + local.get $0 + i32.const 2 + i32.add + local.set $0 + local.get $3 + local.get $0 + i64.extend_i32_s + i64.shr_u + local.set $9 + end + br $continue|40 + end + end + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 + local.get $3 + local.set $11 + i64.const 0 + local.set $10 + block $break|41 + loop $continue|41 + local.get $0 + i32.const 0 + i32.ge_s + if + block + local.get $10 + i64.const 1 + i64.shl + local.set $10 + local.get $10 + i64.const 1 + i64.add + local.set $12 + local.get $12 + local.get $12 + i64.mul + local.get $11 + local.get $0 + i64.extend_i32_s + i64.shr_u + i64.le_u + if + local.get $12 + local.set $10 + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 + end + br $continue|41 + end + end + end + local.get $10 + br $~lib/math/IntegerMath.sqrt|inlined.3 + end + i64.const 1 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3369 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.sqrt|inlined.4 (result i32) + i32.const 4 + local.set $0 + local.get $0 + i32.const 0 + i32.lt_s + if + i32.const 0 + i32.const 40 + i32.const 2415 + i32.const 19 + call $~lib/env/abort + unreachable + end + local.get $0 + i32.const 2 + i32.lt_s + if + local.get $0 + br $~lib/math/IntegerMath.sqrt|inlined.4 + end + i32.const 2 + local.set $2 + local.get $0 + i32.const 2 + i32.shr_s + local.set $5 + block $break|42 + loop $continue|42 + local.get $5 + if (result i32) + local.get $5 + local.get $0 + i32.ne + else + local.get $5 + end + if + block + local.get $2 + i32.const 2 + i32.add + local.set $2 + local.get $0 + local.get $2 + i32.const 16 + i32.shl + i32.const 16 + i32.shr_s + i32.shr_s + local.set $5 + end + br $continue|42 + end + end + end + local.get $2 + i32.const 2 + i32.sub + local.set $2 + local.get $0 + local.set $6 + i32.const 0 + local.set $7 + block $break|43 + loop $continue|43 + local.get $2 + i32.const 0 + i32.ge_s + if + block + local.get $7 + i32.const 1 + i32.shl + local.set $7 + local.get $7 + i32.const 1 + i32.add + local.set $8 + local.get $8 + local.get $8 + i32.mul + local.get $6 + local.get $2 + i32.shr_u + i32.le_u + if + local.get $8 + local.set $7 + end + local.get $2 + i32.const 2 + i32.sub + local.set $2 + end + br $continue|43 + end + end + end + local.get $7 + br $~lib/math/IntegerMath.sqrt|inlined.4 + end + i32.const 16 + i32.shl + i32.const 16 + i32.shr_s + i32.const 2 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3370 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.sqrt|inlined.4 (result i32) + i32.const 4 + local.set $0 + local.get $0 + i32.const 0 + i32.lt_s + if + i32.const 0 + i32.const 40 + i32.const 2415 + i32.const 19 + call $~lib/env/abort + unreachable + end + local.get $0 + i32.const 2 + i32.lt_s + if + local.get $0 + br $~lib/math/IntegerMath.sqrt|inlined.4 + end + i32.const 2 + local.set $5 + local.get $0 + i32.const 2 + i32.shr_s + local.set $2 + block $break|44 + loop $continue|44 + local.get $2 + if (result i32) + local.get $2 + local.get $0 + i32.ne + else + local.get $2 + end + if + block + local.get $5 + i32.const 2 + i32.add + local.set $5 + local.get $0 + local.get $5 + i32.shr_s + local.set $2 + end + br $continue|44 + end + end + end + local.get $5 + i32.const 2 + i32.sub + local.set $5 + local.get $0 + local.set $7 + i32.const 0 + local.set $6 + block $break|45 + loop $continue|45 + local.get $5 + i32.const 0 + i32.ge_s + if + block + local.get $6 + i32.const 1 + i32.shl + local.set $6 + local.get $6 + i32.const 1 + i32.add + local.set $8 + local.get $8 + local.get $8 + i32.mul + local.get $7 + local.get $5 + i32.shr_u + i32.le_u + if + local.get $8 + local.set $6 + end + local.get $5 + i32.const 2 + i32.sub + local.set $5 + end + br $continue|45 + end + end + end + local.get $6 + br $~lib/math/IntegerMath.sqrt|inlined.4 + end + i32.const 2 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3371 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.sqrt|inlined.4 (result i32) + i32.const 4 + local.set $0 + local.get $0 + i32.const 2 + i32.lt_u + if + local.get $0 + br $~lib/math/IntegerMath.sqrt|inlined.4 + end + i32.const 2 + local.set $2 + local.get $0 + i32.const 2 + i32.shr_u + local.set $5 + block $break|46 + loop $continue|46 + local.get $5 + if (result i32) + local.get $5 + local.get $0 + i32.ne + else + local.get $5 + end + if + block + local.get $2 + i32.const 2 + i32.add + local.set $2 + local.get $0 + local.get $2 + i32.shr_u + local.set $5 + end + br $continue|46 + end + end + end + local.get $2 + i32.const 2 + i32.sub + local.set $2 + local.get $0 + local.set $6 + i32.const 0 + local.set $7 + block $break|47 + loop $continue|47 + local.get $2 + i32.const 0 + i32.ge_s + if + block + local.get $7 + i32.const 1 + i32.shl + local.set $7 + local.get $7 + i32.const 1 + i32.add + local.set $8 + local.get $8 + local.get $8 + i32.mul + local.get $6 + local.get $2 + i32.shr_u + i32.le_u + if + local.get $8 + local.set $7 + end + local.get $2 + i32.const 2 + i32.sub + local.set $2 + end + br $continue|47 + end + end + end + local.get $7 + br $~lib/math/IntegerMath.sqrt|inlined.4 + end + i32.const 2 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3372 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.sqrt|inlined.4 (result i64) + i64.const 4 + local.set $3 + local.get $3 + i64.const 0 + i64.lt_s + if + i32.const 0 + i32.const 40 + i32.const 2415 + i32.const 19 + call $~lib/env/abort + unreachable + end + local.get $3 + i64.const 2 + i64.lt_s + if + local.get $3 + br $~lib/math/IntegerMath.sqrt|inlined.4 + end + i32.const 2 + local.set $0 + local.get $3 + i64.const 2 + i64.shr_s + local.set $9 + block $break|48 + loop $continue|48 + local.get $9 + i64.const 0 + i64.ne + if (result i64) + local.get $9 + local.get $3 + i64.ne + i64.extend_i32_u + else + local.get $9 + end + i64.const 0 + i64.ne + if + block + local.get $0 + i32.const 2 + i32.add + local.set $0 + local.get $3 + local.get $0 + i64.extend_i32_s + i64.shr_s + local.set $9 + end + br $continue|48 + end + end + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 + local.get $3 + local.set $10 + i64.const 0 + local.set $11 + block $break|49 + loop $continue|49 + local.get $0 + i32.const 0 + i32.ge_s + if + block + local.get $11 + i64.const 1 + i64.shl + local.set $11 + local.get $11 + i64.const 1 + i64.add + local.set $12 + local.get $12 + local.get $12 + i64.mul + local.get $10 + local.get $0 + i64.extend_i32_s + i64.shr_u + i64.le_u + if + local.get $12 + local.set $11 + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 + end + br $continue|49 + end + end + end + local.get $11 + br $~lib/math/IntegerMath.sqrt|inlined.4 + end + i64.const 2 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3373 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.sqrt|inlined.4 (result i64) + i64.const 4 + local.set $3 + local.get $3 + i64.const 2 + i64.lt_u + if + local.get $3 + br $~lib/math/IntegerMath.sqrt|inlined.4 + end + i32.const 2 + local.set $0 + local.get $3 + i64.const 2 + i64.shr_u + local.set $9 + block $break|50 + loop $continue|50 + local.get $9 + i64.const 0 + i64.ne + if (result i64) + local.get $9 + local.get $3 + i64.ne + i64.extend_i32_u + else + local.get $9 + end + i64.const 0 + i64.ne + if + block + local.get $0 + i32.const 2 + i32.add + local.set $0 + local.get $3 + local.get $0 + i64.extend_i32_s + i64.shr_u + local.set $9 + end + br $continue|50 + end + end + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 + local.get $3 + local.set $11 + i64.const 0 + local.set $10 + block $break|51 + loop $continue|51 + local.get $0 + i32.const 0 + i32.ge_s + if + block + local.get $10 + i64.const 1 + i64.shl + local.set $10 + local.get $10 + i64.const 1 + i64.add + local.set $12 + local.get $12 + local.get $12 + i64.mul + local.get $11 + local.get $0 + i64.extend_i32_s + i64.shr_u + i64.le_u + if + local.get $12 + local.set $10 + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 + end + br $continue|51 + end + end + end + local.get $10 + br $~lib/math/IntegerMath.sqrt|inlined.4 + end + i64.const 2 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3374 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.sqrt|inlined.5 (result i32) + global.get $~lib/builtins/i16.MAX_VALUE + local.set $0 + local.get $0 + i32.const 0 + i32.lt_s + if + i32.const 0 + i32.const 40 + i32.const 2415 + i32.const 19 + call $~lib/env/abort + unreachable + end + local.get $0 + i32.const 2 + i32.lt_s + if + local.get $0 + br $~lib/math/IntegerMath.sqrt|inlined.5 + end + i32.const 2 + local.set $5 + local.get $0 + i32.const 2 + i32.shr_s + local.set $2 + block $break|52 + loop $continue|52 + local.get $2 + if (result i32) + local.get $2 + local.get $0 + i32.ne + else + local.get $2 + end + if + block + local.get $5 + i32.const 2 + i32.add + local.set $5 + local.get $0 + local.get $5 + i32.const 16 + i32.shl + i32.const 16 + i32.shr_s + i32.shr_s + local.set $2 + end + br $continue|52 + end + end + end + local.get $5 + i32.const 2 + i32.sub + local.set $5 + local.get $0 + local.set $7 + i32.const 0 + local.set $6 + block $break|53 + loop $continue|53 + local.get $5 + i32.const 0 + i32.ge_s + if + block + local.get $6 + i32.const 1 + i32.shl + local.set $6 + local.get $6 + i32.const 1 + i32.add + local.set $8 + local.get $8 + local.get $8 + i32.mul + local.get $7 + local.get $5 + i32.shr_u + i32.le_u + if + local.get $8 + local.set $6 + end + local.get $5 + i32.const 2 + i32.sub + local.set $5 + end + br $continue|53 + end + end + end + local.get $6 + br $~lib/math/IntegerMath.sqrt|inlined.5 + end + i32.const 16 + i32.shl + i32.const 16 + i32.shr_s + i32.const 181 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3375 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.sqrt|inlined.0 (result i32) + global.get $~lib/builtins/i16.MAX_VALUE + local.set $0 + local.get $0 + i32.const 65535 + i32.and + i32.const 2 + i32.lt_u + if + local.get $0 + br $~lib/math/IntegerMath.sqrt|inlined.0 + end + i32.const 2 + local.set $2 + local.get $0 + i32.const 65535 + i32.and + i32.const 2 + i32.shr_u + local.set $5 + block $break|54 + loop $continue|54 + local.get $5 + if (result i32) + local.get $5 + local.get $0 + i32.const 65535 + i32.and + i32.ne + else + local.get $5 + end + if + block + local.get $2 + i32.const 2 + i32.add + local.set $2 + local.get $0 + i32.const 65535 + i32.and + local.get $2 + i32.const 65535 + i32.and + i32.shr_u + local.set $5 + end + br $continue|54 + end + end + end + local.get $2 + i32.const 2 + i32.sub + local.set $2 + local.get $0 + i32.const 65535 + i32.and + local.set $6 + i32.const 0 + local.set $7 + block $break|55 + loop $continue|55 + local.get $2 + i32.const 0 + i32.ge_s + if + block + local.get $7 + i32.const 1 + i32.shl + local.set $7 + local.get $7 + i32.const 1 + i32.add + local.set $8 + local.get $8 + local.get $8 + i32.mul + local.get $6 + local.get $2 + i32.shr_u + i32.le_u + if + local.get $8 + local.set $7 + end + local.get $2 + i32.const 2 + i32.sub + local.set $2 + end + br $continue|55 + end + end + end + local.get $7 + br $~lib/math/IntegerMath.sqrt|inlined.0 + end + i32.const 65535 + i32.and + i32.const 181 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3376 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.sqrt|inlined.5 (result i32) + global.get $~lib/builtins/i16.MAX_VALUE + local.set $0 + local.get $0 + i32.const 0 + i32.lt_s + if + i32.const 0 + i32.const 40 + i32.const 2415 + i32.const 19 + call $~lib/env/abort + unreachable + end + local.get $0 + i32.const 2 + i32.lt_s + if + local.get $0 + br $~lib/math/IntegerMath.sqrt|inlined.5 + end + i32.const 2 + local.set $5 + local.get $0 + i32.const 2 + i32.shr_s + local.set $2 + block $break|56 + loop $continue|56 + local.get $2 + if (result i32) + local.get $2 + local.get $0 + i32.ne + else + local.get $2 + end + if + block + local.get $5 + i32.const 2 + i32.add + local.set $5 + local.get $0 + local.get $5 + i32.shr_s + local.set $2 + end + br $continue|56 + end + end + end + local.get $5 + i32.const 2 + i32.sub + local.set $5 + local.get $0 + local.set $7 + i32.const 0 + local.set $6 + block $break|57 + loop $continue|57 + local.get $5 + i32.const 0 + i32.ge_s + if + block + local.get $6 + i32.const 1 + i32.shl + local.set $6 + local.get $6 + i32.const 1 + i32.add + local.set $8 + local.get $8 + local.get $8 + i32.mul + local.get $7 + local.get $5 + i32.shr_u + i32.le_u + if + local.get $8 + local.set $6 + end + local.get $5 + i32.const 2 + i32.sub + local.set $5 + end + br $continue|57 + end + end + end + local.get $6 + br $~lib/math/IntegerMath.sqrt|inlined.5 + end + i32.const 181 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3377 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.sqrt|inlined.5 (result i32) + global.get $~lib/builtins/i16.MAX_VALUE + local.set $0 + local.get $0 + i32.const 2 + i32.lt_u + if + local.get $0 + br $~lib/math/IntegerMath.sqrt|inlined.5 + end + i32.const 2 + local.set $2 + local.get $0 + i32.const 2 + i32.shr_u + local.set $5 + block $break|58 + loop $continue|58 + local.get $5 + if (result i32) + local.get $5 + local.get $0 + i32.ne + else + local.get $5 + end + if + block + local.get $2 + i32.const 2 + i32.add + local.set $2 + local.get $0 + local.get $2 + i32.shr_u + local.set $5 + end + br $continue|58 + end + end + end + local.get $2 + i32.const 2 + i32.sub + local.set $2 + local.get $0 + local.set $6 + i32.const 0 + local.set $7 + block $break|59 + loop $continue|59 + local.get $2 + i32.const 0 + i32.ge_s + if + block + local.get $7 + i32.const 1 + i32.shl + local.set $7 + local.get $7 + i32.const 1 + i32.add + local.set $8 + local.get $8 + local.get $8 + i32.mul + local.get $6 + local.get $2 + i32.shr_u + i32.le_u + if + local.get $8 + local.set $7 + end + local.get $2 + i32.const 2 + i32.sub + local.set $2 + end + br $continue|59 + end + end + end + local.get $7 + br $~lib/math/IntegerMath.sqrt|inlined.5 + end + i32.const 181 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3378 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.sqrt|inlined.1 (result i32) + global.get $~lib/builtins/u16.MAX_VALUE + local.set $0 + local.get $0 + i32.const 2 + i32.lt_u + if + local.get $0 + br $~lib/math/IntegerMath.sqrt|inlined.1 + end + i32.const 2 + local.set $5 + local.get $0 + i32.const 2 + i32.shr_u + local.set $2 + block $break|60 + loop $continue|60 + local.get $2 + if (result i32) + local.get $2 + local.get $0 + i32.ne + else + local.get $2 + end + if + block + local.get $5 + i32.const 2 + i32.add + local.set $5 + local.get $0 + local.get $5 + i32.const 65535 + i32.and + i32.shr_u + local.set $2 + end + br $continue|60 + end + end + end + local.get $5 + i32.const 2 + i32.sub + local.set $5 + local.get $0 + local.set $7 + i32.const 0 + local.set $6 + block $break|61 + loop $continue|61 + local.get $5 + i32.const 0 + i32.ge_s + if + block + local.get $6 + i32.const 1 + i32.shl + local.set $6 + local.get $6 + i32.const 1 + i32.add + local.set $8 + local.get $8 + local.get $8 + i32.mul + local.get $7 + local.get $5 + i32.shr_u + i32.le_u + if + local.get $8 + local.set $6 + end + local.get $5 + i32.const 2 + i32.sub + local.set $5 + end + br $continue|61 + end + end + end + local.get $6 + br $~lib/math/IntegerMath.sqrt|inlined.1 + end + i32.const 65535 + i32.and + i32.const 255 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3379 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.sqrt|inlined.6 (result i32) + global.get $~lib/builtins/i32.MAX_VALUE + local.set $0 + local.get $0 + i32.const 0 + i32.lt_s + if + i32.const 0 + i32.const 40 + i32.const 2415 + i32.const 19 + call $~lib/env/abort + unreachable + end + local.get $0 + i32.const 2 + i32.lt_s + if + local.get $0 + br $~lib/math/IntegerMath.sqrt|inlined.6 + end + i32.const 2 + local.set $2 + local.get $0 + i32.const 2 + i32.shr_s + local.set $5 + block $break|62 + loop $continue|62 + local.get $5 + if (result i32) + local.get $5 + local.get $0 + i32.ne + else + local.get $5 + end + if + block + local.get $2 + i32.const 2 + i32.add + local.set $2 + local.get $0 + local.get $2 + i32.shr_s + local.set $5 + end + br $continue|62 + end + end + end + local.get $2 + i32.const 2 + i32.sub + local.set $2 + local.get $0 + local.set $6 + i32.const 0 + local.set $7 + block $break|63 + loop $continue|63 + local.get $2 + i32.const 0 + i32.ge_s + if + block + local.get $7 + i32.const 1 + i32.shl + local.set $7 + local.get $7 + i32.const 1 + i32.add + local.set $8 + local.get $8 + local.get $8 + i32.mul + local.get $6 + local.get $2 + i32.shr_u + i32.le_u + if + local.get $8 + local.set $7 + end + local.get $2 + i32.const 2 + i32.sub + local.set $2 + end + br $continue|63 + end + end + end + local.get $7 + br $~lib/math/IntegerMath.sqrt|inlined.6 + end + i32.const 46340 + i32.eq + i32.eqz + if + i32.const 0 i32.const 8 - i32.const 3361 + i32.const 3380 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.sqrt|inlined.6 (result i32) + global.get $~lib/builtins/i32.MAX_VALUE + local.set $0 + local.get $0 + i32.const 2 + i32.lt_u + if + local.get $0 + br $~lib/math/IntegerMath.sqrt|inlined.6 + end + i32.const 2 + local.set $5 + local.get $0 + i32.const 2 + i32.shr_u + local.set $2 + block $break|64 + loop $continue|64 + local.get $2 + if (result i32) + local.get $2 + local.get $0 + i32.ne + else + local.get $2 + end + if + block + local.get $5 + i32.const 2 + i32.add + local.set $5 + local.get $0 + local.get $5 + i32.shr_u + local.set $2 + end + br $continue|64 + end + end + end + local.get $5 + i32.const 2 + i32.sub + local.set $5 + local.get $0 + local.set $7 + i32.const 0 + local.set $6 + block $break|65 + loop $continue|65 + local.get $5 + i32.const 0 + i32.ge_s + if + block + local.get $6 + i32.const 1 + i32.shl + local.set $6 + local.get $6 + i32.const 1 + i32.add + local.set $8 + local.get $8 + local.get $8 + i32.mul + local.get $7 + local.get $5 + i32.shr_u + i32.le_u + if + local.get $8 + local.set $6 + end + local.get $5 + i32.const 2 + i32.sub + local.set $5 + end + br $continue|65 + end + end + end + local.get $6 + br $~lib/math/IntegerMath.sqrt|inlined.6 + end + i32.const 46340 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3381 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.sqrt|inlined.7 (result i32) + global.get $~lib/builtins/u32.MAX_VALUE + local.set $0 + local.get $0 + i32.const 2 + i32.lt_u + if + local.get $0 + br $~lib/math/IntegerMath.sqrt|inlined.7 + end + i32.const 2 + local.set $2 + local.get $0 + i32.const 2 + i32.shr_u + local.set $5 + block $break|66 + loop $continue|66 + local.get $5 + if (result i32) + local.get $5 + local.get $0 + i32.ne + else + local.get $5 + end + if + block + local.get $2 + i32.const 2 + i32.add + local.set $2 + local.get $0 + local.get $2 + i32.shr_u + local.set $5 + end + br $continue|66 + end + end + end + local.get $2 + i32.const 2 + i32.sub + local.set $2 + local.get $0 + local.set $6 + i32.const 0 + local.set $7 + block $break|67 + loop $continue|67 + local.get $2 + i32.const 0 + i32.ge_s + if + block + local.get $7 + i32.const 1 + i32.shl + local.set $7 + local.get $7 + i32.const 1 + i32.add + local.set $8 + local.get $8 + local.get $8 + i32.mul + local.get $6 + local.get $2 + i32.shr_u + i32.le_u + if + local.get $8 + local.set $7 + end + local.get $2 + i32.const 2 + i32.sub + local.set $2 + end + br $continue|67 + end + end + end + local.get $7 + br $~lib/math/IntegerMath.sqrt|inlined.7 + end + i32.const 65535 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3382 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.sqrt|inlined.5 (result i64) + global.get $~lib/builtins/i64.MAX_VALUE + local.set $3 + local.get $3 + i64.const 0 + i64.lt_s + if + i32.const 0 + i32.const 40 + i32.const 2415 + i32.const 19 + call $~lib/env/abort + unreachable + end + local.get $3 + i64.const 2 + i64.lt_s + if + local.get $3 + br $~lib/math/IntegerMath.sqrt|inlined.5 + end + i32.const 2 + local.set $0 + local.get $3 + i64.const 2 + i64.shr_s + local.set $9 + block $break|68 + loop $continue|68 + local.get $9 + i64.const 0 + i64.ne + if (result i64) + local.get $9 + local.get $3 + i64.ne + i64.extend_i32_u + else + local.get $9 + end + i64.const 0 + i64.ne + if + block + local.get $0 + i32.const 2 + i32.add + local.set $0 + local.get $3 + local.get $0 + i64.extend_i32_s + i64.shr_s + local.set $9 + end + br $continue|68 + end + end + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 + local.get $3 + local.set $10 + i64.const 0 + local.set $11 + block $break|69 + loop $continue|69 + local.get $0 + i32.const 0 + i32.ge_s + if + block + local.get $11 + i64.const 1 + i64.shl + local.set $11 + local.get $11 + i64.const 1 + i64.add + local.set $12 + local.get $12 + local.get $12 + i64.mul + local.get $10 + local.get $0 + i64.extend_i32_s + i64.shr_u + i64.le_u + if + local.get $12 + local.set $11 + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 + end + br $continue|69 + end + end + end + local.get $11 + br $~lib/math/IntegerMath.sqrt|inlined.5 + end + i64.const 3037000499 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3383 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.sqrt|inlined.5 (result i64) + global.get $~lib/builtins/i64.MAX_VALUE + local.set $3 + local.get $3 + i64.const 2 + i64.lt_u + if + local.get $3 + br $~lib/math/IntegerMath.sqrt|inlined.5 + end + i32.const 2 + local.set $0 + local.get $3 + i64.const 2 + i64.shr_u + local.set $9 + block $break|70 + loop $continue|70 + local.get $9 + i64.const 0 + i64.ne + if (result i64) + local.get $9 + local.get $3 + i64.ne + i64.extend_i32_u + else + local.get $9 + end + i64.const 0 + i64.ne + if + block + local.get $0 + i32.const 2 + i32.add + local.set $0 + local.get $3 + local.get $0 + i64.extend_i32_s + i64.shr_u + local.set $9 + end + br $continue|70 + end + end + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 + local.get $3 + local.set $11 + i64.const 0 + local.set $10 + block $break|71 + loop $continue|71 + local.get $0 + i32.const 0 + i32.ge_s + if + block + local.get $10 + i64.const 1 + i64.shl + local.set $10 + local.get $10 + i64.const 1 + i64.add + local.set $12 + local.get $12 + local.get $12 + i64.mul + local.get $11 + local.get $0 + i64.extend_i32_s + i64.shr_u + i64.le_u + if + local.get $12 + local.set $10 + end + local.get $0 + i32.const 2 + i32.sub + local.set $0 + end + br $continue|71 + end + end + end + local.get $10 + br $~lib/math/IntegerMath.sqrt|inlined.5 + end + i64.const 3037000499 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3384 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $~lib/builtins/u64.MAX_VALUE + call $~lib/math/IntegerMath.sqrt + i64.const 4294967295 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3385 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 0 + i32.const 0 + call $~lib/math/ipow64 + i64.const 1 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3389 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 0 + i32.const 1 + call $~lib/math/ipow64 + i64.const 0 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3390 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 0 + i32.const 2 + call $~lib/math/ipow64 + i64.const 0 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3391 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 0 + i32.const 3 + call $~lib/math/ipow64 + i64.const 0 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3392 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 1 + i32.const 0 + call $~lib/math/ipow64 + i64.const 1 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3394 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 1 + i32.const 1 + call $~lib/math/ipow64 + i64.const 1 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3395 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 1 + i32.const 2 + call $~lib/math/ipow64 + i64.const 1 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3396 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 1 + i32.const 3 + call $~lib/math/ipow64 + i64.const 1 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3397 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 2 + i32.const 0 + call $~lib/math/ipow64 + i64.const 1 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3399 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 2 + i32.const 1 + call $~lib/math/ipow64 + i64.const 2 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3400 i32.const 0 call $~lib/env/abort unreachable @@ -43576,7 +47484,7 @@ if i32.const 0 i32.const 8 - i32.const 3362 + i32.const 3401 i32.const 0 call $~lib/env/abort unreachable @@ -43590,7 +47498,7 @@ if i32.const 0 i32.const 8 - i32.const 3363 + i32.const 3402 i32.const 0 call $~lib/env/abort unreachable @@ -43604,7 +47512,7 @@ if i32.const 0 i32.const 8 - i32.const 3365 + i32.const 3404 i32.const 0 call $~lib/env/abort unreachable @@ -43618,7 +47526,7 @@ if i32.const 0 i32.const 8 - i32.const 3366 + i32.const 3405 i32.const 0 call $~lib/env/abort unreachable @@ -43632,7 +47540,7 @@ if i32.const 0 i32.const 8 - i32.const 3367 + i32.const 3406 i32.const 0 call $~lib/env/abort unreachable @@ -43646,7 +47554,7 @@ if i32.const 0 i32.const 8 - i32.const 3368 + i32.const 3407 i32.const 0 call $~lib/env/abort unreachable @@ -43660,7 +47568,7 @@ if i32.const 0 i32.const 8 - i32.const 3370 + i32.const 3409 i32.const 0 call $~lib/env/abort unreachable @@ -43674,7 +47582,7 @@ if i32.const 0 i32.const 8 - i32.const 3371 + i32.const 3410 i32.const 0 call $~lib/env/abort unreachable @@ -43688,7 +47596,7 @@ if i32.const 0 i32.const 8 - i32.const 3372 + i32.const 3411 i32.const 0 call $~lib/env/abort unreachable @@ -43702,7 +47610,7 @@ if i32.const 0 i32.const 8 - i32.const 3373 + i32.const 3412 i32.const 0 call $~lib/env/abort unreachable @@ -43716,7 +47624,7 @@ if i32.const 0 i32.const 8 - i32.const 3375 + i32.const 3414 i32.const 0 call $~lib/env/abort unreachable @@ -43730,7 +47638,7 @@ if i32.const 0 i32.const 8 - i32.const 3376 + i32.const 3415 i32.const 0 call $~lib/env/abort unreachable @@ -43744,7 +47652,7 @@ if i32.const 0 i32.const 8 - i32.const 3377 + i32.const 3416 i32.const 0 call $~lib/env/abort unreachable @@ -43758,7 +47666,7 @@ if i32.const 0 i32.const 8 - i32.const 3378 + i32.const 3417 i32.const 0 call $~lib/env/abort unreachable @@ -43772,7 +47680,7 @@ if i32.const 0 i32.const 8 - i32.const 3379 + i32.const 3418 i32.const 0 call $~lib/env/abort unreachable @@ -43786,7 +47694,7 @@ if i32.const 0 i32.const 8 - i32.const 3380 + i32.const 3419 i32.const 0 call $~lib/env/abort unreachable @@ -43800,7 +47708,7 @@ if i32.const 0 i32.const 8 - i32.const 3381 + i32.const 3420 i32.const 0 call $~lib/env/abort unreachable @@ -43818,7 +47726,7 @@ if i32.const 0 i32.const 8 - i32.const 3383 + i32.const 3422 i32.const 0 call $~lib/env/abort unreachable @@ -43832,7 +47740,7 @@ if i32.const 0 i32.const 8 - i32.const 3387 + i32.const 3426 i32.const 0 call $~lib/env/abort unreachable @@ -43846,7 +47754,7 @@ if i32.const 0 i32.const 8 - i32.const 3388 + i32.const 3427 i32.const 0 call $~lib/env/abort unreachable @@ -43866,7 +47774,7 @@ if i32.const 0 i32.const 8 - i32.const 3389 + i32.const 3428 i32.const 0 call $~lib/env/abort unreachable @@ -43886,7 +47794,7 @@ if i32.const 0 i32.const 8 - i32.const 3390 + i32.const 3429 i32.const 0 call $~lib/env/abort unreachable @@ -43906,7 +47814,7 @@ if i32.const 0 i32.const 8 - i32.const 3391 + i32.const 3430 i32.const 0 call $~lib/env/abort unreachable @@ -43920,7 +47828,7 @@ if i32.const 0 i32.const 8 - i32.const 3392 + i32.const 3431 i32.const 0 call $~lib/env/abort unreachable @@ -43934,7 +47842,7 @@ if i32.const 0 i32.const 8 - i32.const 3393 + i32.const 3432 i32.const 0 call $~lib/env/abort unreachable @@ -43949,7 +47857,7 @@ if i32.const 0 i32.const 8 - i32.const 3394 + i32.const 3433 i32.const 0 call $~lib/env/abort unreachable @@ -43965,7 +47873,7 @@ if i32.const 0 i32.const 8 - i32.const 3395 + i32.const 3434 i32.const 0 call $~lib/env/abort unreachable @@ -43980,7 +47888,7 @@ if i32.const 0 i32.const 8 - i32.const 3396 + i32.const 3435 i32.const 0 call $~lib/env/abort unreachable @@ -43994,7 +47902,7 @@ if i32.const 0 i32.const 8 - i32.const 3397 + i32.const 3436 i32.const 0 call $~lib/env/abort unreachable @@ -44008,7 +47916,7 @@ if i32.const 0 i32.const 8 - i32.const 3398 + i32.const 3437 i32.const 0 call $~lib/env/abort unreachable @@ -44022,7 +47930,7 @@ if i32.const 0 i32.const 8 - i32.const 3399 + i32.const 3438 i32.const 0 call $~lib/env/abort unreachable @@ -44036,7 +47944,7 @@ if i32.const 0 i32.const 8 - i32.const 3400 + i32.const 3439 i32.const 0 call $~lib/env/abort unreachable @@ -44050,7 +47958,7 @@ if i32.const 0 i32.const 8 - i32.const 3401 + i32.const 3440 i32.const 0 call $~lib/env/abort unreachable @@ -44064,7 +47972,7 @@ if i32.const 0 i32.const 8 - i32.const 3402 + i32.const 3441 i32.const 0 call $~lib/env/abort unreachable @@ -44078,7 +47986,7 @@ if i32.const 0 i32.const 8 - i32.const 3406 + i32.const 3445 i32.const 0 call $~lib/env/abort unreachable @@ -44092,7 +48000,7 @@ if i32.const 0 i32.const 8 - i32.const 3407 + i32.const 3446 i32.const 0 call $~lib/env/abort unreachable @@ -44105,7 +48013,7 @@ if i32.const 0 i32.const 8 - i32.const 3408 + i32.const 3447 i32.const 0 call $~lib/env/abort unreachable @@ -44118,7 +48026,7 @@ if i32.const 0 i32.const 8 - i32.const 3409 + i32.const 3448 i32.const 0 call $~lib/env/abort unreachable @@ -44131,7 +48039,7 @@ if i32.const 0 i32.const 8 - i32.const 3410 + i32.const 3449 i32.const 0 call $~lib/env/abort unreachable @@ -44145,7 +48053,7 @@ if i32.const 0 i32.const 8 - i32.const 3411 + i32.const 3450 i32.const 0 call $~lib/env/abort unreachable @@ -44159,7 +48067,7 @@ if i32.const 0 i32.const 8 - i32.const 3412 + i32.const 3451 i32.const 0 call $~lib/env/abort unreachable @@ -44174,7 +48082,7 @@ if i32.const 0 i32.const 8 - i32.const 3413 + i32.const 3452 i32.const 0 call $~lib/env/abort unreachable @@ -44190,7 +48098,7 @@ if i32.const 0 i32.const 8 - i32.const 3414 + i32.const 3453 i32.const 0 call $~lib/env/abort unreachable @@ -44205,7 +48113,7 @@ if i32.const 0 i32.const 8 - i32.const 3415 + i32.const 3454 i32.const 0 call $~lib/env/abort unreachable @@ -44219,7 +48127,7 @@ if i32.const 0 i32.const 8 - i32.const 3416 + i32.const 3455 i32.const 0 call $~lib/env/abort unreachable @@ -44233,7 +48141,7 @@ if i32.const 0 i32.const 8 - i32.const 3417 + i32.const 3456 i32.const 0 call $~lib/env/abort unreachable @@ -44247,7 +48155,7 @@ if i32.const 0 i32.const 8 - i32.const 3418 + i32.const 3457 i32.const 0 call $~lib/env/abort unreachable @@ -44261,7 +48169,7 @@ if i32.const 0 i32.const 8 - i32.const 3419 + i32.const 3458 i32.const 0 call $~lib/env/abort unreachable @@ -44275,7 +48183,7 @@ if i32.const 0 i32.const 8 - i32.const 3420 + i32.const 3459 i32.const 0 call $~lib/env/abort unreachable @@ -44289,12 +48197,12 @@ if i32.const 0 i32.const 8 - i32.const 3421 + i32.const 3460 i32.const 0 call $~lib/env/abort unreachable end ) - (func $null (; 167 ;) (type $_) + (func $null (; 168 ;) (type $_) ) ) From 034c41dc389b3a4d2a5c9fd0350e64e2556c07e0 Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Tue, 19 Feb 2019 20:39:53 +0200 Subject: [PATCH 16/22] refactoring --- std/assembly/math.ts | 85 +- tests/compiler/std/math.optimized.wat | 1885 +++------------ tests/compiler/std/math.untouched.wat | 3161 ++----------------------- 3 files changed, 519 insertions(+), 4612 deletions(-) diff --git a/std/assembly/math.ts b/std/assembly/math.ts index 47984d9f49..5278e18848 100644 --- a/std/assembly/math.ts +++ b/std/assembly/math.ts @@ -2414,47 +2414,60 @@ export namespace IntegerMath { if (isSigned()) { if (x < 0) throw new RangeError("Math.sqrt received negative argument"); } - // Complexity: O(log n) - // Iterative version of approach described in this article: - // https://www.cs.uni-potsdam.de/ti/kreitz/PDF/03cucs-intsqrt.pdf - if (x < 2) return x; - let s = 2; - let xs = x >> 2; - while (xs && xs != x) { - s += 2; - xs = x >> s; - } - s -= 2; - if (sizeof() <= 4) { - let ux = x; - let res: u32 = 0; - while (s >= 0) { - res <<= 1; - let m = res + 1; - if (m * m <= (ux >> s)) { - res = m; - } - s -= 2; - } - return res; - } else { - let ux = x; - let res: u64 = 0; - while (s >= 0) { - res <<= 1; - let m = res + 1; - if (m * m <= (ux >> s)) { - res = m; - } - s -= 2; - } - return res; - } + if (sizeof() <= 4) return isqrt32(x); + if (sizeof() == 8) return isqrt64(x); } throw new TypeError("Unexpected generic type"); } } +// Complexity: O(log n) +// Iterative version of approach described in this article: +// https://www.cs.uni-potsdam.de/ti/kreitz/PDF/03cucs-intsqrt.pdf +export function isqrt32(x: u32): u32 { + if (x < 2) return x; + var s = 2; + var xs = x >> 2; + while (xs && xs != x) { + s += 2; + xs = x >> s; + } + s -= 2; + var ux = x; + var res: u32 = 0; + while (s >= 0) { + res <<= 1; + let m = res + 1; + if (m * m <= (ux >> s)) { + res = m; + } + s -= 2; + } + return res; +} + +export function isqrt64(x: u64): u64 { + if (x < 2) return x; + var s = 2; + var xs = x >> 2; + while (xs && xs != x) { + s += 2; + xs = x >> s; + } + s -= 2; + var ux = x; + var res: u64 = 0; + while (s >= 0) { + res <<= 1; + let m = res + 1; + if (m * m <= (ux >> s)) { + res = m; + } + s -= 2; + } + return res; +} + export function ipow32(x: i32, e: i32): i32 { var out = 1; if (ASC_SHRINK_LEVEL < 1) { diff --git a/tests/compiler/std/math.optimized.wat b/tests/compiler/std/math.optimized.wat index 55252343ff..ee1c516d92 100644 --- a/tests/compiler/std/math.optimized.wat +++ b/tests/compiler/std/math.optimized.wat @@ -14,6 +14,7 @@ (type $fff (func (param f32 f32) (result f32))) (type $F (func (result f64))) (type $I_ (func (param i64))) + (type $II (func (param i64) (result i64))) (type $ii (func (param i32) (result i32))) (type $f (func (result f32))) (type $IiI (func (param i64 i32) (result i64))) @@ -28,7 +29,6 @@ (type $FUNCSIG$iffi (func (param f32 f32 i32) (result i32))) (type $FUNCSIG$idddi (func (param f64 f64 f64 i32) (result i32))) (type $FUNCSIG$ifffi (func (param f32 f32 f32 i32) (result i32))) - (type $FUNCSIG$j (func (result i64))) (import "Math" "E" (global $~lib/bindings/Math/E f64)) (import "Math" "LN2" (global $~lib/bindings/Math/LN2 f64)) (import "Math" "LN10" (global $~lib/bindings/Math/LN10 f64)) @@ -9223,75 +9223,158 @@ i32.mul f64.convert_i32_s ) - (func $~lib/math/IntegerMath.sqrt (; 146 ;) (type $FUNCSIG$j) (result i64) - (local $0 i32) - (local $1 i64) - (local $2 i64) + (func $~lib/math/isqrt32 (; 146 ;) (type $ii) (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + local.get $0 + i32.const 2 + i32.lt_u + if + local.get $0 + return + end i32.const 2 - local.set $0 - i64.const 4611686018427387903 local.set $1 + local.get $0 + i32.const 2 + i32.shr_u + local.set $2 loop $continue|0 + local.get $2 + if + local.get $0 + local.get $2 + i32.ne + local.set $2 + end + local.get $2 + if + local.get $0 + local.get $1 + i32.const 2 + i32.add + local.tee $1 + i32.shr_u + local.set $2 + br $continue|0 + end + end + local.get $1 + i32.const 2 + i32.sub + local.set $1 + loop $continue|1 local.get $1 - i64.const -1 - i64.ne - i64.extend_i32_u - local.get $1 - local.get $1 + i32.const 0 + i32.ge_s + if + local.get $3 + i32.const 1 + i32.shl + local.tee $3 + i32.const 1 + i32.add + local.tee $2 + local.get $2 + i32.mul + local.get $0 + local.get $1 + i32.shr_u + i32.le_u + if + local.get $2 + local.set $3 + end + local.get $1 + i32.const 2 + i32.sub + local.set $1 + br $continue|1 + end + end + local.get $3 + ) + (func $~lib/math/isqrt64 (; 147 ;) (type $II) (param $0 i64) (result i64) + (local $1 i32) + (local $2 i64) + (local $3 i64) + local.get $0 + i64.const 2 + i64.lt_u + if + local.get $0 + return + end + i32.const 2 + local.set $1 + local.get $0 + i64.const 2 + i64.shr_u + local.set $2 + loop $continue|0 + local.get $2 i64.const 0 i64.ne - select + if + local.get $0 + local.get $2 + i64.ne + i64.extend_i32_u + local.set $2 + end + local.get $2 i64.const 0 i64.ne if - i64.const -1 local.get $0 + local.get $1 i32.const 2 i32.add - local.tee $0 + local.tee $1 i64.extend_i32_s i64.shr_u - local.set $1 + local.set $2 br $continue|0 end end - local.get $0 + local.get $1 i32.const 2 i32.sub - local.set $0 + local.set $1 loop $continue|1 - local.get $0 + local.get $1 i32.const 0 i32.ge_s if - local.get $2 + local.get $3 i64.const 1 i64.shl - local.tee $2 + local.tee $3 i64.const 1 i64.add - local.tee $1 - local.get $1 + local.tee $2 + local.get $2 i64.mul - i64.const -1 local.get $0 + local.get $1 i64.extend_i32_s i64.shr_u i64.le_u if - local.get $1 - local.set $2 + local.get $2 + local.set $3 end - local.get $0 + local.get $1 i32.const 2 i32.sub - local.set $0 + local.set $1 br $continue|1 end end - local.get $2 + local.get $3 ) - (func $~lib/math/ipow64 (; 147 ;) (type $IiI) (param $0 i64) (param $1 i32) (result i64) + (func $~lib/math/ipow64 (; 148 ;) (type $IiI) (param $0 i64) (param $1 i32) (result i64) (local $2 i64) (local $3 i32) i64.const 1 @@ -9487,7 +9570,7 @@ end local.get $2 ) - (func $~lib/math/ipow32f (; 148 ;) (type $fif) (param $0 f32) (param $1 i32) (result f32) + (func $~lib/math/ipow32f (; 149 ;) (type $fif) (param $0 f32) (param $1 i32) (result f32) (local $2 f32) (local $3 i32) local.get $1 @@ -9533,7 +9616,7 @@ end local.get $2 ) - (func $~lib/math/ipow64f (; 149 ;) (type $FiF) (param $0 f64) (param $1 i32) (result f64) + (func $~lib/math/ipow64f (; 150 ;) (type $FiF) (param $0 f64) (param $1 i32) (result f64) (local $2 f64) (local $3 i32) local.get $1 @@ -9579,14 +9662,11 @@ end local.get $2 ) - (func $start (; 150 ;) (type $_) - (local $0 i32) - (local $1 i32) + (func $start (; 151 ;) (type $_) + (local $0 f64) + (local $1 f32) (local $2 i32) - (local $3 i64) - (local $4 i64) - (local $5 f64) - (local $6 f32) + (local $3 i32) f64.const 2.718281828459045 global.get $~lib/bindings/Math/E f64.const 0 @@ -31506,16 +31586,16 @@ f64.lt if call $~lib/math/NativeMath.random - local.tee $5 + local.tee $0 f64.const 0 f64.ge - local.tee $0 + local.tee $3 if (result i32) - local.get $5 + local.get $0 f64.const 1 f64.lt else - local.get $0 + local.get $3 end if local.get $2 @@ -31546,16 +31626,16 @@ f64.lt if call $~lib/math/NativeMathf.random - local.tee $6 + local.tee $1 f32.const 0 f32.ge - local.tee $0 + local.tee $3 if (result i32) - local.get $6 + local.get $1 f32.const 1 f32.lt else - local.get $0 + local.get $3 end if local.get $2 @@ -37918,66 +37998,64 @@ call $~lib/env/abort unreachable end - i32.const 2 - local.set $0 - loop $continue|22 - local.get $1 - i32.const 2 - i32.ne - local.get $1 - local.get $1 - select - if - i32.const 2 - local.get $0 - i32.const 2 - i32.add - local.tee $0 - i32.const 16 - i32.shl - i32.const 16 - i32.shr_s - i32.shr_s - local.set $1 - br $continue|22 - end + i32.const 0 + call $~lib/math/isqrt32 + i32.const 65535 + i32.and + if + i32.const 0 + i32.const 8 + i32.const 3350 + i32.const 0 + call $~lib/env/abort + unreachable end - local.get $0 - i32.const 2 - i32.sub - local.set $0 i32.const 0 - local.set $1 - loop $continue|23 - local.get $0 + call $~lib/math/isqrt32 + if i32.const 0 - i32.ge_s - if - local.get $1 - i32.const 1 - i32.shl - local.tee $1 - i32.const 1 - i32.add - local.tee $2 - local.get $2 - i32.mul - i32.const 2 - local.get $0 - i32.shr_u - i32.le_u - if - local.get $2 - local.set $1 - end - local.get $0 - i32.const 2 - i32.sub - local.set $0 - br $continue|23 - end + i32.const 8 + i32.const 3351 + i32.const 0 + call $~lib/env/abort + unreachable end - local.get $1 + i32.const 0 + call $~lib/math/isqrt32 + if + i32.const 0 + i32.const 8 + i32.const 3352 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 0 + call $~lib/math/isqrt64 + i64.const 0 + i64.ne + if + i32.const 0 + i32.const 8 + i32.const 3353 + i32.const 0 + call $~lib/env/abort + unreachable + end + i64.const 0 + call $~lib/math/isqrt64 + i64.const 0 + i64.ne + if + i32.const 0 + i32.const 8 + i32.const 3354 + i32.const 0 + call $~lib/env/abort + unreachable + end + i32.const 1 + call $~lib/math/isqrt32 i32.const 65535 i32.and i32.const 1 @@ -37985,208 +38063,99 @@ if i32.const 0 i32.const 8 - i32.const 3360 + i32.const 3355 i32.const 0 call $~lib/env/abort unreachable end - i32.const 2 - local.set $1 - i32.const 0 - local.set $0 - loop $continue|24 - local.get $0 - i32.const 2 - i32.ne - local.get $0 - local.get $0 - select - if - i32.const 2 - local.get $1 - i32.const 2 - i32.add - local.tee $1 - i32.shr_s - local.set $0 - br $continue|24 - end - end - local.get $1 - i32.const 2 - i32.sub - local.set $1 - i32.const 0 - local.set $0 - loop $continue|25 - local.get $1 + i32.const 1 + call $~lib/math/isqrt32 + i32.const 1 + i32.ne + if i32.const 0 - i32.ge_s - if - local.get $0 - i32.const 1 - i32.shl - local.tee $0 - i32.const 1 - i32.add - local.tee $2 - local.get $2 - i32.mul - i32.const 2 - local.get $1 - i32.shr_u - i32.le_u - if - local.get $2 - local.set $0 - end - local.get $1 - i32.const 2 - i32.sub - local.set $1 - br $continue|25 - end + i32.const 8 + i32.const 3356 + i32.const 0 + call $~lib/env/abort + unreachable end - local.get $0 + i32.const 1 + call $~lib/math/isqrt32 i32.const 1 i32.ne if i32.const 0 i32.const 8 - i32.const 3361 + i32.const 3357 i32.const 0 call $~lib/env/abort unreachable end - i32.const 2 - local.set $0 - i32.const 0 - local.set $1 - loop $continue|26 - local.get $1 - i32.const 2 - i32.ne - local.get $1 - local.get $1 - select - if - i32.const 2 - local.get $0 - i32.const 2 - i32.add - local.tee $0 - i32.shr_u - local.set $1 - br $continue|26 - end + i64.const 1 + call $~lib/math/isqrt64 + i64.const 1 + i64.ne + if + i32.const 0 + i32.const 8 + i32.const 3358 + i32.const 0 + call $~lib/env/abort + unreachable end - local.get $0 - i32.const 2 - i32.sub - local.set $0 - i32.const 0 - local.set $1 - loop $continue|27 - local.get $0 + i64.const 1 + call $~lib/math/isqrt64 + i64.const 1 + i64.ne + if i32.const 0 - i32.ge_s - if - local.get $1 - i32.const 1 - i32.shl - local.tee $1 - i32.const 1 - i32.add - local.tee $2 - local.get $2 - i32.mul - i32.const 2 - local.get $0 - i32.shr_u - i32.le_u - if - local.get $2 - local.set $1 - end - local.get $0 - i32.const 2 - i32.sub - local.set $0 - br $continue|27 - end + i32.const 8 + i32.const 3359 + i32.const 0 + call $~lib/env/abort + unreachable end - local.get $1 + i32.const 2 + call $~lib/math/isqrt32 + i32.const 65535 + i32.and i32.const 1 i32.ne if i32.const 0 i32.const 8 - i32.const 3362 + i32.const 3360 i32.const 0 call $~lib/env/abort unreachable end i32.const 2 - local.set $2 - loop $continue|28 - local.get $3 - i64.const 2 - i64.ne - i64.extend_i32_u - local.get $3 - local.get $3 - i64.const 0 - i64.ne - select - i64.const 0 - i64.ne - if - i64.const 2 - local.get $2 - i32.const 2 - i32.add - local.tee $2 - i64.extend_i32_s - i64.shr_s - local.set $3 - br $continue|28 - end + call $~lib/math/isqrt32 + i32.const 1 + i32.ne + if + i32.const 0 + i32.const 8 + i32.const 3361 + i32.const 0 + call $~lib/env/abort + unreachable end - local.get $2 i32.const 2 - i32.sub - local.set $2 - loop $continue|29 - local.get $2 + call $~lib/math/isqrt32 + i32.const 1 + i32.ne + if i32.const 0 - i32.ge_s - if - local.get $4 - i64.const 1 - i64.shl - local.tee $4 - i64.const 1 - i64.add - local.tee $3 - local.get $3 - i64.mul - i64.const 2 - local.get $2 - i64.extend_i32_s - i64.shr_u - i64.le_u - if - local.get $3 - local.set $4 - end - local.get $2 - i32.const 2 - i32.sub - local.set $2 - br $continue|29 - end + i32.const 8 + i32.const 3362 + i32.const 0 + call $~lib/env/abort + unreachable end - local.get $4 + i64.const 2 + call $~lib/math/isqrt64 i64.const 1 i64.ne if @@ -38197,71 +38166,8 @@ call $~lib/env/abort unreachable end - i32.const 2 - local.set $2 - i64.const 0 - local.set $3 - loop $continue|30 - local.get $3 - i64.const 2 - i64.ne - i64.extend_i32_u - local.get $3 - local.get $3 - i64.const 0 - i64.ne - select - i64.const 0 - i64.ne - if - i64.const 2 - local.get $2 - i32.const 2 - i32.add - local.tee $2 - i64.extend_i32_s - i64.shr_u - local.set $3 - br $continue|30 - end - end - local.get $2 - i32.const 2 - i32.sub - local.set $2 - i64.const 0 - local.set $4 - loop $continue|31 - local.get $2 - i32.const 0 - i32.ge_s - if - local.get $4 - i64.const 1 - i64.shl - local.tee $4 - i64.const 1 - i64.add - local.tee $3 - local.get $3 - i64.mul - i64.const 2 - local.get $2 - i64.extend_i32_s - i64.shr_u - i64.le_u - if - local.get $3 - local.set $4 - end - local.get $2 - i32.const 2 - i32.sub - local.set $2 - br $continue|31 - end - end - local.get $4 + i64.const 2 + call $~lib/math/isqrt64 i64.const 1 i64.ne if @@ -38272,68 +38178,8 @@ call $~lib/env/abort unreachable end - i32.const 2 - local.set $1 - i32.const 0 - local.set $0 - loop $continue|32 - local.get $0 - i32.const 3 - i32.ne - local.get $0 - local.get $0 - select - if - i32.const 3 - local.get $1 - i32.const 2 - i32.add - local.tee $1 - i32.const 16 - i32.shl - i32.const 16 - i32.shr_s - i32.shr_s - local.set $0 - br $continue|32 - end - end - local.get $1 - i32.const 2 - i32.sub - local.set $1 - i32.const 0 - local.set $0 - loop $continue|33 - local.get $1 - i32.const 0 - i32.ge_s - if - local.get $0 - i32.const 1 - i32.shl - local.tee $0 - i32.const 1 - i32.add - local.tee $2 - local.get $2 - i32.mul - i32.const 3 - local.get $1 - i32.shr_u - i32.le_u - if - local.get $2 - local.set $0 - end - local.get $1 - i32.const 2 - i32.sub - local.set $1 - br $continue|33 - end - end - local.get $0 + i32.const 3 + call $~lib/math/isqrt32 i32.const 65535 i32.and i32.const 1 @@ -38346,64 +38192,8 @@ call $~lib/env/abort unreachable end - i32.const 2 - local.set $0 - i32.const 0 - local.set $1 - loop $continue|34 - local.get $1 - i32.const 3 - i32.ne - local.get $1 - local.get $1 - select - if - i32.const 3 - local.get $0 - i32.const 2 - i32.add - local.tee $0 - i32.shr_s - local.set $1 - br $continue|34 - end - end - local.get $0 - i32.const 2 - i32.sub - local.set $0 - i32.const 0 - local.set $1 - loop $continue|35 - local.get $0 - i32.const 0 - i32.ge_s - if - local.get $1 - i32.const 1 - i32.shl - local.tee $1 - i32.const 1 - i32.add - local.tee $2 - local.get $2 - i32.mul - i32.const 3 - local.get $0 - i32.shr_u - i32.le_u - if - local.get $2 - local.set $1 - end - local.get $0 - i32.const 2 - i32.sub - local.set $0 - br $continue|35 - end - end - local.get $1 + i32.const 3 + call $~lib/math/isqrt32 i32.const 1 i32.ne if @@ -38414,64 +38204,8 @@ call $~lib/env/abort unreachable end - i32.const 2 - local.set $1 - i32.const 0 - local.set $0 - loop $continue|36 - local.get $0 - i32.const 3 - i32.ne - local.get $0 - local.get $0 - select - if - i32.const 3 - local.get $1 - i32.const 2 - i32.add - local.tee $1 - i32.shr_u - local.set $0 - br $continue|36 - end - end - local.get $1 - i32.const 2 - i32.sub - local.set $1 - i32.const 0 - local.set $0 - loop $continue|37 - local.get $1 - i32.const 0 - i32.ge_s - if - local.get $0 - i32.const 1 - i32.shl - local.tee $0 - i32.const 1 - i32.add - local.tee $2 - local.get $2 - i32.mul - i32.const 3 - local.get $1 - i32.shr_u - i32.le_u - if - local.get $2 - local.set $0 - end - local.get $1 - i32.const 2 - i32.sub - local.set $1 - br $continue|37 - end - end - local.get $0 + i32.const 3 + call $~lib/math/isqrt32 i32.const 1 i32.ne if @@ -38482,71 +38216,8 @@ call $~lib/env/abort unreachable end - i32.const 2 - local.set $2 - i64.const 0 - local.set $3 - loop $continue|38 - local.get $3 - i64.const 3 - i64.ne - i64.extend_i32_u - local.get $3 - local.get $3 - i64.const 0 - i64.ne - select - i64.const 0 - i64.ne - if - i64.const 3 - local.get $2 - i32.const 2 - i32.add - local.tee $2 - i64.extend_i32_s - i64.shr_s - local.set $3 - br $continue|38 - end - end - local.get $2 - i32.const 2 - i32.sub - local.set $2 - i64.const 0 - local.set $4 - loop $continue|39 - local.get $2 - i32.const 0 - i32.ge_s - if - local.get $4 - i64.const 1 - i64.shl - local.tee $4 - i64.const 1 - i64.add - local.tee $3 - local.get $3 - i64.mul - i64.const 3 - local.get $2 - i64.extend_i32_s - i64.shr_u - i64.le_u - if - local.get $3 - local.set $4 - end - local.get $2 - i32.const 2 - i32.sub - local.set $2 - br $continue|39 - end - end - local.get $4 + i64.const 3 + call $~lib/math/isqrt64 i64.const 1 i64.ne if @@ -38557,71 +38228,8 @@ call $~lib/env/abort unreachable end - i32.const 2 - local.set $2 - i64.const 0 - local.set $3 - loop $continue|40 - local.get $3 - i64.const 3 - i64.ne - i64.extend_i32_u - local.get $3 - local.get $3 - i64.const 0 - i64.ne - select - i64.const 0 - i64.ne - if - i64.const 3 - local.get $2 - i32.const 2 - i32.add - local.tee $2 - i64.extend_i32_s - i64.shr_u - local.set $3 - br $continue|40 - end - end - local.get $2 - i32.const 2 - i32.sub - local.set $2 - i64.const 0 - local.set $4 - loop $continue|41 - local.get $2 - i32.const 0 - i32.ge_s - if - local.get $4 - i64.const 1 - i64.shl - local.tee $4 - i64.const 1 - i64.add - local.tee $3 - local.get $3 - i64.mul - i64.const 3 - local.get $2 - i64.extend_i32_s - i64.shr_u - i64.le_u - if - local.get $3 - local.set $4 - end - local.get $2 - i32.const 2 - i32.sub - local.set $2 - br $continue|41 - end - end - local.get $4 + i64.const 3 + call $~lib/math/isqrt64 i64.const 1 i64.ne if @@ -38632,68 +38240,8 @@ call $~lib/env/abort unreachable end - i32.const 2 - local.set $0 - i32.const 1 - local.set $1 - loop $continue|42 - local.get $1 - i32.const 4 - i32.ne - local.get $1 - local.get $1 - select - if - i32.const 4 - local.get $0 - i32.const 2 - i32.add - local.tee $0 - i32.const 16 - i32.shl - i32.const 16 - i32.shr_s - i32.shr_s - local.set $1 - br $continue|42 - end - end - local.get $0 - i32.const 2 - i32.sub - local.set $0 - i32.const 0 - local.set $1 - loop $continue|43 - local.get $0 - i32.const 0 - i32.ge_s - if - local.get $1 - i32.const 1 - i32.shl - local.tee $1 - i32.const 1 - i32.add - local.tee $2 - local.get $2 - i32.mul - i32.const 4 - local.get $0 - i32.shr_u - i32.le_u - if - local.get $2 - local.set $1 - end - local.get $0 - i32.const 2 - i32.sub - local.set $0 - br $continue|43 - end - end - local.get $1 + i32.const 4 + call $~lib/math/isqrt32 i32.const 65535 i32.and i32.const 2 @@ -38706,64 +38254,8 @@ call $~lib/env/abort unreachable end - i32.const 2 - local.set $1 - i32.const 1 - local.set $0 - loop $continue|44 - local.get $0 - i32.const 4 - i32.ne - local.get $0 - local.get $0 - select - if - i32.const 4 - local.get $1 - i32.const 2 - i32.add - local.tee $1 - i32.shr_s - local.set $0 - br $continue|44 - end - end - local.get $1 - i32.const 2 - i32.sub - local.set $1 - i32.const 0 - local.set $0 - loop $continue|45 - local.get $1 - i32.const 0 - i32.ge_s - if - local.get $0 - i32.const 1 - i32.shl - local.tee $0 - i32.const 1 - i32.add - local.tee $2 - local.get $2 - i32.mul - i32.const 4 - local.get $1 - i32.shr_u - i32.le_u - if - local.get $2 - local.set $0 - end - local.get $1 - i32.const 2 - i32.sub - local.set $1 - br $continue|45 - end - end - local.get $0 + i32.const 4 + call $~lib/math/isqrt32 i32.const 2 i32.ne if @@ -38774,64 +38266,8 @@ call $~lib/env/abort unreachable end - i32.const 2 - local.set $0 - i32.const 1 - local.set $1 - loop $continue|46 - local.get $1 - i32.const 4 - i32.ne - local.get $1 - local.get $1 - select - if - i32.const 4 - local.get $0 - i32.const 2 - i32.add - local.tee $0 - i32.shr_u - local.set $1 - br $continue|46 - end - end - local.get $0 - i32.const 2 - i32.sub - local.set $0 - i32.const 0 - local.set $1 - loop $continue|47 - local.get $0 - i32.const 0 - i32.ge_s - if - local.get $1 - i32.const 1 - i32.shl - local.tee $1 - i32.const 1 - i32.add - local.tee $2 - local.get $2 - i32.mul - i32.const 4 - local.get $0 - i32.shr_u - i32.le_u - if - local.get $2 - local.set $1 - end - local.get $0 - i32.const 2 - i32.sub - local.set $0 - br $continue|47 - end - end - local.get $1 + i32.const 4 + call $~lib/math/isqrt32 i32.const 2 i32.ne if @@ -38842,71 +38278,8 @@ call $~lib/env/abort unreachable end - i32.const 2 - local.set $2 - i64.const 1 - local.set $3 - loop $continue|48 - local.get $3 - i64.const 4 - i64.ne - i64.extend_i32_u - local.get $3 - local.get $3 - i64.const 0 - i64.ne - select - i64.const 0 - i64.ne - if - i64.const 4 - local.get $2 - i32.const 2 - i32.add - local.tee $2 - i64.extend_i32_s - i64.shr_s - local.set $3 - br $continue|48 - end - end - local.get $2 - i32.const 2 - i32.sub - local.set $2 - i64.const 0 - local.set $4 - loop $continue|49 - local.get $2 - i32.const 0 - i32.ge_s - if - local.get $4 - i64.const 1 - i64.shl - local.tee $4 - i64.const 1 - i64.add - local.tee $3 - local.get $3 - i64.mul - i64.const 4 - local.get $2 - i64.extend_i32_s - i64.shr_u - i64.le_u - if - local.get $3 - local.set $4 - end - local.get $2 - i32.const 2 - i32.sub - local.set $2 - br $continue|49 - end - end - local.get $4 + i64.const 4 + call $~lib/math/isqrt64 i64.const 2 i64.ne if @@ -38917,143 +38290,20 @@ call $~lib/env/abort unreachable end - i32.const 2 - local.set $2 - i64.const 1 - local.set $3 - loop $continue|50 - local.get $3 - i64.const 4 - i64.ne - i64.extend_i32_u - local.get $3 - local.get $3 - i64.const 0 - i64.ne - select - i64.const 0 - i64.ne - if - i64.const 4 - local.get $2 - i32.const 2 - i32.add - local.tee $2 - i64.extend_i32_s - i64.shr_u - local.set $3 - br $continue|50 - end - end - local.get $2 - i32.const 2 - i32.sub - local.set $2 - i64.const 0 - local.set $4 - loop $continue|51 - local.get $2 - i32.const 0 - i32.ge_s - if - local.get $4 - i64.const 1 - i64.shl - local.tee $4 - i64.const 1 - i64.add - local.tee $3 - local.get $3 - i64.mul - i64.const 4 - local.get $2 - i64.extend_i32_s - i64.shr_u - i64.le_u - if - local.get $3 - local.set $4 - end - local.get $2 - i32.const 2 - i32.sub - local.set $2 - br $continue|51 - end - end - local.get $4 + i64.const 4 + call $~lib/math/isqrt64 i64.const 2 - i64.ne - if - i32.const 0 - i32.const 8 - i32.const 3374 - i32.const 0 - call $~lib/env/abort - unreachable - end - i32.const 2 - local.set $1 - i32.const 8191 - local.set $0 - loop $continue|52 - local.get $0 - i32.const 32767 - i32.ne - local.get $0 - local.get $0 - select - if - i32.const 32767 - local.get $1 - i32.const 2 - i32.add - local.tee $1 - i32.const 16 - i32.shl - i32.const 16 - i32.shr_s - i32.shr_s - local.set $0 - br $continue|52 - end - end - local.get $1 - i32.const 2 - i32.sub - local.set $1 - i32.const 0 - local.set $0 - loop $continue|53 - local.get $1 - i32.const 0 - i32.ge_s - if - local.get $0 - i32.const 1 - i32.shl - local.tee $0 - i32.const 1 - i32.add - local.tee $2 - local.get $2 - i32.mul - i32.const 32767 - local.get $1 - i32.shr_u - i32.le_u - if - local.get $2 - local.set $0 - end - local.get $1 - i32.const 2 - i32.sub - local.set $1 - br $continue|53 - end + i64.ne + if + i32.const 0 + i32.const 8 + i32.const 3374 + i32.const 0 + call $~lib/env/abort + unreachable end - local.get $0 + i32.const 32767 + call $~lib/math/isqrt32 i32.const 65535 i32.and i32.const 181 @@ -39066,66 +38316,8 @@ call $~lib/env/abort unreachable end - i32.const 2 - local.set $0 - i32.const 8191 - local.set $1 - loop $continue|54 - local.get $1 - i32.const 32767 - i32.ne - local.get $1 - local.get $1 - select - if - i32.const 32767 - local.get $0 - i32.const 2 - i32.add - local.tee $0 - i32.const 65535 - i32.and - i32.shr_u - local.set $1 - br $continue|54 - end - end - local.get $0 - i32.const 2 - i32.sub - local.set $0 - i32.const 0 - local.set $1 - loop $continue|55 - local.get $0 - i32.const 0 - i32.ge_s - if - local.get $1 - i32.const 1 - i32.shl - local.tee $1 - i32.const 1 - i32.add - local.tee $2 - local.get $2 - i32.mul - i32.const 32767 - local.get $0 - i32.shr_u - i32.le_u - if - local.get $2 - local.set $1 - end - local.get $0 - i32.const 2 - i32.sub - local.set $0 - br $continue|55 - end - end - local.get $1 + i32.const 32767 + call $~lib/math/isqrt32 i32.const 65535 i32.and i32.const 181 @@ -39138,64 +38330,8 @@ call $~lib/env/abort unreachable end - i32.const 2 - local.set $1 - i32.const 8191 - local.set $0 - loop $continue|56 - local.get $0 - i32.const 32767 - i32.ne - local.get $0 - local.get $0 - select - if - i32.const 32767 - local.get $1 - i32.const 2 - i32.add - local.tee $1 - i32.shr_s - local.set $0 - br $continue|56 - end - end - local.get $1 - i32.const 2 - i32.sub - local.set $1 - i32.const 0 - local.set $0 - loop $continue|57 - local.get $1 - i32.const 0 - i32.ge_s - if - local.get $0 - i32.const 1 - i32.shl - local.tee $0 - i32.const 1 - i32.add - local.tee $2 - local.get $2 - i32.mul - i32.const 32767 - local.get $1 - i32.shr_u - i32.le_u - if - local.get $2 - local.set $0 - end - local.get $1 - i32.const 2 - i32.sub - local.set $1 - br $continue|57 - end - end - local.get $0 + i32.const 32767 + call $~lib/math/isqrt32 i32.const 181 i32.ne if @@ -39206,64 +38342,8 @@ call $~lib/env/abort unreachable end - i32.const 2 - local.set $0 - i32.const 8191 - local.set $1 - loop $continue|58 - local.get $1 - i32.const 32767 - i32.ne - local.get $1 - local.get $1 - select - if - i32.const 32767 - local.get $0 - i32.const 2 - i32.add - local.tee $0 - i32.shr_u - local.set $1 - br $continue|58 - end - end - local.get $0 - i32.const 2 - i32.sub - local.set $0 - i32.const 0 - local.set $1 - loop $continue|59 - local.get $0 - i32.const 0 - i32.ge_s - if - local.get $1 - i32.const 1 - i32.shl - local.tee $1 - i32.const 1 - i32.add - local.tee $2 - local.get $2 - i32.mul - i32.const 32767 - local.get $0 - i32.shr_u - i32.le_u - if - local.get $2 - local.set $1 - end - local.get $0 - i32.const 2 - i32.sub - local.set $0 - br $continue|59 - end - end - local.get $1 + i32.const 32767 + call $~lib/math/isqrt32 i32.const 181 i32.ne if @@ -39274,66 +38354,8 @@ call $~lib/env/abort unreachable end - i32.const 2 - local.set $1 - i32.const 16383 - local.set $0 - loop $continue|60 - local.get $0 - i32.const 65535 - i32.ne - local.get $0 - local.get $0 - select - if - i32.const 65535 - local.get $1 - i32.const 2 - i32.add - local.tee $1 - i32.const 65535 - i32.and - i32.shr_u - local.set $0 - br $continue|60 - end - end - local.get $1 - i32.const 2 - i32.sub - local.set $1 - i32.const 0 - local.set $0 - loop $continue|61 - local.get $1 - i32.const 0 - i32.ge_s - if - local.get $0 - i32.const 1 - i32.shl - local.tee $0 - i32.const 1 - i32.add - local.tee $2 - local.get $2 - i32.mul - i32.const 65535 - local.get $1 - i32.shr_u - i32.le_u - if - local.get $2 - local.set $0 - end - local.get $1 - i32.const 2 - i32.sub - local.set $1 - br $continue|61 - end - end - local.get $0 + i32.const 65535 + call $~lib/math/isqrt32 i32.const 65535 i32.and i32.const 255 @@ -39346,64 +38368,8 @@ call $~lib/env/abort unreachable end - i32.const 2 - local.set $0 - i32.const 536870911 - local.set $1 - loop $continue|62 - local.get $1 - i32.const 2147483647 - i32.ne - local.get $1 - local.get $1 - select - if - i32.const 2147483647 - local.get $0 - i32.const 2 - i32.add - local.tee $0 - i32.shr_s - local.set $1 - br $continue|62 - end - end - local.get $0 - i32.const 2 - i32.sub - local.set $0 - i32.const 0 - local.set $1 - loop $continue|63 - local.get $0 - i32.const 0 - i32.ge_s - if - local.get $1 - i32.const 1 - i32.shl - local.tee $1 - i32.const 1 - i32.add - local.tee $2 - local.get $2 - i32.mul - i32.const 2147483647 - local.get $0 - i32.shr_u - i32.le_u - if - local.get $2 - local.set $1 - end - local.get $0 - i32.const 2 - i32.sub - local.set $0 - br $continue|63 - end - end - local.get $1 + i32.const 2147483647 + call $~lib/math/isqrt32 i32.const 46340 i32.ne if @@ -39414,64 +38380,8 @@ call $~lib/env/abort unreachable end - i32.const 2 - local.set $1 - i32.const 536870911 - local.set $0 - loop $continue|64 - local.get $0 - i32.const 2147483647 - i32.ne - local.get $0 - local.get $0 - select - if - i32.const 2147483647 - local.get $1 - i32.const 2 - i32.add - local.tee $1 - i32.shr_u - local.set $0 - br $continue|64 - end - end - local.get $1 - i32.const 2 - i32.sub - local.set $1 - i32.const 0 - local.set $0 - loop $continue|65 - local.get $1 - i32.const 0 - i32.ge_s - if - local.get $0 - i32.const 1 - i32.shl - local.tee $0 - i32.const 1 - i32.add - local.tee $2 - local.get $2 - i32.mul - i32.const 2147483647 - local.get $1 - i32.shr_u - i32.le_u - if - local.get $2 - local.set $0 - end - local.get $1 - i32.const 2 - i32.sub - local.set $1 - br $continue|65 - end - end - local.get $0 + i32.const 2147483647 + call $~lib/math/isqrt32 i32.const 46340 i32.ne if @@ -39482,64 +38392,8 @@ call $~lib/env/abort unreachable end - i32.const 2 - local.set $0 - i32.const 1073741823 - local.set $1 - loop $continue|66 - local.get $1 - i32.const -1 - i32.ne - local.get $1 - local.get $1 - select - if - i32.const -1 - local.get $0 - i32.const 2 - i32.add - local.tee $0 - i32.shr_u - local.set $1 - br $continue|66 - end - end - local.get $0 - i32.const 2 - i32.sub - local.set $0 - i32.const 0 - local.set $1 - loop $continue|67 - local.get $0 - i32.const 0 - i32.ge_s - if - local.get $1 - i32.const 1 - i32.shl - local.tee $1 - i32.const 1 - i32.add - local.tee $2 - local.get $2 - i32.mul - i32.const -1 - local.get $0 - i32.shr_u - i32.le_u - if - local.get $2 - local.set $1 - end - local.get $0 - i32.const 2 - i32.sub - local.set $0 - br $continue|67 - end - end - local.get $1 + i32.const -1 + call $~lib/math/isqrt32 i32.const 65535 i32.ne if @@ -39550,71 +38404,8 @@ call $~lib/env/abort unreachable end - i32.const 2 - local.set $2 - i64.const 2305843009213693951 - local.set $3 - loop $continue|68 - local.get $3 - i64.const 9223372036854775807 - i64.ne - i64.extend_i32_u - local.get $3 - local.get $3 - i64.const 0 - i64.ne - select - i64.const 0 - i64.ne - if - i64.const 9223372036854775807 - local.get $2 - i32.const 2 - i32.add - local.tee $2 - i64.extend_i32_s - i64.shr_s - local.set $3 - br $continue|68 - end - end - local.get $2 - i32.const 2 - i32.sub - local.set $2 - i64.const 0 - local.set $4 - loop $continue|69 - local.get $2 - i32.const 0 - i32.ge_s - if - local.get $4 - i64.const 1 - i64.shl - local.tee $4 - i64.const 1 - i64.add - local.tee $3 - local.get $3 - i64.mul - i64.const 9223372036854775807 - local.get $2 - i64.extend_i32_s - i64.shr_u - i64.le_u - if - local.get $3 - local.set $4 - end - local.get $2 - i32.const 2 - i32.sub - local.set $2 - br $continue|69 - end - end - local.get $4 + i64.const 9223372036854775807 + call $~lib/math/isqrt64 i64.const 3037000499 i64.ne if @@ -39625,71 +38416,8 @@ call $~lib/env/abort unreachable end - i32.const 2 - local.set $2 - i64.const 2305843009213693951 - local.set $3 - loop $continue|70 - local.get $3 - i64.const 9223372036854775807 - i64.ne - i64.extend_i32_u - local.get $3 - local.get $3 - i64.const 0 - i64.ne - select - i64.const 0 - i64.ne - if - i64.const 9223372036854775807 - local.get $2 - i32.const 2 - i32.add - local.tee $2 - i64.extend_i32_s - i64.shr_u - local.set $3 - br $continue|70 - end - end - local.get $2 - i32.const 2 - i32.sub - local.set $2 - i64.const 0 - local.set $4 - loop $continue|71 - local.get $2 - i32.const 0 - i32.ge_s - if - local.get $4 - i64.const 1 - i64.shl - local.tee $4 - i64.const 1 - i64.add - local.tee $3 - local.get $3 - i64.mul - i64.const 9223372036854775807 - local.get $2 - i64.extend_i32_s - i64.shr_u - i64.le_u - if - local.get $3 - local.set $4 - end - local.get $2 - i32.const 2 - i32.sub - local.set $2 - br $continue|71 - end - end - local.get $4 + i64.const 9223372036854775807 + call $~lib/math/isqrt64 i64.const 3037000499 i64.ne if @@ -39700,7 +38428,8 @@ call $~lib/env/abort unreachable end - call $~lib/math/IntegerMath.sqrt + i64.const -1 + call $~lib/math/isqrt64 i64.const 4294967295 i64.ne if @@ -40108,8 +38837,8 @@ f32.const nan:0x400000 i32.const 1 call $~lib/math/ipow32f - local.tee $6 - local.get $6 + local.tee $1 + local.get $1 f32.eq if i32.const 0 @@ -40122,8 +38851,8 @@ f32.const nan:0x400000 i32.const -1 call $~lib/math/ipow32f - local.tee $6 - local.get $6 + local.tee $1 + local.get $1 f32.eq if i32.const 0 @@ -40136,8 +38865,8 @@ f32.const nan:0x400000 i32.const 2 call $~lib/math/ipow32f - local.tee $6 - local.get $6 + local.tee $1 + local.get $1 f32.eq if i32.const 0 @@ -40319,8 +39048,8 @@ f64.const nan:0x8000000000000 i32.const 1 call $~lib/math/ipow64f - local.tee $5 - local.get $5 + local.tee $0 + local.get $0 f64.eq if i32.const 0 @@ -40333,8 +39062,8 @@ f64.const nan:0x8000000000000 i32.const -1 call $~lib/math/ipow64f - local.tee $5 - local.get $5 + local.tee $0 + local.get $0 f64.eq if i32.const 0 @@ -40347,8 +39076,8 @@ f64.const nan:0x8000000000000 i32.const 2 call $~lib/math/ipow64f - local.tee $5 - local.get $5 + local.tee $0 + local.get $0 f64.eq if i32.const 0 @@ -40502,7 +39231,7 @@ unreachable end ) - (func $null (; 151 ;) (type $_) + (func $null (; 152 ;) (type $_) nop ) ) diff --git a/tests/compiler/std/math.untouched.wat b/tests/compiler/std/math.untouched.wat index 7edf0f04af..683999c0cf 100644 --- a/tests/compiler/std/math.untouched.wat +++ b/tests/compiler/std/math.untouched.wat @@ -11389,7 +11389,96 @@ i64.sub return ) - (func $~lib/math/IntegerMath.sqrt (; 163 ;) (type $II) (param $0 i64) (result i64) + (func $~lib/math/isqrt32 (; 163 ;) (type $ii) (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + local.get $0 + i32.const 2 + i32.lt_u + if + local.get $0 + return + end + i32.const 2 + local.set $1 + local.get $0 + i32.const 2 + i32.shr_u + local.set $2 + block $break|0 + loop $continue|0 + local.get $2 + if (result i32) + local.get $2 + local.get $0 + i32.ne + else + local.get $2 + end + if + block + local.get $1 + i32.const 2 + i32.add + local.set $1 + local.get $0 + local.get $1 + i32.shr_u + local.set $2 + end + br $continue|0 + end + end + end + local.get $1 + i32.const 2 + i32.sub + local.set $1 + local.get $0 + local.set $3 + i32.const 0 + local.set $4 + block $break|1 + loop $continue|1 + local.get $1 + i32.const 0 + i32.ge_s + if + block + local.get $4 + i32.const 1 + i32.shl + local.set $4 + local.get $4 + i32.const 1 + i32.add + local.set $5 + local.get $5 + local.get $5 + i32.mul + local.get $3 + local.get $1 + i32.shr_u + i32.le_u + if + local.get $5 + local.set $4 + end + local.get $1 + i32.const 2 + i32.sub + local.set $1 + end + br $continue|1 + end + end + end + local.get $4 + ) + (func $~lib/math/isqrt64 (; 164 ;) (type $II) (param $0 i64) (result i64) (local $1 i32) (local $2 i64) (local $3 i64) @@ -11484,9 +11573,13 @@ end end local.get $4 + ) + (func $~lib/math/IntegerMath.sqrt (; 165 ;) (type $II) (param $0 i64) (result i64) + local.get $0 + call $~lib/math/isqrt64 return ) - (func $~lib/math/ipow64 (; 164 ;) (type $IiI) (param $0 i64) (param $1 i32) (result i64) + (func $~lib/math/ipow64 (; 166 ;) (type $IiI) (param $0 i64) (param $1 i32) (result i64) (local $2 i64) (local $3 i32) (local $4 i32) @@ -11718,7 +11811,7 @@ end local.get $2 ) - (func $~lib/math/ipow32f (; 165 ;) (type $fif) (param $0 f32) (param $1 i32) (result f32) + (func $~lib/math/ipow32f (; 167 ;) (type $fif) (param $0 f32) (param $1 i32) (result f32) (local $2 i32) (local $3 f32) local.get $1 @@ -11769,7 +11862,7 @@ local.get $3 end ) - (func $~lib/math/ipow64f (; 166 ;) (type $FiF) (param $0 f64) (param $1 i32) (result f64) + (func $~lib/math/ipow64f (; 168 ;) (type $FiF) (param $0 f64) (param $1 i32) (result f64) (local $2 i32) (local $3 f64) local.get $1 @@ -11820,20 +11913,12 @@ local.get $3 end ) - (func $start (; 167 ;) (type $_) + (func $start (; 169 ;) (type $_) (local $0 i32) (local $1 f64) (local $2 i32) (local $3 i64) (local $4 f32) - (local $5 i32) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i64) - (local $10 i64) - (local $11 i64) - (local $12 i64) global.get $~lib/math/NativeMath.E global.get $~lib/math/NativeMath.E f64.eq @@ -43548,91 +43633,7 @@ unreachable end local.get $0 - i32.const 2 - i32.lt_s - if - local.get $0 - br $~lib/math/IntegerMath.sqrt|inlined.0 - end - i32.const 2 - local.set $2 - local.get $0 - i32.const 2 - i32.shr_s - local.set $5 - block $break|2 - loop $continue|2 - local.get $5 - if (result i32) - local.get $5 - local.get $0 - i32.ne - else - local.get $5 - end - if - block - local.get $2 - i32.const 2 - i32.add - local.set $2 - local.get $0 - local.get $2 - i32.const 16 - i32.shl - i32.const 16 - i32.shr_s - i32.shr_s - local.set $5 - end - br $continue|2 - end - end - end - local.get $2 - i32.const 2 - i32.sub - local.set $2 - local.get $0 - local.set $6 - i32.const 0 - local.set $7 - block $break|3 - loop $continue|3 - local.get $2 - i32.const 0 - i32.ge_s - if - block - local.get $7 - i32.const 1 - i32.shl - local.set $7 - local.get $7 - i32.const 1 - i32.add - local.set $8 - local.get $8 - local.get $8 - i32.mul - local.get $6 - local.get $2 - i32.shr_u - i32.le_u - if - local.get $8 - local.set $7 - end - local.get $2 - i32.const 2 - i32.sub - local.set $2 - end - br $continue|3 - end - end - end - local.get $7 + call $~lib/math/isqrt32 br $~lib/math/IntegerMath.sqrt|inlined.0 end i32.const 16 @@ -43665,87 +43666,7 @@ unreachable end local.get $0 - i32.const 2 - i32.lt_s - if - local.get $0 - br $~lib/math/IntegerMath.sqrt|inlined.0 - end - i32.const 2 - local.set $5 - local.get $0 - i32.const 2 - i32.shr_s - local.set $2 - block $break|4 - loop $continue|4 - local.get $2 - if (result i32) - local.get $2 - local.get $0 - i32.ne - else - local.get $2 - end - if - block - local.get $5 - i32.const 2 - i32.add - local.set $5 - local.get $0 - local.get $5 - i32.shr_s - local.set $2 - end - br $continue|4 - end - end - end - local.get $5 - i32.const 2 - i32.sub - local.set $5 - local.get $0 - local.set $7 - i32.const 0 - local.set $6 - block $break|5 - loop $continue|5 - local.get $5 - i32.const 0 - i32.ge_s - if - block - local.get $6 - i32.const 1 - i32.shl - local.set $6 - local.get $6 - i32.const 1 - i32.add - local.set $8 - local.get $8 - local.get $8 - i32.mul - local.get $7 - local.get $5 - i32.shr_u - i32.le_u - if - local.get $8 - local.set $6 - end - local.get $5 - i32.const 2 - i32.sub - local.set $5 - end - br $continue|5 - end - end - end - local.get $6 + call $~lib/math/isqrt32 br $~lib/math/IntegerMath.sqrt|inlined.0 end i32.const 0 @@ -43763,87 +43684,7 @@ i32.const 0 local.set $0 local.get $0 - i32.const 2 - i32.lt_u - if - local.get $0 - br $~lib/math/IntegerMath.sqrt|inlined.0 - end - i32.const 2 - local.set $2 - local.get $0 - i32.const 2 - i32.shr_u - local.set $5 - block $break|6 - loop $continue|6 - local.get $5 - if (result i32) - local.get $5 - local.get $0 - i32.ne - else - local.get $5 - end - if - block - local.get $2 - i32.const 2 - i32.add - local.set $2 - local.get $0 - local.get $2 - i32.shr_u - local.set $5 - end - br $continue|6 - end - end - end - local.get $2 - i32.const 2 - i32.sub - local.set $2 - local.get $0 - local.set $6 - i32.const 0 - local.set $7 - block $break|7 - loop $continue|7 - local.get $2 - i32.const 0 - i32.ge_s - if - block - local.get $7 - i32.const 1 - i32.shl - local.set $7 - local.get $7 - i32.const 1 - i32.add - local.set $8 - local.get $8 - local.get $8 - i32.mul - local.get $6 - local.get $2 - i32.shr_u - i32.le_u - if - local.get $8 - local.set $7 - end - local.get $2 - i32.const 2 - i32.sub - local.set $2 - end - br $continue|7 - end - end - end - local.get $7 + call $~lib/math/isqrt32 br $~lib/math/IntegerMath.sqrt|inlined.0 end i32.const 0 @@ -43872,94 +43713,7 @@ unreachable end local.get $3 - i64.const 2 - i64.lt_s - if - local.get $3 - br $~lib/math/IntegerMath.sqrt|inlined.0 - end - i32.const 2 - local.set $0 - local.get $3 - i64.const 2 - i64.shr_s - local.set $9 - block $break|8 - loop $continue|8 - local.get $9 - i64.const 0 - i64.ne - if (result i64) - local.get $9 - local.get $3 - i64.ne - i64.extend_i32_u - else - local.get $9 - end - i64.const 0 - i64.ne - if - block - local.get $0 - i32.const 2 - i32.add - local.set $0 - local.get $3 - local.get $0 - i64.extend_i32_s - i64.shr_s - local.set $9 - end - br $continue|8 - end - end - end - local.get $0 - i32.const 2 - i32.sub - local.set $0 - local.get $3 - local.set $10 - i64.const 0 - local.set $11 - block $break|9 - loop $continue|9 - local.get $0 - i32.const 0 - i32.ge_s - if - block - local.get $11 - i64.const 1 - i64.shl - local.set $11 - local.get $11 - i64.const 1 - i64.add - local.set $12 - local.get $12 - local.get $12 - i64.mul - local.get $10 - local.get $0 - i64.extend_i32_s - i64.shr_u - i64.le_u - if - local.get $12 - local.set $11 - end - local.get $0 - i32.const 2 - i32.sub - local.set $0 - end - br $continue|9 - end - end - end - local.get $11 + call $~lib/math/isqrt64 br $~lib/math/IntegerMath.sqrt|inlined.0 end i64.const 0 @@ -43977,94 +43731,7 @@ i64.const 0 local.set $3 local.get $3 - i64.const 2 - i64.lt_u - if - local.get $3 - br $~lib/math/IntegerMath.sqrt|inlined.0 - end - i32.const 2 - local.set $0 - local.get $3 - i64.const 2 - i64.shr_u - local.set $9 - block $break|10 - loop $continue|10 - local.get $9 - i64.const 0 - i64.ne - if (result i64) - local.get $9 - local.get $3 - i64.ne - i64.extend_i32_u - else - local.get $9 - end - i64.const 0 - i64.ne - if - block - local.get $0 - i32.const 2 - i32.add - local.set $0 - local.get $3 - local.get $0 - i64.extend_i32_s - i64.shr_u - local.set $9 - end - br $continue|10 - end - end - end - local.get $0 - i32.const 2 - i32.sub - local.set $0 - local.get $3 - local.set $11 - i64.const 0 - local.set $10 - block $break|11 - loop $continue|11 - local.get $0 - i32.const 0 - i32.ge_s - if - block - local.get $10 - i64.const 1 - i64.shl - local.set $10 - local.get $10 - i64.const 1 - i64.add - local.set $12 - local.get $12 - local.get $12 - i64.mul - local.get $11 - local.get $0 - i64.extend_i32_s - i64.shr_u - i64.le_u - if - local.get $12 - local.set $10 - end - local.get $0 - i32.const 2 - i32.sub - local.set $0 - end - br $continue|11 - end - end - end - local.get $10 + call $~lib/math/isqrt64 br $~lib/math/IntegerMath.sqrt|inlined.0 end i64.const 0 @@ -44093,91 +43760,7 @@ unreachable end local.get $0 - i32.const 2 - i32.lt_s - if - local.get $0 - br $~lib/math/IntegerMath.sqrt|inlined.1 - end - i32.const 2 - local.set $5 - local.get $0 - i32.const 2 - i32.shr_s - local.set $2 - block $break|12 - loop $continue|12 - local.get $2 - if (result i32) - local.get $2 - local.get $0 - i32.ne - else - local.get $2 - end - if - block - local.get $5 - i32.const 2 - i32.add - local.set $5 - local.get $0 - local.get $5 - i32.const 16 - i32.shl - i32.const 16 - i32.shr_s - i32.shr_s - local.set $2 - end - br $continue|12 - end - end - end - local.get $5 - i32.const 2 - i32.sub - local.set $5 - local.get $0 - local.set $7 - i32.const 0 - local.set $6 - block $break|13 - loop $continue|13 - local.get $5 - i32.const 0 - i32.ge_s - if - block - local.get $6 - i32.const 1 - i32.shl - local.set $6 - local.get $6 - i32.const 1 - i32.add - local.set $8 - local.get $8 - local.get $8 - i32.mul - local.get $7 - local.get $5 - i32.shr_u - i32.le_u - if - local.get $8 - local.set $6 - end - local.get $5 - i32.const 2 - i32.sub - local.set $5 - end - br $continue|13 - end - end - end - local.get $6 + call $~lib/math/isqrt32 br $~lib/math/IntegerMath.sqrt|inlined.1 end i32.const 16 @@ -44210,87 +43793,7 @@ unreachable end local.get $0 - i32.const 2 - i32.lt_s - if - local.get $0 - br $~lib/math/IntegerMath.sqrt|inlined.1 - end - i32.const 2 - local.set $2 - local.get $0 - i32.const 2 - i32.shr_s - local.set $5 - block $break|14 - loop $continue|14 - local.get $5 - if (result i32) - local.get $5 - local.get $0 - i32.ne - else - local.get $5 - end - if - block - local.get $2 - i32.const 2 - i32.add - local.set $2 - local.get $0 - local.get $2 - i32.shr_s - local.set $5 - end - br $continue|14 - end - end - end - local.get $2 - i32.const 2 - i32.sub - local.set $2 - local.get $0 - local.set $6 - i32.const 0 - local.set $7 - block $break|15 - loop $continue|15 - local.get $2 - i32.const 0 - i32.ge_s - if - block - local.get $7 - i32.const 1 - i32.shl - local.set $7 - local.get $7 - i32.const 1 - i32.add - local.set $8 - local.get $8 - local.get $8 - i32.mul - local.get $6 - local.get $2 - i32.shr_u - i32.le_u - if - local.get $8 - local.set $7 - end - local.get $2 - i32.const 2 - i32.sub - local.set $2 - end - br $continue|15 - end - end - end - local.get $7 + call $~lib/math/isqrt32 br $~lib/math/IntegerMath.sqrt|inlined.1 end i32.const 1 @@ -44308,87 +43811,7 @@ i32.const 1 local.set $0 local.get $0 - i32.const 2 - i32.lt_u - if - local.get $0 - br $~lib/math/IntegerMath.sqrt|inlined.1 - end - i32.const 2 - local.set $5 - local.get $0 - i32.const 2 - i32.shr_u - local.set $2 - block $break|16 - loop $continue|16 - local.get $2 - if (result i32) - local.get $2 - local.get $0 - i32.ne - else - local.get $2 - end - if - block - local.get $5 - i32.const 2 - i32.add - local.set $5 - local.get $0 - local.get $5 - i32.shr_u - local.set $2 - end - br $continue|16 - end - end - end - local.get $5 - i32.const 2 - i32.sub - local.set $5 - local.get $0 - local.set $7 - i32.const 0 - local.set $6 - block $break|17 - loop $continue|17 - local.get $5 - i32.const 0 - i32.ge_s - if - block - local.get $6 - i32.const 1 - i32.shl - local.set $6 - local.get $6 - i32.const 1 - i32.add - local.set $8 - local.get $8 - local.get $8 - i32.mul - local.get $7 - local.get $5 - i32.shr_u - i32.le_u - if - local.get $8 - local.set $6 - end - local.get $5 - i32.const 2 - i32.sub - local.set $5 - end - br $continue|17 - end - end - end - local.get $6 + call $~lib/math/isqrt32 br $~lib/math/IntegerMath.sqrt|inlined.1 end i32.const 1 @@ -44417,94 +43840,7 @@ unreachable end local.get $3 - i64.const 2 - i64.lt_s - if - local.get $3 - br $~lib/math/IntegerMath.sqrt|inlined.1 - end - i32.const 2 - local.set $0 - local.get $3 - i64.const 2 - i64.shr_s - local.set $9 - block $break|18 - loop $continue|18 - local.get $9 - i64.const 0 - i64.ne - if (result i64) - local.get $9 - local.get $3 - i64.ne - i64.extend_i32_u - else - local.get $9 - end - i64.const 0 - i64.ne - if - block - local.get $0 - i32.const 2 - i32.add - local.set $0 - local.get $3 - local.get $0 - i64.extend_i32_s - i64.shr_s - local.set $9 - end - br $continue|18 - end - end - end - local.get $0 - i32.const 2 - i32.sub - local.set $0 - local.get $3 - local.set $10 - i64.const 0 - local.set $11 - block $break|19 - loop $continue|19 - local.get $0 - i32.const 0 - i32.ge_s - if - block - local.get $11 - i64.const 1 - i64.shl - local.set $11 - local.get $11 - i64.const 1 - i64.add - local.set $12 - local.get $12 - local.get $12 - i64.mul - local.get $10 - local.get $0 - i64.extend_i32_s - i64.shr_u - i64.le_u - if - local.get $12 - local.set $11 - end - local.get $0 - i32.const 2 - i32.sub - local.set $0 - end - br $continue|19 - end - end - end - local.get $11 + call $~lib/math/isqrt64 br $~lib/math/IntegerMath.sqrt|inlined.1 end i64.const 1 @@ -44522,94 +43858,7 @@ i64.const 1 local.set $3 local.get $3 - i64.const 2 - i64.lt_u - if - local.get $3 - br $~lib/math/IntegerMath.sqrt|inlined.1 - end - i32.const 2 - local.set $0 - local.get $3 - i64.const 2 - i64.shr_u - local.set $9 - block $break|20 - loop $continue|20 - local.get $9 - i64.const 0 - i64.ne - if (result i64) - local.get $9 - local.get $3 - i64.ne - i64.extend_i32_u - else - local.get $9 - end - i64.const 0 - i64.ne - if - block - local.get $0 - i32.const 2 - i32.add - local.set $0 - local.get $3 - local.get $0 - i64.extend_i32_s - i64.shr_u - local.set $9 - end - br $continue|20 - end - end - end - local.get $0 - i32.const 2 - i32.sub - local.set $0 - local.get $3 - local.set $11 - i64.const 0 - local.set $10 - block $break|21 - loop $continue|21 - local.get $0 - i32.const 0 - i32.ge_s - if - block - local.get $10 - i64.const 1 - i64.shl - local.set $10 - local.get $10 - i64.const 1 - i64.add - local.set $12 - local.get $12 - local.get $12 - i64.mul - local.get $11 - local.get $0 - i64.extend_i32_s - i64.shr_u - i64.le_u - if - local.get $12 - local.set $10 - end - local.get $0 - i32.const 2 - i32.sub - local.set $0 - end - br $continue|21 - end - end - end - local.get $10 + call $~lib/math/isqrt64 br $~lib/math/IntegerMath.sqrt|inlined.1 end i64.const 1 @@ -44638,91 +43887,7 @@ unreachable end local.get $0 - i32.const 2 - i32.lt_s - if - local.get $0 - br $~lib/math/IntegerMath.sqrt|inlined.2 - end - i32.const 2 - local.set $2 - local.get $0 - i32.const 2 - i32.shr_s - local.set $5 - block $break|22 - loop $continue|22 - local.get $5 - if (result i32) - local.get $5 - local.get $0 - i32.ne - else - local.get $5 - end - if - block - local.get $2 - i32.const 2 - i32.add - local.set $2 - local.get $0 - local.get $2 - i32.const 16 - i32.shl - i32.const 16 - i32.shr_s - i32.shr_s - local.set $5 - end - br $continue|22 - end - end - end - local.get $2 - i32.const 2 - i32.sub - local.set $2 - local.get $0 - local.set $6 - i32.const 0 - local.set $7 - block $break|23 - loop $continue|23 - local.get $2 - i32.const 0 - i32.ge_s - if - block - local.get $7 - i32.const 1 - i32.shl - local.set $7 - local.get $7 - i32.const 1 - i32.add - local.set $8 - local.get $8 - local.get $8 - i32.mul - local.get $6 - local.get $2 - i32.shr_u - i32.le_u - if - local.get $8 - local.set $7 - end - local.get $2 - i32.const 2 - i32.sub - local.set $2 - end - br $continue|23 - end - end - end - local.get $7 + call $~lib/math/isqrt32 br $~lib/math/IntegerMath.sqrt|inlined.2 end i32.const 16 @@ -44755,185 +43920,25 @@ unreachable end local.get $0 + call $~lib/math/isqrt32 + br $~lib/math/IntegerMath.sqrt|inlined.2 + end + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3361 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.sqrt|inlined.2 (result i32) i32.const 2 - i32.lt_s - if - local.get $0 - br $~lib/math/IntegerMath.sqrt|inlined.2 - end - i32.const 2 - local.set $5 + local.set $0 local.get $0 - i32.const 2 - i32.shr_s - local.set $2 - block $break|24 - loop $continue|24 - local.get $2 - if (result i32) - local.get $2 - local.get $0 - i32.ne - else - local.get $2 - end - if - block - local.get $5 - i32.const 2 - i32.add - local.set $5 - local.get $0 - local.get $5 - i32.shr_s - local.set $2 - end - br $continue|24 - end - end - end - local.get $5 - i32.const 2 - i32.sub - local.set $5 - local.get $0 - local.set $7 - i32.const 0 - local.set $6 - block $break|25 - loop $continue|25 - local.get $5 - i32.const 0 - i32.ge_s - if - block - local.get $6 - i32.const 1 - i32.shl - local.set $6 - local.get $6 - i32.const 1 - i32.add - local.set $8 - local.get $8 - local.get $8 - i32.mul - local.get $7 - local.get $5 - i32.shr_u - i32.le_u - if - local.get $8 - local.set $6 - end - local.get $5 - i32.const 2 - i32.sub - local.set $5 - end - br $continue|25 - end - end - end - local.get $6 - br $~lib/math/IntegerMath.sqrt|inlined.2 - end - i32.const 1 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 8 - i32.const 3361 - i32.const 0 - call $~lib/env/abort - unreachable - end - block $~lib/math/IntegerMath.sqrt|inlined.2 (result i32) - i32.const 2 - local.set $0 - local.get $0 - i32.const 2 - i32.lt_u - if - local.get $0 - br $~lib/math/IntegerMath.sqrt|inlined.2 - end - i32.const 2 - local.set $2 - local.get $0 - i32.const 2 - i32.shr_u - local.set $5 - block $break|26 - loop $continue|26 - local.get $5 - if (result i32) - local.get $5 - local.get $0 - i32.ne - else - local.get $5 - end - if - block - local.get $2 - i32.const 2 - i32.add - local.set $2 - local.get $0 - local.get $2 - i32.shr_u - local.set $5 - end - br $continue|26 - end - end - end - local.get $2 - i32.const 2 - i32.sub - local.set $2 - local.get $0 - local.set $6 - i32.const 0 - local.set $7 - block $break|27 - loop $continue|27 - local.get $2 - i32.const 0 - i32.ge_s - if - block - local.get $7 - i32.const 1 - i32.shl - local.set $7 - local.get $7 - i32.const 1 - i32.add - local.set $8 - local.get $8 - local.get $8 - i32.mul - local.get $6 - local.get $2 - i32.shr_u - i32.le_u - if - local.get $8 - local.set $7 - end - local.get $2 - i32.const 2 - i32.sub - local.set $2 - end - br $continue|27 - end - end - end - local.get $7 + call $~lib/math/isqrt32 br $~lib/math/IntegerMath.sqrt|inlined.2 end i32.const 1 @@ -44962,94 +43967,7 @@ unreachable end local.get $3 - i64.const 2 - i64.lt_s - if - local.get $3 - br $~lib/math/IntegerMath.sqrt|inlined.2 - end - i32.const 2 - local.set $0 - local.get $3 - i64.const 2 - i64.shr_s - local.set $9 - block $break|28 - loop $continue|28 - local.get $9 - i64.const 0 - i64.ne - if (result i64) - local.get $9 - local.get $3 - i64.ne - i64.extend_i32_u - else - local.get $9 - end - i64.const 0 - i64.ne - if - block - local.get $0 - i32.const 2 - i32.add - local.set $0 - local.get $3 - local.get $0 - i64.extend_i32_s - i64.shr_s - local.set $9 - end - br $continue|28 - end - end - end - local.get $0 - i32.const 2 - i32.sub - local.set $0 - local.get $3 - local.set $10 - i64.const 0 - local.set $11 - block $break|29 - loop $continue|29 - local.get $0 - i32.const 0 - i32.ge_s - if - block - local.get $11 - i64.const 1 - i64.shl - local.set $11 - local.get $11 - i64.const 1 - i64.add - local.set $12 - local.get $12 - local.get $12 - i64.mul - local.get $10 - local.get $0 - i64.extend_i32_s - i64.shr_u - i64.le_u - if - local.get $12 - local.set $11 - end - local.get $0 - i32.const 2 - i32.sub - local.set $0 - end - br $continue|29 - end - end - end - local.get $11 + call $~lib/math/isqrt64 br $~lib/math/IntegerMath.sqrt|inlined.2 end i64.const 1 @@ -45067,94 +43985,7 @@ i64.const 2 local.set $3 local.get $3 - i64.const 2 - i64.lt_u - if - local.get $3 - br $~lib/math/IntegerMath.sqrt|inlined.2 - end - i32.const 2 - local.set $0 - local.get $3 - i64.const 2 - i64.shr_u - local.set $9 - block $break|30 - loop $continue|30 - local.get $9 - i64.const 0 - i64.ne - if (result i64) - local.get $9 - local.get $3 - i64.ne - i64.extend_i32_u - else - local.get $9 - end - i64.const 0 - i64.ne - if - block - local.get $0 - i32.const 2 - i32.add - local.set $0 - local.get $3 - local.get $0 - i64.extend_i32_s - i64.shr_u - local.set $9 - end - br $continue|30 - end - end - end - local.get $0 - i32.const 2 - i32.sub - local.set $0 - local.get $3 - local.set $11 - i64.const 0 - local.set $10 - block $break|31 - loop $continue|31 - local.get $0 - i32.const 0 - i32.ge_s - if - block - local.get $10 - i64.const 1 - i64.shl - local.set $10 - local.get $10 - i64.const 1 - i64.add - local.set $12 - local.get $12 - local.get $12 - i64.mul - local.get $11 - local.get $0 - i64.extend_i32_s - i64.shr_u - i64.le_u - if - local.get $12 - local.set $10 - end - local.get $0 - i32.const 2 - i32.sub - local.set $0 - end - br $continue|31 - end - end - end - local.get $10 + call $~lib/math/isqrt64 br $~lib/math/IntegerMath.sqrt|inlined.2 end i64.const 1 @@ -45183,91 +44014,7 @@ unreachable end local.get $0 - i32.const 2 - i32.lt_s - if - local.get $0 - br $~lib/math/IntegerMath.sqrt|inlined.3 - end - i32.const 2 - local.set $5 - local.get $0 - i32.const 2 - i32.shr_s - local.set $2 - block $break|32 - loop $continue|32 - local.get $2 - if (result i32) - local.get $2 - local.get $0 - i32.ne - else - local.get $2 - end - if - block - local.get $5 - i32.const 2 - i32.add - local.set $5 - local.get $0 - local.get $5 - i32.const 16 - i32.shl - i32.const 16 - i32.shr_s - i32.shr_s - local.set $2 - end - br $continue|32 - end - end - end - local.get $5 - i32.const 2 - i32.sub - local.set $5 - local.get $0 - local.set $7 - i32.const 0 - local.set $6 - block $break|33 - loop $continue|33 - local.get $5 - i32.const 0 - i32.ge_s - if - block - local.get $6 - i32.const 1 - i32.shl - local.set $6 - local.get $6 - i32.const 1 - i32.add - local.set $8 - local.get $8 - local.get $8 - i32.mul - local.get $7 - local.get $5 - i32.shr_u - i32.le_u - if - local.get $8 - local.set $6 - end - local.get $5 - i32.const 2 - i32.sub - local.set $5 - end - br $continue|33 - end - end - end - local.get $6 + call $~lib/math/isqrt32 br $~lib/math/IntegerMath.sqrt|inlined.3 end i32.const 16 @@ -45300,87 +44047,7 @@ unreachable end local.get $0 - i32.const 2 - i32.lt_s - if - local.get $0 - br $~lib/math/IntegerMath.sqrt|inlined.3 - end - i32.const 2 - local.set $2 - local.get $0 - i32.const 2 - i32.shr_s - local.set $5 - block $break|34 - loop $continue|34 - local.get $5 - if (result i32) - local.get $5 - local.get $0 - i32.ne - else - local.get $5 - end - if - block - local.get $2 - i32.const 2 - i32.add - local.set $2 - local.get $0 - local.get $2 - i32.shr_s - local.set $5 - end - br $continue|34 - end - end - end - local.get $2 - i32.const 2 - i32.sub - local.set $2 - local.get $0 - local.set $6 - i32.const 0 - local.set $7 - block $break|35 - loop $continue|35 - local.get $2 - i32.const 0 - i32.ge_s - if - block - local.get $7 - i32.const 1 - i32.shl - local.set $7 - local.get $7 - i32.const 1 - i32.add - local.set $8 - local.get $8 - local.get $8 - i32.mul - local.get $6 - local.get $2 - i32.shr_u - i32.le_u - if - local.get $8 - local.set $7 - end - local.get $2 - i32.const 2 - i32.sub - local.set $2 - end - br $continue|35 - end - end - end - local.get $7 + call $~lib/math/isqrt32 br $~lib/math/IntegerMath.sqrt|inlined.3 end i32.const 1 @@ -45398,87 +44065,7 @@ i32.const 3 local.set $0 local.get $0 - i32.const 2 - i32.lt_u - if - local.get $0 - br $~lib/math/IntegerMath.sqrt|inlined.3 - end - i32.const 2 - local.set $5 - local.get $0 - i32.const 2 - i32.shr_u - local.set $2 - block $break|36 - loop $continue|36 - local.get $2 - if (result i32) - local.get $2 - local.get $0 - i32.ne - else - local.get $2 - end - if - block - local.get $5 - i32.const 2 - i32.add - local.set $5 - local.get $0 - local.get $5 - i32.shr_u - local.set $2 - end - br $continue|36 - end - end - end - local.get $5 - i32.const 2 - i32.sub - local.set $5 - local.get $0 - local.set $7 - i32.const 0 - local.set $6 - block $break|37 - loop $continue|37 - local.get $5 - i32.const 0 - i32.ge_s - if - block - local.get $6 - i32.const 1 - i32.shl - local.set $6 - local.get $6 - i32.const 1 - i32.add - local.set $8 - local.get $8 - local.get $8 - i32.mul - local.get $7 - local.get $5 - i32.shr_u - i32.le_u - if - local.get $8 - local.set $6 - end - local.get $5 - i32.const 2 - i32.sub - local.set $5 - end - br $continue|37 - end - end - end - local.get $6 + call $~lib/math/isqrt32 br $~lib/math/IntegerMath.sqrt|inlined.3 end i32.const 1 @@ -45507,94 +44094,7 @@ unreachable end local.get $3 - i64.const 2 - i64.lt_s - if - local.get $3 - br $~lib/math/IntegerMath.sqrt|inlined.3 - end - i32.const 2 - local.set $0 - local.get $3 - i64.const 2 - i64.shr_s - local.set $9 - block $break|38 - loop $continue|38 - local.get $9 - i64.const 0 - i64.ne - if (result i64) - local.get $9 - local.get $3 - i64.ne - i64.extend_i32_u - else - local.get $9 - end - i64.const 0 - i64.ne - if - block - local.get $0 - i32.const 2 - i32.add - local.set $0 - local.get $3 - local.get $0 - i64.extend_i32_s - i64.shr_s - local.set $9 - end - br $continue|38 - end - end - end - local.get $0 - i32.const 2 - i32.sub - local.set $0 - local.get $3 - local.set $10 - i64.const 0 - local.set $11 - block $break|39 - loop $continue|39 - local.get $0 - i32.const 0 - i32.ge_s - if - block - local.get $11 - i64.const 1 - i64.shl - local.set $11 - local.get $11 - i64.const 1 - i64.add - local.set $12 - local.get $12 - local.get $12 - i64.mul - local.get $10 - local.get $0 - i64.extend_i32_s - i64.shr_u - i64.le_u - if - local.get $12 - local.set $11 - end - local.get $0 - i32.const 2 - i32.sub - local.set $0 - end - br $continue|39 - end - end - end - local.get $11 + call $~lib/math/isqrt64 br $~lib/math/IntegerMath.sqrt|inlined.3 end i64.const 1 @@ -45612,94 +44112,7 @@ i64.const 3 local.set $3 local.get $3 - i64.const 2 - i64.lt_u - if - local.get $3 - br $~lib/math/IntegerMath.sqrt|inlined.3 - end - i32.const 2 - local.set $0 - local.get $3 - i64.const 2 - i64.shr_u - local.set $9 - block $break|40 - loop $continue|40 - local.get $9 - i64.const 0 - i64.ne - if (result i64) - local.get $9 - local.get $3 - i64.ne - i64.extend_i32_u - else - local.get $9 - end - i64.const 0 - i64.ne - if - block - local.get $0 - i32.const 2 - i32.add - local.set $0 - local.get $3 - local.get $0 - i64.extend_i32_s - i64.shr_u - local.set $9 - end - br $continue|40 - end - end - end - local.get $0 - i32.const 2 - i32.sub - local.set $0 - local.get $3 - local.set $11 - i64.const 0 - local.set $10 - block $break|41 - loop $continue|41 - local.get $0 - i32.const 0 - i32.ge_s - if - block - local.get $10 - i64.const 1 - i64.shl - local.set $10 - local.get $10 - i64.const 1 - i64.add - local.set $12 - local.get $12 - local.get $12 - i64.mul - local.get $11 - local.get $0 - i64.extend_i32_s - i64.shr_u - i64.le_u - if - local.get $12 - local.set $10 - end - local.get $0 - i32.const 2 - i32.sub - local.set $0 - end - br $continue|41 - end - end - end - local.get $10 + call $~lib/math/isqrt64 br $~lib/math/IntegerMath.sqrt|inlined.3 end i64.const 1 @@ -45728,91 +44141,7 @@ unreachable end local.get $0 - i32.const 2 - i32.lt_s - if - local.get $0 - br $~lib/math/IntegerMath.sqrt|inlined.4 - end - i32.const 2 - local.set $2 - local.get $0 - i32.const 2 - i32.shr_s - local.set $5 - block $break|42 - loop $continue|42 - local.get $5 - if (result i32) - local.get $5 - local.get $0 - i32.ne - else - local.get $5 - end - if - block - local.get $2 - i32.const 2 - i32.add - local.set $2 - local.get $0 - local.get $2 - i32.const 16 - i32.shl - i32.const 16 - i32.shr_s - i32.shr_s - local.set $5 - end - br $continue|42 - end - end - end - local.get $2 - i32.const 2 - i32.sub - local.set $2 - local.get $0 - local.set $6 - i32.const 0 - local.set $7 - block $break|43 - loop $continue|43 - local.get $2 - i32.const 0 - i32.ge_s - if - block - local.get $7 - i32.const 1 - i32.shl - local.set $7 - local.get $7 - i32.const 1 - i32.add - local.set $8 - local.get $8 - local.get $8 - i32.mul - local.get $6 - local.get $2 - i32.shr_u - i32.le_u - if - local.get $8 - local.set $7 - end - local.get $2 - i32.const 2 - i32.sub - local.set $2 - end - br $continue|43 - end - end - end - local.get $7 + call $~lib/math/isqrt32 br $~lib/math/IntegerMath.sqrt|inlined.4 end i32.const 16 @@ -45845,87 +44174,7 @@ unreachable end local.get $0 - i32.const 2 - i32.lt_s - if - local.get $0 - br $~lib/math/IntegerMath.sqrt|inlined.4 - end - i32.const 2 - local.set $5 - local.get $0 - i32.const 2 - i32.shr_s - local.set $2 - block $break|44 - loop $continue|44 - local.get $2 - if (result i32) - local.get $2 - local.get $0 - i32.ne - else - local.get $2 - end - if - block - local.get $5 - i32.const 2 - i32.add - local.set $5 - local.get $0 - local.get $5 - i32.shr_s - local.set $2 - end - br $continue|44 - end - end - end - local.get $5 - i32.const 2 - i32.sub - local.set $5 - local.get $0 - local.set $7 - i32.const 0 - local.set $6 - block $break|45 - loop $continue|45 - local.get $5 - i32.const 0 - i32.ge_s - if - block - local.get $6 - i32.const 1 - i32.shl - local.set $6 - local.get $6 - i32.const 1 - i32.add - local.set $8 - local.get $8 - local.get $8 - i32.mul - local.get $7 - local.get $5 - i32.shr_u - i32.le_u - if - local.get $8 - local.set $6 - end - local.get $5 - i32.const 2 - i32.sub - local.set $5 - end - br $continue|45 - end - end - end - local.get $6 + call $~lib/math/isqrt32 br $~lib/math/IntegerMath.sqrt|inlined.4 end i32.const 2 @@ -45943,87 +44192,7 @@ i32.const 4 local.set $0 local.get $0 - i32.const 2 - i32.lt_u - if - local.get $0 - br $~lib/math/IntegerMath.sqrt|inlined.4 - end - i32.const 2 - local.set $2 - local.get $0 - i32.const 2 - i32.shr_u - local.set $5 - block $break|46 - loop $continue|46 - local.get $5 - if (result i32) - local.get $5 - local.get $0 - i32.ne - else - local.get $5 - end - if - block - local.get $2 - i32.const 2 - i32.add - local.set $2 - local.get $0 - local.get $2 - i32.shr_u - local.set $5 - end - br $continue|46 - end - end - end - local.get $2 - i32.const 2 - i32.sub - local.set $2 - local.get $0 - local.set $6 - i32.const 0 - local.set $7 - block $break|47 - loop $continue|47 - local.get $2 - i32.const 0 - i32.ge_s - if - block - local.get $7 - i32.const 1 - i32.shl - local.set $7 - local.get $7 - i32.const 1 - i32.add - local.set $8 - local.get $8 - local.get $8 - i32.mul - local.get $6 - local.get $2 - i32.shr_u - i32.le_u - if - local.get $8 - local.set $7 - end - local.get $2 - i32.const 2 - i32.sub - local.set $2 - end - br $continue|47 - end - end - end - local.get $7 + call $~lib/math/isqrt32 br $~lib/math/IntegerMath.sqrt|inlined.4 end i32.const 2 @@ -46052,94 +44221,7 @@ unreachable end local.get $3 - i64.const 2 - i64.lt_s - if - local.get $3 - br $~lib/math/IntegerMath.sqrt|inlined.4 - end - i32.const 2 - local.set $0 - local.get $3 - i64.const 2 - i64.shr_s - local.set $9 - block $break|48 - loop $continue|48 - local.get $9 - i64.const 0 - i64.ne - if (result i64) - local.get $9 - local.get $3 - i64.ne - i64.extend_i32_u - else - local.get $9 - end - i64.const 0 - i64.ne - if - block - local.get $0 - i32.const 2 - i32.add - local.set $0 - local.get $3 - local.get $0 - i64.extend_i32_s - i64.shr_s - local.set $9 - end - br $continue|48 - end - end - end - local.get $0 - i32.const 2 - i32.sub - local.set $0 - local.get $3 - local.set $10 - i64.const 0 - local.set $11 - block $break|49 - loop $continue|49 - local.get $0 - i32.const 0 - i32.ge_s - if - block - local.get $11 - i64.const 1 - i64.shl - local.set $11 - local.get $11 - i64.const 1 - i64.add - local.set $12 - local.get $12 - local.get $12 - i64.mul - local.get $10 - local.get $0 - i64.extend_i32_s - i64.shr_u - i64.le_u - if - local.get $12 - local.set $11 - end - local.get $0 - i32.const 2 - i32.sub - local.set $0 - end - br $continue|49 - end - end - end - local.get $11 + call $~lib/math/isqrt64 br $~lib/math/IntegerMath.sqrt|inlined.4 end i64.const 2 @@ -46157,94 +44239,7 @@ i64.const 4 local.set $3 local.get $3 - i64.const 2 - i64.lt_u - if - local.get $3 - br $~lib/math/IntegerMath.sqrt|inlined.4 - end - i32.const 2 - local.set $0 - local.get $3 - i64.const 2 - i64.shr_u - local.set $9 - block $break|50 - loop $continue|50 - local.get $9 - i64.const 0 - i64.ne - if (result i64) - local.get $9 - local.get $3 - i64.ne - i64.extend_i32_u - else - local.get $9 - end - i64.const 0 - i64.ne - if - block - local.get $0 - i32.const 2 - i32.add - local.set $0 - local.get $3 - local.get $0 - i64.extend_i32_s - i64.shr_u - local.set $9 - end - br $continue|50 - end - end - end - local.get $0 - i32.const 2 - i32.sub - local.set $0 - local.get $3 - local.set $11 - i64.const 0 - local.set $10 - block $break|51 - loop $continue|51 - local.get $0 - i32.const 0 - i32.ge_s - if - block - local.get $10 - i64.const 1 - i64.shl - local.set $10 - local.get $10 - i64.const 1 - i64.add - local.set $12 - local.get $12 - local.get $12 - i64.mul - local.get $11 - local.get $0 - i64.extend_i32_s - i64.shr_u - i64.le_u - if - local.get $12 - local.set $10 - end - local.get $0 - i32.const 2 - i32.sub - local.set $0 - end - br $continue|51 - end - end - end - local.get $10 + call $~lib/math/isqrt64 br $~lib/math/IntegerMath.sqrt|inlined.4 end i64.const 2 @@ -46273,205 +44268,31 @@ unreachable end local.get $0 - i32.const 2 - i32.lt_s - if - local.get $0 - br $~lib/math/IntegerMath.sqrt|inlined.5 - end - i32.const 2 - local.set $5 - local.get $0 - i32.const 2 - i32.shr_s - local.set $2 - block $break|52 - loop $continue|52 - local.get $2 - if (result i32) - local.get $2 - local.get $0 - i32.ne - else - local.get $2 - end - if - block - local.get $5 - i32.const 2 - i32.add - local.set $5 - local.get $0 - local.get $5 - i32.const 16 - i32.shl - i32.const 16 - i32.shr_s - i32.shr_s - local.set $2 - end - br $continue|52 - end - end - end - local.get $5 - i32.const 2 - i32.sub - local.set $5 - local.get $0 - local.set $7 - i32.const 0 - local.set $6 - block $break|53 - loop $continue|53 - local.get $5 - i32.const 0 - i32.ge_s - if - block - local.get $6 - i32.const 1 - i32.shl - local.set $6 - local.get $6 - i32.const 1 - i32.add - local.set $8 - local.get $8 - local.get $8 - i32.mul - local.get $7 - local.get $5 - i32.shr_u - i32.le_u - if - local.get $8 - local.set $6 - end - local.get $5 - i32.const 2 - i32.sub - local.set $5 - end - br $continue|53 - end - end - end - local.get $6 + call $~lib/math/isqrt32 br $~lib/math/IntegerMath.sqrt|inlined.5 end i32.const 16 i32.shl i32.const 16 i32.shr_s - i32.const 181 - i32.eq - i32.eqz - if - i32.const 0 - i32.const 8 - i32.const 3375 - i32.const 0 - call $~lib/env/abort - unreachable - end - block $~lib/math/IntegerMath.sqrt|inlined.0 (result i32) - global.get $~lib/builtins/i16.MAX_VALUE - local.set $0 - local.get $0 - i32.const 65535 - i32.and - i32.const 2 - i32.lt_u - if - local.get $0 - br $~lib/math/IntegerMath.sqrt|inlined.0 - end - i32.const 2 - local.set $2 - local.get $0 - i32.const 65535 - i32.and - i32.const 2 - i32.shr_u - local.set $5 - block $break|54 - loop $continue|54 - local.get $5 - if (result i32) - local.get $5 - local.get $0 - i32.const 65535 - i32.and - i32.ne - else - local.get $5 - end - if - block - local.get $2 - i32.const 2 - i32.add - local.set $2 - local.get $0 - i32.const 65535 - i32.and - local.get $2 - i32.const 65535 - i32.and - i32.shr_u - local.set $5 - end - br $continue|54 - end - end - end - local.get $2 - i32.const 2 - i32.sub - local.set $2 + i32.const 181 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3375 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.sqrt|inlined.0 (result i32) + global.get $~lib/builtins/i16.MAX_VALUE + local.set $0 local.get $0 i32.const 65535 i32.and - local.set $6 - i32.const 0 - local.set $7 - block $break|55 - loop $continue|55 - local.get $2 - i32.const 0 - i32.ge_s - if - block - local.get $7 - i32.const 1 - i32.shl - local.set $7 - local.get $7 - i32.const 1 - i32.add - local.set $8 - local.get $8 - local.get $8 - i32.mul - local.get $6 - local.get $2 - i32.shr_u - i32.le_u - if - local.get $8 - local.set $7 - end - local.get $2 - i32.const 2 - i32.sub - local.set $2 - end - br $continue|55 - end - end - end - local.get $7 + call $~lib/math/isqrt32 br $~lib/math/IntegerMath.sqrt|inlined.0 end i32.const 65535 @@ -46502,87 +44323,7 @@ unreachable end local.get $0 - i32.const 2 - i32.lt_s - if - local.get $0 - br $~lib/math/IntegerMath.sqrt|inlined.5 - end - i32.const 2 - local.set $5 - local.get $0 - i32.const 2 - i32.shr_s - local.set $2 - block $break|56 - loop $continue|56 - local.get $2 - if (result i32) - local.get $2 - local.get $0 - i32.ne - else - local.get $2 - end - if - block - local.get $5 - i32.const 2 - i32.add - local.set $5 - local.get $0 - local.get $5 - i32.shr_s - local.set $2 - end - br $continue|56 - end - end - end - local.get $5 - i32.const 2 - i32.sub - local.set $5 - local.get $0 - local.set $7 - i32.const 0 - local.set $6 - block $break|57 - loop $continue|57 - local.get $5 - i32.const 0 - i32.ge_s - if - block - local.get $6 - i32.const 1 - i32.shl - local.set $6 - local.get $6 - i32.const 1 - i32.add - local.set $8 - local.get $8 - local.get $8 - i32.mul - local.get $7 - local.get $5 - i32.shr_u - i32.le_u - if - local.get $8 - local.set $6 - end - local.get $5 - i32.const 2 - i32.sub - local.set $5 - end - br $continue|57 - end - end - end - local.get $6 + call $~lib/math/isqrt32 br $~lib/math/IntegerMath.sqrt|inlined.5 end i32.const 181 @@ -46600,87 +44341,7 @@ global.get $~lib/builtins/i16.MAX_VALUE local.set $0 local.get $0 - i32.const 2 - i32.lt_u - if - local.get $0 - br $~lib/math/IntegerMath.sqrt|inlined.5 - end - i32.const 2 - local.set $2 - local.get $0 - i32.const 2 - i32.shr_u - local.set $5 - block $break|58 - loop $continue|58 - local.get $5 - if (result i32) - local.get $5 - local.get $0 - i32.ne - else - local.get $5 - end - if - block - local.get $2 - i32.const 2 - i32.add - local.set $2 - local.get $0 - local.get $2 - i32.shr_u - local.set $5 - end - br $continue|58 - end - end - end - local.get $2 - i32.const 2 - i32.sub - local.set $2 - local.get $0 - local.set $6 - i32.const 0 - local.set $7 - block $break|59 - loop $continue|59 - local.get $2 - i32.const 0 - i32.ge_s - if - block - local.get $7 - i32.const 1 - i32.shl - local.set $7 - local.get $7 - i32.const 1 - i32.add - local.set $8 - local.get $8 - local.get $8 - i32.mul - local.get $6 - local.get $2 - i32.shr_u - i32.le_u - if - local.get $8 - local.set $7 - end - local.get $2 - i32.const 2 - i32.sub - local.set $2 - end - br $continue|59 - end - end - end - local.get $7 + call $~lib/math/isqrt32 br $~lib/math/IntegerMath.sqrt|inlined.5 end i32.const 181 @@ -46698,89 +44359,7 @@ global.get $~lib/builtins/u16.MAX_VALUE local.set $0 local.get $0 - i32.const 2 - i32.lt_u - if - local.get $0 - br $~lib/math/IntegerMath.sqrt|inlined.1 - end - i32.const 2 - local.set $5 - local.get $0 - i32.const 2 - i32.shr_u - local.set $2 - block $break|60 - loop $continue|60 - local.get $2 - if (result i32) - local.get $2 - local.get $0 - i32.ne - else - local.get $2 - end - if - block - local.get $5 - i32.const 2 - i32.add - local.set $5 - local.get $0 - local.get $5 - i32.const 65535 - i32.and - i32.shr_u - local.set $2 - end - br $continue|60 - end - end - end - local.get $5 - i32.const 2 - i32.sub - local.set $5 - local.get $0 - local.set $7 - i32.const 0 - local.set $6 - block $break|61 - loop $continue|61 - local.get $5 - i32.const 0 - i32.ge_s - if - block - local.get $6 - i32.const 1 - i32.shl - local.set $6 - local.get $6 - i32.const 1 - i32.add - local.set $8 - local.get $8 - local.get $8 - i32.mul - local.get $7 - local.get $5 - i32.shr_u - i32.le_u - if - local.get $8 - local.set $6 - end - local.get $5 - i32.const 2 - i32.sub - local.set $5 - end - br $continue|61 - end - end - end - local.get $6 + call $~lib/math/isqrt32 br $~lib/math/IntegerMath.sqrt|inlined.1 end i32.const 65535 @@ -46811,87 +44390,7 @@ unreachable end local.get $0 - i32.const 2 - i32.lt_s - if - local.get $0 - br $~lib/math/IntegerMath.sqrt|inlined.6 - end - i32.const 2 - local.set $2 - local.get $0 - i32.const 2 - i32.shr_s - local.set $5 - block $break|62 - loop $continue|62 - local.get $5 - if (result i32) - local.get $5 - local.get $0 - i32.ne - else - local.get $5 - end - if - block - local.get $2 - i32.const 2 - i32.add - local.set $2 - local.get $0 - local.get $2 - i32.shr_s - local.set $5 - end - br $continue|62 - end - end - end - local.get $2 - i32.const 2 - i32.sub - local.set $2 - local.get $0 - local.set $6 - i32.const 0 - local.set $7 - block $break|63 - loop $continue|63 - local.get $2 - i32.const 0 - i32.ge_s - if - block - local.get $7 - i32.const 1 - i32.shl - local.set $7 - local.get $7 - i32.const 1 - i32.add - local.set $8 - local.get $8 - local.get $8 - i32.mul - local.get $6 - local.get $2 - i32.shr_u - i32.le_u - if - local.get $8 - local.set $7 - end - local.get $2 - i32.const 2 - i32.sub - local.set $2 - end - br $continue|63 - end - end - end - local.get $7 + call $~lib/math/isqrt32 br $~lib/math/IntegerMath.sqrt|inlined.6 end i32.const 46340 @@ -46909,87 +44408,7 @@ global.get $~lib/builtins/i32.MAX_VALUE local.set $0 local.get $0 - i32.const 2 - i32.lt_u - if - local.get $0 - br $~lib/math/IntegerMath.sqrt|inlined.6 - end - i32.const 2 - local.set $5 - local.get $0 - i32.const 2 - i32.shr_u - local.set $2 - block $break|64 - loop $continue|64 - local.get $2 - if (result i32) - local.get $2 - local.get $0 - i32.ne - else - local.get $2 - end - if - block - local.get $5 - i32.const 2 - i32.add - local.set $5 - local.get $0 - local.get $5 - i32.shr_u - local.set $2 - end - br $continue|64 - end - end - end - local.get $5 - i32.const 2 - i32.sub - local.set $5 - local.get $0 - local.set $7 - i32.const 0 - local.set $6 - block $break|65 - loop $continue|65 - local.get $5 - i32.const 0 - i32.ge_s - if - block - local.get $6 - i32.const 1 - i32.shl - local.set $6 - local.get $6 - i32.const 1 - i32.add - local.set $8 - local.get $8 - local.get $8 - i32.mul - local.get $7 - local.get $5 - i32.shr_u - i32.le_u - if - local.get $8 - local.set $6 - end - local.get $5 - i32.const 2 - i32.sub - local.set $5 - end - br $continue|65 - end - end - end - local.get $6 + call $~lib/math/isqrt32 br $~lib/math/IntegerMath.sqrt|inlined.6 end i32.const 46340 @@ -47007,87 +44426,7 @@ global.get $~lib/builtins/u32.MAX_VALUE local.set $0 local.get $0 - i32.const 2 - i32.lt_u - if - local.get $0 - br $~lib/math/IntegerMath.sqrt|inlined.7 - end - i32.const 2 - local.set $2 - local.get $0 - i32.const 2 - i32.shr_u - local.set $5 - block $break|66 - loop $continue|66 - local.get $5 - if (result i32) - local.get $5 - local.get $0 - i32.ne - else - local.get $5 - end - if - block - local.get $2 - i32.const 2 - i32.add - local.set $2 - local.get $0 - local.get $2 - i32.shr_u - local.set $5 - end - br $continue|66 - end - end - end - local.get $2 - i32.const 2 - i32.sub - local.set $2 - local.get $0 - local.set $6 - i32.const 0 - local.set $7 - block $break|67 - loop $continue|67 - local.get $2 - i32.const 0 - i32.ge_s - if - block - local.get $7 - i32.const 1 - i32.shl - local.set $7 - local.get $7 - i32.const 1 - i32.add - local.set $8 - local.get $8 - local.get $8 - i32.mul - local.get $6 - local.get $2 - i32.shr_u - i32.le_u - if - local.get $8 - local.set $7 - end - local.get $2 - i32.const 2 - i32.sub - local.set $2 - end - br $continue|67 - end - end - end - local.get $7 + call $~lib/math/isqrt32 br $~lib/math/IntegerMath.sqrt|inlined.7 end i32.const 65535 @@ -47116,94 +44455,7 @@ unreachable end local.get $3 - i64.const 2 - i64.lt_s - if - local.get $3 - br $~lib/math/IntegerMath.sqrt|inlined.5 - end - i32.const 2 - local.set $0 - local.get $3 - i64.const 2 - i64.shr_s - local.set $9 - block $break|68 - loop $continue|68 - local.get $9 - i64.const 0 - i64.ne - if (result i64) - local.get $9 - local.get $3 - i64.ne - i64.extend_i32_u - else - local.get $9 - end - i64.const 0 - i64.ne - if - block - local.get $0 - i32.const 2 - i32.add - local.set $0 - local.get $3 - local.get $0 - i64.extend_i32_s - i64.shr_s - local.set $9 - end - br $continue|68 - end - end - end - local.get $0 - i32.const 2 - i32.sub - local.set $0 - local.get $3 - local.set $10 - i64.const 0 - local.set $11 - block $break|69 - loop $continue|69 - local.get $0 - i32.const 0 - i32.ge_s - if - block - local.get $11 - i64.const 1 - i64.shl - local.set $11 - local.get $11 - i64.const 1 - i64.add - local.set $12 - local.get $12 - local.get $12 - i64.mul - local.get $10 - local.get $0 - i64.extend_i32_s - i64.shr_u - i64.le_u - if - local.get $12 - local.set $11 - end - local.get $0 - i32.const 2 - i32.sub - local.set $0 - end - br $continue|69 - end - end - end - local.get $11 + call $~lib/math/isqrt64 br $~lib/math/IntegerMath.sqrt|inlined.5 end i64.const 3037000499 @@ -47221,94 +44473,7 @@ global.get $~lib/builtins/i64.MAX_VALUE local.set $3 local.get $3 - i64.const 2 - i64.lt_u - if - local.get $3 - br $~lib/math/IntegerMath.sqrt|inlined.5 - end - i32.const 2 - local.set $0 - local.get $3 - i64.const 2 - i64.shr_u - local.set $9 - block $break|70 - loop $continue|70 - local.get $9 - i64.const 0 - i64.ne - if (result i64) - local.get $9 - local.get $3 - i64.ne - i64.extend_i32_u - else - local.get $9 - end - i64.const 0 - i64.ne - if - block - local.get $0 - i32.const 2 - i32.add - local.set $0 - local.get $3 - local.get $0 - i64.extend_i32_s - i64.shr_u - local.set $9 - end - br $continue|70 - end - end - end - local.get $0 - i32.const 2 - i32.sub - local.set $0 - local.get $3 - local.set $11 - i64.const 0 - local.set $10 - block $break|71 - loop $continue|71 - local.get $0 - i32.const 0 - i32.ge_s - if - block - local.get $10 - i64.const 1 - i64.shl - local.set $10 - local.get $10 - i64.const 1 - i64.add - local.set $12 - local.get $12 - local.get $12 - i64.mul - local.get $11 - local.get $0 - i64.extend_i32_s - i64.shr_u - i64.le_u - if - local.get $12 - local.set $10 - end - local.get $0 - i32.const 2 - i32.sub - local.set $0 - end - br $continue|71 - end - end - end - local.get $10 + call $~lib/math/isqrt64 br $~lib/math/IntegerMath.sqrt|inlined.5 end i64.const 3037000499 @@ -48203,6 +45368,6 @@ unreachable end ) - (func $null (; 168 ;) (type $_) + (func $null (; 170 ;) (type $_) ) ) From fc23c09775c5a7fe8966a8245f22cf7b5b08c5ee Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Tue, 19 Feb 2019 21:03:58 +0200 Subject: [PATCH 17/22] more refactors --- std/assembly/math.ts | 17 +- tests/compiler/std/math.untouched.wat | 292 +++++++++++++++++--------- 2 files changed, 201 insertions(+), 108 deletions(-) diff --git a/std/assembly/math.ts b/std/assembly/math.ts index 5278e18848..0020495309 100644 --- a/std/assembly/math.ts +++ b/std/assembly/math.ts @@ -2375,11 +2375,8 @@ export namespace IntegerMath { } else { if (!x) throw new RangeError("Math.log2 received zero argument"); } - if (sizeof() <= 4) { - return (31 - builtin_clz(x)); - } else { - return (63 - builtin_clz(x)); - } + if (sizeof() <= 4) return ilog2_32(x); + if (sizeof() == 8) return ilog2_64(x); } throw new TypeError("Unexpected generic type"); } @@ -2421,6 +2418,16 @@ export namespace IntegerMath { } } +@inline +export function ilog2_32(x: u32): u32 { + return 31 - builtin_clz(x); +} + +@inline +export function ilog2_64(x: u64): u64 { + return 63 - builtin_clz(x); +} + // Complexity: O(log n) // Iterative version of approach described in this article: // https://www.cs.uni-potsdam.de/ti/kreitz/PDF/03cucs-intsqrt.pdf diff --git a/tests/compiler/std/math.untouched.wat b/tests/compiler/std/math.untouched.wat index 683999c0cf..f97ee5157d 100644 --- a/tests/compiler/std/math.untouched.wat +++ b/tests/compiler/std/math.untouched.wat @@ -11294,6 +11294,7 @@ return ) (func $~lib/math/IntegerMath.log2 (; 158 ;) (type $ii) (param $0 i32) (result i32) + (local $1 i32) local.get $0 i32.const 16 i32.shl @@ -11309,17 +11310,22 @@ call $~lib/env/abort unreachable end - i32.const 31 - local.get $0 - i32.const 16 - i32.shl - i32.const 16 - i32.shr_s - i32.clz - i32.sub + block $~lib/math/ilog2_32|inlined.9 (result i32) + local.get $0 + i32.const 16 + i32.shl + i32.const 16 + i32.shr_s + local.set $1 + i32.const 31 + local.get $1 + i32.clz + i32.sub + end return ) (func $~lib/math/IntegerMath.log2 (; 159 ;) (type $ii) (param $0 i32) (result i32) + (local $1 i32) local.get $0 i32.const 0 i32.le_s @@ -11331,13 +11337,18 @@ call $~lib/env/abort unreachable end - i32.const 31 - local.get $0 - i32.clz - i32.sub + block $~lib/math/ilog2_32|inlined.10 (result i32) + local.get $0 + local.set $1 + i32.const 31 + local.get $1 + i32.clz + i32.sub + end return ) (func $~lib/math/IntegerMath.log2 (; 160 ;) (type $ii) (param $0 i32) (result i32) + (local $1 i32) local.get $0 i32.eqz if @@ -11348,13 +11359,18 @@ call $~lib/env/abort unreachable end - i32.const 31 - local.get $0 - i32.clz - i32.sub + block $~lib/math/ilog2_32|inlined.11 (result i32) + local.get $0 + local.set $1 + i32.const 31 + local.get $1 + i32.clz + i32.sub + end return ) (func $~lib/math/IntegerMath.log2 (; 161 ;) (type $II) (param $0 i64) (result i64) + (local $1 i64) local.get $0 i64.const 0 i64.le_s @@ -11366,13 +11382,18 @@ call $~lib/env/abort unreachable end - i64.const 63 - local.get $0 - i64.clz - i64.sub + block $~lib/math/ilog2_64|inlined.6 (result i64) + local.get $0 + local.set $1 + i64.const 63 + local.get $1 + i64.clz + i64.sub + end return ) (func $~lib/math/IntegerMath.log2 (; 162 ;) (type $II) (param $0 i64) (result i64) + (local $1 i64) local.get $0 i64.eqz if @@ -11383,10 +11404,14 @@ call $~lib/env/abort unreachable end - i64.const 63 - local.get $0 - i64.clz - i64.sub + block $~lib/math/ilog2_64|inlined.7 (result i64) + local.get $0 + local.set $1 + i64.const 63 + local.get $1 + i64.clz + i64.sub + end return ) (func $~lib/math/isqrt32 (; 163 ;) (type $ii) (param $0 i32) (result i32) @@ -11919,6 +11944,7 @@ (local $2 i32) (local $3 i64) (local $4 f32) + (local $5 i64) global.get $~lib/math/NativeMath.E global.get $~lib/math/NativeMath.E f64.eq @@ -43092,10 +43118,14 @@ call $~lib/env/abort unreachable end - i32.const 31 - local.get $0 - i32.clz - i32.sub + block $~lib/math/ilog2_32|inlined.0 (result i32) + local.get $0 + local.set $2 + i32.const 31 + local.get $2 + i32.clz + i32.sub + end br $~lib/math/IntegerMath.log2|inlined.0 end i32.const 16 @@ -43127,10 +43157,14 @@ call $~lib/env/abort unreachable end - i32.const 31 - local.get $0 - i32.clz - i32.sub + block $~lib/math/ilog2_32|inlined.1 (result i32) + local.get $0 + local.set $2 + i32.const 31 + local.get $2 + i32.clz + i32.sub + end br $~lib/math/IntegerMath.log2|inlined.0 end i32.const 0 @@ -43157,10 +43191,14 @@ call $~lib/env/abort unreachable end - i32.const 31 - local.get $0 - i32.clz - i32.sub + block $~lib/math/ilog2_32|inlined.2 (result i32) + local.get $0 + local.set $2 + i32.const 31 + local.get $2 + i32.clz + i32.sub + end br $~lib/math/IntegerMath.log2|inlined.0 end i32.const 0 @@ -43188,10 +43226,14 @@ call $~lib/env/abort unreachable end - i64.const 63 - local.get $3 - i64.clz - i64.sub + block $~lib/math/ilog2_64|inlined.0 (result i64) + local.get $3 + local.set $5 + i64.const 63 + local.get $5 + i64.clz + i64.sub + end br $~lib/math/IntegerMath.log2|inlined.0 end i64.const 0 @@ -43218,10 +43260,14 @@ call $~lib/env/abort unreachable end - i64.const 63 - local.get $3 - i64.clz - i64.sub + block $~lib/math/ilog2_64|inlined.1 (result i64) + local.get $3 + local.set $5 + i64.const 63 + local.get $5 + i64.clz + i64.sub + end br $~lib/math/IntegerMath.log2|inlined.0 end i64.const 0 @@ -43249,10 +43295,14 @@ call $~lib/env/abort unreachable end - i32.const 31 - local.get $0 - i32.clz - i32.sub + block $~lib/math/ilog2_32|inlined.3 (result i32) + local.get $0 + local.set $2 + i32.const 31 + local.get $2 + i32.clz + i32.sub + end br $~lib/math/IntegerMath.log2|inlined.1 end i32.const 16 @@ -43284,10 +43334,14 @@ call $~lib/env/abort unreachable end - i32.const 31 - local.get $0 - i32.clz - i32.sub + block $~lib/math/ilog2_32|inlined.4 (result i32) + local.get $0 + local.set $2 + i32.const 31 + local.get $2 + i32.clz + i32.sub + end br $~lib/math/IntegerMath.log2|inlined.1 end i32.const 1 @@ -43314,10 +43368,14 @@ call $~lib/env/abort unreachable end - i32.const 31 - local.get $0 - i32.clz - i32.sub + block $~lib/math/ilog2_32|inlined.5 (result i32) + local.get $0 + local.set $2 + i32.const 31 + local.get $2 + i32.clz + i32.sub + end br $~lib/math/IntegerMath.log2|inlined.1 end i32.const 1 @@ -43345,10 +43403,14 @@ call $~lib/env/abort unreachable end - i64.const 63 - local.get $3 - i64.clz - i64.sub + block $~lib/math/ilog2_64|inlined.2 (result i64) + local.get $3 + local.set $5 + i64.const 63 + local.get $5 + i64.clz + i64.sub + end br $~lib/math/IntegerMath.log2|inlined.1 end i64.const 1 @@ -43375,10 +43437,14 @@ call $~lib/env/abort unreachable end - i64.const 63 - local.get $3 - i64.clz - i64.sub + block $~lib/math/ilog2_64|inlined.3 (result i64) + local.get $3 + local.set $5 + i64.const 63 + local.get $5 + i64.clz + i64.sub + end br $~lib/math/IntegerMath.log2|inlined.1 end i64.const 1 @@ -43406,10 +43472,14 @@ call $~lib/env/abort unreachable end - i32.const 31 - local.get $0 - i32.clz - i32.sub + block $~lib/math/ilog2_32|inlined.6 (result i32) + local.get $0 + local.set $2 + i32.const 31 + local.get $2 + i32.clz + i32.sub + end br $~lib/math/IntegerMath.log2|inlined.2 end i32.const 16 @@ -43441,10 +43511,14 @@ call $~lib/env/abort unreachable end - i32.const 31 - local.get $0 - i32.clz - i32.sub + block $~lib/math/ilog2_32|inlined.7 (result i32) + local.get $0 + local.set $2 + i32.const 31 + local.get $2 + i32.clz + i32.sub + end br $~lib/math/IntegerMath.log2|inlined.2 end i32.const 1 @@ -43471,10 +43545,14 @@ call $~lib/env/abort unreachable end - i32.const 31 - local.get $0 - i32.clz - i32.sub + block $~lib/math/ilog2_32|inlined.8 (result i32) + local.get $0 + local.set $2 + i32.const 31 + local.get $2 + i32.clz + i32.sub + end br $~lib/math/IntegerMath.log2|inlined.2 end i32.const 1 @@ -43502,10 +43580,14 @@ call $~lib/env/abort unreachable end - i64.const 63 - local.get $3 - i64.clz - i64.sub + block $~lib/math/ilog2_64|inlined.4 (result i64) + local.get $3 + local.set $5 + i64.const 63 + local.get $5 + i64.clz + i64.sub + end br $~lib/math/IntegerMath.log2|inlined.2 end i64.const 1 @@ -43532,10 +43614,14 @@ call $~lib/env/abort unreachable end - i64.const 63 - local.get $3 - i64.clz - i64.sub + block $~lib/math/ilog2_64|inlined.5 (result i64) + local.get $3 + local.set $5 + i64.const 63 + local.get $5 + i64.clz + i64.sub + end br $~lib/math/IntegerMath.log2|inlined.2 end i64.const 1 @@ -43627,7 +43713,7 @@ if i32.const 0 i32.const 40 - i32.const 2415 + i32.const 2412 i32.const 19 call $~lib/env/abort unreachable @@ -43660,7 +43746,7 @@ if i32.const 0 i32.const 40 - i32.const 2415 + i32.const 2412 i32.const 19 call $~lib/env/abort unreachable @@ -43707,7 +43793,7 @@ if i32.const 0 i32.const 40 - i32.const 2415 + i32.const 2412 i32.const 19 call $~lib/env/abort unreachable @@ -43754,7 +43840,7 @@ if i32.const 0 i32.const 40 - i32.const 2415 + i32.const 2412 i32.const 19 call $~lib/env/abort unreachable @@ -43787,7 +43873,7 @@ if i32.const 0 i32.const 40 - i32.const 2415 + i32.const 2412 i32.const 19 call $~lib/env/abort unreachable @@ -43834,7 +43920,7 @@ if i32.const 0 i32.const 40 - i32.const 2415 + i32.const 2412 i32.const 19 call $~lib/env/abort unreachable @@ -43881,7 +43967,7 @@ if i32.const 0 i32.const 40 - i32.const 2415 + i32.const 2412 i32.const 19 call $~lib/env/abort unreachable @@ -43914,7 +44000,7 @@ if i32.const 0 i32.const 40 - i32.const 2415 + i32.const 2412 i32.const 19 call $~lib/env/abort unreachable @@ -43961,7 +44047,7 @@ if i32.const 0 i32.const 40 - i32.const 2415 + i32.const 2412 i32.const 19 call $~lib/env/abort unreachable @@ -44008,7 +44094,7 @@ if i32.const 0 i32.const 40 - i32.const 2415 + i32.const 2412 i32.const 19 call $~lib/env/abort unreachable @@ -44041,7 +44127,7 @@ if i32.const 0 i32.const 40 - i32.const 2415 + i32.const 2412 i32.const 19 call $~lib/env/abort unreachable @@ -44088,7 +44174,7 @@ if i32.const 0 i32.const 40 - i32.const 2415 + i32.const 2412 i32.const 19 call $~lib/env/abort unreachable @@ -44135,7 +44221,7 @@ if i32.const 0 i32.const 40 - i32.const 2415 + i32.const 2412 i32.const 19 call $~lib/env/abort unreachable @@ -44168,7 +44254,7 @@ if i32.const 0 i32.const 40 - i32.const 2415 + i32.const 2412 i32.const 19 call $~lib/env/abort unreachable @@ -44215,7 +44301,7 @@ if i32.const 0 i32.const 40 - i32.const 2415 + i32.const 2412 i32.const 19 call $~lib/env/abort unreachable @@ -44262,7 +44348,7 @@ if i32.const 0 i32.const 40 - i32.const 2415 + i32.const 2412 i32.const 19 call $~lib/env/abort unreachable @@ -44317,7 +44403,7 @@ if i32.const 0 i32.const 40 - i32.const 2415 + i32.const 2412 i32.const 19 call $~lib/env/abort unreachable @@ -44384,7 +44470,7 @@ if i32.const 0 i32.const 40 - i32.const 2415 + i32.const 2412 i32.const 19 call $~lib/env/abort unreachable @@ -44449,7 +44535,7 @@ if i32.const 0 i32.const 40 - i32.const 2415 + i32.const 2412 i32.const 19 call $~lib/env/abort unreachable From c90d693cd3bebd50977ffa4805379e68237c70ef Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Wed, 20 Feb 2019 00:54:38 +0200 Subject: [PATCH 18/22] cleanups --- std/assembly/math.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/std/assembly/math.ts b/std/assembly/math.ts index 0020495309..8b47582ff0 100644 --- a/std/assembly/math.ts +++ b/std/assembly/math.ts @@ -2437,7 +2437,7 @@ export function isqrt32(x: u32): u32 { var xs = x >> 2; while (xs && xs != x) { s += 2; - xs = x >> s; + xs = x >> s; } s -= 2; var ux = x; @@ -2445,7 +2445,7 @@ export function isqrt32(x: u32): u32 { while (s >= 0) { res <<= 1; let m = res + 1; - if (m * m <= (ux >> s)) { + if (m * m <= ux >> s) { res = m; } s -= 2; @@ -2459,7 +2459,7 @@ export function isqrt64(x: u64): u64 { var xs = x >> 2; while (xs && xs != x) { s += 2; - xs = x >> s; + xs = x >> s; } s -= 2; var ux = x; @@ -2467,7 +2467,7 @@ export function isqrt64(x: u64): u64 { while (s >= 0) { res <<= 1; let m = res + 1; - if (m * m <= (ux >> s)) { + if (m * m <= ux >> s) { res = m; } s -= 2; From 7be71b7276b446ac86e4dbe0b59eb53d4e87cf6b Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Wed, 20 Feb 2019 02:52:12 +0200 Subject: [PATCH 19/22] add imul tests --- tests/compiler/std/math.optimized.wat | 120 +++++++------- tests/compiler/std/math.ts | 8 + tests/compiler/std/math.untouched.wat | 225 +++++++++++++++++++------- 3 files changed, 233 insertions(+), 120 deletions(-) diff --git a/tests/compiler/std/math.optimized.wat b/tests/compiler/std/math.optimized.wat index ee1c516d92..c3c8d0f14c 100644 --- a/tests/compiler/std/math.optimized.wat +++ b/tests/compiler/std/math.optimized.wat @@ -38448,7 +38448,7 @@ if i32.const 0 i32.const 8 - i32.const 3389 + i32.const 3397 i32.const 0 call $~lib/env/abort unreachable @@ -38461,7 +38461,7 @@ if i32.const 0 i32.const 8 - i32.const 3390 + i32.const 3398 i32.const 0 call $~lib/env/abort unreachable @@ -38474,7 +38474,7 @@ if i32.const 0 i32.const 8 - i32.const 3391 + i32.const 3399 i32.const 0 call $~lib/env/abort unreachable @@ -38487,7 +38487,7 @@ if i32.const 0 i32.const 8 - i32.const 3392 + i32.const 3400 i32.const 0 call $~lib/env/abort unreachable @@ -38500,7 +38500,7 @@ if i32.const 0 i32.const 8 - i32.const 3394 + i32.const 3402 i32.const 0 call $~lib/env/abort unreachable @@ -38513,7 +38513,7 @@ if i32.const 0 i32.const 8 - i32.const 3395 + i32.const 3403 i32.const 0 call $~lib/env/abort unreachable @@ -38526,7 +38526,7 @@ if i32.const 0 i32.const 8 - i32.const 3396 + i32.const 3404 i32.const 0 call $~lib/env/abort unreachable @@ -38539,7 +38539,7 @@ if i32.const 0 i32.const 8 - i32.const 3397 + i32.const 3405 i32.const 0 call $~lib/env/abort unreachable @@ -38552,7 +38552,7 @@ if i32.const 0 i32.const 8 - i32.const 3399 + i32.const 3407 i32.const 0 call $~lib/env/abort unreachable @@ -38565,7 +38565,7 @@ if i32.const 0 i32.const 8 - i32.const 3400 + i32.const 3408 i32.const 0 call $~lib/env/abort unreachable @@ -38578,7 +38578,7 @@ if i32.const 0 i32.const 8 - i32.const 3401 + i32.const 3409 i32.const 0 call $~lib/env/abort unreachable @@ -38591,7 +38591,7 @@ if i32.const 0 i32.const 8 - i32.const 3402 + i32.const 3410 i32.const 0 call $~lib/env/abort unreachable @@ -38604,7 +38604,7 @@ if i32.const 0 i32.const 8 - i32.const 3404 + i32.const 3412 i32.const 0 call $~lib/env/abort unreachable @@ -38617,7 +38617,7 @@ if i32.const 0 i32.const 8 - i32.const 3405 + i32.const 3413 i32.const 0 call $~lib/env/abort unreachable @@ -38630,7 +38630,7 @@ if i32.const 0 i32.const 8 - i32.const 3406 + i32.const 3414 i32.const 0 call $~lib/env/abort unreachable @@ -38643,7 +38643,7 @@ if i32.const 0 i32.const 8 - i32.const 3407 + i32.const 3415 i32.const 0 call $~lib/env/abort unreachable @@ -38656,7 +38656,7 @@ if i32.const 0 i32.const 8 - i32.const 3409 + i32.const 3417 i32.const 0 call $~lib/env/abort unreachable @@ -38669,7 +38669,7 @@ if i32.const 0 i32.const 8 - i32.const 3410 + i32.const 3418 i32.const 0 call $~lib/env/abort unreachable @@ -38682,7 +38682,7 @@ if i32.const 0 i32.const 8 - i32.const 3411 + i32.const 3419 i32.const 0 call $~lib/env/abort unreachable @@ -38695,7 +38695,7 @@ if i32.const 0 i32.const 8 - i32.const 3412 + i32.const 3420 i32.const 0 call $~lib/env/abort unreachable @@ -38708,7 +38708,7 @@ if i32.const 0 i32.const 8 - i32.const 3414 + i32.const 3422 i32.const 0 call $~lib/env/abort unreachable @@ -38721,7 +38721,7 @@ if i32.const 0 i32.const 8 - i32.const 3415 + i32.const 3423 i32.const 0 call $~lib/env/abort unreachable @@ -38734,7 +38734,7 @@ if i32.const 0 i32.const 8 - i32.const 3416 + i32.const 3424 i32.const 0 call $~lib/env/abort unreachable @@ -38747,7 +38747,7 @@ if i32.const 0 i32.const 8 - i32.const 3417 + i32.const 3425 i32.const 0 call $~lib/env/abort unreachable @@ -38760,7 +38760,7 @@ if i32.const 0 i32.const 8 - i32.const 3418 + i32.const 3426 i32.const 0 call $~lib/env/abort unreachable @@ -38773,7 +38773,7 @@ if i32.const 0 i32.const 8 - i32.const 3419 + i32.const 3427 i32.const 0 call $~lib/env/abort unreachable @@ -38786,7 +38786,7 @@ if i32.const 0 i32.const 8 - i32.const 3420 + i32.const 3428 i32.const 0 call $~lib/env/abort unreachable @@ -38803,7 +38803,7 @@ if i32.const 0 i32.const 8 - i32.const 3422 + i32.const 3430 i32.const 0 call $~lib/env/abort unreachable @@ -38816,7 +38816,7 @@ if i32.const 0 i32.const 8 - i32.const 3426 + i32.const 3434 i32.const 0 call $~lib/env/abort unreachable @@ -38829,7 +38829,7 @@ if i32.const 0 i32.const 8 - i32.const 3427 + i32.const 3435 i32.const 0 call $~lib/env/abort unreachable @@ -38843,7 +38843,7 @@ if i32.const 0 i32.const 8 - i32.const 3428 + i32.const 3436 i32.const 0 call $~lib/env/abort unreachable @@ -38857,7 +38857,7 @@ if i32.const 0 i32.const 8 - i32.const 3429 + i32.const 3437 i32.const 0 call $~lib/env/abort unreachable @@ -38871,7 +38871,7 @@ if i32.const 0 i32.const 8 - i32.const 3430 + i32.const 3438 i32.const 0 call $~lib/env/abort unreachable @@ -38884,7 +38884,7 @@ if i32.const 0 i32.const 8 - i32.const 3431 + i32.const 3439 i32.const 0 call $~lib/env/abort unreachable @@ -38897,7 +38897,7 @@ if i32.const 0 i32.const 8 - i32.const 3432 + i32.const 3440 i32.const 0 call $~lib/env/abort unreachable @@ -38910,7 +38910,7 @@ if i32.const 0 i32.const 8 - i32.const 3433 + i32.const 3441 i32.const 0 call $~lib/env/abort unreachable @@ -38923,7 +38923,7 @@ if i32.const 0 i32.const 8 - i32.const 3434 + i32.const 3442 i32.const 0 call $~lib/env/abort unreachable @@ -38936,7 +38936,7 @@ if i32.const 0 i32.const 8 - i32.const 3435 + i32.const 3443 i32.const 0 call $~lib/env/abort unreachable @@ -38949,7 +38949,7 @@ if i32.const 0 i32.const 8 - i32.const 3436 + i32.const 3444 i32.const 0 call $~lib/env/abort unreachable @@ -38962,7 +38962,7 @@ if i32.const 0 i32.const 8 - i32.const 3437 + i32.const 3445 i32.const 0 call $~lib/env/abort unreachable @@ -38975,7 +38975,7 @@ if i32.const 0 i32.const 8 - i32.const 3438 + i32.const 3446 i32.const 0 call $~lib/env/abort unreachable @@ -38988,7 +38988,7 @@ if i32.const 0 i32.const 8 - i32.const 3439 + i32.const 3447 i32.const 0 call $~lib/env/abort unreachable @@ -39001,7 +39001,7 @@ if i32.const 0 i32.const 8 - i32.const 3440 + i32.const 3448 i32.const 0 call $~lib/env/abort unreachable @@ -39014,7 +39014,7 @@ if i32.const 0 i32.const 8 - i32.const 3441 + i32.const 3449 i32.const 0 call $~lib/env/abort unreachable @@ -39027,7 +39027,7 @@ if i32.const 0 i32.const 8 - i32.const 3445 + i32.const 3453 i32.const 0 call $~lib/env/abort unreachable @@ -39040,7 +39040,7 @@ if i32.const 0 i32.const 8 - i32.const 3446 + i32.const 3454 i32.const 0 call $~lib/env/abort unreachable @@ -39054,7 +39054,7 @@ if i32.const 0 i32.const 8 - i32.const 3447 + i32.const 3455 i32.const 0 call $~lib/env/abort unreachable @@ -39068,7 +39068,7 @@ if i32.const 0 i32.const 8 - i32.const 3448 + i32.const 3456 i32.const 0 call $~lib/env/abort unreachable @@ -39082,7 +39082,7 @@ if i32.const 0 i32.const 8 - i32.const 3449 + i32.const 3457 i32.const 0 call $~lib/env/abort unreachable @@ -39095,7 +39095,7 @@ if i32.const 0 i32.const 8 - i32.const 3450 + i32.const 3458 i32.const 0 call $~lib/env/abort unreachable @@ -39108,7 +39108,7 @@ if i32.const 0 i32.const 8 - i32.const 3451 + i32.const 3459 i32.const 0 call $~lib/env/abort unreachable @@ -39121,7 +39121,7 @@ if i32.const 0 i32.const 8 - i32.const 3452 + i32.const 3460 i32.const 0 call $~lib/env/abort unreachable @@ -39134,7 +39134,7 @@ if i32.const 0 i32.const 8 - i32.const 3453 + i32.const 3461 i32.const 0 call $~lib/env/abort unreachable @@ -39147,7 +39147,7 @@ if i32.const 0 i32.const 8 - i32.const 3454 + i32.const 3462 i32.const 0 call $~lib/env/abort unreachable @@ -39160,7 +39160,7 @@ if i32.const 0 i32.const 8 - i32.const 3455 + i32.const 3463 i32.const 0 call $~lib/env/abort unreachable @@ -39173,7 +39173,7 @@ if i32.const 0 i32.const 8 - i32.const 3456 + i32.const 3464 i32.const 0 call $~lib/env/abort unreachable @@ -39186,7 +39186,7 @@ if i32.const 0 i32.const 8 - i32.const 3457 + i32.const 3465 i32.const 0 call $~lib/env/abort unreachable @@ -39199,7 +39199,7 @@ if i32.const 0 i32.const 8 - i32.const 3458 + i32.const 3466 i32.const 0 call $~lib/env/abort unreachable @@ -39212,7 +39212,7 @@ if i32.const 0 i32.const 8 - i32.const 3459 + i32.const 3467 i32.const 0 call $~lib/env/abort unreachable @@ -39225,7 +39225,7 @@ if i32.const 0 i32.const 8 - i32.const 3460 + i32.const 3468 i32.const 0 call $~lib/env/abort unreachable diff --git a/tests/compiler/std/math.ts b/tests/compiler/std/math.ts index 4a662c6a9b..c511e839e7 100644 --- a/tests/compiler/std/math.ts +++ b/tests/compiler/std/math.ts @@ -3384,6 +3384,14 @@ assert(IntegerMath.sqrt(i64.MAX_VALUE) == 3037000499); assert(IntegerMath.sqrt(i64.MAX_VALUE) == 3037000499); assert(IntegerMath.sqrt(u64.MAX_VALUE) == 4294967295); +// IntegerMath.imul /////////////////////////////////////////////////////////////////////////// + +assert(IntegerMath.imul(2, 4) == 8); +assert(IntegerMath.imul(-1, 8) == -8); +assert(IntegerMath.imul(-2, -2) == 4); +assert(IntegerMath.imul(0xffffffff, 5) == -5); +assert(IntegerMath.imul(0xfffffffe, 5) == -10); + // ipow64 ///////////////////////////////////////////////////////////////////////////////////// assert(ipow64(0, 0) == 1); diff --git a/tests/compiler/std/math.untouched.wat b/tests/compiler/std/math.untouched.wat index f97ee5157d..17356afb97 100644 --- a/tests/compiler/std/math.untouched.wat +++ b/tests/compiler/std/math.untouched.wat @@ -44586,6 +44586,111 @@ call $~lib/env/abort unreachable end + block $~lib/math/IntegerMath.imul|inlined.0 (result i32) + i32.const 2 + local.set $0 + i32.const 4 + local.set $2 + local.get $0 + local.get $2 + i32.mul + br $~lib/math/IntegerMath.imul|inlined.0 + end + i32.const 8 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3389 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.imul|inlined.1 (result i32) + i32.const -1 + local.set $2 + i32.const 8 + local.set $0 + local.get $2 + local.get $0 + i32.mul + br $~lib/math/IntegerMath.imul|inlined.1 + end + i32.const -8 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3390 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.imul|inlined.2 (result i32) + i32.const -2 + local.set $0 + i32.const -2 + local.set $2 + local.get $0 + local.get $2 + i32.mul + br $~lib/math/IntegerMath.imul|inlined.2 + end + i32.const 4 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3391 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.imul|inlined.0 (result i32) + i32.const -1 + local.set $2 + i32.const 5 + local.set $0 + local.get $2 + local.get $0 + i32.mul + br $~lib/math/IntegerMath.imul|inlined.0 + end + i32.const -5 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3392 + i32.const 0 + call $~lib/env/abort + unreachable + end + block $~lib/math/IntegerMath.imul|inlined.1 (result i32) + i32.const -2 + local.set $0 + i32.const 5 + local.set $2 + local.get $0 + local.get $2 + i32.mul + br $~lib/math/IntegerMath.imul|inlined.1 + end + i32.const -10 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3393 + i32.const 0 + call $~lib/env/abort + unreachable + end i64.const 0 i32.const 0 call $~lib/math/ipow64 @@ -44595,7 +44700,7 @@ if i32.const 0 i32.const 8 - i32.const 3389 + i32.const 3397 i32.const 0 call $~lib/env/abort unreachable @@ -44609,7 +44714,7 @@ if i32.const 0 i32.const 8 - i32.const 3390 + i32.const 3398 i32.const 0 call $~lib/env/abort unreachable @@ -44623,7 +44728,7 @@ if i32.const 0 i32.const 8 - i32.const 3391 + i32.const 3399 i32.const 0 call $~lib/env/abort unreachable @@ -44637,7 +44742,7 @@ if i32.const 0 i32.const 8 - i32.const 3392 + i32.const 3400 i32.const 0 call $~lib/env/abort unreachable @@ -44651,7 +44756,7 @@ if i32.const 0 i32.const 8 - i32.const 3394 + i32.const 3402 i32.const 0 call $~lib/env/abort unreachable @@ -44665,7 +44770,7 @@ if i32.const 0 i32.const 8 - i32.const 3395 + i32.const 3403 i32.const 0 call $~lib/env/abort unreachable @@ -44679,7 +44784,7 @@ if i32.const 0 i32.const 8 - i32.const 3396 + i32.const 3404 i32.const 0 call $~lib/env/abort unreachable @@ -44693,7 +44798,7 @@ if i32.const 0 i32.const 8 - i32.const 3397 + i32.const 3405 i32.const 0 call $~lib/env/abort unreachable @@ -44707,7 +44812,7 @@ if i32.const 0 i32.const 8 - i32.const 3399 + i32.const 3407 i32.const 0 call $~lib/env/abort unreachable @@ -44721,7 +44826,7 @@ if i32.const 0 i32.const 8 - i32.const 3400 + i32.const 3408 i32.const 0 call $~lib/env/abort unreachable @@ -44735,7 +44840,7 @@ if i32.const 0 i32.const 8 - i32.const 3401 + i32.const 3409 i32.const 0 call $~lib/env/abort unreachable @@ -44749,7 +44854,7 @@ if i32.const 0 i32.const 8 - i32.const 3402 + i32.const 3410 i32.const 0 call $~lib/env/abort unreachable @@ -44763,7 +44868,7 @@ if i32.const 0 i32.const 8 - i32.const 3404 + i32.const 3412 i32.const 0 call $~lib/env/abort unreachable @@ -44777,7 +44882,7 @@ if i32.const 0 i32.const 8 - i32.const 3405 + i32.const 3413 i32.const 0 call $~lib/env/abort unreachable @@ -44791,7 +44896,7 @@ if i32.const 0 i32.const 8 - i32.const 3406 + i32.const 3414 i32.const 0 call $~lib/env/abort unreachable @@ -44805,7 +44910,7 @@ if i32.const 0 i32.const 8 - i32.const 3407 + i32.const 3415 i32.const 0 call $~lib/env/abort unreachable @@ -44819,7 +44924,7 @@ if i32.const 0 i32.const 8 - i32.const 3409 + i32.const 3417 i32.const 0 call $~lib/env/abort unreachable @@ -44833,7 +44938,7 @@ if i32.const 0 i32.const 8 - i32.const 3410 + i32.const 3418 i32.const 0 call $~lib/env/abort unreachable @@ -44847,7 +44952,7 @@ if i32.const 0 i32.const 8 - i32.const 3411 + i32.const 3419 i32.const 0 call $~lib/env/abort unreachable @@ -44861,7 +44966,7 @@ if i32.const 0 i32.const 8 - i32.const 3412 + i32.const 3420 i32.const 0 call $~lib/env/abort unreachable @@ -44875,7 +44980,7 @@ if i32.const 0 i32.const 8 - i32.const 3414 + i32.const 3422 i32.const 0 call $~lib/env/abort unreachable @@ -44889,7 +44994,7 @@ if i32.const 0 i32.const 8 - i32.const 3415 + i32.const 3423 i32.const 0 call $~lib/env/abort unreachable @@ -44903,7 +45008,7 @@ if i32.const 0 i32.const 8 - i32.const 3416 + i32.const 3424 i32.const 0 call $~lib/env/abort unreachable @@ -44917,7 +45022,7 @@ if i32.const 0 i32.const 8 - i32.const 3417 + i32.const 3425 i32.const 0 call $~lib/env/abort unreachable @@ -44931,7 +45036,7 @@ if i32.const 0 i32.const 8 - i32.const 3418 + i32.const 3426 i32.const 0 call $~lib/env/abort unreachable @@ -44945,7 +45050,7 @@ if i32.const 0 i32.const 8 - i32.const 3419 + i32.const 3427 i32.const 0 call $~lib/env/abort unreachable @@ -44959,7 +45064,7 @@ if i32.const 0 i32.const 8 - i32.const 3420 + i32.const 3428 i32.const 0 call $~lib/env/abort unreachable @@ -44977,7 +45082,7 @@ if i32.const 0 i32.const 8 - i32.const 3422 + i32.const 3430 i32.const 0 call $~lib/env/abort unreachable @@ -44991,7 +45096,7 @@ if i32.const 0 i32.const 8 - i32.const 3426 + i32.const 3434 i32.const 0 call $~lib/env/abort unreachable @@ -45005,7 +45110,7 @@ if i32.const 0 i32.const 8 - i32.const 3427 + i32.const 3435 i32.const 0 call $~lib/env/abort unreachable @@ -45025,7 +45130,7 @@ if i32.const 0 i32.const 8 - i32.const 3428 + i32.const 3436 i32.const 0 call $~lib/env/abort unreachable @@ -45045,7 +45150,7 @@ if i32.const 0 i32.const 8 - i32.const 3429 + i32.const 3437 i32.const 0 call $~lib/env/abort unreachable @@ -45065,7 +45170,7 @@ if i32.const 0 i32.const 8 - i32.const 3430 + i32.const 3438 i32.const 0 call $~lib/env/abort unreachable @@ -45079,7 +45184,7 @@ if i32.const 0 i32.const 8 - i32.const 3431 + i32.const 3439 i32.const 0 call $~lib/env/abort unreachable @@ -45093,7 +45198,7 @@ if i32.const 0 i32.const 8 - i32.const 3432 + i32.const 3440 i32.const 0 call $~lib/env/abort unreachable @@ -45108,7 +45213,7 @@ if i32.const 0 i32.const 8 - i32.const 3433 + i32.const 3441 i32.const 0 call $~lib/env/abort unreachable @@ -45124,7 +45229,7 @@ if i32.const 0 i32.const 8 - i32.const 3434 + i32.const 3442 i32.const 0 call $~lib/env/abort unreachable @@ -45139,7 +45244,7 @@ if i32.const 0 i32.const 8 - i32.const 3435 + i32.const 3443 i32.const 0 call $~lib/env/abort unreachable @@ -45153,7 +45258,7 @@ if i32.const 0 i32.const 8 - i32.const 3436 + i32.const 3444 i32.const 0 call $~lib/env/abort unreachable @@ -45167,7 +45272,7 @@ if i32.const 0 i32.const 8 - i32.const 3437 + i32.const 3445 i32.const 0 call $~lib/env/abort unreachable @@ -45181,7 +45286,7 @@ if i32.const 0 i32.const 8 - i32.const 3438 + i32.const 3446 i32.const 0 call $~lib/env/abort unreachable @@ -45195,7 +45300,7 @@ if i32.const 0 i32.const 8 - i32.const 3439 + i32.const 3447 i32.const 0 call $~lib/env/abort unreachable @@ -45209,7 +45314,7 @@ if i32.const 0 i32.const 8 - i32.const 3440 + i32.const 3448 i32.const 0 call $~lib/env/abort unreachable @@ -45223,7 +45328,7 @@ if i32.const 0 i32.const 8 - i32.const 3441 + i32.const 3449 i32.const 0 call $~lib/env/abort unreachable @@ -45237,7 +45342,7 @@ if i32.const 0 i32.const 8 - i32.const 3445 + i32.const 3453 i32.const 0 call $~lib/env/abort unreachable @@ -45251,7 +45356,7 @@ if i32.const 0 i32.const 8 - i32.const 3446 + i32.const 3454 i32.const 0 call $~lib/env/abort unreachable @@ -45264,7 +45369,7 @@ if i32.const 0 i32.const 8 - i32.const 3447 + i32.const 3455 i32.const 0 call $~lib/env/abort unreachable @@ -45277,7 +45382,7 @@ if i32.const 0 i32.const 8 - i32.const 3448 + i32.const 3456 i32.const 0 call $~lib/env/abort unreachable @@ -45290,7 +45395,7 @@ if i32.const 0 i32.const 8 - i32.const 3449 + i32.const 3457 i32.const 0 call $~lib/env/abort unreachable @@ -45304,7 +45409,7 @@ if i32.const 0 i32.const 8 - i32.const 3450 + i32.const 3458 i32.const 0 call $~lib/env/abort unreachable @@ -45318,7 +45423,7 @@ if i32.const 0 i32.const 8 - i32.const 3451 + i32.const 3459 i32.const 0 call $~lib/env/abort unreachable @@ -45333,7 +45438,7 @@ if i32.const 0 i32.const 8 - i32.const 3452 + i32.const 3460 i32.const 0 call $~lib/env/abort unreachable @@ -45349,7 +45454,7 @@ if i32.const 0 i32.const 8 - i32.const 3453 + i32.const 3461 i32.const 0 call $~lib/env/abort unreachable @@ -45364,7 +45469,7 @@ if i32.const 0 i32.const 8 - i32.const 3454 + i32.const 3462 i32.const 0 call $~lib/env/abort unreachable @@ -45378,7 +45483,7 @@ if i32.const 0 i32.const 8 - i32.const 3455 + i32.const 3463 i32.const 0 call $~lib/env/abort unreachable @@ -45392,7 +45497,7 @@ if i32.const 0 i32.const 8 - i32.const 3456 + i32.const 3464 i32.const 0 call $~lib/env/abort unreachable @@ -45406,7 +45511,7 @@ if i32.const 0 i32.const 8 - i32.const 3457 + i32.const 3465 i32.const 0 call $~lib/env/abort unreachable @@ -45420,7 +45525,7 @@ if i32.const 0 i32.const 8 - i32.const 3458 + i32.const 3466 i32.const 0 call $~lib/env/abort unreachable @@ -45434,7 +45539,7 @@ if i32.const 0 i32.const 8 - i32.const 3459 + i32.const 3467 i32.const 0 call $~lib/env/abort unreachable @@ -45448,7 +45553,7 @@ if i32.const 0 i32.const 8 - i32.const 3460 + i32.const 3468 i32.const 0 call $~lib/env/abort unreachable From 9a890abf31e064181c8ca80a2f661cb39336a95c Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Thu, 21 Feb 2019 13:23:19 +0200 Subject: [PATCH 20/22] rebuild --- tests/compiler/std/math.optimized.wat | 424 +++++++++++++---- tests/compiler/std/math.untouched.wat | 656 +++++++++++++++++--------- 2 files changed, 767 insertions(+), 313 deletions(-) diff --git a/tests/compiler/std/math.optimized.wat b/tests/compiler/std/math.optimized.wat index 6783eff7f7..1d93d8e2f4 100644 --- a/tests/compiler/std/math.optimized.wat +++ b/tests/compiler/std/math.optimized.wat @@ -9223,7 +9223,30 @@ i32.mul f64.convert_i32_s ) - (func $~lib/math/isqrt32 (; 146 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/math/NativeMath.clz32 (; 146 ;) (type $FF) (param $0 f64) (result f64) + local.get $0 + local.get $0 + f64.sub + f64.const 0 + f64.ne + if + f64.const 32 + return + end + local.get $0 + f64.const 4294967296 + local.get $0 + f64.const 2.3283064365386963e-10 + f64.mul + f64.floor + f64.mul + f64.sub + i64.trunc_f64_s + i32.wrap_i64 + i32.clz + f64.convert_i32_s + ) + (func $~lib/math/isqrt32 (; 147 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -9295,7 +9318,7 @@ end local.get $3 ) - (func $~lib/math/isqrt64 (; 147 ;) (type $II) (param $0 i64) (result i64) + (func $~lib/math/isqrt64 (; 148 ;) (type $II) (param $0 i64) (result i64) (local $1 i32) (local $2 i64) (local $3 i64) @@ -9374,7 +9397,7 @@ end local.get $3 ) - (func $~lib/math/ipow64 (; 148 ;) (type $IiI) (param $0 i64) (param $1 i32) (result i64) + (func $~lib/math/ipow64 (; 149 ;) (type $IiI) (param $0 i64) (param $1 i32) (result i64) (local $2 i64) (local $3 i32) i64.const 1 @@ -9570,7 +9593,7 @@ end local.get $2 ) - (func $~lib/math/ipow32f (; 149 ;) (type $fif) (param $0 f32) (param $1 i32) (result f32) + (func $~lib/math/ipow32f (; 150 ;) (type $fif) (param $0 f32) (param $1 i32) (result f32) (local $2 f32) (local $3 i32) local.get $1 @@ -9616,7 +9639,7 @@ end local.get $2 ) - (func $~lib/math/ipow64f (; 150 ;) (type $FiF) (param $0 f64) (param $1 i32) (result f64) + (func $~lib/math/ipow64f (; 151 ;) (type $FiF) (param $0 f64) (param $1 i32) (result f64) (local $2 f64) (local $3 i32) local.get $1 @@ -9662,7 +9685,7 @@ end local.get $2 ) - (func $start (; 151 ;) (type $_) + (func $start:std/math (; 152 ;) (type $_) (local $0 f64) (local $1 f32) (local $2 i32) @@ -37998,6 +38021,198 @@ call $~lib/env/abort unreachable end + f64.const 0 + call $~lib/math/NativeMath.clz32 + f64.const 32 + f64.ne + if + i32.const 0 + i32.const 8 + i32.const 3289 + i32.const 0 + call $~lib/env/abort + unreachable + end + f64.const 1 + call $~lib/math/NativeMath.clz32 + f64.const 31 + f64.ne + if + i32.const 0 + i32.const 8 + i32.const 3290 + i32.const 0 + call $~lib/env/abort + unreachable + end + f64.const -1 + call $~lib/math/NativeMath.clz32 + f64.const 0 + f64.ne + if + i32.const 0 + i32.const 8 + i32.const 3291 + i32.const 0 + call $~lib/env/abort + unreachable + end + f64.const -128 + call $~lib/math/NativeMath.clz32 + f64.const 0 + f64.ne + if + i32.const 0 + i32.const 8 + i32.const 3292 + i32.const 0 + call $~lib/env/abort + unreachable + end + f64.const 4294967295 + call $~lib/math/NativeMath.clz32 + f64.const 0 + f64.ne + if + i32.const 0 + i32.const 8 + i32.const 3293 + i32.const 0 + call $~lib/env/abort + unreachable + end + f64.const 4294967295.5 + call $~lib/math/NativeMath.clz32 + f64.const 0 + f64.ne + if + i32.const 0 + i32.const 8 + i32.const 3294 + i32.const 0 + call $~lib/env/abort + unreachable + end + f64.const 4294967296 + call $~lib/math/NativeMath.clz32 + f64.const 32 + f64.ne + if + i32.const 0 + i32.const 8 + i32.const 3295 + i32.const 0 + call $~lib/env/abort + unreachable + end + f64.const 4294967297 + call $~lib/math/NativeMath.clz32 + f64.const 31 + f64.ne + if + i32.const 0 + i32.const 8 + i32.const 3296 + i32.const 0 + call $~lib/env/abort + unreachable + end + f64.const nan:0x8000000000000 + call $~lib/math/NativeMath.clz32 + f64.const 32 + f64.ne + if + i32.const 0 + i32.const 8 + i32.const 3297 + i32.const 0 + call $~lib/env/abort + unreachable + end + f64.const inf + call $~lib/math/NativeMath.clz32 + f64.const 32 + f64.ne + if + i32.const 0 + i32.const 8 + i32.const 3298 + i32.const 0 + call $~lib/env/abort + unreachable + end + f64.const 9007199254740991 + call $~lib/math/NativeMath.clz32 + f64.const 0 + f64.ne + if + i32.const 0 + i32.const 8 + i32.const 3299 + i32.const 0 + call $~lib/env/abort + unreachable + end + f64.const -9007199254740991 + call $~lib/math/NativeMath.clz32 + f64.const 31 + f64.ne + if + i32.const 0 + i32.const 8 + i32.const 3300 + i32.const 0 + call $~lib/env/abort + unreachable + end + f64.const 1797693134862315708145274e284 + call $~lib/math/NativeMath.clz32 + f64.const 32 + f64.ne + if + i32.const 0 + i32.const 8 + i32.const 3301 + i32.const 0 + call $~lib/env/abort + unreachable + end + f64.const 5e-324 + call $~lib/math/NativeMath.clz32 + f64.const 32 + f64.ne + if + i32.const 0 + i32.const 8 + i32.const 3302 + i32.const 0 + call $~lib/env/abort + unreachable + end + f64.const -1797693134862315708145274e284 + call $~lib/math/NativeMath.clz32 + f64.const 32 + f64.ne + if + i32.const 0 + i32.const 8 + i32.const 3303 + i32.const 0 + call $~lib/env/abort + unreachable + end + f64.const 2.220446049250313e-16 + call $~lib/math/NativeMath.clz32 + f64.const 32 + f64.ne + if + i32.const 0 + i32.const 8 + i32.const 3304 + i32.const 0 + call $~lib/env/abort + unreachable + end i32.const 0 call $~lib/math/isqrt32 i32.const 65535 @@ -38005,7 +38220,7 @@ if i32.const 0 i32.const 8 - i32.const 3350 + i32.const 3369 i32.const 0 call $~lib/env/abort unreachable @@ -38015,7 +38230,7 @@ if i32.const 0 i32.const 8 - i32.const 3351 + i32.const 3370 i32.const 0 call $~lib/env/abort unreachable @@ -38025,7 +38240,7 @@ if i32.const 0 i32.const 8 - i32.const 3352 + i32.const 3371 i32.const 0 call $~lib/env/abort unreachable @@ -38037,7 +38252,7 @@ if i32.const 0 i32.const 8 - i32.const 3353 + i32.const 3372 i32.const 0 call $~lib/env/abort unreachable @@ -38049,7 +38264,7 @@ if i32.const 0 i32.const 8 - i32.const 3354 + i32.const 3373 i32.const 0 call $~lib/env/abort unreachable @@ -38063,7 +38278,7 @@ if i32.const 0 i32.const 8 - i32.const 3355 + i32.const 3374 i32.const 0 call $~lib/env/abort unreachable @@ -38075,7 +38290,7 @@ if i32.const 0 i32.const 8 - i32.const 3356 + i32.const 3375 i32.const 0 call $~lib/env/abort unreachable @@ -38087,7 +38302,7 @@ if i32.const 0 i32.const 8 - i32.const 3357 + i32.const 3376 i32.const 0 call $~lib/env/abort unreachable @@ -38099,7 +38314,7 @@ if i32.const 0 i32.const 8 - i32.const 3358 + i32.const 3377 i32.const 0 call $~lib/env/abort unreachable @@ -38111,7 +38326,7 @@ if i32.const 0 i32.const 8 - i32.const 3359 + i32.const 3378 i32.const 0 call $~lib/env/abort unreachable @@ -38125,7 +38340,7 @@ if i32.const 0 i32.const 8 - i32.const 3360 + i32.const 3379 i32.const 0 call $~lib/env/abort unreachable @@ -38137,7 +38352,7 @@ if i32.const 0 i32.const 8 - i32.const 3361 + i32.const 3380 i32.const 0 call $~lib/env/abort unreachable @@ -38149,7 +38364,7 @@ if i32.const 0 i32.const 8 - i32.const 3362 + i32.const 3381 i32.const 0 call $~lib/env/abort unreachable @@ -38161,7 +38376,7 @@ if i32.const 0 i32.const 8 - i32.const 3363 + i32.const 3382 i32.const 0 call $~lib/env/abort unreachable @@ -38173,7 +38388,7 @@ if i32.const 0 i32.const 8 - i32.const 3364 + i32.const 3383 i32.const 0 call $~lib/env/abort unreachable @@ -38187,7 +38402,7 @@ if i32.const 0 i32.const 8 - i32.const 3365 + i32.const 3384 i32.const 0 call $~lib/env/abort unreachable @@ -38199,7 +38414,7 @@ if i32.const 0 i32.const 8 - i32.const 3366 + i32.const 3385 i32.const 0 call $~lib/env/abort unreachable @@ -38211,7 +38426,7 @@ if i32.const 0 i32.const 8 - i32.const 3367 + i32.const 3386 i32.const 0 call $~lib/env/abort unreachable @@ -38223,7 +38438,7 @@ if i32.const 0 i32.const 8 - i32.const 3368 + i32.const 3387 i32.const 0 call $~lib/env/abort unreachable @@ -38235,7 +38450,7 @@ if i32.const 0 i32.const 8 - i32.const 3369 + i32.const 3388 i32.const 0 call $~lib/env/abort unreachable @@ -38249,7 +38464,7 @@ if i32.const 0 i32.const 8 - i32.const 3370 + i32.const 3389 i32.const 0 call $~lib/env/abort unreachable @@ -38261,7 +38476,7 @@ if i32.const 0 i32.const 8 - i32.const 3371 + i32.const 3390 i32.const 0 call $~lib/env/abort unreachable @@ -38273,7 +38488,7 @@ if i32.const 0 i32.const 8 - i32.const 3372 + i32.const 3391 i32.const 0 call $~lib/env/abort unreachable @@ -38285,7 +38500,7 @@ if i32.const 0 i32.const 8 - i32.const 3373 + i32.const 3392 i32.const 0 call $~lib/env/abort unreachable @@ -38297,7 +38512,7 @@ if i32.const 0 i32.const 8 - i32.const 3374 + i32.const 3393 i32.const 0 call $~lib/env/abort unreachable @@ -38311,7 +38526,7 @@ if i32.const 0 i32.const 8 - i32.const 3375 + i32.const 3394 i32.const 0 call $~lib/env/abort unreachable @@ -38325,7 +38540,7 @@ if i32.const 0 i32.const 8 - i32.const 3376 + i32.const 3395 i32.const 0 call $~lib/env/abort unreachable @@ -38337,7 +38552,7 @@ if i32.const 0 i32.const 8 - i32.const 3377 + i32.const 3396 i32.const 0 call $~lib/env/abort unreachable @@ -38349,7 +38564,7 @@ if i32.const 0 i32.const 8 - i32.const 3378 + i32.const 3397 i32.const 0 call $~lib/env/abort unreachable @@ -38363,7 +38578,7 @@ if i32.const 0 i32.const 8 - i32.const 3379 + i32.const 3398 i32.const 0 call $~lib/env/abort unreachable @@ -38375,7 +38590,7 @@ if i32.const 0 i32.const 8 - i32.const 3380 + i32.const 3399 i32.const 0 call $~lib/env/abort unreachable @@ -38387,7 +38602,7 @@ if i32.const 0 i32.const 8 - i32.const 3381 + i32.const 3400 i32.const 0 call $~lib/env/abort unreachable @@ -38399,7 +38614,7 @@ if i32.const 0 i32.const 8 - i32.const 3382 + i32.const 3401 i32.const 0 call $~lib/env/abort unreachable @@ -38411,7 +38626,7 @@ if i32.const 0 i32.const 8 - i32.const 3383 + i32.const 3402 i32.const 0 call $~lib/env/abort unreachable @@ -38423,7 +38638,7 @@ if i32.const 0 i32.const 8 - i32.const 3384 + i32.const 3403 i32.const 0 call $~lib/env/abort unreachable @@ -38435,7 +38650,7 @@ if i32.const 0 i32.const 8 - i32.const 3385 + i32.const 3404 i32.const 0 call $~lib/env/abort unreachable @@ -38448,7 +38663,7 @@ if i32.const 0 i32.const 8 - i32.const 3397 + i32.const 3416 i32.const 0 call $~lib/env/abort unreachable @@ -38461,7 +38676,7 @@ if i32.const 0 i32.const 8 - i32.const 3398 + i32.const 3417 i32.const 0 call $~lib/env/abort unreachable @@ -38474,7 +38689,7 @@ if i32.const 0 i32.const 8 - i32.const 3399 + i32.const 3418 i32.const 0 call $~lib/env/abort unreachable @@ -38487,7 +38702,7 @@ if i32.const 0 i32.const 8 - i32.const 3400 + i32.const 3419 i32.const 0 call $~lib/env/abort unreachable @@ -38500,7 +38715,7 @@ if i32.const 0 i32.const 8 - i32.const 3402 + i32.const 3421 i32.const 0 call $~lib/env/abort unreachable @@ -38513,7 +38728,7 @@ if i32.const 0 i32.const 8 - i32.const 3403 + i32.const 3422 i32.const 0 call $~lib/env/abort unreachable @@ -38526,7 +38741,7 @@ if i32.const 0 i32.const 8 - i32.const 3404 + i32.const 3423 i32.const 0 call $~lib/env/abort unreachable @@ -38539,7 +38754,7 @@ if i32.const 0 i32.const 8 - i32.const 3405 + i32.const 3424 i32.const 0 call $~lib/env/abort unreachable @@ -38552,7 +38767,7 @@ if i32.const 0 i32.const 8 - i32.const 3407 + i32.const 3426 i32.const 0 call $~lib/env/abort unreachable @@ -38565,7 +38780,7 @@ if i32.const 0 i32.const 8 - i32.const 3408 + i32.const 3427 i32.const 0 call $~lib/env/abort unreachable @@ -38578,7 +38793,7 @@ if i32.const 0 i32.const 8 - i32.const 3409 + i32.const 3428 i32.const 0 call $~lib/env/abort unreachable @@ -38591,7 +38806,7 @@ if i32.const 0 i32.const 8 - i32.const 3410 + i32.const 3429 i32.const 0 call $~lib/env/abort unreachable @@ -38604,7 +38819,7 @@ if i32.const 0 i32.const 8 - i32.const 3412 + i32.const 3431 i32.const 0 call $~lib/env/abort unreachable @@ -38617,7 +38832,7 @@ if i32.const 0 i32.const 8 - i32.const 3413 + i32.const 3432 i32.const 0 call $~lib/env/abort unreachable @@ -38630,7 +38845,7 @@ if i32.const 0 i32.const 8 - i32.const 3414 + i32.const 3433 i32.const 0 call $~lib/env/abort unreachable @@ -38643,7 +38858,7 @@ if i32.const 0 i32.const 8 - i32.const 3415 + i32.const 3434 i32.const 0 call $~lib/env/abort unreachable @@ -38656,7 +38871,7 @@ if i32.const 0 i32.const 8 - i32.const 3417 + i32.const 3436 i32.const 0 call $~lib/env/abort unreachable @@ -38669,7 +38884,7 @@ if i32.const 0 i32.const 8 - i32.const 3418 + i32.const 3437 i32.const 0 call $~lib/env/abort unreachable @@ -38682,7 +38897,7 @@ if i32.const 0 i32.const 8 - i32.const 3419 + i32.const 3438 i32.const 0 call $~lib/env/abort unreachable @@ -38695,7 +38910,7 @@ if i32.const 0 i32.const 8 - i32.const 3420 + i32.const 3439 i32.const 0 call $~lib/env/abort unreachable @@ -38708,7 +38923,7 @@ if i32.const 0 i32.const 8 - i32.const 3422 + i32.const 3441 i32.const 0 call $~lib/env/abort unreachable @@ -38721,7 +38936,7 @@ if i32.const 0 i32.const 8 - i32.const 3423 + i32.const 3442 i32.const 0 call $~lib/env/abort unreachable @@ -38734,7 +38949,7 @@ if i32.const 0 i32.const 8 - i32.const 3424 + i32.const 3443 i32.const 0 call $~lib/env/abort unreachable @@ -38747,7 +38962,7 @@ if i32.const 0 i32.const 8 - i32.const 3425 + i32.const 3444 i32.const 0 call $~lib/env/abort unreachable @@ -38760,7 +38975,7 @@ if i32.const 0 i32.const 8 - i32.const 3426 + i32.const 3445 i32.const 0 call $~lib/env/abort unreachable @@ -38773,7 +38988,7 @@ if i32.const 0 i32.const 8 - i32.const 3427 + i32.const 3446 i32.const 0 call $~lib/env/abort unreachable @@ -38786,7 +39001,7 @@ if i32.const 0 i32.const 8 - i32.const 3428 + i32.const 3447 i32.const 0 call $~lib/env/abort unreachable @@ -38803,7 +39018,7 @@ if i32.const 0 i32.const 8 - i32.const 3430 + i32.const 3449 i32.const 0 call $~lib/env/abort unreachable @@ -38816,7 +39031,7 @@ if i32.const 0 i32.const 8 - i32.const 3434 + i32.const 3453 i32.const 0 call $~lib/env/abort unreachable @@ -38829,7 +39044,7 @@ if i32.const 0 i32.const 8 - i32.const 3435 + i32.const 3454 i32.const 0 call $~lib/env/abort unreachable @@ -38843,7 +39058,7 @@ if i32.const 0 i32.const 8 - i32.const 3436 + i32.const 3455 i32.const 0 call $~lib/env/abort unreachable @@ -38857,7 +39072,7 @@ if i32.const 0 i32.const 8 - i32.const 3437 + i32.const 3456 i32.const 0 call $~lib/env/abort unreachable @@ -38871,7 +39086,7 @@ if i32.const 0 i32.const 8 - i32.const 3438 + i32.const 3457 i32.const 0 call $~lib/env/abort unreachable @@ -38884,7 +39099,7 @@ if i32.const 0 i32.const 8 - i32.const 3439 + i32.const 3458 i32.const 0 call $~lib/env/abort unreachable @@ -38897,7 +39112,7 @@ if i32.const 0 i32.const 8 - i32.const 3440 + i32.const 3459 i32.const 0 call $~lib/env/abort unreachable @@ -38910,7 +39125,7 @@ if i32.const 0 i32.const 8 - i32.const 3441 + i32.const 3460 i32.const 0 call $~lib/env/abort unreachable @@ -38923,7 +39138,7 @@ if i32.const 0 i32.const 8 - i32.const 3442 + i32.const 3461 i32.const 0 call $~lib/env/abort unreachable @@ -38936,7 +39151,7 @@ if i32.const 0 i32.const 8 - i32.const 3443 + i32.const 3462 i32.const 0 call $~lib/env/abort unreachable @@ -38949,7 +39164,7 @@ if i32.const 0 i32.const 8 - i32.const 3444 + i32.const 3463 i32.const 0 call $~lib/env/abort unreachable @@ -38962,7 +39177,7 @@ if i32.const 0 i32.const 8 - i32.const 3445 + i32.const 3464 i32.const 0 call $~lib/env/abort unreachable @@ -38975,7 +39190,7 @@ if i32.const 0 i32.const 8 - i32.const 3446 + i32.const 3465 i32.const 0 call $~lib/env/abort unreachable @@ -38988,7 +39203,7 @@ if i32.const 0 i32.const 8 - i32.const 3447 + i32.const 3466 i32.const 0 call $~lib/env/abort unreachable @@ -39001,7 +39216,7 @@ if i32.const 0 i32.const 8 - i32.const 3448 + i32.const 3467 i32.const 0 call $~lib/env/abort unreachable @@ -39014,7 +39229,7 @@ if i32.const 0 i32.const 8 - i32.const 3449 + i32.const 3468 i32.const 0 call $~lib/env/abort unreachable @@ -39027,7 +39242,7 @@ if i32.const 0 i32.const 8 - i32.const 3453 + i32.const 3472 i32.const 0 call $~lib/env/abort unreachable @@ -39040,7 +39255,7 @@ if i32.const 0 i32.const 8 - i32.const 3454 + i32.const 3473 i32.const 0 call $~lib/env/abort unreachable @@ -39054,7 +39269,7 @@ if i32.const 0 i32.const 8 - i32.const 3455 + i32.const 3474 i32.const 0 call $~lib/env/abort unreachable @@ -39068,7 +39283,7 @@ if i32.const 0 i32.const 8 - i32.const 3456 + i32.const 3475 i32.const 0 call $~lib/env/abort unreachable @@ -39082,7 +39297,7 @@ if i32.const 0 i32.const 8 - i32.const 3457 + i32.const 3476 i32.const 0 call $~lib/env/abort unreachable @@ -39095,7 +39310,7 @@ if i32.const 0 i32.const 8 - i32.const 3458 + i32.const 3477 i32.const 0 call $~lib/env/abort unreachable @@ -39108,7 +39323,7 @@ if i32.const 0 i32.const 8 - i32.const 3459 + i32.const 3478 i32.const 0 call $~lib/env/abort unreachable @@ -39121,7 +39336,7 @@ if i32.const 0 i32.const 8 - i32.const 3460 + i32.const 3479 i32.const 0 call $~lib/env/abort unreachable @@ -39134,7 +39349,7 @@ if i32.const 0 i32.const 8 - i32.const 3461 + i32.const 3480 i32.const 0 call $~lib/env/abort unreachable @@ -39147,7 +39362,7 @@ if i32.const 0 i32.const 8 - i32.const 3462 + i32.const 3481 i32.const 0 call $~lib/env/abort unreachable @@ -39160,7 +39375,7 @@ if i32.const 0 i32.const 8 - i32.const 3463 + i32.const 3482 i32.const 0 call $~lib/env/abort unreachable @@ -39173,7 +39388,7 @@ if i32.const 0 i32.const 8 - i32.const 3464 + i32.const 3483 i32.const 0 call $~lib/env/abort unreachable @@ -39186,7 +39401,7 @@ if i32.const 0 i32.const 8 - i32.const 3465 + i32.const 3484 i32.const 0 call $~lib/env/abort unreachable @@ -39199,7 +39414,7 @@ if i32.const 0 i32.const 8 - i32.const 3466 + i32.const 3485 i32.const 0 call $~lib/env/abort unreachable @@ -39212,7 +39427,7 @@ if i32.const 0 i32.const 8 - i32.const 3467 + i32.const 3486 i32.const 0 call $~lib/env/abort unreachable @@ -39225,13 +39440,16 @@ if i32.const 0 i32.const 8 - i32.const 3468 + i32.const 3487 i32.const 0 call $~lib/env/abort unreachable end ) - (func $null (; 152 ;) (type $_) + (func $start (; 153 ;) (type $_) + call $start:std/math + ) + (func $null (; 154 ;) (type $_) nop ) ) diff --git a/tests/compiler/std/math.untouched.wat b/tests/compiler/std/math.untouched.wat index 391c8a7ce3..4b635107fb 100644 --- a/tests/compiler/std/math.untouched.wat +++ b/tests/compiler/std/math.untouched.wat @@ -93,6 +93,8 @@ (global $~lib/math/random_state1_32 (mut i32) (i32.const 0)) (global $~lib/ASC_SHRINK_LEVEL i32 (i32.const 0)) (global $~lib/builtins/f64.MAX_VALUE f64 (f64.const 1797693134862315708145274e284)) + (global $~lib/builtins/f64.MAX_SAFE_INTEGER f64 (f64.const 9007199254740991)) + (global $~lib/builtins/f64.EPSILON f64 (f64.const 2.220446049250313e-16)) (global $~lib/builtins/i16.MAX_VALUE i32 (i32.const 32767)) (global $~lib/builtins/i32.MAX_VALUE i32 (i32.const 2147483647)) (global $~lib/builtins/u32.MAX_VALUE i32 (i32.const -1)) @@ -11251,7 +11253,30 @@ i32.mul f64.convert_i32_s ) - (func $~lib/math/IntegerMath.sign (; 154 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/math/NativeMath.clz32 (; 154 ;) (type $FF) (param $0 f64) (result f64) + local.get $0 + call $~lib/builtins/isFinite + i32.eqz + if + f64.const 32 + return + end + local.get $0 + f64.const 4294967296 + local.get $0 + f64.const 1 + f64.const 4294967296 + f64.div + f64.mul + f64.floor + f64.mul + f64.sub + i64.trunc_f64_s + i32.wrap_i64 + i32.clz + f64.convert_i32_s + ) + (func $~lib/math/IntegerMath.sign (; 155 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.const 16 i32.shl @@ -11269,7 +11294,7 @@ i32.sub return ) - (func $~lib/math/IntegerMath.sign (; 155 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/math/IntegerMath.sign (; 156 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.const 65535 i32.and @@ -11277,7 +11302,7 @@ i32.ne return ) - (func $~lib/math/IntegerMath.signbit (; 156 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/math/IntegerMath.signbit (; 157 ;) (type $ii) (param $0 i32) (result i32) local.get $0 i32.const 16 i32.shl @@ -11287,11 +11312,11 @@ i32.lt_s return ) - (func $~lib/math/IntegerMath.signbit (; 157 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/math/IntegerMath.signbit (; 158 ;) (type $ii) (param $0 i32) (result i32) i32.const 0 return ) - (func $~lib/math/IntegerMath.log2 (; 158 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/math/IntegerMath.log2 (; 159 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) local.get $0 i32.const 16 @@ -11303,7 +11328,7 @@ if i32.const 0 i32.const 40 - i32.const 2374 + i32.const 2387 i32.const 20 call $~lib/env/abort unreachable @@ -11322,7 +11347,7 @@ end return ) - (func $~lib/math/IntegerMath.log2 (; 159 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/math/IntegerMath.log2 (; 160 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) local.get $0 i32.const 0 @@ -11330,7 +11355,7 @@ if i32.const 0 i32.const 40 - i32.const 2374 + i32.const 2387 i32.const 20 call $~lib/env/abort unreachable @@ -11345,14 +11370,14 @@ end return ) - (func $~lib/math/IntegerMath.log2 (; 160 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/math/IntegerMath.log2 (; 161 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) local.get $0 i32.eqz if i32.const 0 i32.const 40 - i32.const 2376 + i32.const 2389 i32.const 16 call $~lib/env/abort unreachable @@ -11367,7 +11392,7 @@ end return ) - (func $~lib/math/IntegerMath.log2 (; 161 ;) (type $II) (param $0 i64) (result i64) + (func $~lib/math/IntegerMath.log2 (; 162 ;) (type $II) (param $0 i64) (result i64) (local $1 i64) local.get $0 i64.const 0 @@ -11375,7 +11400,7 @@ if i32.const 0 i32.const 40 - i32.const 2374 + i32.const 2387 i32.const 20 call $~lib/env/abort unreachable @@ -11390,14 +11415,14 @@ end return ) - (func $~lib/math/IntegerMath.log2 (; 162 ;) (type $II) (param $0 i64) (result i64) + (func $~lib/math/IntegerMath.log2 (; 163 ;) (type $II) (param $0 i64) (result i64) (local $1 i64) local.get $0 i64.eqz if i32.const 0 i32.const 40 - i32.const 2376 + i32.const 2389 i32.const 16 call $~lib/env/abort unreachable @@ -11412,7 +11437,7 @@ end return ) - (func $~lib/math/isqrt32 (; 163 ;) (type $ii) (param $0 i32) (result i32) + (func $~lib/math/isqrt32 (; 164 ;) (type $ii) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) (local $3 i32) @@ -11501,7 +11526,7 @@ end local.get $4 ) - (func $~lib/math/isqrt64 (; 164 ;) (type $II) (param $0 i64) (result i64) + (func $~lib/math/isqrt64 (; 165 ;) (type $II) (param $0 i64) (result i64) (local $1 i32) (local $2 i64) (local $3 i64) @@ -11597,12 +11622,12 @@ end local.get $4 ) - (func $~lib/math/IntegerMath.sqrt (; 165 ;) (type $II) (param $0 i64) (result i64) + (func $~lib/math/IntegerMath.sqrt (; 166 ;) (type $II) (param $0 i64) (result i64) local.get $0 call $~lib/math/isqrt64 return ) - (func $~lib/math/ipow64 (; 166 ;) (type $IiI) (param $0 i64) (param $1 i32) (result i64) + (func $~lib/math/ipow64 (; 167 ;) (type $IiI) (param $0 i64) (param $1 i32) (result i64) (local $2 i64) (local $3 i32) (local $4 i32) @@ -11834,7 +11859,7 @@ end local.get $2 ) - (func $~lib/math/ipow32f (; 167 ;) (type $fif) (param $0 f32) (param $1 i32) (result f32) + (func $~lib/math/ipow32f (; 168 ;) (type $fif) (param $0 f32) (param $1 i32) (result f32) (local $2 i32) (local $3 f32) local.get $1 @@ -11885,7 +11910,7 @@ local.get $3 end ) - (func $~lib/math/ipow64f (; 168 ;) (type $FiF) (param $0 f64) (param $1 i32) (result f64) + (func $~lib/math/ipow64f (; 169 ;) (type $FiF) (param $0 f64) (param $1 i32) (result f64) (local $2 i32) (local $3 f64) local.get $1 @@ -11936,7 +11961,7 @@ local.get $3 end ) - (func $start (; 169 ;) (type $_) + (func $start:std/math (; 170 ;) (type $_) (local $0 i32) (local $1 f64) (local $2 i32) @@ -42476,6 +42501,216 @@ call $~lib/env/abort unreachable end + f64.const 0 + call $~lib/math/NativeMath.clz32 + f64.const 32 + f64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3289 + i32.const 0 + call $~lib/env/abort + unreachable + end + f64.const 1 + call $~lib/math/NativeMath.clz32 + f64.const 31 + f64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3290 + i32.const 0 + call $~lib/env/abort + unreachable + end + f64.const -1 + call $~lib/math/NativeMath.clz32 + f64.const 0 + f64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3291 + i32.const 0 + call $~lib/env/abort + unreachable + end + f64.const -128 + call $~lib/math/NativeMath.clz32 + f64.const 0 + f64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3292 + i32.const 0 + call $~lib/env/abort + unreachable + end + f64.const 4294967295 + call $~lib/math/NativeMath.clz32 + f64.const 0 + f64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3293 + i32.const 0 + call $~lib/env/abort + unreachable + end + f64.const 4294967295.5 + call $~lib/math/NativeMath.clz32 + f64.const 0 + f64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3294 + i32.const 0 + call $~lib/env/abort + unreachable + end + f64.const 4294967296 + call $~lib/math/NativeMath.clz32 + f64.const 32 + f64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3295 + i32.const 0 + call $~lib/env/abort + unreachable + end + f64.const 4294967297 + call $~lib/math/NativeMath.clz32 + f64.const 31 + f64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3296 + i32.const 0 + call $~lib/env/abort + unreachable + end + f64.const nan:0x8000000000000 + call $~lib/math/NativeMath.clz32 + f64.const 32 + f64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3297 + i32.const 0 + call $~lib/env/abort + unreachable + end + f64.const inf + call $~lib/math/NativeMath.clz32 + f64.const 32 + f64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3298 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $~lib/builtins/f64.MAX_SAFE_INTEGER + call $~lib/math/NativeMath.clz32 + f64.const 0 + f64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3299 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $~lib/builtins/f64.MAX_SAFE_INTEGER + f64.neg + call $~lib/math/NativeMath.clz32 + f64.const 31 + f64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3300 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $~lib/builtins/f64.MAX_VALUE + call $~lib/math/NativeMath.clz32 + f64.const 32 + f64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3301 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $~lib/builtins/f64.MIN_VALUE + call $~lib/math/NativeMath.clz32 + f64.const 32 + f64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3302 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $~lib/builtins/f64.MAX_VALUE + f64.neg + call $~lib/math/NativeMath.clz32 + f64.const 32 + f64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3303 + i32.const 0 + call $~lib/env/abort + unreachable + end + global.get $~lib/builtins/f64.EPSILON + call $~lib/math/NativeMath.clz32 + f64.const 32 + f64.eq + i32.eqz + if + i32.const 0 + i32.const 8 + i32.const 3304 + i32.const 0 + call $~lib/env/abort + unreachable + end block $~lib/math/IntegerMath.sign|inlined.0 (result i32) i32.const 0 local.set $0 @@ -42494,7 +42729,7 @@ if i32.const 0 i32.const 8 - i32.const 3289 + i32.const 3308 i32.const 0 call $~lib/env/abort unreachable @@ -42513,7 +42748,7 @@ if i32.const 0 i32.const 8 - i32.const 3290 + i32.const 3309 i32.const 0 call $~lib/env/abort unreachable @@ -42536,7 +42771,7 @@ if i32.const 0 i32.const 8 - i32.const 3291 + i32.const 3310 i32.const 0 call $~lib/env/abort unreachable @@ -42555,7 +42790,7 @@ if i32.const 0 i32.const 8 - i32.const 3292 + i32.const 3311 i32.const 0 call $~lib/env/abort unreachable @@ -42578,7 +42813,7 @@ if i32.const 0 i32.const 8 - i32.const 3293 + i32.const 3312 i32.const 0 call $~lib/env/abort unreachable @@ -42597,7 +42832,7 @@ if i32.const 0 i32.const 8 - i32.const 3294 + i32.const 3313 i32.const 0 call $~lib/env/abort unreachable @@ -42620,7 +42855,7 @@ if i32.const 0 i32.const 8 - i32.const 3295 + i32.const 3314 i32.const 0 call $~lib/env/abort unreachable @@ -42639,7 +42874,7 @@ if i32.const 0 i32.const 8 - i32.const 3296 + i32.const 3315 i32.const 0 call $~lib/env/abort unreachable @@ -42662,7 +42897,7 @@ if i32.const 0 i32.const 8 - i32.const 3297 + i32.const 3316 i32.const 0 call $~lib/env/abort unreachable @@ -42681,7 +42916,7 @@ if i32.const 0 i32.const 8 - i32.const 3298 + i32.const 3317 i32.const 0 call $~lib/env/abort unreachable @@ -42704,7 +42939,7 @@ if i32.const 0 i32.const 8 - i32.const 3299 + i32.const 3318 i32.const 0 call $~lib/env/abort unreachable @@ -42727,7 +42962,7 @@ if i32.const 0 i32.const 8 - i32.const 3300 + i32.const 3319 i32.const 0 call $~lib/env/abort unreachable @@ -42746,7 +42981,7 @@ if i32.const 0 i32.const 8 - i32.const 3301 + i32.const 3320 i32.const 0 call $~lib/env/abort unreachable @@ -42765,7 +43000,7 @@ if i32.const 0 i32.const 8 - i32.const 3302 + i32.const 3321 i32.const 0 call $~lib/env/abort unreachable @@ -42778,7 +43013,7 @@ if i32.const 0 i32.const 8 - i32.const 3303 + i32.const 3322 i32.const 0 call $~lib/env/abort unreachable @@ -42791,7 +43026,7 @@ if i32.const 0 i32.const 8 - i32.const 3304 + i32.const 3323 i32.const 0 call $~lib/env/abort unreachable @@ -42812,7 +43047,7 @@ if i32.const 0 i32.const 8 - i32.const 3308 + i32.const 3327 i32.const 0 call $~lib/env/abort unreachable @@ -42831,7 +43066,7 @@ if i32.const 0 i32.const 8 - i32.const 3309 + i32.const 3328 i32.const 0 call $~lib/env/abort unreachable @@ -42852,7 +43087,7 @@ if i32.const 0 i32.const 8 - i32.const 3310 + i32.const 3329 i32.const 0 call $~lib/env/abort unreachable @@ -42871,7 +43106,7 @@ if i32.const 0 i32.const 8 - i32.const 3311 + i32.const 3330 i32.const 0 call $~lib/env/abort unreachable @@ -42892,7 +43127,7 @@ if i32.const 0 i32.const 8 - i32.const 3312 + i32.const 3331 i32.const 0 call $~lib/env/abort unreachable @@ -42911,7 +43146,7 @@ if i32.const 0 i32.const 8 - i32.const 3313 + i32.const 3332 i32.const 0 call $~lib/env/abort unreachable @@ -42932,7 +43167,7 @@ if i32.const 0 i32.const 8 - i32.const 3314 + i32.const 3333 i32.const 0 call $~lib/env/abort unreachable @@ -42951,7 +43186,7 @@ if i32.const 0 i32.const 8 - i32.const 3315 + i32.const 3334 i32.const 0 call $~lib/env/abort unreachable @@ -42972,7 +43207,7 @@ if i32.const 0 i32.const 8 - i32.const 3316 + i32.const 3335 i32.const 0 call $~lib/env/abort unreachable @@ -42991,7 +43226,7 @@ if i32.const 0 i32.const 8 - i32.const 3317 + i32.const 3336 i32.const 0 call $~lib/env/abort unreachable @@ -43012,7 +43247,7 @@ if i32.const 0 i32.const 8 - i32.const 3318 + i32.const 3337 i32.const 0 call $~lib/env/abort unreachable @@ -43033,7 +43268,7 @@ if i32.const 0 i32.const 8 - i32.const 3319 + i32.const 3338 i32.const 0 call $~lib/env/abort unreachable @@ -43052,7 +43287,7 @@ if i32.const 0 i32.const 8 - i32.const 3320 + i32.const 3339 i32.const 0 call $~lib/env/abort unreachable @@ -43071,7 +43306,7 @@ if i32.const 0 i32.const 8 - i32.const 3321 + i32.const 3340 i32.const 0 call $~lib/env/abort unreachable @@ -43084,7 +43319,7 @@ if i32.const 0 i32.const 8 - i32.const 3322 + i32.const 3341 i32.const 0 call $~lib/env/abort unreachable @@ -43097,7 +43332,7 @@ if i32.const 0 i32.const 8 - i32.const 3323 + i32.const 3342 i32.const 0 call $~lib/env/abort unreachable @@ -43111,7 +43346,7 @@ if i32.const 0 i32.const 40 - i32.const 2374 + i32.const 2387 i32.const 20 call $~lib/env/abort unreachable @@ -43136,7 +43371,7 @@ if i32.const 0 i32.const 8 - i32.const 3327 + i32.const 3346 i32.const 0 call $~lib/env/abort unreachable @@ -43150,7 +43385,7 @@ if i32.const 0 i32.const 40 - i32.const 2374 + i32.const 2387 i32.const 20 call $~lib/env/abort unreachable @@ -43171,7 +43406,7 @@ if i32.const 0 i32.const 8 - i32.const 3328 + i32.const 3347 i32.const 0 call $~lib/env/abort unreachable @@ -43184,7 +43419,7 @@ if i32.const 0 i32.const 40 - i32.const 2376 + i32.const 2389 i32.const 16 call $~lib/env/abort unreachable @@ -43205,7 +43440,7 @@ if i32.const 0 i32.const 8 - i32.const 3329 + i32.const 3348 i32.const 0 call $~lib/env/abort unreachable @@ -43219,7 +43454,7 @@ if i32.const 0 i32.const 40 - i32.const 2374 + i32.const 2387 i32.const 20 call $~lib/env/abort unreachable @@ -43240,7 +43475,7 @@ if i32.const 0 i32.const 8 - i32.const 3330 + i32.const 3349 i32.const 0 call $~lib/env/abort unreachable @@ -43253,7 +43488,7 @@ if i32.const 0 i32.const 40 - i32.const 2376 + i32.const 2389 i32.const 16 call $~lib/env/abort unreachable @@ -43274,7 +43509,7 @@ if i32.const 0 i32.const 8 - i32.const 3331 + i32.const 3350 i32.const 0 call $~lib/env/abort unreachable @@ -43288,7 +43523,7 @@ if i32.const 0 i32.const 40 - i32.const 2374 + i32.const 2387 i32.const 20 call $~lib/env/abort unreachable @@ -43313,7 +43548,7 @@ if i32.const 0 i32.const 8 - i32.const 3332 + i32.const 3351 i32.const 0 call $~lib/env/abort unreachable @@ -43327,7 +43562,7 @@ if i32.const 0 i32.const 40 - i32.const 2374 + i32.const 2387 i32.const 20 call $~lib/env/abort unreachable @@ -43348,7 +43583,7 @@ if i32.const 0 i32.const 8 - i32.const 3333 + i32.const 3352 i32.const 0 call $~lib/env/abort unreachable @@ -43361,7 +43596,7 @@ if i32.const 0 i32.const 40 - i32.const 2376 + i32.const 2389 i32.const 16 call $~lib/env/abort unreachable @@ -43382,7 +43617,7 @@ if i32.const 0 i32.const 8 - i32.const 3334 + i32.const 3353 i32.const 0 call $~lib/env/abort unreachable @@ -43396,7 +43631,7 @@ if i32.const 0 i32.const 40 - i32.const 2374 + i32.const 2387 i32.const 20 call $~lib/env/abort unreachable @@ -43417,7 +43652,7 @@ if i32.const 0 i32.const 8 - i32.const 3335 + i32.const 3354 i32.const 0 call $~lib/env/abort unreachable @@ -43430,7 +43665,7 @@ if i32.const 0 i32.const 40 - i32.const 2376 + i32.const 2389 i32.const 16 call $~lib/env/abort unreachable @@ -43451,7 +43686,7 @@ if i32.const 0 i32.const 8 - i32.const 3336 + i32.const 3355 i32.const 0 call $~lib/env/abort unreachable @@ -43465,7 +43700,7 @@ if i32.const 0 i32.const 40 - i32.const 2374 + i32.const 2387 i32.const 20 call $~lib/env/abort unreachable @@ -43490,7 +43725,7 @@ if i32.const 0 i32.const 8 - i32.const 3337 + i32.const 3356 i32.const 0 call $~lib/env/abort unreachable @@ -43504,7 +43739,7 @@ if i32.const 0 i32.const 40 - i32.const 2374 + i32.const 2387 i32.const 20 call $~lib/env/abort unreachable @@ -43525,7 +43760,7 @@ if i32.const 0 i32.const 8 - i32.const 3338 + i32.const 3357 i32.const 0 call $~lib/env/abort unreachable @@ -43538,7 +43773,7 @@ if i32.const 0 i32.const 40 - i32.const 2376 + i32.const 2389 i32.const 16 call $~lib/env/abort unreachable @@ -43559,7 +43794,7 @@ if i32.const 0 i32.const 8 - i32.const 3339 + i32.const 3358 i32.const 0 call $~lib/env/abort unreachable @@ -43573,7 +43808,7 @@ if i32.const 0 i32.const 40 - i32.const 2374 + i32.const 2387 i32.const 20 call $~lib/env/abort unreachable @@ -43594,7 +43829,7 @@ if i32.const 0 i32.const 8 - i32.const 3340 + i32.const 3359 i32.const 0 call $~lib/env/abort unreachable @@ -43607,7 +43842,7 @@ if i32.const 0 i32.const 40 - i32.const 2376 + i32.const 2389 i32.const 16 call $~lib/env/abort unreachable @@ -43628,7 +43863,7 @@ if i32.const 0 i32.const 8 - i32.const 3341 + i32.const 3360 i32.const 0 call $~lib/env/abort unreachable @@ -43645,7 +43880,7 @@ if i32.const 0 i32.const 8 - i32.const 3342 + i32.const 3361 i32.const 0 call $~lib/env/abort unreachable @@ -43658,7 +43893,7 @@ if i32.const 0 i32.const 8 - i32.const 3343 + i32.const 3362 i32.const 0 call $~lib/env/abort unreachable @@ -43671,7 +43906,7 @@ if i32.const 0 i32.const 8 - i32.const 3344 + i32.const 3363 i32.const 0 call $~lib/env/abort unreachable @@ -43684,7 +43919,7 @@ if i32.const 0 i32.const 8 - i32.const 3345 + i32.const 3364 i32.const 0 call $~lib/env/abort unreachable @@ -43697,7 +43932,7 @@ if i32.const 0 i32.const 8 - i32.const 3346 + i32.const 3365 i32.const 0 call $~lib/env/abort unreachable @@ -43711,7 +43946,7 @@ if i32.const 0 i32.const 40 - i32.const 2412 + i32.const 2425 i32.const 19 call $~lib/env/abort unreachable @@ -43730,7 +43965,7 @@ if i32.const 0 i32.const 8 - i32.const 3350 + i32.const 3369 i32.const 0 call $~lib/env/abort unreachable @@ -43744,7 +43979,7 @@ if i32.const 0 i32.const 40 - i32.const 2412 + i32.const 2425 i32.const 19 call $~lib/env/abort unreachable @@ -43759,7 +43994,7 @@ if i32.const 0 i32.const 8 - i32.const 3351 + i32.const 3370 i32.const 0 call $~lib/env/abort unreachable @@ -43777,7 +44012,7 @@ if i32.const 0 i32.const 8 - i32.const 3352 + i32.const 3371 i32.const 0 call $~lib/env/abort unreachable @@ -43791,7 +44026,7 @@ if i32.const 0 i32.const 40 - i32.const 2412 + i32.const 2425 i32.const 19 call $~lib/env/abort unreachable @@ -43806,7 +44041,7 @@ if i32.const 0 i32.const 8 - i32.const 3353 + i32.const 3372 i32.const 0 call $~lib/env/abort unreachable @@ -43824,7 +44059,7 @@ if i32.const 0 i32.const 8 - i32.const 3354 + i32.const 3373 i32.const 0 call $~lib/env/abort unreachable @@ -43838,7 +44073,7 @@ if i32.const 0 i32.const 40 - i32.const 2412 + i32.const 2425 i32.const 19 call $~lib/env/abort unreachable @@ -43857,7 +44092,7 @@ if i32.const 0 i32.const 8 - i32.const 3355 + i32.const 3374 i32.const 0 call $~lib/env/abort unreachable @@ -43871,7 +44106,7 @@ if i32.const 0 i32.const 40 - i32.const 2412 + i32.const 2425 i32.const 19 call $~lib/env/abort unreachable @@ -43886,7 +44121,7 @@ if i32.const 0 i32.const 8 - i32.const 3356 + i32.const 3375 i32.const 0 call $~lib/env/abort unreachable @@ -43904,7 +44139,7 @@ if i32.const 0 i32.const 8 - i32.const 3357 + i32.const 3376 i32.const 0 call $~lib/env/abort unreachable @@ -43918,7 +44153,7 @@ if i32.const 0 i32.const 40 - i32.const 2412 + i32.const 2425 i32.const 19 call $~lib/env/abort unreachable @@ -43933,7 +44168,7 @@ if i32.const 0 i32.const 8 - i32.const 3358 + i32.const 3377 i32.const 0 call $~lib/env/abort unreachable @@ -43951,7 +44186,7 @@ if i32.const 0 i32.const 8 - i32.const 3359 + i32.const 3378 i32.const 0 call $~lib/env/abort unreachable @@ -43965,7 +44200,7 @@ if i32.const 0 i32.const 40 - i32.const 2412 + i32.const 2425 i32.const 19 call $~lib/env/abort unreachable @@ -43984,7 +44219,7 @@ if i32.const 0 i32.const 8 - i32.const 3360 + i32.const 3379 i32.const 0 call $~lib/env/abort unreachable @@ -43998,7 +44233,7 @@ if i32.const 0 i32.const 40 - i32.const 2412 + i32.const 2425 i32.const 19 call $~lib/env/abort unreachable @@ -44013,7 +44248,7 @@ if i32.const 0 i32.const 8 - i32.const 3361 + i32.const 3380 i32.const 0 call $~lib/env/abort unreachable @@ -44031,7 +44266,7 @@ if i32.const 0 i32.const 8 - i32.const 3362 + i32.const 3381 i32.const 0 call $~lib/env/abort unreachable @@ -44045,7 +44280,7 @@ if i32.const 0 i32.const 40 - i32.const 2412 + i32.const 2425 i32.const 19 call $~lib/env/abort unreachable @@ -44060,7 +44295,7 @@ if i32.const 0 i32.const 8 - i32.const 3363 + i32.const 3382 i32.const 0 call $~lib/env/abort unreachable @@ -44078,7 +44313,7 @@ if i32.const 0 i32.const 8 - i32.const 3364 + i32.const 3383 i32.const 0 call $~lib/env/abort unreachable @@ -44092,7 +44327,7 @@ if i32.const 0 i32.const 40 - i32.const 2412 + i32.const 2425 i32.const 19 call $~lib/env/abort unreachable @@ -44111,7 +44346,7 @@ if i32.const 0 i32.const 8 - i32.const 3365 + i32.const 3384 i32.const 0 call $~lib/env/abort unreachable @@ -44125,7 +44360,7 @@ if i32.const 0 i32.const 40 - i32.const 2412 + i32.const 2425 i32.const 19 call $~lib/env/abort unreachable @@ -44140,7 +44375,7 @@ if i32.const 0 i32.const 8 - i32.const 3366 + i32.const 3385 i32.const 0 call $~lib/env/abort unreachable @@ -44158,7 +44393,7 @@ if i32.const 0 i32.const 8 - i32.const 3367 + i32.const 3386 i32.const 0 call $~lib/env/abort unreachable @@ -44172,7 +44407,7 @@ if i32.const 0 i32.const 40 - i32.const 2412 + i32.const 2425 i32.const 19 call $~lib/env/abort unreachable @@ -44187,7 +44422,7 @@ if i32.const 0 i32.const 8 - i32.const 3368 + i32.const 3387 i32.const 0 call $~lib/env/abort unreachable @@ -44205,7 +44440,7 @@ if i32.const 0 i32.const 8 - i32.const 3369 + i32.const 3388 i32.const 0 call $~lib/env/abort unreachable @@ -44219,7 +44454,7 @@ if i32.const 0 i32.const 40 - i32.const 2412 + i32.const 2425 i32.const 19 call $~lib/env/abort unreachable @@ -44238,7 +44473,7 @@ if i32.const 0 i32.const 8 - i32.const 3370 + i32.const 3389 i32.const 0 call $~lib/env/abort unreachable @@ -44252,7 +44487,7 @@ if i32.const 0 i32.const 40 - i32.const 2412 + i32.const 2425 i32.const 19 call $~lib/env/abort unreachable @@ -44267,7 +44502,7 @@ if i32.const 0 i32.const 8 - i32.const 3371 + i32.const 3390 i32.const 0 call $~lib/env/abort unreachable @@ -44285,7 +44520,7 @@ if i32.const 0 i32.const 8 - i32.const 3372 + i32.const 3391 i32.const 0 call $~lib/env/abort unreachable @@ -44299,7 +44534,7 @@ if i32.const 0 i32.const 40 - i32.const 2412 + i32.const 2425 i32.const 19 call $~lib/env/abort unreachable @@ -44314,7 +44549,7 @@ if i32.const 0 i32.const 8 - i32.const 3373 + i32.const 3392 i32.const 0 call $~lib/env/abort unreachable @@ -44332,7 +44567,7 @@ if i32.const 0 i32.const 8 - i32.const 3374 + i32.const 3393 i32.const 0 call $~lib/env/abort unreachable @@ -44346,7 +44581,7 @@ if i32.const 0 i32.const 40 - i32.const 2412 + i32.const 2425 i32.const 19 call $~lib/env/abort unreachable @@ -44365,7 +44600,7 @@ if i32.const 0 i32.const 8 - i32.const 3375 + i32.const 3394 i32.const 0 call $~lib/env/abort unreachable @@ -44387,7 +44622,7 @@ if i32.const 0 i32.const 8 - i32.const 3376 + i32.const 3395 i32.const 0 call $~lib/env/abort unreachable @@ -44401,7 +44636,7 @@ if i32.const 0 i32.const 40 - i32.const 2412 + i32.const 2425 i32.const 19 call $~lib/env/abort unreachable @@ -44416,7 +44651,7 @@ if i32.const 0 i32.const 8 - i32.const 3377 + i32.const 3396 i32.const 0 call $~lib/env/abort unreachable @@ -44434,7 +44669,7 @@ if i32.const 0 i32.const 8 - i32.const 3378 + i32.const 3397 i32.const 0 call $~lib/env/abort unreachable @@ -44454,7 +44689,7 @@ if i32.const 0 i32.const 8 - i32.const 3379 + i32.const 3398 i32.const 0 call $~lib/env/abort unreachable @@ -44468,7 +44703,7 @@ if i32.const 0 i32.const 40 - i32.const 2412 + i32.const 2425 i32.const 19 call $~lib/env/abort unreachable @@ -44483,7 +44718,7 @@ if i32.const 0 i32.const 8 - i32.const 3380 + i32.const 3399 i32.const 0 call $~lib/env/abort unreachable @@ -44501,7 +44736,7 @@ if i32.const 0 i32.const 8 - i32.const 3381 + i32.const 3400 i32.const 0 call $~lib/env/abort unreachable @@ -44519,7 +44754,7 @@ if i32.const 0 i32.const 8 - i32.const 3382 + i32.const 3401 i32.const 0 call $~lib/env/abort unreachable @@ -44533,7 +44768,7 @@ if i32.const 0 i32.const 40 - i32.const 2412 + i32.const 2425 i32.const 19 call $~lib/env/abort unreachable @@ -44548,7 +44783,7 @@ if i32.const 0 i32.const 8 - i32.const 3383 + i32.const 3402 i32.const 0 call $~lib/env/abort unreachable @@ -44566,7 +44801,7 @@ if i32.const 0 i32.const 8 - i32.const 3384 + i32.const 3403 i32.const 0 call $~lib/env/abort unreachable @@ -44579,7 +44814,7 @@ if i32.const 0 i32.const 8 - i32.const 3385 + i32.const 3404 i32.const 0 call $~lib/env/abort unreachable @@ -44600,7 +44835,7 @@ if i32.const 0 i32.const 8 - i32.const 3389 + i32.const 3408 i32.const 0 call $~lib/env/abort unreachable @@ -44621,7 +44856,7 @@ if i32.const 0 i32.const 8 - i32.const 3390 + i32.const 3409 i32.const 0 call $~lib/env/abort unreachable @@ -44642,7 +44877,7 @@ if i32.const 0 i32.const 8 - i32.const 3391 + i32.const 3410 i32.const 0 call $~lib/env/abort unreachable @@ -44663,7 +44898,7 @@ if i32.const 0 i32.const 8 - i32.const 3392 + i32.const 3411 i32.const 0 call $~lib/env/abort unreachable @@ -44684,7 +44919,7 @@ if i32.const 0 i32.const 8 - i32.const 3393 + i32.const 3412 i32.const 0 call $~lib/env/abort unreachable @@ -44698,7 +44933,7 @@ if i32.const 0 i32.const 8 - i32.const 3397 + i32.const 3416 i32.const 0 call $~lib/env/abort unreachable @@ -44712,7 +44947,7 @@ if i32.const 0 i32.const 8 - i32.const 3398 + i32.const 3417 i32.const 0 call $~lib/env/abort unreachable @@ -44726,7 +44961,7 @@ if i32.const 0 i32.const 8 - i32.const 3399 + i32.const 3418 i32.const 0 call $~lib/env/abort unreachable @@ -44740,7 +44975,7 @@ if i32.const 0 i32.const 8 - i32.const 3400 + i32.const 3419 i32.const 0 call $~lib/env/abort unreachable @@ -44754,7 +44989,7 @@ if i32.const 0 i32.const 8 - i32.const 3402 + i32.const 3421 i32.const 0 call $~lib/env/abort unreachable @@ -44768,7 +45003,7 @@ if i32.const 0 i32.const 8 - i32.const 3403 + i32.const 3422 i32.const 0 call $~lib/env/abort unreachable @@ -44782,7 +45017,7 @@ if i32.const 0 i32.const 8 - i32.const 3404 + i32.const 3423 i32.const 0 call $~lib/env/abort unreachable @@ -44796,7 +45031,7 @@ if i32.const 0 i32.const 8 - i32.const 3405 + i32.const 3424 i32.const 0 call $~lib/env/abort unreachable @@ -44810,7 +45045,7 @@ if i32.const 0 i32.const 8 - i32.const 3407 + i32.const 3426 i32.const 0 call $~lib/env/abort unreachable @@ -44824,7 +45059,7 @@ if i32.const 0 i32.const 8 - i32.const 3408 + i32.const 3427 i32.const 0 call $~lib/env/abort unreachable @@ -44838,7 +45073,7 @@ if i32.const 0 i32.const 8 - i32.const 3409 + i32.const 3428 i32.const 0 call $~lib/env/abort unreachable @@ -44852,7 +45087,7 @@ if i32.const 0 i32.const 8 - i32.const 3410 + i32.const 3429 i32.const 0 call $~lib/env/abort unreachable @@ -44866,7 +45101,7 @@ if i32.const 0 i32.const 8 - i32.const 3412 + i32.const 3431 i32.const 0 call $~lib/env/abort unreachable @@ -44880,7 +45115,7 @@ if i32.const 0 i32.const 8 - i32.const 3413 + i32.const 3432 i32.const 0 call $~lib/env/abort unreachable @@ -44894,7 +45129,7 @@ if i32.const 0 i32.const 8 - i32.const 3414 + i32.const 3433 i32.const 0 call $~lib/env/abort unreachable @@ -44908,7 +45143,7 @@ if i32.const 0 i32.const 8 - i32.const 3415 + i32.const 3434 i32.const 0 call $~lib/env/abort unreachable @@ -44922,7 +45157,7 @@ if i32.const 0 i32.const 8 - i32.const 3417 + i32.const 3436 i32.const 0 call $~lib/env/abort unreachable @@ -44936,7 +45171,7 @@ if i32.const 0 i32.const 8 - i32.const 3418 + i32.const 3437 i32.const 0 call $~lib/env/abort unreachable @@ -44950,7 +45185,7 @@ if i32.const 0 i32.const 8 - i32.const 3419 + i32.const 3438 i32.const 0 call $~lib/env/abort unreachable @@ -44964,7 +45199,7 @@ if i32.const 0 i32.const 8 - i32.const 3420 + i32.const 3439 i32.const 0 call $~lib/env/abort unreachable @@ -44978,7 +45213,7 @@ if i32.const 0 i32.const 8 - i32.const 3422 + i32.const 3441 i32.const 0 call $~lib/env/abort unreachable @@ -44992,7 +45227,7 @@ if i32.const 0 i32.const 8 - i32.const 3423 + i32.const 3442 i32.const 0 call $~lib/env/abort unreachable @@ -45006,7 +45241,7 @@ if i32.const 0 i32.const 8 - i32.const 3424 + i32.const 3443 i32.const 0 call $~lib/env/abort unreachable @@ -45020,7 +45255,7 @@ if i32.const 0 i32.const 8 - i32.const 3425 + i32.const 3444 i32.const 0 call $~lib/env/abort unreachable @@ -45034,7 +45269,7 @@ if i32.const 0 i32.const 8 - i32.const 3426 + i32.const 3445 i32.const 0 call $~lib/env/abort unreachable @@ -45048,7 +45283,7 @@ if i32.const 0 i32.const 8 - i32.const 3427 + i32.const 3446 i32.const 0 call $~lib/env/abort unreachable @@ -45062,7 +45297,7 @@ if i32.const 0 i32.const 8 - i32.const 3428 + i32.const 3447 i32.const 0 call $~lib/env/abort unreachable @@ -45080,7 +45315,7 @@ if i32.const 0 i32.const 8 - i32.const 3430 + i32.const 3449 i32.const 0 call $~lib/env/abort unreachable @@ -45094,7 +45329,7 @@ if i32.const 0 i32.const 8 - i32.const 3434 + i32.const 3453 i32.const 0 call $~lib/env/abort unreachable @@ -45108,7 +45343,7 @@ if i32.const 0 i32.const 8 - i32.const 3435 + i32.const 3454 i32.const 0 call $~lib/env/abort unreachable @@ -45128,7 +45363,7 @@ if i32.const 0 i32.const 8 - i32.const 3436 + i32.const 3455 i32.const 0 call $~lib/env/abort unreachable @@ -45148,7 +45383,7 @@ if i32.const 0 i32.const 8 - i32.const 3437 + i32.const 3456 i32.const 0 call $~lib/env/abort unreachable @@ -45168,7 +45403,7 @@ if i32.const 0 i32.const 8 - i32.const 3438 + i32.const 3457 i32.const 0 call $~lib/env/abort unreachable @@ -45182,7 +45417,7 @@ if i32.const 0 i32.const 8 - i32.const 3439 + i32.const 3458 i32.const 0 call $~lib/env/abort unreachable @@ -45196,7 +45431,7 @@ if i32.const 0 i32.const 8 - i32.const 3440 + i32.const 3459 i32.const 0 call $~lib/env/abort unreachable @@ -45211,7 +45446,7 @@ if i32.const 0 i32.const 8 - i32.const 3441 + i32.const 3460 i32.const 0 call $~lib/env/abort unreachable @@ -45227,7 +45462,7 @@ if i32.const 0 i32.const 8 - i32.const 3442 + i32.const 3461 i32.const 0 call $~lib/env/abort unreachable @@ -45242,7 +45477,7 @@ if i32.const 0 i32.const 8 - i32.const 3443 + i32.const 3462 i32.const 0 call $~lib/env/abort unreachable @@ -45256,7 +45491,7 @@ if i32.const 0 i32.const 8 - i32.const 3444 + i32.const 3463 i32.const 0 call $~lib/env/abort unreachable @@ -45270,7 +45505,7 @@ if i32.const 0 i32.const 8 - i32.const 3445 + i32.const 3464 i32.const 0 call $~lib/env/abort unreachable @@ -45284,7 +45519,7 @@ if i32.const 0 i32.const 8 - i32.const 3446 + i32.const 3465 i32.const 0 call $~lib/env/abort unreachable @@ -45298,7 +45533,7 @@ if i32.const 0 i32.const 8 - i32.const 3447 + i32.const 3466 i32.const 0 call $~lib/env/abort unreachable @@ -45312,7 +45547,7 @@ if i32.const 0 i32.const 8 - i32.const 3448 + i32.const 3467 i32.const 0 call $~lib/env/abort unreachable @@ -45326,7 +45561,7 @@ if i32.const 0 i32.const 8 - i32.const 3449 + i32.const 3468 i32.const 0 call $~lib/env/abort unreachable @@ -45340,7 +45575,7 @@ if i32.const 0 i32.const 8 - i32.const 3453 + i32.const 3472 i32.const 0 call $~lib/env/abort unreachable @@ -45354,7 +45589,7 @@ if i32.const 0 i32.const 8 - i32.const 3454 + i32.const 3473 i32.const 0 call $~lib/env/abort unreachable @@ -45367,7 +45602,7 @@ if i32.const 0 i32.const 8 - i32.const 3455 + i32.const 3474 i32.const 0 call $~lib/env/abort unreachable @@ -45380,7 +45615,7 @@ if i32.const 0 i32.const 8 - i32.const 3456 + i32.const 3475 i32.const 0 call $~lib/env/abort unreachable @@ -45393,7 +45628,7 @@ if i32.const 0 i32.const 8 - i32.const 3457 + i32.const 3476 i32.const 0 call $~lib/env/abort unreachable @@ -45407,7 +45642,7 @@ if i32.const 0 i32.const 8 - i32.const 3458 + i32.const 3477 i32.const 0 call $~lib/env/abort unreachable @@ -45421,7 +45656,7 @@ if i32.const 0 i32.const 8 - i32.const 3459 + i32.const 3478 i32.const 0 call $~lib/env/abort unreachable @@ -45436,7 +45671,7 @@ if i32.const 0 i32.const 8 - i32.const 3460 + i32.const 3479 i32.const 0 call $~lib/env/abort unreachable @@ -45452,7 +45687,7 @@ if i32.const 0 i32.const 8 - i32.const 3461 + i32.const 3480 i32.const 0 call $~lib/env/abort unreachable @@ -45467,7 +45702,7 @@ if i32.const 0 i32.const 8 - i32.const 3462 + i32.const 3481 i32.const 0 call $~lib/env/abort unreachable @@ -45481,7 +45716,7 @@ if i32.const 0 i32.const 8 - i32.const 3463 + i32.const 3482 i32.const 0 call $~lib/env/abort unreachable @@ -45495,7 +45730,7 @@ if i32.const 0 i32.const 8 - i32.const 3464 + i32.const 3483 i32.const 0 call $~lib/env/abort unreachable @@ -45509,7 +45744,7 @@ if i32.const 0 i32.const 8 - i32.const 3465 + i32.const 3484 i32.const 0 call $~lib/env/abort unreachable @@ -45523,7 +45758,7 @@ if i32.const 0 i32.const 8 - i32.const 3466 + i32.const 3485 i32.const 0 call $~lib/env/abort unreachable @@ -45537,7 +45772,7 @@ if i32.const 0 i32.const 8 - i32.const 3467 + i32.const 3486 i32.const 0 call $~lib/env/abort unreachable @@ -45551,14 +45786,15 @@ if i32.const 0 i32.const 8 - i32.const 3468 + i32.const 3487 i32.const 0 call $~lib/env/abort unreachable end ) - (func $null (; 170 ;) (type $_) + (func $start (; 171 ;) (type $_) + call $start:std/math ) - (func $null (; 160 ;) (type $_) + (func $null (; 172 ;) (type $_) ) ) From f554569e63926136019c26645f0fc69b44db3d72 Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Sun, 3 Mar 2019 02:40:56 +0200 Subject: [PATCH 21/22] rebuild --- std/assembly/math.ts | 5 +- tests/compiler/std/math.optimized.wat | 88 ++++++++- tests/compiler/std/math.untouched.wat | 267 +++++++++++++++++++++++++- 3 files changed, 342 insertions(+), 18 deletions(-) diff --git a/std/assembly/math.ts b/std/assembly/math.ts index 58b42cae53..a54b15329b 100644 --- a/std/assembly/math.ts +++ b/std/assembly/math.ts @@ -5,7 +5,6 @@ import { abs as builtin_abs, ceil as builtin_ceil, clz as builtin_clz, - ctz as builtin_ctz, copysign as builtin_copysign, floor as builtin_floor, max as builtin_max, @@ -2434,12 +2433,12 @@ export namespace IntegerMath { @inline export function ilog2_32(x: u32): u32 { - return builtin_ctz(x); + return 31 - builtin_clz(x); } @inline export function ilog2_64(x: u64): u64 { - return builtin_ctz(x); + return 63 - builtin_clz(x); } // Complexity: O(log n) diff --git a/tests/compiler/std/math.optimized.wat b/tests/compiler/std/math.optimized.wat index c70cb983c8..50e9e2de68 100644 --- a/tests/compiler/std/math.optimized.wat +++ b/tests/compiler/std/math.optimized.wat @@ -10,6 +10,7 @@ (type $FUNCSIG$fff (func (param f32 f32) (result f32))) (type $FUNCSIG$d (func (result f64))) (type $FUNCSIG$vj (func (param i64))) + (type $FUNCSIG$jj (func (param i64) (result i64))) (type $FUNCSIG$ii (func (param i32) (result i32))) (type $FUNCSIG$f (func (result f32))) (type $FUNCSIG$jji (func (param i64 i32) (result i64))) @@ -9243,7 +9244,80 @@ i32.clz f64.convert_i32_s ) - (func $~lib/math/ipow64 (; 147 ;) (type $FUNCSIG$jji) (param $0 i64) (param $1 i32) (result i64) + (func $~lib/math/isqrt32 (; 147 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + local.get $0 + i32.const 2 + i32.lt_u + if + local.get $0 + return + end + i32.const 2 + local.set $1 + local.get $0 + i32.const 2 + i32.shr_u + local.set $2 + loop $continue|0 + local.get $2 + if + local.get $0 + local.get $2 + i32.ne + local.set $2 + end + local.get $2 + if + local.get $0 + local.get $1 + i32.const 2 + i32.add + local.tee $1 + i32.shr_u + local.set $2 + br $continue|0 + end + end + local.get $1 + i32.const 2 + i32.sub + local.set $1 + loop $continue|1 + local.get $1 + i32.const 0 + i32.ge_s + if + local.get $3 + i32.const 1 + i32.shl + local.tee $3 + i32.const 1 + i32.add + local.tee $2 + local.get $2 + i32.mul + local.get $0 + local.get $1 + i32.shr_u + i32.le_u + if + local.get $2 + local.set $3 + end + local.get $1 + i32.const 2 + i32.sub + local.set $1 + br $continue|1 + end + end + local.get $3 + ) + (func $~lib/math/isqrt64 (; 148 ;) (type $FUNCSIG$jj) (param $0 i64) (result i64) + (local $1 i32) (local $2 i64) (local $3 i64) local.get $0 @@ -9321,7 +9395,7 @@ end local.get $3 ) - (func $~lib/math/ipow64 (; 149 ;) (type $IiI) (param $0 i64) (param $1 i32) (result i64) + (func $~lib/math/ipow64 (; 149 ;) (type $FUNCSIG$jji) (param $0 i64) (param $1 i32) (result i64) (local $2 i64) (local $3 i32) i64.const 1 @@ -9517,7 +9591,7 @@ end local.get $2 ) - (func $~lib/math/ipow32f (; 148 ;) (type $FUNCSIG$ffi) (param $0 f32) (param $1 i32) (result f32) + (func $~lib/math/ipow32f (; 150 ;) (type $FUNCSIG$ffi) (param $0 f32) (param $1 i32) (result f32) (local $2 f32) (local $3 i32) local.get $1 @@ -9563,7 +9637,7 @@ end local.get $2 ) - (func $~lib/math/ipow64f (; 149 ;) (type $FUNCSIG$ddi) (param $0 f64) (param $1 i32) (result f64) + (func $~lib/math/ipow64f (; 151 ;) (type $FUNCSIG$ddi) (param $0 f64) (param $1 i32) (result f64) (local $2 f64) (local $3 i32) local.get $1 @@ -9609,7 +9683,7 @@ end local.get $2 ) - (func $start:std/math (; 150 ;) (type $FUNCSIG$v) + (func $start:std/math (; 152 ;) (type $FUNCSIG$v) (local $0 f64) (local $1 f32) (local $2 i32) @@ -37678,10 +37752,10 @@ unreachable end ) - (func $start (; 151 ;) (type $FUNCSIG$v) + (func $start (; 153 ;) (type $FUNCSIG$v) call $start:std/math ) - (func $null (; 152 ;) (type $FUNCSIG$v) + (func $null (; 154 ;) (type $FUNCSIG$v) nop ) ) diff --git a/tests/compiler/std/math.untouched.wat b/tests/compiler/std/math.untouched.wat index b3a344c760..962b8e3751 100644 --- a/tests/compiler/std/math.untouched.wat +++ b/tests/compiler/std/math.untouched.wat @@ -11276,7 +11276,258 @@ i32.clz f64.convert_i32_s ) - (func $~lib/math/ipow64 (; 155 ;) (type $FUNCSIG$jji) (param $0 i64) (param $1 i32) (result i64) + (func $~lib/math/IntegerMath.sign (; 155 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + local.get $0 + i32.const 16 + i32.shl + i32.const 16 + i32.shr_s + i32.const 0 + i32.gt_s + local.get $0 + i32.const 16 + i32.shl + i32.const 16 + i32.shr_s + i32.const 0 + i32.lt_s + i32.sub + return + ) + (func $~lib/math/IntegerMath.sign (; 156 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + local.get $0 + i32.const 65535 + i32.and + i32.const 0 + i32.ne + return + ) + (func $~lib/math/IntegerMath.signbit (; 157 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + local.get $0 + i32.const 16 + i32.shl + i32.const 16 + i32.shr_s + i32.const 0 + i32.lt_s + return + ) + (func $~lib/math/IntegerMath.signbit (; 158 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + i32.const 0 + return + ) + (func $~lib/math/IntegerMath.log2 (; 159 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (local $1 i32) + local.get $0 + i32.const 16 + i32.shl + i32.const 16 + i32.shr_s + i32.const 0 + i32.le_s + if + i32.const 0 + i32.const 40 + i32.const 2387 + i32.const 20 + call $~lib/env/abort + unreachable + end + block $~lib/math/ilog2_32|inlined.9 (result i32) + local.get $0 + i32.const 16 + i32.shl + i32.const 16 + i32.shr_s + local.set $1 + i32.const 31 + local.get $1 + i32.clz + i32.sub + end + return + ) + (func $~lib/math/IntegerMath.log2 (; 160 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (local $1 i32) + local.get $0 + i32.const 0 + i32.le_s + if + i32.const 0 + i32.const 40 + i32.const 2387 + i32.const 20 + call $~lib/env/abort + unreachable + end + block $~lib/math/ilog2_32|inlined.10 (result i32) + local.get $0 + local.set $1 + i32.const 31 + local.get $1 + i32.clz + i32.sub + end + return + ) + (func $~lib/math/IntegerMath.log2 (; 161 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (local $1 i32) + local.get $0 + i32.eqz + if + i32.const 0 + i32.const 40 + i32.const 2389 + i32.const 16 + call $~lib/env/abort + unreachable + end + block $~lib/math/ilog2_32|inlined.11 (result i32) + local.get $0 + local.set $1 + i32.const 31 + local.get $1 + i32.clz + i32.sub + end + return + ) + (func $~lib/math/IntegerMath.log2 (; 162 ;) (type $FUNCSIG$jj) (param $0 i64) (result i64) + (local $1 i64) + local.get $0 + i64.const 0 + i64.le_s + if + i32.const 0 + i32.const 40 + i32.const 2387 + i32.const 20 + call $~lib/env/abort + unreachable + end + block $~lib/math/ilog2_64|inlined.6 (result i64) + local.get $0 + local.set $1 + i64.const 63 + local.get $1 + i64.clz + i64.sub + end + return + ) + (func $~lib/math/IntegerMath.log2 (; 163 ;) (type $FUNCSIG$jj) (param $0 i64) (result i64) + (local $1 i64) + local.get $0 + i64.eqz + if + i32.const 0 + i32.const 40 + i32.const 2389 + i32.const 16 + call $~lib/env/abort + unreachable + end + block $~lib/math/ilog2_64|inlined.7 (result i64) + local.get $0 + local.set $1 + i64.const 63 + local.get $1 + i64.clz + i64.sub + end + return + ) + (func $~lib/math/isqrt32 (; 164 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + local.get $0 + i32.const 2 + i32.lt_u + if + local.get $0 + return + end + i32.const 2 + local.set $1 + local.get $0 + i32.const 2 + i32.shr_u + local.set $2 + block $break|0 + loop $continue|0 + local.get $2 + if (result i32) + local.get $2 + local.get $0 + i32.ne + else + local.get $2 + end + if + block + local.get $1 + i32.const 2 + i32.add + local.set $1 + local.get $0 + local.get $1 + i32.shr_u + local.set $2 + end + br $continue|0 + end + end + end + local.get $1 + i32.const 2 + i32.sub + local.set $1 + local.get $0 + local.set $3 + i32.const 0 + local.set $4 + block $break|1 + loop $continue|1 + local.get $1 + i32.const 0 + i32.ge_s + if + block + local.get $4 + i32.const 1 + i32.shl + local.set $4 + local.get $4 + i32.const 1 + i32.add + local.set $5 + local.get $5 + local.get $5 + i32.mul + local.get $3 + local.get $1 + i32.shr_u + i32.le_u + if + local.get $5 + local.set $4 + end + local.get $1 + i32.const 2 + i32.sub + local.set $1 + end + br $continue|1 + end + end + end + local.get $4 + ) + (func $~lib/math/isqrt64 (; 165 ;) (type $FUNCSIG$jj) (param $0 i64) (result i64) + (local $1 i32) (local $2 i64) (local $3 i64) (local $4 i64) @@ -11371,12 +11622,12 @@ end local.get $4 ) - (func $~lib/math/IntegerMath.sqrt (; 166 ;) (type $II) (param $0 i64) (result i64) + (func $~lib/math/IntegerMath.sqrt (; 166 ;) (type $FUNCSIG$jj) (param $0 i64) (result i64) local.get $0 call $~lib/math/isqrt64 return ) - (func $~lib/math/ipow64 (; 167 ;) (type $IiI) (param $0 i64) (param $1 i32) (result i64) + (func $~lib/math/ipow64 (; 167 ;) (type $FUNCSIG$jji) (param $0 i64) (param $1 i32) (result i64) (local $2 i64) (local $3 i32) (local $4 i32) @@ -11608,7 +11859,7 @@ end local.get $2 ) - (func $~lib/math/ipow32f (; 156 ;) (type $FUNCSIG$ffi) (param $0 f32) (param $1 i32) (result f32) + (func $~lib/math/ipow32f (; 168 ;) (type $FUNCSIG$ffi) (param $0 f32) (param $1 i32) (result f32) (local $2 i32) (local $3 f32) local.get $1 @@ -11659,7 +11910,7 @@ local.get $3 end ) - (func $~lib/math/ipow64f (; 157 ;) (type $FUNCSIG$ddi) (param $0 f64) (param $1 i32) (result f64) + (func $~lib/math/ipow64f (; 169 ;) (type $FUNCSIG$ddi) (param $0 f64) (param $1 i32) (result f64) (local $2 i32) (local $3 f64) local.get $1 @@ -11710,7 +11961,7 @@ local.get $3 end ) - (func $start:std/math (; 158 ;) (type $FUNCSIG$v) + (func $start:std/math (; 170 ;) (type $FUNCSIG$v) (local $0 i32) (local $1 f64) (local $2 i32) @@ -45541,9 +45792,9 @@ unreachable end ) - (func $start (; 159 ;) (type $FUNCSIG$v) + (func $start (; 171 ;) (type $FUNCSIG$v) call $start:std/math ) - (func $null (; 160 ;) (type $FUNCSIG$v) + (func $null (; 172 ;) (type $FUNCSIG$v) ) ) From a80a226d661ff06e39412dcc43a2fb75df3862f7 Mon Sep 17 00:00:00 2001 From: MaxGraey Date: Wed, 6 Mar 2019 23:31:09 +0200 Subject: [PATCH 22/22] rebuild --- tests/compiler/std/math.optimized.wat | 279 ++++++---- tests/compiler/std/math.untouched.wat | 715 +++++++++++++++++--------- 2 files changed, 662 insertions(+), 332 deletions(-) diff --git a/tests/compiler/std/math.optimized.wat b/tests/compiler/std/math.optimized.wat index e521a365ca..dceaf5081d 100644 --- a/tests/compiler/std/math.optimized.wat +++ b/tests/compiler/std/math.optimized.wat @@ -10689,7 +10689,80 @@ i32.clz f64.convert_i32_s ) - (func $~lib/math/ipow64 (; 153 ;) (type $FUNCSIG$jji) (param $0 i64) (param $1 i32) (result i64) + (func $~lib/math/isqrt32 (; 153 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + local.get $0 + i32.const 2 + i32.lt_u + if + local.get $0 + return + end + i32.const 2 + local.set $1 + local.get $0 + i32.const 2 + i32.shr_u + local.set $2 + loop $continue|0 + local.get $2 + if + local.get $0 + local.get $2 + i32.ne + local.set $2 + end + local.get $2 + if + local.get $0 + local.get $1 + i32.const 2 + i32.add + local.tee $1 + i32.shr_u + local.set $2 + br $continue|0 + end + end + local.get $1 + i32.const 2 + i32.sub + local.set $1 + loop $continue|1 + local.get $1 + i32.const 0 + i32.ge_s + if + local.get $3 + i32.const 1 + i32.shl + local.tee $3 + i32.const 1 + i32.add + local.tee $2 + local.get $2 + i32.mul + local.get $0 + local.get $1 + i32.shr_u + i32.le_u + if + local.get $2 + local.set $3 + end + local.get $1 + i32.const 2 + i32.sub + local.set $1 + br $continue|1 + end + end + local.get $3 + ) + (func $~lib/math/isqrt64 (; 154 ;) (type $FUNCSIG$jj) (param $0 i64) (result i64) + (local $1 i32) (local $2 i64) (local $3 i64) local.get $0 @@ -10767,7 +10840,7 @@ end local.get $3 ) - (func $~lib/math/ipow64 (; 149 ;) (type $FUNCSIG$jji) (param $0 i64) (param $1 i32) (result i64) + (func $~lib/math/ipow64 (; 155 ;) (type $FUNCSIG$jji) (param $0 i64) (param $1 i32) (result i64) (local $2 i64) (local $3 i32) i64.const 1 @@ -10963,7 +11036,7 @@ end local.get $2 ) - (func $~lib/math/ipow32f (; 154 ;) (type $FUNCSIG$ffi) (param $0 f32) (param $1 i32) (result f32) + (func $~lib/math/ipow32f (; 156 ;) (type $FUNCSIG$ffi) (param $0 f32) (param $1 i32) (result f32) (local $2 f32) (local $3 i32) local.get $1 @@ -11009,7 +11082,7 @@ end local.get $2 ) - (func $~lib/math/ipow64f (; 155 ;) (type $FUNCSIG$ddi) (param $0 f64) (param $1 i32) (result f64) + (func $~lib/math/ipow64f (; 157 ;) (type $FUNCSIG$ddi) (param $0 f64) (param $1 i32) (result f64) (local $2 f64) (local $3 i32) local.get $1 @@ -11055,7 +11128,7 @@ end local.get $2 ) - (func $start:std/math (; 156 ;) (type $FUNCSIG$v) + (func $start:std/math (; 158 ;) (type $FUNCSIG$v) (local $0 f64) (local $1 f32) (local $2 i32) @@ -40303,7 +40376,7 @@ if i32.const 0 i32.const 8 - i32.const 3369 + i32.const 3522 i32.const 0 call $~lib/env/abort unreachable @@ -40313,7 +40386,7 @@ if i32.const 0 i32.const 8 - i32.const 3370 + i32.const 3523 i32.const 0 call $~lib/env/abort unreachable @@ -40323,7 +40396,7 @@ if i32.const 0 i32.const 8 - i32.const 3371 + i32.const 3524 i32.const 0 call $~lib/env/abort unreachable @@ -40335,7 +40408,7 @@ if i32.const 0 i32.const 8 - i32.const 3372 + i32.const 3525 i32.const 0 call $~lib/env/abort unreachable @@ -40347,7 +40420,7 @@ if i32.const 0 i32.const 8 - i32.const 3373 + i32.const 3526 i32.const 0 call $~lib/env/abort unreachable @@ -40361,7 +40434,7 @@ if i32.const 0 i32.const 8 - i32.const 3374 + i32.const 3527 i32.const 0 call $~lib/env/abort unreachable @@ -40373,7 +40446,7 @@ if i32.const 0 i32.const 8 - i32.const 3375 + i32.const 3528 i32.const 0 call $~lib/env/abort unreachable @@ -40385,7 +40458,7 @@ if i32.const 0 i32.const 8 - i32.const 3376 + i32.const 3529 i32.const 0 call $~lib/env/abort unreachable @@ -40397,7 +40470,7 @@ if i32.const 0 i32.const 8 - i32.const 3377 + i32.const 3530 i32.const 0 call $~lib/env/abort unreachable @@ -40409,7 +40482,7 @@ if i32.const 0 i32.const 8 - i32.const 3378 + i32.const 3531 i32.const 0 call $~lib/env/abort unreachable @@ -40423,7 +40496,7 @@ if i32.const 0 i32.const 8 - i32.const 3379 + i32.const 3532 i32.const 0 call $~lib/env/abort unreachable @@ -40435,7 +40508,7 @@ if i32.const 0 i32.const 8 - i32.const 3380 + i32.const 3533 i32.const 0 call $~lib/env/abort unreachable @@ -40447,7 +40520,7 @@ if i32.const 0 i32.const 8 - i32.const 3381 + i32.const 3534 i32.const 0 call $~lib/env/abort unreachable @@ -40459,7 +40532,7 @@ if i32.const 0 i32.const 8 - i32.const 3382 + i32.const 3535 i32.const 0 call $~lib/env/abort unreachable @@ -40471,7 +40544,7 @@ if i32.const 0 i32.const 8 - i32.const 3383 + i32.const 3536 i32.const 0 call $~lib/env/abort unreachable @@ -40485,7 +40558,7 @@ if i32.const 0 i32.const 8 - i32.const 3384 + i32.const 3537 i32.const 0 call $~lib/env/abort unreachable @@ -40497,7 +40570,7 @@ if i32.const 0 i32.const 8 - i32.const 3385 + i32.const 3538 i32.const 0 call $~lib/env/abort unreachable @@ -40509,7 +40582,7 @@ if i32.const 0 i32.const 8 - i32.const 3386 + i32.const 3539 i32.const 0 call $~lib/env/abort unreachable @@ -40521,7 +40594,7 @@ if i32.const 0 i32.const 8 - i32.const 3387 + i32.const 3540 i32.const 0 call $~lib/env/abort unreachable @@ -40533,7 +40606,7 @@ if i32.const 0 i32.const 8 - i32.const 3388 + i32.const 3541 i32.const 0 call $~lib/env/abort unreachable @@ -40547,7 +40620,7 @@ if i32.const 0 i32.const 8 - i32.const 3389 + i32.const 3542 i32.const 0 call $~lib/env/abort unreachable @@ -40559,7 +40632,7 @@ if i32.const 0 i32.const 8 - i32.const 3390 + i32.const 3543 i32.const 0 call $~lib/env/abort unreachable @@ -40571,7 +40644,7 @@ if i32.const 0 i32.const 8 - i32.const 3391 + i32.const 3544 i32.const 0 call $~lib/env/abort unreachable @@ -40583,7 +40656,7 @@ if i32.const 0 i32.const 8 - i32.const 3392 + i32.const 3545 i32.const 0 call $~lib/env/abort unreachable @@ -40595,7 +40668,7 @@ if i32.const 0 i32.const 8 - i32.const 3393 + i32.const 3546 i32.const 0 call $~lib/env/abort unreachable @@ -40609,7 +40682,7 @@ if i32.const 0 i32.const 8 - i32.const 3394 + i32.const 3547 i32.const 0 call $~lib/env/abort unreachable @@ -40623,7 +40696,7 @@ if i32.const 0 i32.const 8 - i32.const 3395 + i32.const 3548 i32.const 0 call $~lib/env/abort unreachable @@ -40635,7 +40708,7 @@ if i32.const 0 i32.const 8 - i32.const 3396 + i32.const 3549 i32.const 0 call $~lib/env/abort unreachable @@ -40647,7 +40720,7 @@ if i32.const 0 i32.const 8 - i32.const 3397 + i32.const 3550 i32.const 0 call $~lib/env/abort unreachable @@ -40661,7 +40734,7 @@ if i32.const 0 i32.const 8 - i32.const 3398 + i32.const 3551 i32.const 0 call $~lib/env/abort unreachable @@ -40673,7 +40746,7 @@ if i32.const 0 i32.const 8 - i32.const 3399 + i32.const 3552 i32.const 0 call $~lib/env/abort unreachable @@ -40685,7 +40758,7 @@ if i32.const 0 i32.const 8 - i32.const 3400 + i32.const 3553 i32.const 0 call $~lib/env/abort unreachable @@ -40697,7 +40770,7 @@ if i32.const 0 i32.const 8 - i32.const 3401 + i32.const 3554 i32.const 0 call $~lib/env/abort unreachable @@ -40709,7 +40782,7 @@ if i32.const 0 i32.const 8 - i32.const 3402 + i32.const 3555 i32.const 0 call $~lib/env/abort unreachable @@ -40721,7 +40794,7 @@ if i32.const 0 i32.const 8 - i32.const 3403 + i32.const 3556 i32.const 0 call $~lib/env/abort unreachable @@ -40733,7 +40806,7 @@ if i32.const 0 i32.const 8 - i32.const 3404 + i32.const 3557 i32.const 0 call $~lib/env/abort unreachable @@ -40746,7 +40819,7 @@ if i32.const 0 i32.const 8 - i32.const 3461 + i32.const 3569 i32.const 0 call $~lib/env/abort unreachable @@ -40759,7 +40832,7 @@ if i32.const 0 i32.const 8 - i32.const 3462 + i32.const 3570 i32.const 0 call $~lib/env/abort unreachable @@ -40772,7 +40845,7 @@ if i32.const 0 i32.const 8 - i32.const 3463 + i32.const 3571 i32.const 0 call $~lib/env/abort unreachable @@ -40785,7 +40858,7 @@ if i32.const 0 i32.const 8 - i32.const 3464 + i32.const 3572 i32.const 0 call $~lib/env/abort unreachable @@ -40798,7 +40871,7 @@ if i32.const 0 i32.const 8 - i32.const 3466 + i32.const 3574 i32.const 0 call $~lib/env/abort unreachable @@ -40811,7 +40884,7 @@ if i32.const 0 i32.const 8 - i32.const 3467 + i32.const 3575 i32.const 0 call $~lib/env/abort unreachable @@ -40824,7 +40897,7 @@ if i32.const 0 i32.const 8 - i32.const 3468 + i32.const 3576 i32.const 0 call $~lib/env/abort unreachable @@ -40837,7 +40910,7 @@ if i32.const 0 i32.const 8 - i32.const 3469 + i32.const 3577 i32.const 0 call $~lib/env/abort unreachable @@ -40850,7 +40923,7 @@ if i32.const 0 i32.const 8 - i32.const 3471 + i32.const 3579 i32.const 0 call $~lib/env/abort unreachable @@ -40863,7 +40936,7 @@ if i32.const 0 i32.const 8 - i32.const 3472 + i32.const 3580 i32.const 0 call $~lib/env/abort unreachable @@ -40876,7 +40949,7 @@ if i32.const 0 i32.const 8 - i32.const 3473 + i32.const 3581 i32.const 0 call $~lib/env/abort unreachable @@ -40889,7 +40962,7 @@ if i32.const 0 i32.const 8 - i32.const 3474 + i32.const 3582 i32.const 0 call $~lib/env/abort unreachable @@ -40902,7 +40975,7 @@ if i32.const 0 i32.const 8 - i32.const 3476 + i32.const 3584 i32.const 0 call $~lib/env/abort unreachable @@ -40915,7 +40988,7 @@ if i32.const 0 i32.const 8 - i32.const 3477 + i32.const 3585 i32.const 0 call $~lib/env/abort unreachable @@ -40928,7 +41001,7 @@ if i32.const 0 i32.const 8 - i32.const 3478 + i32.const 3586 i32.const 0 call $~lib/env/abort unreachable @@ -40941,7 +41014,7 @@ if i32.const 0 i32.const 8 - i32.const 3479 + i32.const 3587 i32.const 0 call $~lib/env/abort unreachable @@ -40954,7 +41027,7 @@ if i32.const 0 i32.const 8 - i32.const 3481 + i32.const 3589 i32.const 0 call $~lib/env/abort unreachable @@ -40967,7 +41040,7 @@ if i32.const 0 i32.const 8 - i32.const 3482 + i32.const 3590 i32.const 0 call $~lib/env/abort unreachable @@ -40980,7 +41053,7 @@ if i32.const 0 i32.const 8 - i32.const 3483 + i32.const 3591 i32.const 0 call $~lib/env/abort unreachable @@ -40993,7 +41066,7 @@ if i32.const 0 i32.const 8 - i32.const 3484 + i32.const 3592 i32.const 0 call $~lib/env/abort unreachable @@ -41006,7 +41079,7 @@ if i32.const 0 i32.const 8 - i32.const 3486 + i32.const 3594 i32.const 0 call $~lib/env/abort unreachable @@ -41019,7 +41092,7 @@ if i32.const 0 i32.const 8 - i32.const 3487 + i32.const 3595 i32.const 0 call $~lib/env/abort unreachable @@ -41032,7 +41105,7 @@ if i32.const 0 i32.const 8 - i32.const 3488 + i32.const 3596 i32.const 0 call $~lib/env/abort unreachable @@ -41045,7 +41118,7 @@ if i32.const 0 i32.const 8 - i32.const 3489 + i32.const 3597 i32.const 0 call $~lib/env/abort unreachable @@ -41058,7 +41131,7 @@ if i32.const 0 i32.const 8 - i32.const 3490 + i32.const 3598 i32.const 0 call $~lib/env/abort unreachable @@ -41071,7 +41144,7 @@ if i32.const 0 i32.const 8 - i32.const 3491 + i32.const 3599 i32.const 0 call $~lib/env/abort unreachable @@ -41084,7 +41157,7 @@ if i32.const 0 i32.const 8 - i32.const 3492 + i32.const 3600 i32.const 0 call $~lib/env/abort unreachable @@ -41101,7 +41174,7 @@ if i32.const 0 i32.const 8 - i32.const 3494 + i32.const 3602 i32.const 0 call $~lib/env/abort unreachable @@ -41114,7 +41187,7 @@ if i32.const 0 i32.const 8 - i32.const 3498 + i32.const 3606 i32.const 0 call $~lib/env/abort unreachable @@ -41127,7 +41200,7 @@ if i32.const 0 i32.const 8 - i32.const 3499 + i32.const 3607 i32.const 0 call $~lib/env/abort unreachable @@ -41141,7 +41214,7 @@ if i32.const 0 i32.const 8 - i32.const 3500 + i32.const 3608 i32.const 0 call $~lib/env/abort unreachable @@ -41155,7 +41228,7 @@ if i32.const 0 i32.const 8 - i32.const 3501 + i32.const 3609 i32.const 0 call $~lib/env/abort unreachable @@ -41169,7 +41242,7 @@ if i32.const 0 i32.const 8 - i32.const 3502 + i32.const 3610 i32.const 0 call $~lib/env/abort unreachable @@ -41182,7 +41255,7 @@ if i32.const 0 i32.const 8 - i32.const 3503 + i32.const 3611 i32.const 0 call $~lib/env/abort unreachable @@ -41195,7 +41268,7 @@ if i32.const 0 i32.const 8 - i32.const 3504 + i32.const 3612 i32.const 0 call $~lib/env/abort unreachable @@ -41208,7 +41281,7 @@ if i32.const 0 i32.const 8 - i32.const 3505 + i32.const 3613 i32.const 0 call $~lib/env/abort unreachable @@ -41221,7 +41294,7 @@ if i32.const 0 i32.const 8 - i32.const 3506 + i32.const 3614 i32.const 0 call $~lib/env/abort unreachable @@ -41234,7 +41307,7 @@ if i32.const 0 i32.const 8 - i32.const 3507 + i32.const 3615 i32.const 0 call $~lib/env/abort unreachable @@ -41247,7 +41320,7 @@ if i32.const 0 i32.const 8 - i32.const 3508 + i32.const 3616 i32.const 0 call $~lib/env/abort unreachable @@ -41260,7 +41333,7 @@ if i32.const 0 i32.const 8 - i32.const 3509 + i32.const 3617 i32.const 0 call $~lib/env/abort unreachable @@ -41273,7 +41346,7 @@ if i32.const 0 i32.const 8 - i32.const 3510 + i32.const 3618 i32.const 0 call $~lib/env/abort unreachable @@ -41286,7 +41359,7 @@ if i32.const 0 i32.const 8 - i32.const 3511 + i32.const 3619 i32.const 0 call $~lib/env/abort unreachable @@ -41299,7 +41372,7 @@ if i32.const 0 i32.const 8 - i32.const 3512 + i32.const 3620 i32.const 0 call $~lib/env/abort unreachable @@ -41312,7 +41385,7 @@ if i32.const 0 i32.const 8 - i32.const 3513 + i32.const 3621 i32.const 0 call $~lib/env/abort unreachable @@ -41325,7 +41398,7 @@ if i32.const 0 i32.const 8 - i32.const 3517 + i32.const 3625 i32.const 0 call $~lib/env/abort unreachable @@ -41338,7 +41411,7 @@ if i32.const 0 i32.const 8 - i32.const 3518 + i32.const 3626 i32.const 0 call $~lib/env/abort unreachable @@ -41352,7 +41425,7 @@ if i32.const 0 i32.const 8 - i32.const 3519 + i32.const 3627 i32.const 0 call $~lib/env/abort unreachable @@ -41366,7 +41439,7 @@ if i32.const 0 i32.const 8 - i32.const 3520 + i32.const 3628 i32.const 0 call $~lib/env/abort unreachable @@ -41380,7 +41453,7 @@ if i32.const 0 i32.const 8 - i32.const 3521 + i32.const 3629 i32.const 0 call $~lib/env/abort unreachable @@ -41393,7 +41466,7 @@ if i32.const 0 i32.const 8 - i32.const 3522 + i32.const 3630 i32.const 0 call $~lib/env/abort unreachable @@ -41406,7 +41479,7 @@ if i32.const 0 i32.const 8 - i32.const 3523 + i32.const 3631 i32.const 0 call $~lib/env/abort unreachable @@ -41419,7 +41492,7 @@ if i32.const 0 i32.const 8 - i32.const 3524 + i32.const 3632 i32.const 0 call $~lib/env/abort unreachable @@ -41432,7 +41505,7 @@ if i32.const 0 i32.const 8 - i32.const 3525 + i32.const 3633 i32.const 0 call $~lib/env/abort unreachable @@ -41445,7 +41518,7 @@ if i32.const 0 i32.const 8 - i32.const 3526 + i32.const 3634 i32.const 0 call $~lib/env/abort unreachable @@ -41458,7 +41531,7 @@ if i32.const 0 i32.const 8 - i32.const 3527 + i32.const 3635 i32.const 0 call $~lib/env/abort unreachable @@ -41471,7 +41544,7 @@ if i32.const 0 i32.const 8 - i32.const 3528 + i32.const 3636 i32.const 0 call $~lib/env/abort unreachable @@ -41484,7 +41557,7 @@ if i32.const 0 i32.const 8 - i32.const 3529 + i32.const 3637 i32.const 0 call $~lib/env/abort unreachable @@ -41497,7 +41570,7 @@ if i32.const 0 i32.const 8 - i32.const 3530 + i32.const 3638 i32.const 0 call $~lib/env/abort unreachable @@ -41510,7 +41583,7 @@ if i32.const 0 i32.const 8 - i32.const 3531 + i32.const 3639 i32.const 0 call $~lib/env/abort unreachable @@ -41523,16 +41596,16 @@ if i32.const 0 i32.const 8 - i32.const 3532 + i32.const 3640 i32.const 0 call $~lib/env/abort unreachable end ) - (func $start (; 157 ;) (type $FUNCSIG$v) + (func $start (; 159 ;) (type $FUNCSIG$v) call $start:std/math ) - (func $null (; 158 ;) (type $FUNCSIG$v) + (func $null (; 160 ;) (type $FUNCSIG$v) nop ) ) diff --git a/tests/compiler/std/math.untouched.wat b/tests/compiler/std/math.untouched.wat index 9a6032aba7..a8eb745295 100644 --- a/tests/compiler/std/math.untouched.wat +++ b/tests/compiler/std/math.untouched.wat @@ -101,6 +101,12 @@ (global $~lib/builtins/f64.MAX_VALUE f64 (f64.const 1797693134862315708145274e284)) (global $~lib/builtins/f64.MAX_SAFE_INTEGER f64 (f64.const 9007199254740991)) (global $~lib/builtins/f64.EPSILON f64 (f64.const 2.220446049250313e-16)) + (global $~lib/builtins/i16.MAX_VALUE i32 (i32.const 32767)) + (global $~lib/builtins/i32.MAX_VALUE i32 (i32.const 2147483647)) + (global $~lib/builtins/u32.MAX_VALUE i32 (i32.const -1)) + (global $~lib/builtins/i64.MAX_VALUE i64 (i64.const 9223372036854775807)) + (global $~lib/builtins/u64.MAX_VALUE i64 (i64.const -1)) + (global $~lib/builtins/u16.MAX_VALUE i32 (i32.const 65535)) (global $~lib/builtins/f32.MIN_VALUE f32 (f32.const 1.401298464324817e-45)) (global $~lib/memory/HEAP_BASE i32 (i32.const 140)) (export "memory" (memory $0)) @@ -13251,7 +13257,258 @@ i32.clz f64.convert_i32_s ) - (func $~lib/math/ipow64 (; 162 ;) (type $FUNCSIG$jji) (param $0 i64) (param $1 i32) (result i64) + (func $~lib/math/IntegerMath.sign (; 162 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + local.get $0 + i32.const 16 + i32.shl + i32.const 16 + i32.shr_s + i32.const 0 + i32.gt_s + local.get $0 + i32.const 16 + i32.shl + i32.const 16 + i32.shr_s + i32.const 0 + i32.lt_s + i32.sub + return + ) + (func $~lib/math/IntegerMath.sign (; 163 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + local.get $0 + i32.const 65535 + i32.and + i32.const 0 + i32.ne + return + ) + (func $~lib/math/IntegerMath.signbit (; 164 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + local.get $0 + i32.const 16 + i32.shl + i32.const 16 + i32.shr_s + i32.const 0 + i32.lt_s + return + ) + (func $~lib/math/IntegerMath.signbit (; 165 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + i32.const 0 + return + ) + (func $~lib/math/IntegerMath.log2 (; 166 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (local $1 i32) + local.get $0 + i32.const 16 + i32.shl + i32.const 16 + i32.shr_s + i32.const 0 + i32.le_s + if + i32.const 0 + i32.const 112 + i32.const 2712 + i32.const 20 + call $~lib/env/abort + unreachable + end + block $~lib/math/ilog2_32|inlined.9 (result i32) + local.get $0 + i32.const 16 + i32.shl + i32.const 16 + i32.shr_s + local.set $1 + i32.const 31 + local.get $1 + i32.clz + i32.sub + end + return + ) + (func $~lib/math/IntegerMath.log2 (; 167 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (local $1 i32) + local.get $0 + i32.const 0 + i32.le_s + if + i32.const 0 + i32.const 112 + i32.const 2712 + i32.const 20 + call $~lib/env/abort + unreachable + end + block $~lib/math/ilog2_32|inlined.10 (result i32) + local.get $0 + local.set $1 + i32.const 31 + local.get $1 + i32.clz + i32.sub + end + return + ) + (func $~lib/math/IntegerMath.log2 (; 168 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (local $1 i32) + local.get $0 + i32.eqz + if + i32.const 0 + i32.const 112 + i32.const 2714 + i32.const 16 + call $~lib/env/abort + unreachable + end + block $~lib/math/ilog2_32|inlined.11 (result i32) + local.get $0 + local.set $1 + i32.const 31 + local.get $1 + i32.clz + i32.sub + end + return + ) + (func $~lib/math/IntegerMath.log2 (; 169 ;) (type $FUNCSIG$jj) (param $0 i64) (result i64) + (local $1 i64) + local.get $0 + i64.const 0 + i64.le_s + if + i32.const 0 + i32.const 112 + i32.const 2712 + i32.const 20 + call $~lib/env/abort + unreachable + end + block $~lib/math/ilog2_64|inlined.6 (result i64) + local.get $0 + local.set $1 + i64.const 63 + local.get $1 + i64.clz + i64.sub + end + return + ) + (func $~lib/math/IntegerMath.log2 (; 170 ;) (type $FUNCSIG$jj) (param $0 i64) (result i64) + (local $1 i64) + local.get $0 + i64.eqz + if + i32.const 0 + i32.const 112 + i32.const 2714 + i32.const 16 + call $~lib/env/abort + unreachable + end + block $~lib/math/ilog2_64|inlined.7 (result i64) + local.get $0 + local.set $1 + i64.const 63 + local.get $1 + i64.clz + i64.sub + end + return + ) + (func $~lib/math/isqrt32 (; 171 ;) (type $FUNCSIG$ii) (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + local.get $0 + i32.const 2 + i32.lt_u + if + local.get $0 + return + end + i32.const 2 + local.set $1 + local.get $0 + i32.const 2 + i32.shr_u + local.set $2 + block $break|0 + loop $continue|0 + local.get $2 + if (result i32) + local.get $2 + local.get $0 + i32.ne + else + local.get $2 + end + if + block + local.get $1 + i32.const 2 + i32.add + local.set $1 + local.get $0 + local.get $1 + i32.shr_u + local.set $2 + end + br $continue|0 + end + end + end + local.get $1 + i32.const 2 + i32.sub + local.set $1 + local.get $0 + local.set $3 + i32.const 0 + local.set $4 + block $break|1 + loop $continue|1 + local.get $1 + i32.const 0 + i32.ge_s + if + block + local.get $4 + i32.const 1 + i32.shl + local.set $4 + local.get $4 + i32.const 1 + i32.add + local.set $5 + local.get $5 + local.get $5 + i32.mul + local.get $3 + local.get $1 + i32.shr_u + i32.le_u + if + local.get $5 + local.set $4 + end + local.get $1 + i32.const 2 + i32.sub + local.set $1 + end + br $continue|1 + end + end + end + local.get $4 + ) + (func $~lib/math/isqrt64 (; 172 ;) (type $FUNCSIG$jj) (param $0 i64) (result i64) + (local $1 i32) (local $2 i64) (local $3 i64) (local $4 i64) @@ -13346,12 +13603,12 @@ end local.get $4 ) - (func $~lib/math/IntegerMath.sqrt (; 166 ;) (type $FUNCSIG$jj) (param $0 i64) (result i64) + (func $~lib/math/IntegerMath.sqrt (; 173 ;) (type $FUNCSIG$jj) (param $0 i64) (result i64) local.get $0 call $~lib/math/isqrt64 return ) - (func $~lib/math/ipow64 (; 167 ;) (type $FUNCSIG$jji) (param $0 i64) (param $1 i32) (result i64) + (func $~lib/math/ipow64 (; 174 ;) (type $FUNCSIG$jji) (param $0 i64) (param $1 i32) (result i64) (local $2 i64) (local $3 i32) (local $4 i32) @@ -13583,7 +13840,7 @@ end local.get $2 ) - (func $~lib/math/ipow32f (; 163 ;) (type $FUNCSIG$ffi) (param $0 f32) (param $1 i32) (result f32) + (func $~lib/math/ipow32f (; 175 ;) (type $FUNCSIG$ffi) (param $0 f32) (param $1 i32) (result f32) (local $2 i32) (local $3 f32) local.get $1 @@ -13634,7 +13891,7 @@ local.get $3 end ) - (func $~lib/math/ipow64f (; 164 ;) (type $FUNCSIG$ddi) (param $0 f64) (param $1 i32) (result f64) + (func $~lib/math/ipow64f (; 176 ;) (type $FUNCSIG$ddi) (param $0 f64) (param $1 i32) (result f64) (local $2 i32) (local $3 f64) local.get $1 @@ -13685,7 +13942,7 @@ local.get $3 end ) - (func $start:std/math (; 165 ;) (type $FUNCSIG$v) + (func $start:std/math (; 177 ;) (type $FUNCSIG$v) (local $0 i32) (local $1 f64) (local $2 i32) @@ -47104,7 +47361,7 @@ if i32.const 0 i32.const 8 - i32.const 3308 + i32.const 3461 i32.const 0 call $~lib/env/abort unreachable @@ -47123,7 +47380,7 @@ if i32.const 0 i32.const 8 - i32.const 3309 + i32.const 3462 i32.const 0 call $~lib/env/abort unreachable @@ -47146,7 +47403,7 @@ if i32.const 0 i32.const 8 - i32.const 3310 + i32.const 3463 i32.const 0 call $~lib/env/abort unreachable @@ -47165,7 +47422,7 @@ if i32.const 0 i32.const 8 - i32.const 3311 + i32.const 3464 i32.const 0 call $~lib/env/abort unreachable @@ -47188,7 +47445,7 @@ if i32.const 0 i32.const 8 - i32.const 3312 + i32.const 3465 i32.const 0 call $~lib/env/abort unreachable @@ -47207,7 +47464,7 @@ if i32.const 0 i32.const 8 - i32.const 3313 + i32.const 3466 i32.const 0 call $~lib/env/abort unreachable @@ -47230,7 +47487,7 @@ if i32.const 0 i32.const 8 - i32.const 3314 + i32.const 3467 i32.const 0 call $~lib/env/abort unreachable @@ -47249,7 +47506,7 @@ if i32.const 0 i32.const 8 - i32.const 3315 + i32.const 3468 i32.const 0 call $~lib/env/abort unreachable @@ -47272,7 +47529,7 @@ if i32.const 0 i32.const 8 - i32.const 3316 + i32.const 3469 i32.const 0 call $~lib/env/abort unreachable @@ -47291,7 +47548,7 @@ if i32.const 0 i32.const 8 - i32.const 3317 + i32.const 3470 i32.const 0 call $~lib/env/abort unreachable @@ -47314,7 +47571,7 @@ if i32.const 0 i32.const 8 - i32.const 3318 + i32.const 3471 i32.const 0 call $~lib/env/abort unreachable @@ -47337,7 +47594,7 @@ if i32.const 0 i32.const 8 - i32.const 3319 + i32.const 3472 i32.const 0 call $~lib/env/abort unreachable @@ -47356,7 +47613,7 @@ if i32.const 0 i32.const 8 - i32.const 3320 + i32.const 3473 i32.const 0 call $~lib/env/abort unreachable @@ -47375,7 +47632,7 @@ if i32.const 0 i32.const 8 - i32.const 3321 + i32.const 3474 i32.const 0 call $~lib/env/abort unreachable @@ -47388,7 +47645,7 @@ if i32.const 0 i32.const 8 - i32.const 3322 + i32.const 3475 i32.const 0 call $~lib/env/abort unreachable @@ -47401,7 +47658,7 @@ if i32.const 0 i32.const 8 - i32.const 3323 + i32.const 3476 i32.const 0 call $~lib/env/abort unreachable @@ -47422,7 +47679,7 @@ if i32.const 0 i32.const 8 - i32.const 3327 + i32.const 3480 i32.const 0 call $~lib/env/abort unreachable @@ -47441,7 +47698,7 @@ if i32.const 0 i32.const 8 - i32.const 3328 + i32.const 3481 i32.const 0 call $~lib/env/abort unreachable @@ -47462,7 +47719,7 @@ if i32.const 0 i32.const 8 - i32.const 3329 + i32.const 3482 i32.const 0 call $~lib/env/abort unreachable @@ -47481,7 +47738,7 @@ if i32.const 0 i32.const 8 - i32.const 3330 + i32.const 3483 i32.const 0 call $~lib/env/abort unreachable @@ -47502,7 +47759,7 @@ if i32.const 0 i32.const 8 - i32.const 3331 + i32.const 3484 i32.const 0 call $~lib/env/abort unreachable @@ -47521,7 +47778,7 @@ if i32.const 0 i32.const 8 - i32.const 3332 + i32.const 3485 i32.const 0 call $~lib/env/abort unreachable @@ -47542,7 +47799,7 @@ if i32.const 0 i32.const 8 - i32.const 3333 + i32.const 3486 i32.const 0 call $~lib/env/abort unreachable @@ -47561,7 +47818,7 @@ if i32.const 0 i32.const 8 - i32.const 3334 + i32.const 3487 i32.const 0 call $~lib/env/abort unreachable @@ -47582,7 +47839,7 @@ if i32.const 0 i32.const 8 - i32.const 3335 + i32.const 3488 i32.const 0 call $~lib/env/abort unreachable @@ -47601,7 +47858,7 @@ if i32.const 0 i32.const 8 - i32.const 3336 + i32.const 3489 i32.const 0 call $~lib/env/abort unreachable @@ -47622,7 +47879,7 @@ if i32.const 0 i32.const 8 - i32.const 3337 + i32.const 3490 i32.const 0 call $~lib/env/abort unreachable @@ -47643,7 +47900,7 @@ if i32.const 0 i32.const 8 - i32.const 3338 + i32.const 3491 i32.const 0 call $~lib/env/abort unreachable @@ -47662,7 +47919,7 @@ if i32.const 0 i32.const 8 - i32.const 3339 + i32.const 3492 i32.const 0 call $~lib/env/abort unreachable @@ -47681,7 +47938,7 @@ if i32.const 0 i32.const 8 - i32.const 3340 + i32.const 3493 i32.const 0 call $~lib/env/abort unreachable @@ -47694,7 +47951,7 @@ if i32.const 0 i32.const 8 - i32.const 3341 + i32.const 3494 i32.const 0 call $~lib/env/abort unreachable @@ -47707,7 +47964,7 @@ if i32.const 0 i32.const 8 - i32.const 3342 + i32.const 3495 i32.const 0 call $~lib/env/abort unreachable @@ -47720,8 +47977,8 @@ i32.le_s if i32.const 0 - i32.const 40 - i32.const 2387 + i32.const 112 + i32.const 2712 i32.const 20 call $~lib/env/abort unreachable @@ -47746,7 +48003,7 @@ if i32.const 0 i32.const 8 - i32.const 3346 + i32.const 3499 i32.const 0 call $~lib/env/abort unreachable @@ -47759,8 +48016,8 @@ i32.le_s if i32.const 0 - i32.const 40 - i32.const 2387 + i32.const 112 + i32.const 2712 i32.const 20 call $~lib/env/abort unreachable @@ -47781,7 +48038,7 @@ if i32.const 0 i32.const 8 - i32.const 3347 + i32.const 3500 i32.const 0 call $~lib/env/abort unreachable @@ -47793,8 +48050,8 @@ i32.eqz if i32.const 0 - i32.const 40 - i32.const 2389 + i32.const 112 + i32.const 2714 i32.const 16 call $~lib/env/abort unreachable @@ -47815,7 +48072,7 @@ if i32.const 0 i32.const 8 - i32.const 3348 + i32.const 3501 i32.const 0 call $~lib/env/abort unreachable @@ -47828,8 +48085,8 @@ i64.le_s if i32.const 0 - i32.const 40 - i32.const 2387 + i32.const 112 + i32.const 2712 i32.const 20 call $~lib/env/abort unreachable @@ -47850,7 +48107,7 @@ if i32.const 0 i32.const 8 - i32.const 3349 + i32.const 3502 i32.const 0 call $~lib/env/abort unreachable @@ -47862,8 +48119,8 @@ i64.eqz if i32.const 0 - i32.const 40 - i32.const 2389 + i32.const 112 + i32.const 2714 i32.const 16 call $~lib/env/abort unreachable @@ -47884,7 +48141,7 @@ if i32.const 0 i32.const 8 - i32.const 3350 + i32.const 3503 i32.const 0 call $~lib/env/abort unreachable @@ -47897,8 +48154,8 @@ i32.le_s if i32.const 0 - i32.const 40 - i32.const 2387 + i32.const 112 + i32.const 2712 i32.const 20 call $~lib/env/abort unreachable @@ -47923,7 +48180,7 @@ if i32.const 0 i32.const 8 - i32.const 3351 + i32.const 3504 i32.const 0 call $~lib/env/abort unreachable @@ -47936,8 +48193,8 @@ i32.le_s if i32.const 0 - i32.const 40 - i32.const 2387 + i32.const 112 + i32.const 2712 i32.const 20 call $~lib/env/abort unreachable @@ -47958,7 +48215,7 @@ if i32.const 0 i32.const 8 - i32.const 3352 + i32.const 3505 i32.const 0 call $~lib/env/abort unreachable @@ -47970,8 +48227,8 @@ i32.eqz if i32.const 0 - i32.const 40 - i32.const 2389 + i32.const 112 + i32.const 2714 i32.const 16 call $~lib/env/abort unreachable @@ -47992,7 +48249,7 @@ if i32.const 0 i32.const 8 - i32.const 3353 + i32.const 3506 i32.const 0 call $~lib/env/abort unreachable @@ -48005,8 +48262,8 @@ i64.le_s if i32.const 0 - i32.const 40 - i32.const 2387 + i32.const 112 + i32.const 2712 i32.const 20 call $~lib/env/abort unreachable @@ -48027,7 +48284,7 @@ if i32.const 0 i32.const 8 - i32.const 3354 + i32.const 3507 i32.const 0 call $~lib/env/abort unreachable @@ -48039,8 +48296,8 @@ i64.eqz if i32.const 0 - i32.const 40 - i32.const 2389 + i32.const 112 + i32.const 2714 i32.const 16 call $~lib/env/abort unreachable @@ -48061,7 +48318,7 @@ if i32.const 0 i32.const 8 - i32.const 3355 + i32.const 3508 i32.const 0 call $~lib/env/abort unreachable @@ -48074,8 +48331,8 @@ i32.le_s if i32.const 0 - i32.const 40 - i32.const 2387 + i32.const 112 + i32.const 2712 i32.const 20 call $~lib/env/abort unreachable @@ -48100,7 +48357,7 @@ if i32.const 0 i32.const 8 - i32.const 3356 + i32.const 3509 i32.const 0 call $~lib/env/abort unreachable @@ -48113,8 +48370,8 @@ i32.le_s if i32.const 0 - i32.const 40 - i32.const 2387 + i32.const 112 + i32.const 2712 i32.const 20 call $~lib/env/abort unreachable @@ -48135,7 +48392,7 @@ if i32.const 0 i32.const 8 - i32.const 3357 + i32.const 3510 i32.const 0 call $~lib/env/abort unreachable @@ -48147,8 +48404,8 @@ i32.eqz if i32.const 0 - i32.const 40 - i32.const 2389 + i32.const 112 + i32.const 2714 i32.const 16 call $~lib/env/abort unreachable @@ -48169,7 +48426,7 @@ if i32.const 0 i32.const 8 - i32.const 3358 + i32.const 3511 i32.const 0 call $~lib/env/abort unreachable @@ -48182,8 +48439,8 @@ i64.le_s if i32.const 0 - i32.const 40 - i32.const 2387 + i32.const 112 + i32.const 2712 i32.const 20 call $~lib/env/abort unreachable @@ -48204,7 +48461,7 @@ if i32.const 0 i32.const 8 - i32.const 3359 + i32.const 3512 i32.const 0 call $~lib/env/abort unreachable @@ -48216,8 +48473,8 @@ i64.eqz if i32.const 0 - i32.const 40 - i32.const 2389 + i32.const 112 + i32.const 2714 i32.const 16 call $~lib/env/abort unreachable @@ -48238,7 +48495,7 @@ if i32.const 0 i32.const 8 - i32.const 3360 + i32.const 3513 i32.const 0 call $~lib/env/abort unreachable @@ -48255,7 +48512,7 @@ if i32.const 0 i32.const 8 - i32.const 3361 + i32.const 3514 i32.const 0 call $~lib/env/abort unreachable @@ -48268,7 +48525,7 @@ if i32.const 0 i32.const 8 - i32.const 3362 + i32.const 3515 i32.const 0 call $~lib/env/abort unreachable @@ -48281,7 +48538,7 @@ if i32.const 0 i32.const 8 - i32.const 3363 + i32.const 3516 i32.const 0 call $~lib/env/abort unreachable @@ -48294,7 +48551,7 @@ if i32.const 0 i32.const 8 - i32.const 3364 + i32.const 3517 i32.const 0 call $~lib/env/abort unreachable @@ -48307,7 +48564,7 @@ if i32.const 0 i32.const 8 - i32.const 3365 + i32.const 3518 i32.const 0 call $~lib/env/abort unreachable @@ -48320,8 +48577,8 @@ i32.lt_s if i32.const 0 - i32.const 40 - i32.const 2425 + i32.const 112 + i32.const 2750 i32.const 19 call $~lib/env/abort unreachable @@ -48340,7 +48597,7 @@ if i32.const 0 i32.const 8 - i32.const 3369 + i32.const 3522 i32.const 0 call $~lib/env/abort unreachable @@ -48353,8 +48610,8 @@ i32.lt_s if i32.const 0 - i32.const 40 - i32.const 2425 + i32.const 112 + i32.const 2750 i32.const 19 call $~lib/env/abort unreachable @@ -48369,7 +48626,7 @@ if i32.const 0 i32.const 8 - i32.const 3370 + i32.const 3523 i32.const 0 call $~lib/env/abort unreachable @@ -48387,7 +48644,7 @@ if i32.const 0 i32.const 8 - i32.const 3371 + i32.const 3524 i32.const 0 call $~lib/env/abort unreachable @@ -48400,8 +48657,8 @@ i64.lt_s if i32.const 0 - i32.const 40 - i32.const 2425 + i32.const 112 + i32.const 2750 i32.const 19 call $~lib/env/abort unreachable @@ -48416,7 +48673,7 @@ if i32.const 0 i32.const 8 - i32.const 3372 + i32.const 3525 i32.const 0 call $~lib/env/abort unreachable @@ -48434,7 +48691,7 @@ if i32.const 0 i32.const 8 - i32.const 3373 + i32.const 3526 i32.const 0 call $~lib/env/abort unreachable @@ -48447,8 +48704,8 @@ i32.lt_s if i32.const 0 - i32.const 40 - i32.const 2425 + i32.const 112 + i32.const 2750 i32.const 19 call $~lib/env/abort unreachable @@ -48467,7 +48724,7 @@ if i32.const 0 i32.const 8 - i32.const 3374 + i32.const 3527 i32.const 0 call $~lib/env/abort unreachable @@ -48480,8 +48737,8 @@ i32.lt_s if i32.const 0 - i32.const 40 - i32.const 2425 + i32.const 112 + i32.const 2750 i32.const 19 call $~lib/env/abort unreachable @@ -48496,7 +48753,7 @@ if i32.const 0 i32.const 8 - i32.const 3375 + i32.const 3528 i32.const 0 call $~lib/env/abort unreachable @@ -48514,7 +48771,7 @@ if i32.const 0 i32.const 8 - i32.const 3376 + i32.const 3529 i32.const 0 call $~lib/env/abort unreachable @@ -48527,8 +48784,8 @@ i64.lt_s if i32.const 0 - i32.const 40 - i32.const 2425 + i32.const 112 + i32.const 2750 i32.const 19 call $~lib/env/abort unreachable @@ -48543,7 +48800,7 @@ if i32.const 0 i32.const 8 - i32.const 3377 + i32.const 3530 i32.const 0 call $~lib/env/abort unreachable @@ -48561,7 +48818,7 @@ if i32.const 0 i32.const 8 - i32.const 3378 + i32.const 3531 i32.const 0 call $~lib/env/abort unreachable @@ -48574,8 +48831,8 @@ i32.lt_s if i32.const 0 - i32.const 40 - i32.const 2425 + i32.const 112 + i32.const 2750 i32.const 19 call $~lib/env/abort unreachable @@ -48594,7 +48851,7 @@ if i32.const 0 i32.const 8 - i32.const 3379 + i32.const 3532 i32.const 0 call $~lib/env/abort unreachable @@ -48607,8 +48864,8 @@ i32.lt_s if i32.const 0 - i32.const 40 - i32.const 2425 + i32.const 112 + i32.const 2750 i32.const 19 call $~lib/env/abort unreachable @@ -48623,7 +48880,7 @@ if i32.const 0 i32.const 8 - i32.const 3380 + i32.const 3533 i32.const 0 call $~lib/env/abort unreachable @@ -48641,7 +48898,7 @@ if i32.const 0 i32.const 8 - i32.const 3381 + i32.const 3534 i32.const 0 call $~lib/env/abort unreachable @@ -48654,8 +48911,8 @@ i64.lt_s if i32.const 0 - i32.const 40 - i32.const 2425 + i32.const 112 + i32.const 2750 i32.const 19 call $~lib/env/abort unreachable @@ -48670,7 +48927,7 @@ if i32.const 0 i32.const 8 - i32.const 3382 + i32.const 3535 i32.const 0 call $~lib/env/abort unreachable @@ -48688,7 +48945,7 @@ if i32.const 0 i32.const 8 - i32.const 3383 + i32.const 3536 i32.const 0 call $~lib/env/abort unreachable @@ -48701,8 +48958,8 @@ i32.lt_s if i32.const 0 - i32.const 40 - i32.const 2425 + i32.const 112 + i32.const 2750 i32.const 19 call $~lib/env/abort unreachable @@ -48721,7 +48978,7 @@ if i32.const 0 i32.const 8 - i32.const 3384 + i32.const 3537 i32.const 0 call $~lib/env/abort unreachable @@ -48734,8 +48991,8 @@ i32.lt_s if i32.const 0 - i32.const 40 - i32.const 2425 + i32.const 112 + i32.const 2750 i32.const 19 call $~lib/env/abort unreachable @@ -48750,7 +49007,7 @@ if i32.const 0 i32.const 8 - i32.const 3385 + i32.const 3538 i32.const 0 call $~lib/env/abort unreachable @@ -48768,7 +49025,7 @@ if i32.const 0 i32.const 8 - i32.const 3386 + i32.const 3539 i32.const 0 call $~lib/env/abort unreachable @@ -48781,8 +49038,8 @@ i64.lt_s if i32.const 0 - i32.const 40 - i32.const 2425 + i32.const 112 + i32.const 2750 i32.const 19 call $~lib/env/abort unreachable @@ -48797,7 +49054,7 @@ if i32.const 0 i32.const 8 - i32.const 3387 + i32.const 3540 i32.const 0 call $~lib/env/abort unreachable @@ -48815,7 +49072,7 @@ if i32.const 0 i32.const 8 - i32.const 3388 + i32.const 3541 i32.const 0 call $~lib/env/abort unreachable @@ -48828,8 +49085,8 @@ i32.lt_s if i32.const 0 - i32.const 40 - i32.const 2425 + i32.const 112 + i32.const 2750 i32.const 19 call $~lib/env/abort unreachable @@ -48848,7 +49105,7 @@ if i32.const 0 i32.const 8 - i32.const 3389 + i32.const 3542 i32.const 0 call $~lib/env/abort unreachable @@ -48861,8 +49118,8 @@ i32.lt_s if i32.const 0 - i32.const 40 - i32.const 2425 + i32.const 112 + i32.const 2750 i32.const 19 call $~lib/env/abort unreachable @@ -48877,7 +49134,7 @@ if i32.const 0 i32.const 8 - i32.const 3390 + i32.const 3543 i32.const 0 call $~lib/env/abort unreachable @@ -48895,7 +49152,7 @@ if i32.const 0 i32.const 8 - i32.const 3391 + i32.const 3544 i32.const 0 call $~lib/env/abort unreachable @@ -48908,8 +49165,8 @@ i64.lt_s if i32.const 0 - i32.const 40 - i32.const 2425 + i32.const 112 + i32.const 2750 i32.const 19 call $~lib/env/abort unreachable @@ -48924,7 +49181,7 @@ if i32.const 0 i32.const 8 - i32.const 3392 + i32.const 3545 i32.const 0 call $~lib/env/abort unreachable @@ -48942,7 +49199,7 @@ if i32.const 0 i32.const 8 - i32.const 3393 + i32.const 3546 i32.const 0 call $~lib/env/abort unreachable @@ -48955,8 +49212,8 @@ i32.lt_s if i32.const 0 - i32.const 40 - i32.const 2425 + i32.const 112 + i32.const 2750 i32.const 19 call $~lib/env/abort unreachable @@ -48975,7 +49232,7 @@ if i32.const 0 i32.const 8 - i32.const 3394 + i32.const 3547 i32.const 0 call $~lib/env/abort unreachable @@ -48997,7 +49254,7 @@ if i32.const 0 i32.const 8 - i32.const 3395 + i32.const 3548 i32.const 0 call $~lib/env/abort unreachable @@ -49010,8 +49267,8 @@ i32.lt_s if i32.const 0 - i32.const 40 - i32.const 2425 + i32.const 112 + i32.const 2750 i32.const 19 call $~lib/env/abort unreachable @@ -49026,7 +49283,7 @@ if i32.const 0 i32.const 8 - i32.const 3396 + i32.const 3549 i32.const 0 call $~lib/env/abort unreachable @@ -49044,7 +49301,7 @@ if i32.const 0 i32.const 8 - i32.const 3397 + i32.const 3550 i32.const 0 call $~lib/env/abort unreachable @@ -49064,7 +49321,7 @@ if i32.const 0 i32.const 8 - i32.const 3398 + i32.const 3551 i32.const 0 call $~lib/env/abort unreachable @@ -49077,8 +49334,8 @@ i32.lt_s if i32.const 0 - i32.const 40 - i32.const 2425 + i32.const 112 + i32.const 2750 i32.const 19 call $~lib/env/abort unreachable @@ -49093,7 +49350,7 @@ if i32.const 0 i32.const 8 - i32.const 3399 + i32.const 3552 i32.const 0 call $~lib/env/abort unreachable @@ -49111,7 +49368,7 @@ if i32.const 0 i32.const 8 - i32.const 3400 + i32.const 3553 i32.const 0 call $~lib/env/abort unreachable @@ -49129,7 +49386,7 @@ if i32.const 0 i32.const 8 - i32.const 3401 + i32.const 3554 i32.const 0 call $~lib/env/abort unreachable @@ -49142,8 +49399,8 @@ i64.lt_s if i32.const 0 - i32.const 40 - i32.const 2425 + i32.const 112 + i32.const 2750 i32.const 19 call $~lib/env/abort unreachable @@ -49158,7 +49415,7 @@ if i32.const 0 i32.const 8 - i32.const 3402 + i32.const 3555 i32.const 0 call $~lib/env/abort unreachable @@ -49176,7 +49433,7 @@ if i32.const 0 i32.const 8 - i32.const 3403 + i32.const 3556 i32.const 0 call $~lib/env/abort unreachable @@ -49189,7 +49446,7 @@ if i32.const 0 i32.const 8 - i32.const 3404 + i32.const 3557 i32.const 0 call $~lib/env/abort unreachable @@ -49210,7 +49467,7 @@ if i32.const 0 i32.const 8 - i32.const 3408 + i32.const 3561 i32.const 0 call $~lib/env/abort unreachable @@ -49231,7 +49488,7 @@ if i32.const 0 i32.const 8 - i32.const 3409 + i32.const 3562 i32.const 0 call $~lib/env/abort unreachable @@ -49252,7 +49509,7 @@ if i32.const 0 i32.const 8 - i32.const 3410 + i32.const 3563 i32.const 0 call $~lib/env/abort unreachable @@ -49273,7 +49530,7 @@ if i32.const 0 i32.const 8 - i32.const 3411 + i32.const 3564 i32.const 0 call $~lib/env/abort unreachable @@ -49294,7 +49551,7 @@ if i32.const 0 i32.const 8 - i32.const 3412 + i32.const 3565 i32.const 0 call $~lib/env/abort unreachable @@ -49308,7 +49565,7 @@ if i32.const 0 i32.const 8 - i32.const 3461 + i32.const 3569 i32.const 0 call $~lib/env/abort unreachable @@ -49322,7 +49579,7 @@ if i32.const 0 i32.const 8 - i32.const 3462 + i32.const 3570 i32.const 0 call $~lib/env/abort unreachable @@ -49336,7 +49593,7 @@ if i32.const 0 i32.const 8 - i32.const 3463 + i32.const 3571 i32.const 0 call $~lib/env/abort unreachable @@ -49350,7 +49607,7 @@ if i32.const 0 i32.const 8 - i32.const 3464 + i32.const 3572 i32.const 0 call $~lib/env/abort unreachable @@ -49364,7 +49621,7 @@ if i32.const 0 i32.const 8 - i32.const 3466 + i32.const 3574 i32.const 0 call $~lib/env/abort unreachable @@ -49378,7 +49635,7 @@ if i32.const 0 i32.const 8 - i32.const 3467 + i32.const 3575 i32.const 0 call $~lib/env/abort unreachable @@ -49392,7 +49649,7 @@ if i32.const 0 i32.const 8 - i32.const 3468 + i32.const 3576 i32.const 0 call $~lib/env/abort unreachable @@ -49406,7 +49663,7 @@ if i32.const 0 i32.const 8 - i32.const 3469 + i32.const 3577 i32.const 0 call $~lib/env/abort unreachable @@ -49420,7 +49677,7 @@ if i32.const 0 i32.const 8 - i32.const 3471 + i32.const 3579 i32.const 0 call $~lib/env/abort unreachable @@ -49434,7 +49691,7 @@ if i32.const 0 i32.const 8 - i32.const 3472 + i32.const 3580 i32.const 0 call $~lib/env/abort unreachable @@ -49448,7 +49705,7 @@ if i32.const 0 i32.const 8 - i32.const 3473 + i32.const 3581 i32.const 0 call $~lib/env/abort unreachable @@ -49462,7 +49719,7 @@ if i32.const 0 i32.const 8 - i32.const 3474 + i32.const 3582 i32.const 0 call $~lib/env/abort unreachable @@ -49476,7 +49733,7 @@ if i32.const 0 i32.const 8 - i32.const 3476 + i32.const 3584 i32.const 0 call $~lib/env/abort unreachable @@ -49490,7 +49747,7 @@ if i32.const 0 i32.const 8 - i32.const 3477 + i32.const 3585 i32.const 0 call $~lib/env/abort unreachable @@ -49504,7 +49761,7 @@ if i32.const 0 i32.const 8 - i32.const 3478 + i32.const 3586 i32.const 0 call $~lib/env/abort unreachable @@ -49518,7 +49775,7 @@ if i32.const 0 i32.const 8 - i32.const 3479 + i32.const 3587 i32.const 0 call $~lib/env/abort unreachable @@ -49532,7 +49789,7 @@ if i32.const 0 i32.const 8 - i32.const 3481 + i32.const 3589 i32.const 0 call $~lib/env/abort unreachable @@ -49546,7 +49803,7 @@ if i32.const 0 i32.const 8 - i32.const 3482 + i32.const 3590 i32.const 0 call $~lib/env/abort unreachable @@ -49560,7 +49817,7 @@ if i32.const 0 i32.const 8 - i32.const 3483 + i32.const 3591 i32.const 0 call $~lib/env/abort unreachable @@ -49574,7 +49831,7 @@ if i32.const 0 i32.const 8 - i32.const 3484 + i32.const 3592 i32.const 0 call $~lib/env/abort unreachable @@ -49588,7 +49845,7 @@ if i32.const 0 i32.const 8 - i32.const 3486 + i32.const 3594 i32.const 0 call $~lib/env/abort unreachable @@ -49602,7 +49859,7 @@ if i32.const 0 i32.const 8 - i32.const 3487 + i32.const 3595 i32.const 0 call $~lib/env/abort unreachable @@ -49616,7 +49873,7 @@ if i32.const 0 i32.const 8 - i32.const 3488 + i32.const 3596 i32.const 0 call $~lib/env/abort unreachable @@ -49630,7 +49887,7 @@ if i32.const 0 i32.const 8 - i32.const 3489 + i32.const 3597 i32.const 0 call $~lib/env/abort unreachable @@ -49644,7 +49901,7 @@ if i32.const 0 i32.const 8 - i32.const 3490 + i32.const 3598 i32.const 0 call $~lib/env/abort unreachable @@ -49658,7 +49915,7 @@ if i32.const 0 i32.const 8 - i32.const 3491 + i32.const 3599 i32.const 0 call $~lib/env/abort unreachable @@ -49672,7 +49929,7 @@ if i32.const 0 i32.const 8 - i32.const 3492 + i32.const 3600 i32.const 0 call $~lib/env/abort unreachable @@ -49690,7 +49947,7 @@ if i32.const 0 i32.const 8 - i32.const 3494 + i32.const 3602 i32.const 0 call $~lib/env/abort unreachable @@ -49704,7 +49961,7 @@ if i32.const 0 i32.const 8 - i32.const 3498 + i32.const 3606 i32.const 0 call $~lib/env/abort unreachable @@ -49718,7 +49975,7 @@ if i32.const 0 i32.const 8 - i32.const 3499 + i32.const 3607 i32.const 0 call $~lib/env/abort unreachable @@ -49738,7 +49995,7 @@ if i32.const 0 i32.const 8 - i32.const 3500 + i32.const 3608 i32.const 0 call $~lib/env/abort unreachable @@ -49758,7 +50015,7 @@ if i32.const 0 i32.const 8 - i32.const 3501 + i32.const 3609 i32.const 0 call $~lib/env/abort unreachable @@ -49778,7 +50035,7 @@ if i32.const 0 i32.const 8 - i32.const 3502 + i32.const 3610 i32.const 0 call $~lib/env/abort unreachable @@ -49792,7 +50049,7 @@ if i32.const 0 i32.const 8 - i32.const 3503 + i32.const 3611 i32.const 0 call $~lib/env/abort unreachable @@ -49806,7 +50063,7 @@ if i32.const 0 i32.const 8 - i32.const 3504 + i32.const 3612 i32.const 0 call $~lib/env/abort unreachable @@ -49821,7 +50078,7 @@ if i32.const 0 i32.const 8 - i32.const 3505 + i32.const 3613 i32.const 0 call $~lib/env/abort unreachable @@ -49837,7 +50094,7 @@ if i32.const 0 i32.const 8 - i32.const 3506 + i32.const 3614 i32.const 0 call $~lib/env/abort unreachable @@ -49852,7 +50109,7 @@ if i32.const 0 i32.const 8 - i32.const 3507 + i32.const 3615 i32.const 0 call $~lib/env/abort unreachable @@ -49866,7 +50123,7 @@ if i32.const 0 i32.const 8 - i32.const 3508 + i32.const 3616 i32.const 0 call $~lib/env/abort unreachable @@ -49880,7 +50137,7 @@ if i32.const 0 i32.const 8 - i32.const 3509 + i32.const 3617 i32.const 0 call $~lib/env/abort unreachable @@ -49894,7 +50151,7 @@ if i32.const 0 i32.const 8 - i32.const 3510 + i32.const 3618 i32.const 0 call $~lib/env/abort unreachable @@ -49908,7 +50165,7 @@ if i32.const 0 i32.const 8 - i32.const 3511 + i32.const 3619 i32.const 0 call $~lib/env/abort unreachable @@ -49922,7 +50179,7 @@ if i32.const 0 i32.const 8 - i32.const 3512 + i32.const 3620 i32.const 0 call $~lib/env/abort unreachable @@ -49936,7 +50193,7 @@ if i32.const 0 i32.const 8 - i32.const 3513 + i32.const 3621 i32.const 0 call $~lib/env/abort unreachable @@ -49950,7 +50207,7 @@ if i32.const 0 i32.const 8 - i32.const 3517 + i32.const 3625 i32.const 0 call $~lib/env/abort unreachable @@ -49964,7 +50221,7 @@ if i32.const 0 i32.const 8 - i32.const 3518 + i32.const 3626 i32.const 0 call $~lib/env/abort unreachable @@ -49977,7 +50234,7 @@ if i32.const 0 i32.const 8 - i32.const 3519 + i32.const 3627 i32.const 0 call $~lib/env/abort unreachable @@ -49990,7 +50247,7 @@ if i32.const 0 i32.const 8 - i32.const 3520 + i32.const 3628 i32.const 0 call $~lib/env/abort unreachable @@ -50003,7 +50260,7 @@ if i32.const 0 i32.const 8 - i32.const 3521 + i32.const 3629 i32.const 0 call $~lib/env/abort unreachable @@ -50017,7 +50274,7 @@ if i32.const 0 i32.const 8 - i32.const 3522 + i32.const 3630 i32.const 0 call $~lib/env/abort unreachable @@ -50031,7 +50288,7 @@ if i32.const 0 i32.const 8 - i32.const 3523 + i32.const 3631 i32.const 0 call $~lib/env/abort unreachable @@ -50046,7 +50303,7 @@ if i32.const 0 i32.const 8 - i32.const 3524 + i32.const 3632 i32.const 0 call $~lib/env/abort unreachable @@ -50062,7 +50319,7 @@ if i32.const 0 i32.const 8 - i32.const 3525 + i32.const 3633 i32.const 0 call $~lib/env/abort unreachable @@ -50077,7 +50334,7 @@ if i32.const 0 i32.const 8 - i32.const 3526 + i32.const 3634 i32.const 0 call $~lib/env/abort unreachable @@ -50091,7 +50348,7 @@ if i32.const 0 i32.const 8 - i32.const 3527 + i32.const 3635 i32.const 0 call $~lib/env/abort unreachable @@ -50105,7 +50362,7 @@ if i32.const 0 i32.const 8 - i32.const 3528 + i32.const 3636 i32.const 0 call $~lib/env/abort unreachable @@ -50119,7 +50376,7 @@ if i32.const 0 i32.const 8 - i32.const 3529 + i32.const 3637 i32.const 0 call $~lib/env/abort unreachable @@ -50133,7 +50390,7 @@ if i32.const 0 i32.const 8 - i32.const 3530 + i32.const 3638 i32.const 0 call $~lib/env/abort unreachable @@ -50147,7 +50404,7 @@ if i32.const 0 i32.const 8 - i32.const 3531 + i32.const 3639 i32.const 0 call $~lib/env/abort unreachable @@ -50161,15 +50418,15 @@ if i32.const 0 i32.const 8 - i32.const 3532 + i32.const 3640 i32.const 0 call $~lib/env/abort unreachable end ) - (func $start (; 166 ;) (type $FUNCSIG$v) + (func $start (; 178 ;) (type $FUNCSIG$v) call $start:std/math ) - (func $null (; 167 ;) (type $FUNCSIG$v) + (func $null (; 179 ;) (type $FUNCSIG$v) ) )