diff --git a/README.md b/README.md index f31c86c8..8c8ec317 100644 --- a/README.md +++ b/README.md @@ -69,16 +69,20 @@ Syntax: asc [options] [file ...] Examples: asc hello.ts Options: - -v, --version Prints the compiler's version. - -h, --help Prints this message. - -O, --optimize Optimizes the module. - -c, --validate Validates the module. - -o, --outFile Specifies the output file. - -b, --binaryFile Specifies the binary format output file. - -t, --textFile Specifies the text format output file. - -a, --asmjsFile Specifies the asm.js format output file. - --noTreeShaking Disables tree-shaking. - --noDebug Disables assertions. + -v, --version Prints the compiler's version. + -h, --help Prints this message. + -O, --optimize Optimizes the module. + -c, --validate Validates the module. + -o, --outFile Specifies the output file. Format is determined by file extension. + -b, --binaryFile Specifies the binary format output file (.wasm). + -t, --textFile Specifies the text format output file (.wast). + -a, --asmjsFile Specifies the asm.js format output file (.js). + --noTreeShaking Disables tree-shaking. + --noDebug Disables assertions. + --trapMode Sets the trap mode to use. + none Do not modify trapping operations. This is the default. + clamp Replace trapping operations with clamping semantics. + js Replace trapping operations with JS semantics. ``` Unless a bundle has been built to `dist/`, `asc` runs the TypeScript sources directly via [ts-node](https://www.npmjs.com/package/ts-node). Useful for development. diff --git a/bin/asc.js b/bin/asc.js index 65330c41..85456b2a 100644 --- a/bin/asc.js +++ b/bin/asc.js @@ -31,6 +31,7 @@ Object.keys(conf).forEach(key => { var args = minimist(process.argv.slice(2), opts); var version = require("../package.json").version; +var indent = 20; if (isDev) version += "-dev"; if (args.version) { @@ -48,9 +49,16 @@ if (args.help || args._.length < 1) { if (option.aliases && option.aliases[0].length === 1) text += "-" + option.aliases[0] + ", "; text += "--" + name; - while (text.length < 24) + while (text.length < indent) text += " "; - options.push(text + option.desc); + if (Array.isArray(option.desc)) { + options.push(text + option.desc[0] + option.desc.slice(1).map(line => { + for (var i = 0; i < indent; ++i) + line = " " + line; + return "\n" + line; + }).join("")); + } else + options.push(text + option.desc); }); console.log([ "Version " + version, @@ -135,6 +143,11 @@ if (args.validate) process.exit(1); } +if (args.trapMode === "clamp") + module.runPasses([ "trap-mode-clamp" ]); +else if (args.trapMode === "js") + module.runPasses([ "trap-mode-js" ]); + if (args.optimize) module.optimize(); diff --git a/bin/asc.json b/bin/asc.json index 88a00ab6..fb4374d1 100644 --- a/bin/asc.json +++ b/bin/asc.json @@ -20,22 +20,22 @@ "aliases": [ "c", "check" ] }, "outFile": { - "desc": "Specifies the output file.", + "desc": "Specifies the output file. Format is determined by file extension.", "type": "string", "aliases": [ "o" ] }, "binaryFile": { - "desc": "Specifies the binary format output file.", + "desc": "Specifies the binary format output file (.wasm).", "type": "string", "aliases": [ "b" ] }, "textFile": { - "desc": "Specifies the text format output file.", + "desc": "Specifies the text format output file (.wast).", "type": "string", "aliases": [ "t" ] }, "asmjsFile": { - "desc": "Specifies the asm.js format output file.", + "desc": "Specifies the asm.js format output file (.js).", "type": "string", "aliases": [ "a" ] }, @@ -46,5 +46,15 @@ "noDebug": { "desc": "Disables assertions.", "type": "boolean" + }, + "trapMode": { + "desc": [ + "Sets the trap mode to use.", + "none Do not modify trapping operations. This is the default.", + "clamp Replace trapping operations with clamping semantics.", + "js Replace trapping operations with JS semantics." + ], + "type": "string", + "default": "none" } } diff --git a/src/compiler.ts b/src/compiler.ts index 47990362..b319b6fa 100644 --- a/src/compiler.ts +++ b/src/compiler.ts @@ -393,7 +393,8 @@ export class Compiler extends DiagnosticEmitter { if (getExpressionId(initializer) != ExpressionId.Const) { initializer = this.precomputeExpressionRef(initializer); if (getExpressionId(initializer) != ExpressionId.Const) { - this.warning(DiagnosticCode.Compiling_constant_global_with_non_constant_initializer_as_mutable, declaration.range); + if (element.isConstant) + this.warning(DiagnosticCode.Compiling_constant_global_with_non_constant_initializer_as_mutable, declaration.range); initializeInStart = true; } } @@ -407,7 +408,8 @@ export class Compiler extends DiagnosticEmitter { this.module.createGetGlobal(previousValue.internalName, NativeType.I32), this.module.createI32(1) ); - this.warning(DiagnosticCode.Compiling_constant_global_with_non_constant_initializer_as_mutable, val.declaration.range); + if (element.isConstant) + this.warning(DiagnosticCode.Compiling_constant_global_with_non_constant_initializer_as_mutable, val.declaration.range); initializeInStart = true; } if (initializeInStart) { diff --git a/src/module.ts b/src/module.ts index 1fafff3e..0f162d48 100644 --- a/src/module.ts +++ b/src/module.ts @@ -702,7 +702,7 @@ export class Module { optimize(func: FunctionRef = 0): void { // see: https://github.com/WebAssembly/binaryen/issues/1331#issuecomment-350328175 - this.runPasses([ "flatten", "ssa" ], func); + // this.runPasses([ "flatten", "ssa" ], func); if (func) { _BinaryenFunctionOptimize(func, this.ref); } else { diff --git a/tests/binaryen/export-import.js b/tests/binaryen/export-import.js deleted file mode 100644 index fa40596f..00000000 --- a/tests/binaryen/export-import.js +++ /dev/null @@ -1,13 +0,0 @@ -var binaryen = require("binaryen"); - -// "unexpected false: module function exports must be found" - -var mod = new binaryen.Module(); - -var funcType = mod.addFunctionType("v", binaryen.none, []); -var func = mod.addImport("test", "env", "test", funcType); -mod.addExport("test", "test"); - -console.log(mod.emitText()); -if (!mod.validate()) - console.log("-> does not validate"); diff --git a/tests/compiler/declare.optimized.wast b/tests/compiler/declare.optimized.wast index e84d4561..6438498e 100644 --- a/tests/compiler/declare.optimized.wast +++ b/tests/compiler/declare.optimized.wast @@ -1,5 +1,7 @@ (module + (type $v (func)) + (import "env" "external" (func $declare/external)) (memory $0 1) - (data (i32.const 4) "\08") + (export "external" (func $declare/external)) (export "memory" (memory $0)) ) diff --git a/tests/compiler/declare.ts b/tests/compiler/declare.ts index f74e909a..616f1548 100644 --- a/tests/compiler/declare.ts +++ b/tests/compiler/declare.ts @@ -1,5 +1,3 @@ declare function external(): void; -// "unexpected false: module function exports must be found" -// see: https://github.com/WebAssembly/binaryen/issues/1325 export { external }; diff --git a/tests/compiler/do.optimized.wast b/tests/compiler/do.optimized.wast index 279653c0..9d4d7f5e 100644 --- a/tests/compiler/do.optimized.wast +++ b/tests/compiler/do.optimized.wast @@ -5,15 +5,11 @@ (export "loopDoInDo" (func $do/loopDoInDo)) (export "memory" (memory $0)) (func $do/loopDo (; 0 ;) (type $iv) (param $0 i32) - (local $1 i32) - (set_local $1 - (get_local $0) - ) (loop $continue|0 (br_if $continue|0 - (tee_local $1 + (tee_local $0 (i32.sub - (get_local $1) + (get_local $0) (i32.const 1) ) ) @@ -21,10 +17,8 @@ ) ) (func $do/loopDoInDo (; 1 ;) (type $iv) (param $0 i32) - (local $1 i32) - (local $2 i32) (loop $continue|0 - (set_local $1 + (set_local $0 (i32.sub (get_local $0) (i32.const 1) @@ -32,20 +26,16 @@ ) (loop $continue|1 (br_if $continue|1 - (tee_local $2 - (tee_local $1 - (tee_local $0 - (i32.sub - (get_local $1) - (i32.const 1) - ) - ) + (tee_local $0 + (i32.sub + (get_local $0) + (i32.const 1) ) ) ) ) (br_if $continue|0 - (get_local $2) + (get_local $0) ) ) ) diff --git a/tests/compiler/game-of-life.optimized.wast b/tests/compiler/game-of-life.optimized.wast index 35b9922a..3078cae6 100644 --- a/tests/compiler/game-of-life.optimized.wast +++ b/tests/compiler/game-of-life.optimized.wast @@ -100,7 +100,7 @@ (get_local $4) (get_global $game-of-life/w) ) - (tee_local $3 + (tee_local $2 (select (i32.sub (get_local $1) @@ -128,7 +128,7 @@ (get_local $4) (get_global $game-of-life/w) ) - (tee_local $2 + (tee_local $3 (select (i32.const 0) (i32.add @@ -150,7 +150,7 @@ (get_local $0) (get_global $game-of-life/w) ) - (get_local $3) + (get_local $2) ) ) ) @@ -160,7 +160,7 @@ (get_local $0) (get_global $game-of-life/w) ) - (get_local $2) + (get_local $3) ) ) ) @@ -170,7 +170,7 @@ (get_local $5) (get_global $game-of-life/w) ) - (get_local $3) + (get_local $2) ) ) ) @@ -190,7 +190,7 @@ (get_local $5) (get_global $game-of-life/w) ) - (get_local $2) + (get_local $3) ) ) ) @@ -205,38 +205,32 @@ (get_local $1) ) ) - (block - (if - (i32.eqz - (tee_local $3 - (i32.lt_s - (get_local $2) - (i32.const 2) - ) + (if + (if (result i32) + (tee_local $3 + (i32.lt_s + (get_local $2) + (i32.const 2) ) ) - (set_local $3 - (i32.gt_s - (get_local $2) - (i32.const 3) - ) + (get_local $3) + (i32.gt_s + (get_local $2) + (i32.const 3) ) ) - (if - (get_local $3) - (i32.store8 + (i32.store8 + (i32.add (i32.add - (i32.add - (get_global $game-of-life/s) - (i32.mul - (get_local $0) - (get_global $game-of-life/w) - ) + (get_global $game-of-life/s) + (i32.mul + (get_local $0) + (get_global $game-of-life/w) ) - (get_local $1) ) - (i32.const 0) + (get_local $1) ) + (i32.const 0) ) ) (if diff --git a/tests/compiler/logical.optimized.wast b/tests/compiler/logical.optimized.wast index 0b2f268e..3c0bd69b 100644 --- a/tests/compiler/logical.optimized.wast +++ b/tests/compiler/logical.optimized.wast @@ -44,48 +44,46 @@ ) (unreachable) ) - (if - (tee_local $0 - (i32.const 1) - ) - (set_local $0 - (i32.const 2) - ) - ) (if (i32.eqz - (get_local $0) + (if (result i32) + (tee_local $0 + (i32.const 1) + ) + (tee_local $0 + (i32.const 2) + ) + (get_local $0) + ) ) (unreachable) ) - (if - (f64.ne - (tee_local $1 - (f64.const 1) - ) - (f64.const 0) - ) - (set_local $1 - (f64.const 2) - ) - ) (if (f64.eq - (get_local $1) + (if (result f64) + (f64.ne + (tee_local $1 + (f64.const 1) + ) + (f64.const 0) + ) + (tee_local $1 + (f64.const 2) + ) + (get_local $1) + ) (f64.const 0) ) (unreachable) ) - (if - (tee_local $0 - (i32.const 1) - ) - (set_local $0 - (i32.const 2) - ) - ) (set_global $logical/i - (get_local $0) + (if (result i32) + (tee_local $0 + (i32.const 1) + ) + (i32.const 2) + (get_local $0) + ) ) (if (i32.ne @@ -94,19 +92,15 @@ ) (unreachable) ) - (if - (i32.eqz + (set_global $logical/i + (if (result i32) (tee_local $0 (i32.const 0) ) - ) - (set_local $0 + (get_local $0) (i32.const 1) ) ) - (set_global $logical/i - (get_local $0) - ) (if (i32.ne (get_global $logical/i) @@ -114,40 +108,36 @@ ) (unreachable) ) - (if - (i64.ne - (tee_local $2 - (i64.const 1) - ) - (i64.const 0) - ) - (set_local $2 - (i64.const 2) - ) - ) (set_global $logical/I - (get_local $2) - ) - (if - (i64.ne - (get_global $logical/I) - (i64.const 2) - ) - (unreachable) - ) - (if - (i64.eq - (tee_local $2 + (if (result i64) + (i64.ne + (tee_local $2 + (i64.const 1) + ) (i64.const 0) ) - (i64.const 0) - ) - (set_local $2 - (i64.const 1) + (i64.const 2) + (get_local $2) ) ) + (if + (i64.ne + (get_global $logical/I) + (i64.const 2) + ) + (unreachable) + ) (set_global $logical/I - (get_local $2) + (if (result i64) + (i64.ne + (tee_local $2 + (i64.const 0) + ) + (i64.const 0) + ) + (get_local $2) + (i64.const 1) + ) ) (if (i64.ne @@ -156,40 +146,36 @@ ) (unreachable) ) - (if - (f32.ne - (tee_local $3 - (f32.const 1) - ) - (f32.const 0) - ) - (set_local $3 - (f32.const 2) - ) - ) (set_global $logical/f - (get_local $3) - ) - (if - (f32.ne - (get_global $logical/f) - (f32.const 2) - ) - (unreachable) - ) - (if - (f32.eq - (tee_local $3 + (if (result f32) + (f32.ne + (tee_local $3 + (f32.const 1) + ) (f32.const 0) ) - (f32.const 0) - ) - (set_local $3 - (f32.const 1) + (f32.const 2) + (get_local $3) ) ) + (if + (f32.ne + (get_global $logical/f) + (f32.const 2) + ) + (unreachable) + ) (set_global $logical/f - (get_local $3) + (if (result f32) + (f32.ne + (tee_local $3 + (f32.const 0) + ) + (f32.const 0) + ) + (get_local $3) + (f32.const 1) + ) ) (if (f32.ne @@ -198,19 +184,17 @@ ) (unreachable) ) - (if - (f64.ne - (tee_local $1 - (f64.const 1) - ) - (f64.const 0) - ) - (set_local $1 - (f64.const 2) - ) - ) (set_global $logical/F - (get_local $1) + (if (result f64) + (f64.ne + (tee_local $1 + (f64.const 1) + ) + (f64.const 0) + ) + (f64.const 2) + (get_local $1) + ) ) (if (f64.ne @@ -219,20 +203,18 @@ ) (unreachable) ) - (if - (f64.eq - (tee_local $1 + (set_global $logical/F + (if (result f64) + (f64.ne + (tee_local $1 + (f64.const 0) + ) (f64.const 0) ) - (f64.const 0) - ) - (set_local $1 + (get_local $1) (f64.const 1) ) ) - (set_global $logical/F - (get_local $1) - ) (if (f64.ne (get_global $logical/F) diff --git a/tests/compiler/memcpy.optimized.wast b/tests/compiler/memcpy.optimized.wast index 02ab6bb0..dcfb3e07 100644 --- a/tests/compiler/memcpy.optimized.wast +++ b/tests/compiler/memcpy.optimized.wast @@ -10,248 +10,50 @@ (local $3 i32) (local $4 i32) (local $5 i32) - (local $6 i32) - (local $7 i32) - (local $8 i32) - (local $9 i32) - (local $10 i32) - (local $11 i32) - (local $12 i32) - (local $13 i32) - (local $14 i32) - (local $15 i32) - (local $16 i32) - (local $17 i32) - (local $18 i32) - (local $19 i32) - (local $20 i32) - (local $21 i32) - (local $22 i32) - (local $23 i32) - (local $24 i32) - (local $25 i32) - (local $26 i32) - (local $27 i32) - (local $28 i32) - (local $29 i32) - (local $30 i32) - (local $31 i32) - (local $32 i32) - (local $33 i32) - (local $34 i32) - (local $35 i32) - (local $36 i32) - (local $37 i32) - (local $38 i32) - (local $39 i32) - (set_local $23 - (get_local $2) - ) - (set_local $16 - (get_local $2) - ) - (set_local $30 - (get_local $2) - ) - (set_local $31 - (get_local $2) - ) - (set_local $32 - (get_local $2) - ) - (set_local $33 - (get_local $2) - ) - (set_local $34 - (get_local $2) - ) - (set_local $35 - (get_local $2) - ) - (set_local $36 - (get_local $2) - ) - (set_local $37 - (get_local $2) - ) - (set_local $38 - (get_local $2) - ) - (set_local $39 - (get_local $2) - ) - (set_local $11 - (get_local $2) - ) - (set_local $19 - (get_local $2) - ) - (set_local $20 - (get_local $2) - ) - (set_local $21 - (get_local $2) - ) - (set_local $22 - (get_local $2) - ) - (set_local $6 - (tee_local $5 - (tee_local $9 - (tee_local $13 - (tee_local $17 - (tee_local $2 - (tee_local $25 - (tee_local $24 - (tee_local $28 - (tee_local $12 - (tee_local $4 - (get_local $0) - ) - ) - ) - ) - ) - ) - ) - ) - ) - ) - ) - (set_local $8 - (tee_local $7 - (tee_local $10 - (tee_local $15 - (tee_local $18 - (tee_local $1 - (tee_local $27 - (tee_local $26 - (tee_local $29 - (tee_local $14 - (tee_local $3 - (get_local $1) - ) - ) - ) - ) - ) - ) - ) - ) - ) - ) + (set_local $4 + (get_local $0) ) (loop $continue|0 (if - (get_local $23) - (set_local $23 + (if (result i32) + (tee_local $3 + (get_local $2) + ) (i32.rem_s - (get_local $3) + (get_local $1) (i32.const 4) ) + (get_local $3) ) - ) - (if - (get_local $23) (block - (set_local $6 - (tee_local $5 - (tee_local $9 - (tee_local $13 - (tee_local $17 - (tee_local $2 - (tee_local $25 - (tee_local $24 - (tee_local $28 - (tee_local $12 - (tee_local $4 - (i32.add - (tee_local $23 - (get_local $4) - ) - (i32.const 1) - ) - ) - ) - ) - ) - ) - ) - ) - ) - ) - ) - ) - (set_local $8 - (tee_local $7 - (tee_local $10 - (tee_local $15 - (tee_local $18 - (tee_local $1 - (tee_local $27 - (tee_local $26 - (tee_local $29 - (tee_local $14 - (tee_local $3 - (i32.add - (tee_local $11 - (get_local $3) - ) - (i32.const 1) - ) - ) - ) - ) - ) - ) - ) - ) - ) + (set_local $4 + (i32.add + (tee_local $3 + (get_local $4) ) + (i32.const 1) ) ) (i32.store8 - (get_local $23) - (i32.load8_u - (get_local $11) - ) - ) - (set_local $22 - (tee_local $21 - (tee_local $20 - (tee_local $19 - (tee_local $11 - (tee_local $39 - (tee_local $38 - (tee_local $37 - (tee_local $36 - (tee_local $35 - (tee_local $34 - (tee_local $33 - (tee_local $32 - (tee_local $31 - (tee_local $30 - (tee_local $16 - (tee_local $23 - (i32.sub - (get_local $16) - (i32.const 1) - ) - ) - ) - ) - ) - ) - ) - ) - ) - ) - ) - ) - ) + (get_local $3) + (block (result i32) + (set_local $1 + (i32.add + (tee_local $3 + (get_local $1) ) + (i32.const 1) ) ) + (i32.load8_u + (get_local $3) + ) + ) + ) + (set_local $2 + (i32.sub + (get_local $2) + (i32.const 1) ) ) (br $continue|0) @@ -269,90 +71,68 @@ (loop $continue|1 (if (i32.ge_s - (get_local $30) + (get_local $2) (i32.const 16) ) (block (i32.store - (get_local $12) + (get_local $4) (i32.load - (get_local $14) + (get_local $1) ) ) (i32.store (i32.add - (get_local $12) + (get_local $4) (i32.const 4) ) (i32.load (i32.add - (get_local $14) + (get_local $1) (i32.const 4) ) ) ) (i32.store (i32.add - (get_local $12) + (get_local $4) (i32.const 8) ) (i32.load (i32.add - (get_local $14) + (get_local $1) (i32.const 8) ) ) ) (i32.store (i32.add - (get_local $12) + (get_local $4) (i32.const 12) ) (i32.load (i32.add - (get_local $14) + (get_local $1) (i32.const 12) ) ) ) - (set_local $27 - (tee_local $26 - (tee_local $29 - (tee_local $14 - (i32.add - (get_local $14) - (i32.const 16) - ) - ) - ) + (set_local $1 + (i32.add + (get_local $1) + (i32.const 16) ) ) - (set_local $25 - (tee_local $24 - (tee_local $28 - (tee_local $12 - (i32.add - (get_local $12) - (i32.const 16) - ) - ) - ) + (set_local $4 + (i32.add + (get_local $4) + (i32.const 16) ) ) - (set_local $35 - (tee_local $34 - (tee_local $33 - (tee_local $32 - (tee_local $31 - (tee_local $30 - (i32.sub - (get_local $31) - (i32.const 16) - ) - ) - ) - ) - ) + (set_local $2 + (i32.sub + (get_local $2) + (i32.const 16) ) ) (br $continue|1) @@ -361,101 +141,89 @@ ) (if (i32.and - (get_local $32) + (get_local $2) (i32.const 8) ) (block (i32.store - (get_local $12) + (get_local $4) (i32.load - (get_local $14) + (get_local $1) ) ) (i32.store (i32.add - (get_local $12) + (get_local $4) (i32.const 4) ) (i32.load (i32.add - (get_local $14) + (get_local $1) (i32.const 4) ) ) ) - (set_local $25 - (tee_local $24 - (tee_local $28 - (i32.add - (get_local $12) - (i32.const 8) - ) - ) + (set_local $4 + (i32.add + (get_local $4) + (i32.const 8) ) ) - (set_local $27 - (tee_local $26 - (tee_local $29 - (i32.add - (get_local $14) - (i32.const 8) - ) - ) + (set_local $1 + (i32.add + (get_local $1) + (i32.const 8) ) ) ) ) (if (i32.and - (get_local $33) + (get_local $2) (i32.const 4) ) (block (i32.store - (get_local $28) + (get_local $4) (i32.load - (get_local $29) + (get_local $1) ) ) - (set_local $25 - (tee_local $24 - (i32.add - (get_local $28) - (i32.const 4) - ) + (set_local $4 + (i32.add + (get_local $4) + (i32.const 4) ) ) - (set_local $27 - (tee_local $26 - (i32.add - (get_local $29) - (i32.const 4) - ) + (set_local $1 + (i32.add + (get_local $1) + (i32.const 4) ) ) ) ) (if (i32.and - (get_local $34) + (get_local $2) (i32.const 2) ) (block (i32.store16 - (get_local $24) + (get_local $4) (i32.load16_u - (get_local $26) + (get_local $1) ) ) - (set_local $25 + (set_local $4 (i32.add - (get_local $24) + (get_local $4) (i32.const 2) ) ) - (set_local $27 + (set_local $1 (i32.add - (get_local $26) + (get_local $1) (i32.const 2) ) ) @@ -463,13 +231,13 @@ ) (if (i32.and - (get_local $35) + (get_local $2) (i32.const 1) ) (i32.store8 - (get_local $25) + (get_local $4) (i32.load8_u - (get_local $27) + (get_local $1) ) ) ) @@ -480,148 +248,128 @@ ) (if (i32.ge_s - (get_local $36) + (get_local $2) (i32.const 32) ) (block $break|2 (block $case2|2 (block $case1|2 - (if - (i32.ne - (tee_local $4 - (i32.rem_s - (get_local $2) - (i32.const 4) - ) - ) - (i32.const 1) - ) - (block - (br_if $case1|2 - (i32.eq - (get_local $4) - (i32.const 2) - ) - ) - (br_if $case2|2 - (i32.eq - (get_local $4) - (i32.const 3) - ) - ) - (br $break|2) - ) - ) - (set_local $3 - (i32.load - (get_local $1) - ) - ) - (i32.store8 - (get_local $2) - (i32.load8_u - (get_local $1) - ) - ) - (i32.store8 - (tee_local $2 - (i32.add - (get_local $2) - (i32.const 1) - ) - ) - (i32.load8_u - (tee_local $4 - (i32.add - (get_local $1) + (block $case0|2 + (block $tablify|0 + (br_table $case0|2 $case1|2 $case2|2 $tablify|0 + (i32.sub + (i32.rem_s + (get_local $4) + (i32.const 4) + ) (i32.const 1) ) ) ) + (br $break|2) ) - (set_local $6 - (tee_local $5 - (tee_local $9 - (tee_local $13 - (tee_local $17 - (tee_local $1 - (i32.add - (tee_local $16 - (i32.add - (get_local $2) - (i32.const 1) - ) - ) - (i32.const 1) - ) - ) - ) - ) - ) + (set_local $5 + (i32.load + (get_local $1) ) ) - (set_local $8 - (tee_local $7 - (tee_local $10 - (tee_local $15 - (tee_local $18 - (tee_local $2 - (i32.add - (tee_local $4 - (i32.add - (get_local $4) - (i32.const 1) - ) - ) - (i32.const 1) - ) - ) - ) - ) + (set_local $4 + (i32.add + (tee_local $3 + (get_local $4) ) + (i32.const 1) ) ) (i32.store8 - (get_local $16) - (i32.load8_u - (get_local $4) - ) - ) - (set_local $22 - (tee_local $21 - (tee_local $20 - (tee_local $19 - (tee_local $11 - (tee_local $4 - (i32.sub - (get_local $37) - (i32.const 3) - ) - ) + (get_local $3) + (block (result i32) + (set_local $1 + (i32.add + (tee_local $3 + (get_local $1) ) + (i32.const 1) ) ) + (i32.load8_u + (get_local $3) + ) + ) + ) + (set_local $4 + (i32.add + (tee_local $3 + (get_local $4) + ) + (i32.const 1) + ) + ) + (i32.store8 + (get_local $3) + (block (result i32) + (set_local $1 + (i32.add + (tee_local $3 + (get_local $1) + ) + (i32.const 1) + ) + ) + (i32.load8_u + (get_local $3) + ) + ) + ) + (set_local $4 + (i32.add + (tee_local $3 + (get_local $4) + ) + (i32.const 1) + ) + ) + (i32.store8 + (get_local $3) + (block (result i32) + (set_local $1 + (i32.add + (tee_local $3 + (get_local $1) + ) + (i32.const 1) + ) + ) + (i32.load8_u + (get_local $3) + ) + ) + ) + (set_local $2 + (i32.sub + (get_local $2) + (i32.const 3) ) ) (loop $continue|3 (if (i32.ge_s - (get_local $4) + (get_local $2) (i32.const 17) ) (block (i32.store - (get_local $1) + (get_local $4) (i32.or (i32.shr_u - (get_local $3) + (get_local $5) (i32.const 24) ) (i32.shl (tee_local $3 (i32.load (i32.add - (get_local $2) + (get_local $1) (i32.const 1) ) ) @@ -632,7 +380,7 @@ ) (i32.store (i32.add - (get_local $1) + (get_local $4) (i32.const 4) ) (i32.or @@ -641,10 +389,10 @@ (i32.const 24) ) (i32.shl - (tee_local $3 + (tee_local $5 (i32.load (i32.add - (get_local $2) + (get_local $1) (i32.const 5) ) ) @@ -655,19 +403,19 @@ ) (i32.store (i32.add - (get_local $1) + (get_local $4) (i32.const 8) ) (i32.or (i32.shr_u - (get_local $3) + (get_local $5) (i32.const 24) ) (i32.shl (tee_local $3 (i32.load (i32.add - (get_local $2) + (get_local $1) (i32.const 9) ) ) @@ -678,7 +426,7 @@ ) (i32.store (i32.add - (get_local $1) + (get_local $4) (i32.const 12) ) (i32.or @@ -687,10 +435,10 @@ (i32.const 24) ) (i32.shl - (tee_local $3 + (tee_local $5 (i32.load (i32.add - (get_local $2) + (get_local $1) (i32.const 13) ) ) @@ -699,52 +447,22 @@ ) ) ) - (set_local $8 - (tee_local $7 - (tee_local $10 - (tee_local $15 - (tee_local $18 - (tee_local $2 - (i32.add - (get_local $2) - (i32.const 16) - ) - ) - ) - ) - ) + (set_local $1 + (i32.add + (get_local $1) + (i32.const 16) ) ) - (set_local $6 - (tee_local $5 - (tee_local $9 - (tee_local $13 - (tee_local $17 - (tee_local $1 - (i32.add - (get_local $1) - (i32.const 16) - ) - ) - ) - ) - ) + (set_local $4 + (i32.add + (get_local $4) + (i32.const 16) ) ) - (set_local $22 - (tee_local $21 - (tee_local $20 - (tee_local $19 - (tee_local $11 - (tee_local $4 - (i32.sub - (get_local $4) - (i32.const 16) - ) - ) - ) - ) - ) + (set_local $2 + (i32.sub + (get_local $2) + (i32.const 16) ) ) (br $continue|3) @@ -753,93 +471,77 @@ ) (br $break|2) ) - (set_local $3 + (set_local $5 (i32.load (get_local $1) ) ) - (i32.store8 - (get_local $2) - (i32.load8_u - (get_local $1) - ) - ) - (set_local $6 - (tee_local $5 - (tee_local $9 - (tee_local $13 - (tee_local $17 - (tee_local $2 - (i32.add - (tee_local $4 - (i32.add - (get_local $2) - (i32.const 1) - ) - ) - (i32.const 1) - ) - ) - ) - ) - ) - ) - ) - (set_local $8 - (tee_local $7 - (tee_local $10 - (tee_local $15 - (tee_local $18 - (tee_local $1 - (i32.add - (tee_local $16 - (i32.add - (get_local $1) - (i32.const 1) - ) - ) - (i32.const 1) - ) - ) - ) - ) + (set_local $4 + (i32.add + (tee_local $3 + (get_local $4) ) + (i32.const 1) ) ) (i32.store8 - (get_local $4) - (i32.load8_u - (get_local $16) - ) - ) - (set_local $22 - (tee_local $21 - (tee_local $20 - (tee_local $19 - (tee_local $11 - (tee_local $4 - (i32.sub - (get_local $38) - (i32.const 2) - ) - ) + (get_local $3) + (block (result i32) + (set_local $1 + (i32.add + (tee_local $3 + (get_local $1) ) + (i32.const 1) ) ) + (i32.load8_u + (get_local $3) + ) + ) + ) + (set_local $4 + (i32.add + (tee_local $3 + (get_local $4) + ) + (i32.const 1) + ) + ) + (i32.store8 + (get_local $3) + (block (result i32) + (set_local $1 + (i32.add + (tee_local $3 + (get_local $1) + ) + (i32.const 1) + ) + ) + (i32.load8_u + (get_local $3) + ) + ) + ) + (set_local $2 + (i32.sub + (get_local $2) + (i32.const 2) ) ) (loop $continue|4 (if (i32.ge_s - (get_local $4) + (get_local $2) (i32.const 18) ) (block (i32.store - (get_local $2) + (get_local $4) (i32.or (i32.shr_u - (get_local $3) + (get_local $5) (i32.const 16) ) (i32.shl @@ -857,7 +559,7 @@ ) (i32.store (i32.add - (get_local $2) + (get_local $4) (i32.const 4) ) (i32.or @@ -866,7 +568,7 @@ (i32.const 16) ) (i32.shl - (tee_local $3 + (tee_local $5 (i32.load (i32.add (get_local $1) @@ -880,12 +582,12 @@ ) (i32.store (i32.add - (get_local $2) + (get_local $4) (i32.const 8) ) (i32.or (i32.shr_u - (get_local $3) + (get_local $5) (i32.const 16) ) (i32.shl @@ -903,7 +605,7 @@ ) (i32.store (i32.add - (get_local $2) + (get_local $4) (i32.const 12) ) (i32.or @@ -912,7 +614,7 @@ (i32.const 16) ) (i32.shl - (tee_local $3 + (tee_local $5 (i32.load (i32.add (get_local $1) @@ -924,52 +626,22 @@ ) ) ) - (set_local $8 - (tee_local $7 - (tee_local $10 - (tee_local $15 - (tee_local $18 - (tee_local $1 - (i32.add - (get_local $1) - (i32.const 16) - ) - ) - ) - ) - ) + (set_local $1 + (i32.add + (get_local $1) + (i32.const 16) ) ) - (set_local $6 - (tee_local $5 - (tee_local $9 - (tee_local $13 - (tee_local $17 - (tee_local $2 - (i32.add - (get_local $2) - (i32.const 16) - ) - ) - ) - ) - ) + (set_local $4 + (i32.add + (get_local $4) + (i32.const 16) ) ) - (set_local $22 - (tee_local $21 - (tee_local $20 - (tee_local $19 - (tee_local $11 - (tee_local $4 - (i32.sub - (get_local $4) - (i32.const 16) - ) - ) - ) - ) - ) + (set_local $2 + (i32.sub + (get_local $2) + (i32.const 16) ) ) (br $continue|4) @@ -978,69 +650,45 @@ ) (br $break|2) ) - (set_local $16 + (set_local $5 (i32.load (get_local $1) ) ) - (set_local $6 - (tee_local $5 - (tee_local $9 - (tee_local $13 - (tee_local $17 - (tee_local $4 - (i32.add - (get_local $2) - (i32.const 1) - ) - ) - ) - ) - ) - ) - ) - (set_local $8 - (tee_local $7 - (tee_local $10 - (tee_local $15 - (tee_local $18 - (tee_local $3 - (i32.add - (get_local $1) - (i32.const 1) - ) - ) - ) - ) + (set_local $4 + (i32.add + (tee_local $3 + (get_local $4) ) + (i32.const 1) ) ) (i32.store8 - (get_local $2) - (i32.load8_u - (get_local $1) - ) - ) - (set_local $22 - (tee_local $21 - (tee_local $20 - (tee_local $19 - (tee_local $11 - (tee_local $1 - (i32.sub - (get_local $39) - (i32.const 1) - ) - ) + (get_local $3) + (block (result i32) + (set_local $1 + (i32.add + (tee_local $3 + (get_local $1) ) + (i32.const 1) ) ) + (i32.load8_u + (get_local $3) + ) + ) + ) + (set_local $2 + (i32.sub + (get_local $2) + (i32.const 1) ) ) (loop $continue|5 (if (i32.ge_s - (get_local $1) + (get_local $2) (i32.const 19) ) (block @@ -1048,14 +696,14 @@ (get_local $4) (i32.or (i32.shr_u - (get_local $16) + (get_local $5) (i32.const 8) ) (i32.shl - (tee_local $2 + (tee_local $3 (i32.load (i32.add - (get_local $3) + (get_local $1) (i32.const 3) ) ) @@ -1071,14 +719,14 @@ ) (i32.or (i32.shr_u - (get_local $2) + (get_local $3) (i32.const 8) ) (i32.shl - (tee_local $2 + (tee_local $5 (i32.load (i32.add - (get_local $3) + (get_local $1) (i32.const 7) ) ) @@ -1094,14 +742,14 @@ ) (i32.or (i32.shr_u - (get_local $2) + (get_local $5) (i32.const 8) ) (i32.shl - (tee_local $2 + (tee_local $3 (i32.load (i32.add - (get_local $3) + (get_local $1) (i32.const 11) ) ) @@ -1117,14 +765,14 @@ ) (i32.or (i32.shr_u - (get_local $2) + (get_local $3) (i32.const 8) ) (i32.shl - (tee_local $16 + (tee_local $5 (i32.load (i32.add - (get_local $3) + (get_local $1) (i32.const 15) ) ) @@ -1133,52 +781,22 @@ ) ) ) - (set_local $8 - (tee_local $7 - (tee_local $10 - (tee_local $15 - (tee_local $18 - (tee_local $3 - (i32.add - (get_local $3) - (i32.const 16) - ) - ) - ) - ) - ) + (set_local $1 + (i32.add + (get_local $1) + (i32.const 16) ) ) - (set_local $6 - (tee_local $5 - (tee_local $9 - (tee_local $13 - (tee_local $17 - (tee_local $4 - (i32.add - (get_local $4) - (i32.const 16) - ) - ) - ) - ) - ) + (set_local $4 + (i32.add + (get_local $4) + (i32.const 16) ) ) - (set_local $22 - (tee_local $21 - (tee_local $20 - (tee_local $19 - (tee_local $11 - (tee_local $1 - (i32.sub - (get_local $1) - (i32.const 16) - ) - ) - ) - ) - ) + (set_local $2 + (i32.sub + (get_local $2) + (i32.const 16) ) ) (br $continue|5) @@ -1189,557 +807,765 @@ ) (if (i32.and - (get_local $11) + (get_local $2) (i32.const 16) ) (block - (i32.store8 - (get_local $17) - (i32.load8_u - (get_local $18) + (set_local $4 + (i32.add + (tee_local $3 + (get_local $4) + ) + (i32.const 1) ) ) (i32.store8 - (tee_local $1 - (i32.add - (get_local $17) - (i32.const 1) - ) - ) - (i32.load8_u - (tee_local $2 + (get_local $3) + (block (result i32) + (set_local $1 (i32.add - (get_local $18) - (i32.const 1) - ) - ) - ) - ) - (i32.store8 - (tee_local $1 - (i32.add - (get_local $1) - (i32.const 1) - ) - ) - (i32.load8_u - (tee_local $2 - (i32.add - (get_local $2) - (i32.const 1) - ) - ) - ) - ) - (i32.store8 - (tee_local $1 - (i32.add - (get_local $1) - (i32.const 1) - ) - ) - (i32.load8_u - (tee_local $2 - (i32.add - (get_local $2) - (i32.const 1) - ) - ) - ) - ) - (i32.store8 - (tee_local $1 - (i32.add - (get_local $1) - (i32.const 1) - ) - ) - (i32.load8_u - (tee_local $2 - (i32.add - (get_local $2) - (i32.const 1) - ) - ) - ) - ) - (i32.store8 - (tee_local $1 - (i32.add - (get_local $1) - (i32.const 1) - ) - ) - (i32.load8_u - (tee_local $2 - (i32.add - (get_local $2) - (i32.const 1) - ) - ) - ) - ) - (i32.store8 - (tee_local $1 - (i32.add - (get_local $1) - (i32.const 1) - ) - ) - (i32.load8_u - (tee_local $2 - (i32.add - (get_local $2) - (i32.const 1) - ) - ) - ) - ) - (i32.store8 - (tee_local $1 - (i32.add - (get_local $1) - (i32.const 1) - ) - ) - (i32.load8_u - (tee_local $2 - (i32.add - (get_local $2) - (i32.const 1) - ) - ) - ) - ) - (i32.store8 - (tee_local $1 - (i32.add - (get_local $1) - (i32.const 1) - ) - ) - (i32.load8_u - (tee_local $2 - (i32.add - (get_local $2) - (i32.const 1) - ) - ) - ) - ) - (i32.store8 - (tee_local $1 - (i32.add - (get_local $1) - (i32.const 1) - ) - ) - (i32.load8_u - (tee_local $2 - (i32.add - (get_local $2) - (i32.const 1) - ) - ) - ) - ) - (i32.store8 - (tee_local $1 - (i32.add - (get_local $1) - (i32.const 1) - ) - ) - (i32.load8_u - (tee_local $2 - (i32.add - (get_local $2) - (i32.const 1) - ) - ) - ) - ) - (i32.store8 - (tee_local $1 - (i32.add - (get_local $1) - (i32.const 1) - ) - ) - (i32.load8_u - (tee_local $2 - (i32.add - (get_local $2) - (i32.const 1) - ) - ) - ) - ) - (i32.store8 - (tee_local $1 - (i32.add - (get_local $1) - (i32.const 1) - ) - ) - (i32.load8_u - (tee_local $2 - (i32.add - (get_local $2) - (i32.const 1) - ) - ) - ) - ) - (i32.store8 - (tee_local $1 - (i32.add - (get_local $1) - (i32.const 1) - ) - ) - (i32.load8_u - (tee_local $2 - (i32.add - (get_local $2) - (i32.const 1) - ) - ) - ) - ) - (i32.store8 - (tee_local $1 - (i32.add - (get_local $1) - (i32.const 1) - ) - ) - (i32.load8_u - (tee_local $2 - (i32.add - (get_local $2) - (i32.const 1) - ) - ) - ) - ) - (set_local $6 - (tee_local $5 - (tee_local $9 - (tee_local $13 - (i32.add - (tee_local $1 - (i32.add - (get_local $1) - (i32.const 1) - ) - ) - (i32.const 1) + (tee_local $3 + (get_local $1) ) + (i32.const 1) ) ) + (i32.load8_u + (get_local $3) + ) ) ) - (set_local $8 - (tee_local $7 - (tee_local $10 - (tee_local $15 - (i32.add - (tee_local $2 - (i32.add - (get_local $2) - (i32.const 1) - ) - ) - (i32.const 1) - ) - ) + (set_local $4 + (i32.add + (tee_local $3 + (get_local $4) ) + (i32.const 1) ) ) (i32.store8 - (get_local $1) - (i32.load8_u - (get_local $2) + (get_local $3) + (block (result i32) + (set_local $1 + (i32.add + (tee_local $3 + (get_local $1) + ) + (i32.const 1) + ) + ) + (i32.load8_u + (get_local $3) + ) + ) + ) + (set_local $4 + (i32.add + (tee_local $3 + (get_local $4) + ) + (i32.const 1) + ) + ) + (i32.store8 + (get_local $3) + (block (result i32) + (set_local $1 + (i32.add + (tee_local $3 + (get_local $1) + ) + (i32.const 1) + ) + ) + (i32.load8_u + (get_local $3) + ) + ) + ) + (set_local $4 + (i32.add + (tee_local $3 + (get_local $4) + ) + (i32.const 1) + ) + ) + (i32.store8 + (get_local $3) + (block (result i32) + (set_local $1 + (i32.add + (tee_local $3 + (get_local $1) + ) + (i32.const 1) + ) + ) + (i32.load8_u + (get_local $3) + ) + ) + ) + (set_local $4 + (i32.add + (tee_local $3 + (get_local $4) + ) + (i32.const 1) + ) + ) + (i32.store8 + (get_local $3) + (block (result i32) + (set_local $1 + (i32.add + (tee_local $3 + (get_local $1) + ) + (i32.const 1) + ) + ) + (i32.load8_u + (get_local $3) + ) + ) + ) + (set_local $4 + (i32.add + (tee_local $3 + (get_local $4) + ) + (i32.const 1) + ) + ) + (i32.store8 + (get_local $3) + (block (result i32) + (set_local $1 + (i32.add + (tee_local $3 + (get_local $1) + ) + (i32.const 1) + ) + ) + (i32.load8_u + (get_local $3) + ) + ) + ) + (set_local $4 + (i32.add + (tee_local $3 + (get_local $4) + ) + (i32.const 1) + ) + ) + (i32.store8 + (get_local $3) + (block (result i32) + (set_local $1 + (i32.add + (tee_local $3 + (get_local $1) + ) + (i32.const 1) + ) + ) + (i32.load8_u + (get_local $3) + ) + ) + ) + (set_local $4 + (i32.add + (tee_local $3 + (get_local $4) + ) + (i32.const 1) + ) + ) + (i32.store8 + (get_local $3) + (block (result i32) + (set_local $1 + (i32.add + (tee_local $3 + (get_local $1) + ) + (i32.const 1) + ) + ) + (i32.load8_u + (get_local $3) + ) + ) + ) + (set_local $4 + (i32.add + (tee_local $3 + (get_local $4) + ) + (i32.const 1) + ) + ) + (i32.store8 + (get_local $3) + (block (result i32) + (set_local $1 + (i32.add + (tee_local $3 + (get_local $1) + ) + (i32.const 1) + ) + ) + (i32.load8_u + (get_local $3) + ) + ) + ) + (set_local $4 + (i32.add + (tee_local $3 + (get_local $4) + ) + (i32.const 1) + ) + ) + (i32.store8 + (get_local $3) + (block (result i32) + (set_local $1 + (i32.add + (tee_local $3 + (get_local $1) + ) + (i32.const 1) + ) + ) + (i32.load8_u + (get_local $3) + ) + ) + ) + (set_local $4 + (i32.add + (tee_local $3 + (get_local $4) + ) + (i32.const 1) + ) + ) + (i32.store8 + (get_local $3) + (block (result i32) + (set_local $1 + (i32.add + (tee_local $3 + (get_local $1) + ) + (i32.const 1) + ) + ) + (i32.load8_u + (get_local $3) + ) + ) + ) + (set_local $4 + (i32.add + (tee_local $3 + (get_local $4) + ) + (i32.const 1) + ) + ) + (i32.store8 + (get_local $3) + (block (result i32) + (set_local $1 + (i32.add + (tee_local $3 + (get_local $1) + ) + (i32.const 1) + ) + ) + (i32.load8_u + (get_local $3) + ) + ) + ) + (set_local $4 + (i32.add + (tee_local $3 + (get_local $4) + ) + (i32.const 1) + ) + ) + (i32.store8 + (get_local $3) + (block (result i32) + (set_local $1 + (i32.add + (tee_local $3 + (get_local $1) + ) + (i32.const 1) + ) + ) + (i32.load8_u + (get_local $3) + ) + ) + ) + (set_local $4 + (i32.add + (tee_local $3 + (get_local $4) + ) + (i32.const 1) + ) + ) + (i32.store8 + (get_local $3) + (block (result i32) + (set_local $1 + (i32.add + (tee_local $3 + (get_local $1) + ) + (i32.const 1) + ) + ) + (i32.load8_u + (get_local $3) + ) + ) + ) + (set_local $4 + (i32.add + (tee_local $3 + (get_local $4) + ) + (i32.const 1) + ) + ) + (i32.store8 + (get_local $3) + (block (result i32) + (set_local $1 + (i32.add + (tee_local $3 + (get_local $1) + ) + (i32.const 1) + ) + ) + (i32.load8_u + (get_local $3) + ) + ) + ) + (set_local $4 + (i32.add + (tee_local $3 + (get_local $4) + ) + (i32.const 1) + ) + ) + (i32.store8 + (get_local $3) + (block (result i32) + (set_local $1 + (i32.add + (tee_local $3 + (get_local $1) + ) + (i32.const 1) + ) + ) + (i32.load8_u + (get_local $3) + ) ) ) ) ) (if (i32.and - (get_local $19) + (get_local $2) (i32.const 8) ) (block - (i32.store8 - (get_local $13) - (i32.load8_u - (get_local $15) + (set_local $4 + (i32.add + (tee_local $3 + (get_local $4) + ) + (i32.const 1) ) ) (i32.store8 - (tee_local $1 - (i32.add - (get_local $13) - (i32.const 1) - ) - ) - (i32.load8_u - (tee_local $2 + (get_local $3) + (block (result i32) + (set_local $1 (i32.add - (get_local $15) - (i32.const 1) - ) - ) - ) - ) - (i32.store8 - (tee_local $1 - (i32.add - (get_local $1) - (i32.const 1) - ) - ) - (i32.load8_u - (tee_local $2 - (i32.add - (get_local $2) - (i32.const 1) - ) - ) - ) - ) - (i32.store8 - (tee_local $1 - (i32.add - (get_local $1) - (i32.const 1) - ) - ) - (i32.load8_u - (tee_local $2 - (i32.add - (get_local $2) - (i32.const 1) - ) - ) - ) - ) - (i32.store8 - (tee_local $1 - (i32.add - (get_local $1) - (i32.const 1) - ) - ) - (i32.load8_u - (tee_local $2 - (i32.add - (get_local $2) - (i32.const 1) - ) - ) - ) - ) - (i32.store8 - (tee_local $1 - (i32.add - (get_local $1) - (i32.const 1) - ) - ) - (i32.load8_u - (tee_local $2 - (i32.add - (get_local $2) - (i32.const 1) - ) - ) - ) - ) - (i32.store8 - (tee_local $1 - (i32.add - (get_local $1) - (i32.const 1) - ) - ) - (i32.load8_u - (tee_local $2 - (i32.add - (get_local $2) - (i32.const 1) - ) - ) - ) - ) - (set_local $6 - (tee_local $5 - (tee_local $9 - (i32.add - (tee_local $1 - (i32.add - (get_local $1) - (i32.const 1) - ) + (tee_local $3 + (get_local $1) ) (i32.const 1) ) ) + (i32.load8_u + (get_local $3) + ) ) ) - (set_local $8 - (tee_local $7 - (tee_local $10 + (set_local $4 + (i32.add + (tee_local $3 + (get_local $4) + ) + (i32.const 1) + ) + ) + (i32.store8 + (get_local $3) + (block (result i32) + (set_local $1 (i32.add - (tee_local $2 - (i32.add - (get_local $2) - (i32.const 1) - ) + (tee_local $3 + (get_local $1) ) (i32.const 1) ) ) + (i32.load8_u + (get_local $3) + ) + ) + ) + (set_local $4 + (i32.add + (tee_local $3 + (get_local $4) + ) + (i32.const 1) ) ) (i32.store8 - (get_local $1) - (i32.load8_u - (get_local $2) + (get_local $3) + (block (result i32) + (set_local $1 + (i32.add + (tee_local $3 + (get_local $1) + ) + (i32.const 1) + ) + ) + (i32.load8_u + (get_local $3) + ) + ) + ) + (set_local $4 + (i32.add + (tee_local $3 + (get_local $4) + ) + (i32.const 1) + ) + ) + (i32.store8 + (get_local $3) + (block (result i32) + (set_local $1 + (i32.add + (tee_local $3 + (get_local $1) + ) + (i32.const 1) + ) + ) + (i32.load8_u + (get_local $3) + ) + ) + ) + (set_local $4 + (i32.add + (tee_local $3 + (get_local $4) + ) + (i32.const 1) + ) + ) + (i32.store8 + (get_local $3) + (block (result i32) + (set_local $1 + (i32.add + (tee_local $3 + (get_local $1) + ) + (i32.const 1) + ) + ) + (i32.load8_u + (get_local $3) + ) + ) + ) + (set_local $4 + (i32.add + (tee_local $3 + (get_local $4) + ) + (i32.const 1) + ) + ) + (i32.store8 + (get_local $3) + (block (result i32) + (set_local $1 + (i32.add + (tee_local $3 + (get_local $1) + ) + (i32.const 1) + ) + ) + (i32.load8_u + (get_local $3) + ) + ) + ) + (set_local $4 + (i32.add + (tee_local $3 + (get_local $4) + ) + (i32.const 1) + ) + ) + (i32.store8 + (get_local $3) + (block (result i32) + (set_local $1 + (i32.add + (tee_local $3 + (get_local $1) + ) + (i32.const 1) + ) + ) + (i32.load8_u + (get_local $3) + ) + ) + ) + (set_local $4 + (i32.add + (tee_local $3 + (get_local $4) + ) + (i32.const 1) + ) + ) + (i32.store8 + (get_local $3) + (block (result i32) + (set_local $1 + (i32.add + (tee_local $3 + (get_local $1) + ) + (i32.const 1) + ) + ) + (i32.load8_u + (get_local $3) + ) ) ) ) ) (if (i32.and - (get_local $20) + (get_local $2) (i32.const 4) ) (block - (i32.store8 - (get_local $9) - (i32.load8_u - (get_local $10) + (set_local $4 + (i32.add + (tee_local $3 + (get_local $4) + ) + (i32.const 1) ) ) (i32.store8 - (tee_local $1 - (i32.add - (get_local $9) - (i32.const 1) - ) - ) - (i32.load8_u - (tee_local $2 + (get_local $3) + (block (result i32) + (set_local $1 (i32.add - (get_local $10) - (i32.const 1) - ) - ) - ) - ) - (i32.store8 - (tee_local $1 - (i32.add - (get_local $1) - (i32.const 1) - ) - ) - (i32.load8_u - (tee_local $2 - (i32.add - (get_local $2) - (i32.const 1) - ) - ) - ) - ) - (set_local $6 - (tee_local $5 - (i32.add - (tee_local $1 - (i32.add + (tee_local $3 (get_local $1) - (i32.const 1) ) + (i32.const 1) ) - (i32.const 1) + ) + (i32.load8_u + (get_local $3) ) ) ) - (set_local $8 - (tee_local $7 - (i32.add - (tee_local $2 - (i32.add - (get_local $2) - (i32.const 1) - ) - ) - (i32.const 1) + (set_local $4 + (i32.add + (tee_local $3 + (get_local $4) ) + (i32.const 1) ) ) (i32.store8 - (get_local $1) - (i32.load8_u - (get_local $2) + (get_local $3) + (block (result i32) + (set_local $1 + (i32.add + (tee_local $3 + (get_local $1) + ) + (i32.const 1) + ) + ) + (i32.load8_u + (get_local $3) + ) + ) + ) + (set_local $4 + (i32.add + (tee_local $3 + (get_local $4) + ) + (i32.const 1) + ) + ) + (i32.store8 + (get_local $3) + (block (result i32) + (set_local $1 + (i32.add + (tee_local $3 + (get_local $1) + ) + (i32.const 1) + ) + ) + (i32.load8_u + (get_local $3) + ) + ) + ) + (set_local $4 + (i32.add + (tee_local $3 + (get_local $4) + ) + (i32.const 1) + ) + ) + (i32.store8 + (get_local $3) + (block (result i32) + (set_local $1 + (i32.add + (tee_local $3 + (get_local $1) + ) + (i32.const 1) + ) + ) + (i32.load8_u + (get_local $3) + ) ) ) ) ) (if (i32.and - (get_local $21) + (get_local $2) (i32.const 2) ) (block - (i32.store8 - (get_local $5) - (i32.load8_u - (get_local $7) - ) - ) - (set_local $6 + (set_local $4 (i32.add - (tee_local $1 - (i32.add - (get_local $5) - (i32.const 1) - ) - ) - (i32.const 1) - ) - ) - (set_local $8 - (i32.add - (tee_local $2 - (i32.add - (get_local $7) - (i32.const 1) - ) + (tee_local $3 + (get_local $4) ) (i32.const 1) ) ) (i32.store8 - (get_local $1) - (i32.load8_u - (get_local $2) + (get_local $3) + (block (result i32) + (set_local $1 + (i32.add + (tee_local $3 + (get_local $1) + ) + (i32.const 1) + ) + ) + (i32.load8_u + (get_local $3) + ) + ) + ) + (set_local $4 + (i32.add + (tee_local $3 + (get_local $4) + ) + (i32.const 1) + ) + ) + (i32.store8 + (get_local $3) + (block (result i32) + (set_local $1 + (i32.add + (tee_local $3 + (get_local $1) + ) + (i32.const 1) + ) + ) + (i32.load8_u + (get_local $3) + ) ) ) ) ) (if (i32.and - (get_local $22) + (get_local $2) (i32.const 1) ) (i32.store8 - (get_local $6) + (get_local $4) (i32.load8_u - (get_local $8) + (get_local $1) ) ) ) diff --git a/tests/compiler/switch.optimized.wast b/tests/compiler/switch.optimized.wast index bff092c8..094ada85 100644 --- a/tests/compiler/switch.optimized.wast +++ b/tests/compiler/switch.optimized.wast @@ -6,36 +6,15 @@ (export "doSwitchDefaultOmitted" (func $switch/doSwitchDefaultOmitted)) (export "memory" (memory $0)) (func $switch/doSwitch (; 0 ;) (type $ii) (param $0 i32) (result i32) - (local $1 i32) (block $case4|0 (block $case2|0 - (if - (i32.ne - (tee_local $1 + (block $case0|0 + (block $tablify|0 + (br_table $case2|0 $case0|0 $case4|0 $case4|0 $tablify|0 (get_local $0) ) - (i32.const 1) - ) - (block - (br_if $case2|0 - (i32.eqz - (get_local $1) - ) - ) - (br_if $case4|0 - (i32.eq - (get_local $1) - (i32.const 2) - ) - ) - (br_if $case4|0 - (i32.eq - (get_local $1) - (i32.const 3) - ) - ) - (br $case2|0) ) + (br $case2|0) ) (return (i32.const 1) @@ -48,31 +27,18 @@ (i32.const 23) ) (func $switch/doSwitchDefaultFirst (; 1 ;) (type $ii) (param $0 i32) (result i32) - (local $1 i32) (block $case3|0 - (if - (i32.ne - (tee_local $1 - (get_local $0) + (block $case1|0 + (block $tablify|0 + (br_table $case1|0 $case3|0 $case3|0 $tablify|0 + (i32.sub + (get_local $0) + (i32.const 1) + ) ) - (i32.const 1) ) - (block - (br_if $case3|0 - (i32.eq - (get_local $1) - (i32.const 2) - ) - ) - (br_if $case3|0 - (i32.eq - (get_local $1) - (i32.const 3) - ) - ) - (return - (i32.const 0) - ) + (return + (i32.const 0) ) ) (return @@ -82,31 +48,18 @@ (i32.const 23) ) (func $switch/doSwitchDefaultOmitted (; 2 ;) (type $ii) (param $0 i32) (result i32) - (local $1 i32) (block $break|0 (block $case2|0 - (if - (i32.ne - (tee_local $1 - (get_local $0) - ) - (i32.const 1) - ) - (block - (br_if $case2|0 - (i32.eq - (get_local $1) - (i32.const 2) + (block $case0|0 + (block $tablify|0 + (br_table $case0|0 $case2|0 $case2|0 $tablify|0 + (i32.sub + (get_local $0) + (i32.const 1) ) ) - (br_if $case2|0 - (i32.eq - (get_local $1) - (i32.const 3) - ) - ) - (br $break|0) ) + (br $break|0) ) (return (i32.const 1) diff --git a/tests/compiler/ternary.optimized.wast b/tests/compiler/ternary.optimized.wast index a558589b..d0d8d5ae 100644 --- a/tests/compiler/ternary.optimized.wast +++ b/tests/compiler/ternary.optimized.wast @@ -5,28 +5,14 @@ (export "memory" (memory $0)) (start $start) (func $start (; 0 ;) (type $v) - (local $0 i32) (set_global $ternary/a - (tee_local $0 - (i32.const 1) - ) + (i32.const 1) ) (set_global $ternary/a - (tee_local $0 - (i32.const 1) - ) - ) - (if - (tee_local $0 - (i32.const 1) - ) - (set_local $0 - (i32.const 1) - ) - (unreachable) + (i32.const 1) ) (set_global $ternary/a - (get_local $0) + (i32.const 1) ) ) ) diff --git a/tests/compiler/unary.optimized.wast b/tests/compiler/unary.optimized.wast index 382e59d5..7c28bb5b 100644 --- a/tests/compiler/unary.optimized.wast +++ b/tests/compiler/unary.optimized.wast @@ -66,38 +66,52 @@ ) ) (set_global $unary/i - (i32.add - (get_global $unary/i) - (i32.const 1) - ) - ) - (set_global $unary/i - (i32.sub - (get_global $unary/i) - (i32.const 1) - ) - ) - (set_global $unary/i - (i32.add - (tee_local $0 - (get_global $unary/i) + (block (result i32) + (set_global $unary/i + (i32.add + (get_global $unary/i) + (i32.const 1) + ) ) - (i32.const 1) + (get_global $unary/i) ) ) (set_global $unary/i - (get_local $0) - ) - (set_global $unary/i - (i32.sub - (tee_local $0 - (get_global $unary/i) + (block (result i32) + (set_global $unary/i + (i32.sub + (get_global $unary/i) + (i32.const 1) + ) ) - (i32.const 1) + (get_global $unary/i) ) ) (set_global $unary/i - (get_local $0) + (block (result i32) + (set_global $unary/i + (i32.add + (tee_local $0 + (get_global $unary/i) + ) + (i32.const 1) + ) + ) + (get_local $0) + ) + ) + (set_global $unary/i + (block (result i32) + (set_global $unary/i + (i32.sub + (tee_local $0 + (get_global $unary/i) + ) + (i32.const 1) + ) + ) + (get_local $0) + ) ) (set_global $unary/I (i64.add @@ -155,38 +169,52 @@ ) ) (set_global $unary/I - (i64.add - (get_global $unary/I) - (i64.const 1) - ) - ) - (set_global $unary/I - (i64.sub - (get_global $unary/I) - (i64.const 1) - ) - ) - (set_global $unary/I - (i64.add - (tee_local $1 - (get_global $unary/I) + (block (result i64) + (set_global $unary/I + (i64.add + (get_global $unary/I) + (i64.const 1) + ) ) - (i64.const 1) + (get_global $unary/I) ) ) (set_global $unary/I - (get_local $1) - ) - (set_global $unary/I - (i64.sub - (tee_local $1 - (get_global $unary/I) + (block (result i64) + (set_global $unary/I + (i64.sub + (get_global $unary/I) + (i64.const 1) + ) ) - (i64.const 1) + (get_global $unary/I) ) ) (set_global $unary/I - (get_local $1) + (block (result i64) + (set_global $unary/I + (i64.add + (tee_local $1 + (get_global $unary/I) + ) + (i64.const 1) + ) + ) + (get_local $1) + ) + ) + (set_global $unary/I + (block (result i64) + (set_global $unary/I + (i64.sub + (tee_local $1 + (get_global $unary/I) + ) + (i64.const 1) + ) + ) + (get_local $1) + ) ) (set_global $unary/f (f32.add @@ -233,38 +261,52 @@ ) ) (set_global $unary/f - (f32.add - (get_global $unary/f) - (f32.const 1) - ) - ) - (set_global $unary/f - (f32.sub - (get_global $unary/f) - (f32.const 1) - ) - ) - (set_global $unary/f - (f32.add - (tee_local $2 - (get_global $unary/f) + (block (result f32) + (set_global $unary/f + (f32.add + (get_global $unary/f) + (f32.const 1) + ) ) - (f32.const 1) + (get_global $unary/f) ) ) (set_global $unary/f - (get_local $2) - ) - (set_global $unary/f - (f32.sub - (tee_local $2 - (get_global $unary/f) + (block (result f32) + (set_global $unary/f + (f32.sub + (get_global $unary/f) + (f32.const 1) + ) ) - (f32.const 1) + (get_global $unary/f) ) ) (set_global $unary/f - (get_local $2) + (block (result f32) + (set_global $unary/f + (f32.add + (tee_local $2 + (get_global $unary/f) + ) + (f32.const 1) + ) + ) + (get_local $2) + ) + ) + (set_global $unary/f + (block (result f32) + (set_global $unary/f + (f32.sub + (tee_local $2 + (get_global $unary/f) + ) + (f32.const 1) + ) + ) + (get_local $2) + ) ) (set_global $unary/F (f64.add @@ -313,38 +355,52 @@ ) ) (set_global $unary/F - (f64.add - (get_global $unary/F) - (f64.const 1) - ) - ) - (set_global $unary/F - (f64.sub - (get_global $unary/F) - (f64.const 1) - ) - ) - (set_global $unary/F - (f64.add - (tee_local $3 - (get_global $unary/F) + (block (result f64) + (set_global $unary/F + (f64.add + (get_global $unary/F) + (f64.const 1) + ) ) - (f64.const 1) + (get_global $unary/F) ) ) (set_global $unary/F - (get_local $3) - ) - (set_global $unary/F - (f64.sub - (tee_local $3 - (get_global $unary/F) + (block (result f64) + (set_global $unary/F + (f64.sub + (get_global $unary/F) + (f64.const 1) + ) ) - (f64.const 1) + (get_global $unary/F) ) ) (set_global $unary/F - (get_local $3) + (block (result f64) + (set_global $unary/F + (f64.add + (tee_local $3 + (get_global $unary/F) + ) + (f64.const 1) + ) + ) + (get_local $3) + ) + ) + (set_global $unary/F + (block (result f64) + (set_global $unary/F + (f64.sub + (tee_local $3 + (get_global $unary/F) + ) + (f64.const 1) + ) + ) + (get_local $3) + ) ) ) ) diff --git a/tests/compiler/while.optimized.wast b/tests/compiler/while.optimized.wast index fb50bea0..d7dfbaf4 100644 --- a/tests/compiler/while.optimized.wast +++ b/tests/compiler/while.optimized.wast @@ -5,20 +5,14 @@ (export "loopWhileInWhile" (func $while/loopWhileInWhile)) (export "memory" (memory $0)) (func $while/loopWhile (; 0 ;) (type $iv) (param $0 i32) - (local $1 i32) - (set_local $1 - (get_local $0) - ) (loop $continue|0 (if - (get_local $1) + (get_local $0) (block (set_local $0 - (tee_local $1 - (i32.sub - (get_local $0) - (i32.const 1) - ) + (i32.sub + (get_local $0) + (i32.const 1) ) ) (br $continue|0) @@ -27,32 +21,24 @@ ) ) (func $while/loopWhileInWhile (; 1 ;) (type $iv) (param $0 i32) - (local $1 i32) - (set_local $1 - (get_local $0) - ) (loop $continue|0 (if - (get_local $1) + (get_local $0) (block (set_local $0 - (tee_local $1 - (i32.sub - (get_local $0) - (i32.const 1) - ) + (i32.sub + (get_local $0) + (i32.const 1) ) ) (loop $continue|1 (if - (get_local $1) + (get_local $0) (block (set_local $0 - (tee_local $1 - (i32.sub - (get_local $1) - (i32.const 1) - ) + (i32.sub + (get_local $0) + (i32.const 1) ) ) (br $continue|1)