diff options
-rwxr-xr-x | build-js.sh | 1 | ||||
-rw-r--r-- | src/passes/AvoidReinterprets.cpp | 181 | ||||
-rw-r--r-- | src/passes/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/passes/pass.cpp | 7 | ||||
-rw-r--r-- | src/passes/passes.h | 1 | ||||
-rw-r--r-- | src/wasm-type.h | 1 | ||||
-rw-r--r-- | src/wasm/wasm-type.cpp | 19 | ||||
-rw-r--r-- | src/wasm2js.h | 11 | ||||
-rw-r--r-- | test/passes/avoid-reinterprets.txt | 151 | ||||
-rw-r--r-- | test/passes/avoid-reinterprets.wast | 38 | ||||
-rw-r--r-- | test/wasm2js/br_table_temp.2asm.js.opt | 111 | ||||
-rw-r--r-- | test/wasm2js/float-ops.2asm.js.opt | 4 | ||||
-rw-r--r-- | test/wasm2js/get-set-local.2asm.js.opt | 6 | ||||
-rw-r--r-- | test/wasm2js/i64-add-sub.2asm.js.opt | 60 | ||||
-rw-r--r-- | test/wasm2js/i64-lowering.2asm.js.opt | 160 | ||||
-rw-r--r-- | test/wasm2js/i64-rotate.2asm.js.opt | 4 | ||||
-rw-r--r-- | test/wasm2js/i64-shifts.2asm.js.opt | 90 | ||||
-rw-r--r-- | test/wasm2js/reinterpret.2asm.js.opt | 16 | ||||
-rw-r--r-- | test/wasm2js/stack-modified.2asm.js.opt | 56 | ||||
-rw-r--r-- | test/wasm2js/unaligned.2asm.js.opt | 57 | ||||
-rw-r--r-- | test/wasm2js/unary-ops.2asm.js.opt | 40 |
21 files changed, 689 insertions, 326 deletions
diff --git a/build-js.sh b/build-js.sh index 72bfbb0ed..42f81bb64 100755 --- a/build-js.sh +++ b/build-js.sh @@ -92,6 +92,7 @@ echo "building shared bitcode" $BINARYEN_SRC/ir/ReFinalize.cpp \ $BINARYEN_SRC/passes/pass.cpp \ $BINARYEN_SRC/passes/AlignmentLowering.cpp \ + $BINARYEN_SRC/passes/AvoidReinterprets.cpp \ $BINARYEN_SRC/passes/CoalesceLocals.cpp \ $BINARYEN_SRC/passes/DeadArgumentElimination.cpp \ $BINARYEN_SRC/passes/CodeFolding.cpp \ diff --git a/src/passes/AvoidReinterprets.cpp b/src/passes/AvoidReinterprets.cpp new file mode 100644 index 000000000..d79645dc6 --- /dev/null +++ b/src/passes/AvoidReinterprets.cpp @@ -0,0 +1,181 @@ +/* + * Copyright 2017 WebAssembly Community Group participants + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Avoids reinterprets by using more loads: if we load a value and +// reinterpret it, we could have loaded it with the other type +// anyhow. This uses more locals and loads, so it is not generally +// beneficial, unless reinterprets are very costly. + +#include <ir/local-graph.h> +#include <ir/properties.h> +#include <pass.h> +#include <wasm-builder.h> +#include <wasm.h> + +namespace wasm { + +static Load* getSingleLoad(LocalGraph* localGraph, GetLocal* get) { + while (1) { + auto& sets = localGraph->getSetses[get]; + if (sets.size() != 1) { + return nullptr; + } + auto* set = *sets.begin(); + if (!set) { + return nullptr; + } + auto* value = Properties::getFallthrough(set->value); + if (auto* parentGet = value->dynCast<GetLocal>()) { + get = parentGet; + continue; + } + if (auto* load = value->dynCast<Load>()) { + return load; + } + return nullptr; + } +} + +static bool isReinterpret(Unary* curr) { + return curr->op == ReinterpretInt32 || curr->op == ReinterpretInt64 || + curr->op == ReinterpretFloat32 || curr->op == ReinterpretFloat64; +} + +struct AvoidReinterprets : public WalkerPass<PostWalker<AvoidReinterprets>> { + bool isFunctionParallel() override { return true; } + + Pass* create() override { return new AvoidReinterprets; } + + struct Info { + // Info used when analyzing. + bool reinterpreted; + // Info used when optimizing. + Index ptrLocal; + Index reinterpretedLocal; + }; + std::map<Load*, Info> infos; + + LocalGraph* localGraph; + + void doWalkFunction(Function* func) { + // prepare + LocalGraph localGraph_(func); + localGraph = &localGraph_; + // walk + PostWalker<AvoidReinterprets>::doWalkFunction(func); + // optimize + optimize(func); + } + + void visitUnary(Unary* curr) { + if (isReinterpret(curr)) { + if (auto* get = + Properties::getFallthrough(curr->value)->dynCast<GetLocal>()) { + if (auto* load = getSingleLoad(localGraph, get)) { + auto& info = infos[load]; + info.reinterpreted = true; + } + } + } + } + + void optimize(Function* func) { + std::set<Load*> unoptimizables; + for (auto& pair : infos) { + auto* load = pair.first; + auto& info = pair.second; + if (info.reinterpreted && load->type != unreachable) { + // We should use another load here, to avoid reinterprets. + info.ptrLocal = Builder::addVar(func, i32); + info.reinterpretedLocal = + Builder::addVar(func, reinterpretType(load->type)); + } else { + unoptimizables.insert(load); + } + } + for (auto* load : unoptimizables) { + infos.erase(load); + } + // We now know which we can optimize, and how. + struct FinalOptimizer : public PostWalker<FinalOptimizer> { + std::map<Load*, Info>& infos; + LocalGraph* localGraph; + Module* module; + + FinalOptimizer(std::map<Load*, Info>& infos, + LocalGraph* localGraph, + Module* module) + : infos(infos), localGraph(localGraph), module(module) {} + + void visitUnary(Unary* curr) { + if (isReinterpret(curr)) { + auto* value = Properties::getFallthrough(curr->value); + if (auto* load = value->dynCast<Load>()) { + // A reinterpret of a load - flip it right here. + replaceCurrent(makeReinterpretedLoad(load, load->ptr)); + } else if (auto* get = value->dynCast<GetLocal>()) { + if (auto* load = getSingleLoad(localGraph, get)) { + auto iter = infos.find(load); + if (iter != infos.end()) { + auto& info = iter->second; + // A reinterpret of a get of a load - use the new local. + Builder builder(*module); + replaceCurrent(builder.makeGetLocal( + info.reinterpretedLocal, reinterpretType(load->type))); + } + } + } + } + } + + void visitLoad(Load* curr) { + auto iter = infos.find(curr); + if (iter != infos.end()) { + auto& info = iter->second; + Builder builder(*module); + auto* ptr = curr->ptr; + curr->ptr = builder.makeGetLocal(info.ptrLocal, i32); + // Note that the other load can have its sign set to false - if the + // original were an integer, the other is a float anyhow; and if + // original were a float, we don't know what sign to use. + replaceCurrent(builder.makeBlock( + {builder.makeSetLocal(info.ptrLocal, ptr), + builder.makeSetLocal( + info.reinterpretedLocal, + makeReinterpretedLoad(curr, + builder.makeGetLocal(info.ptrLocal, i32))), + curr})); + } + } + + Load* makeReinterpretedLoad(Load* load, Expression* ptr) { + Builder builder(*module); + return builder.makeLoad(load->bytes, + false, + load->offset, + load->align, + ptr, + reinterpretType(load->type)); + } + } finalOptimizer(infos, localGraph, getModule()); + + finalOptimizer.walk(func->body); + } +}; + +Pass* createAvoidReinterpretsPass() { return new AvoidReinterprets(); } + +} // namespace wasm diff --git a/src/passes/CMakeLists.txt b/src/passes/CMakeLists.txt index 9d98930ed..6605d7a09 100644 --- a/src/passes/CMakeLists.txt +++ b/src/passes/CMakeLists.txt @@ -6,6 +6,7 @@ add_custom_command( SET(passes_SOURCES pass.cpp AlignmentLowering.cpp + AvoidReinterprets.cpp CoalesceLocals.cpp CodePushing.cpp CodeFolding.cpp diff --git a/src/passes/pass.cpp b/src/passes/pass.cpp index 287dd1cf9..bb1a062e7 100644 --- a/src/passes/pass.cpp +++ b/src/passes/pass.cpp @@ -71,11 +71,14 @@ std::string PassRegistry::getPassDescription(std::string name) { // PassRunner void PassRegistry::registerPasses() { - registerPass( - "dae", "removes arguments to calls in an lto-like manner", createDAEPass); registerPass("alignment-lowering", "lower unaligned loads and stores to smaller aligned ones", createAlignmentLoweringPass); + registerPass("avoid-reinterprets", + "Tries to avoid reinterpret operations via more loads", + createAvoidReinterpretsPass); + registerPass( + "dae", "removes arguments to calls in an lto-like manner", createDAEPass); registerPass("dae-optimizing", "removes arguments to calls in an lto-like manner, and " "optimizes where we removed", diff --git a/src/passes/passes.h b/src/passes/passes.h index cb2950bd4..f3bec3f04 100644 --- a/src/passes/passes.h +++ b/src/passes/passes.h @@ -23,6 +23,7 @@ class Pass; // All passes: Pass* createAlignmentLoweringPass(); +Pass* createAvoidReinterpretsPass(); Pass* createCoalesceLocalsPass(); Pass* createCoalesceLocalsWithLearningPass(); Pass* createCodeFoldingPass(); diff --git a/src/wasm-type.h b/src/wasm-type.h index 6c8ea82a6..e685bc4b5 100644 --- a/src/wasm-type.h +++ b/src/wasm-type.h @@ -45,6 +45,7 @@ bool isFloatType(Type type); bool isIntegerType(Type type); bool isVectorType(Type type); bool isReferenceType(Type type); +Type reinterpretType(Type type); } // namespace wasm diff --git a/src/wasm/wasm-type.cpp b/src/wasm/wasm-type.cpp index 091d851f6..ebaba3f24 100644 --- a/src/wasm/wasm-type.cpp +++ b/src/wasm/wasm-type.cpp @@ -118,4 +118,23 @@ bool isReferenceType(Type type) { return type == except_ref; } +Type reinterpretType(Type type) { + switch (type) { + case Type::i32: + return f32; + case Type::i64: + return f64; + case Type::f32: + return i32; + case Type::f64: + return i64; + case Type::v128: + case Type::except_ref: + case Type::none: + case Type::unreachable: + WASM_UNREACHABLE(); + } + WASM_UNREACHABLE(); +} + } // namespace wasm diff --git a/src/wasm2js.h b/src/wasm2js.h index 24d168355..78bfd30ff 100644 --- a/src/wasm2js.h +++ b/src/wasm2js.h @@ -296,7 +296,18 @@ Ref Wasm2JSBuilder::processWasm(Module* wasm, Name funcName) { // Next, optimize that as best we can. This should not generate // non-JS-friendly things. if (options.optimizeLevel > 0) { + // It is especially import to propagate constants after the lowering. + // However, this can be a slow operation, especially after flattening; + // some local simplification helps. + if (options.optimizeLevel >= 3 || options.shrinkLevel >= 1) { + runner.add("simplify-locals-nonesting"); + runner.add("precompute-propagate"); + // Avoiding reinterpretation is helped by propagation. We also run + // it later down as default optimizations help as well. + runner.add("avoid-reinterprets"); + } runner.addDefaultOptimizationPasses(); + runner.add("avoid-reinterprets"); } // Finally, get the code into the flat form we need for wasm2js itself, and // optimize that a little in a way that keeps flat property. diff --git a/test/passes/avoid-reinterprets.txt b/test/passes/avoid-reinterprets.txt new file mode 100644 index 000000000..f78c6443b --- /dev/null +++ b/test/passes/avoid-reinterprets.txt @@ -0,0 +1,151 @@ +(module + (type $0 (func)) + (memory $0 1) + (func $simple (; 0 ;) (type $0) + (drop + (f32.load + (i32.const 1024) + ) + ) + (drop + (i32.load + (i32.const 1024) + ) + ) + (drop + (f64.load + (i32.const 1024) + ) + ) + (drop + (i64.load + (i32.const 1024) + ) + ) + ) + (func $one (; 1 ;) (type $0) + (local $x i32) + (local $1 i32) + (local $2 f32) + (local.set $x + (block (result i32) + (local.set $1 + (i32.const 1024) + ) + (local.set $2 + (f32.load + (local.get $1) + ) + ) + (i32.load + (local.get $1) + ) + ) + ) + (drop + (local.get $2) + ) + ) + (func $one-b (; 2 ;) (type $0) + (local $x f32) + (local $1 i32) + (local $2 i32) + (local.set $x + (block (result f32) + (local.set $1 + (i32.const 1024) + ) + (local.set $2 + (i32.load + (local.get $1) + ) + ) + (f32.load + (local.get $1) + ) + ) + ) + (drop + (local.get $2) + ) + ) + (func $both (; 3 ;) (type $0) + (local $x i32) + (local $1 i32) + (local $2 f32) + (local.set $x + (block (result i32) + (local.set $1 + (i32.const 1024) + ) + (local.set $2 + (f32.load + (local.get $1) + ) + ) + (i32.load + (local.get $1) + ) + ) + ) + (drop + (local.get $2) + ) + (drop + (local.get $2) + ) + ) + (func $half (; 4 ;) (type $0) + (local $x i32) + (local $1 i32) + (local $2 f32) + (local.set $x + (block (result i32) + (local.set $1 + (i32.const 1024) + ) + (local.set $2 + (f32.load + (local.get $1) + ) + ) + (i32.load + (local.get $1) + ) + ) + ) + (drop + (local.get $x) + ) + (drop + (local.get $2) + ) + ) + (func $copy (; 5 ;) (type $0) + (local $x i32) + (local $y i32) + (local $2 i32) + (local $3 f32) + (local.set $x + (block (result i32) + (local.set $2 + (i32.const 1024) + ) + (local.set $3 + (f32.load + (local.get $2) + ) + ) + (i32.load + (local.get $2) + ) + ) + ) + (local.set $y + (local.get $x) + ) + (drop + (local.get $3) + ) + ) +) diff --git a/test/passes/avoid-reinterprets.wast b/test/passes/avoid-reinterprets.wast new file mode 100644 index 000000000..1499f8356 --- /dev/null +++ b/test/passes/avoid-reinterprets.wast @@ -0,0 +1,38 @@ +(module + (memory 1) + (func $simple + (drop (f32.reinterpret_i32 (i32.load (i32.const 1024)))) + (drop (i32.reinterpret_f32 (f32.load (i32.const 1024)))) + (drop (f64.reinterpret_i64 (i64.load (i32.const 1024)))) + (drop (i64.reinterpret_f64 (f64.load (i32.const 1024)))) + ) + (func $one + (local $x i32) + (local.set $x (i32.load (i32.const 1024))) + (drop (f32.reinterpret_i32 (local.get $x))) + ) + (func $one-b + (local $x f32) + (local.set $x (f32.load (i32.const 1024))) + (drop (i32.reinterpret_f32 (local.get $x))) + ) + (func $both + (local $x i32) + (local.set $x (i32.load (i32.const 1024))) + (drop (f32.reinterpret_i32 (local.get $x))) + (drop (f32.reinterpret_i32 (local.get $x))) + ) + (func $half + (local $x i32) + (local.set $x (i32.load (i32.const 1024))) + (drop (local.get $x)) + (drop (f32.reinterpret_i32 (local.get $x))) + ) + (func $copy + (local $x i32) + (local $y i32) + (local.set $x (i32.load (i32.const 1024))) + (local.set $y (local.get $x)) + (drop (f32.reinterpret_i32 (local.get $y))) + ) +) diff --git a/test/wasm2js/br_table_temp.2asm.js.opt b/test/wasm2js/br_table_temp.2asm.js.opt index 3364ce9ae..b6325ab2e 100644 --- a/test/wasm2js/br_table_temp.2asm.js.opt +++ b/test/wasm2js/br_table_temp.2asm.js.opt @@ -20,7 +20,7 @@ function asmFunc(global, env, buffer) { var abort = env.abort; var nan = global.NaN; var infinity = global.Infinity; - function $1() { + function dummy() { } @@ -101,12 +101,6 @@ function asmFunc(global, env, buffer) { function $14($0) { $0 = $0 | 0; - var $1_1 = 0, $2 = 0, $3 = 0, $4 = 0, $5_1 = 0; - $1_1 = 200; - $2 = $1_1; - $3 = $1_1; - $4 = $1_1; - $5_1 = $1_1; block : { block6 : { block7 : { @@ -125,15 +119,15 @@ function asmFunc(global, env, buffer) { break block; }; } - return $1_1 + 10 | 0; + return 210 | 0; } - return $5_1 + 11 | 0; + return 211 | 0; } - return $4 + 12 | 0; + return 212 | 0; } - return $3 + 13 | 0; + return 213 | 0; } - return $2 + 14 | 0; + return 214 | 0; } function $15($0) { @@ -12491,33 +12485,33 @@ function asmFunc(global, env, buffer) { return 7 | 0; } - function $32($0, $1_1) { + function $32($0, $1) { $0 = $0 | 0; - $1_1 = $1_1 | 0; + $1 = $1 | 0; if ($0) { - $1_1 = 3 + $1 = 3 } - return $1_1 | 0; + return $1 | 0; } - function $33($0, $1_1) { + function $33($0, $1) { $0 = $0 | 0; - $1_1 = $1_1 | 0; + $1 = $1 | 0; if (!$0) { - $1_1 = 4 + $1 = 4 } - return $1_1 | 0; + return $1 | 0; } - function $34($0, $1_1) { + function $34($0, $1) { $0 = $0 | 0; - $1_1 = $1_1 | 0; + $1 = $1 | 0; return 5 | 0; } - function $35($0, $1_1) { + function $35($0, $1) { $0 = $0 | 0; - $1_1 = $1_1 | 0; + $1 = $1 | 0; return 6 | 0; } @@ -12595,10 +12589,9 @@ function asmFunc(global, env, buffer) { function $60($0) { $0 = $0 | 0; - var $1_1 = 0, $2 = 0, $3 = 0; - $1_1 = 16; - $2 = $1_1; - $3 = $1_1; + var $1 = 0, $2 = 0; + $1 = 16; + $2 = 16; block : { block11 : { block12 : { @@ -12611,18 +12604,18 @@ function asmFunc(global, env, buffer) { break block; }; } - $3 = $1_1 + 2 | 0; + $2 = 18; } - $2 = $3 + 1 | 0; + $1 = $2 + 1 | 0; } - return $2 | 0; + return $1 | 0; } function $61($0) { $0 = $0 | 0; - var $1_1 = 0, $2 = 0; - $1_1 = 8; - $2 = $1_1; + var $1 = 0, $2 = 0; + $1 = 8; + $2 = 8; block : { block13 : { block14 : { @@ -12635,18 +12628,18 @@ function asmFunc(global, env, buffer) { break block14; }; } - $1_1 = 16; + $2 = 16; } - $2 = $1_1 + 1 | 0; + $1 = $2 + 1 | 0; } - return $2 | 0; + return $1 | 0; } function $62($0) { $0 = $0 | 0; - var $1_1 = 0, $2 = 0; - $1_1 = 8; - $2 = $1_1; + var $1 = 0, $2 = 0; + $1 = 8; + $2 = 8; block : { block15 : { block16 : { @@ -12659,33 +12652,29 @@ function asmFunc(global, env, buffer) { break block; }; } - $1_1 = 16; + $2 = 16; } - $2 = $1_1 + 1 | 0; + $1 = $2 + 1 | 0; } - return $2 | 0; + return $1 | 0; } function $63($0) { $0 = $0 | 0; - var $1_1 = 0, $2 = 0; - $2 = 8; - $1_1 = $2; - block : { - if (!($0 - 1 | 0)) { - break block - } - $1_1 = $2 + 1 | 0; + if ($0 - 1 | 0) { + $0 = 9 + } else { + $0 = 8 } - return $1_1 | 0; + return $0 | 0; } var FUNCTION_TABLE = []; return { - "type_i32": $1, - "type_i64": $1, - "type_f32": $1, - "type_f64": $1, + "type_i32": dummy, + "type_i64": dummy, + "type_f32": dummy, + "type_f64": dummy, "type_i32_value": $5, "type_i64_value": $6, "type_f32_value": $7, @@ -12697,18 +12686,18 @@ function asmFunc(global, env, buffer) { "multiple": $13, "multiple_value": $14, "large": $15, - "as_block_first": $1, - "as_block_mid": $1, - "as_block_last": $1, + "as_block_first": dummy, + "as_block_mid": dummy, + "as_block_last": dummy, "as_block_value": $6, "as_loop_first": $20, "as_loop_mid": $21, "as_loop_last": $22, "as_br_value": $23, - "as_br_if_cond": $1, + "as_br_if_cond": dummy, "as_br_if_value": $25, "as_br_if_value_cond": $23, - "as_br_table_index": $1, + "as_br_table_index": dummy, "as_br_table_value": $28, "as_br_table_value_index": $29, "as_return_value": $30, diff --git a/test/wasm2js/float-ops.2asm.js.opt b/test/wasm2js/float-ops.2asm.js.opt index cc8f90643..416f144d2 100644 --- a/test/wasm2js/float-ops.2asm.js.opt +++ b/test/wasm2js/float-ops.2asm.js.opt @@ -246,12 +246,12 @@ function asmFunc(global, env, buffer) { function $47($0) { $0 = Math_fround($0); - return !(~~$0 >>> 0 | (Math_fround(Math_abs($0)) >= Math_fround(1.0) ? ($0 > Math_fround(0.0) ? ~~Math_fround(Math_min(Math_fround(Math_floor(Math_fround($0 / Math_fround(4294967296.0)))), Math_fround(4294967296.0))) >>> 0 : ~~Math_fround(Math_ceil(Math_fround(Math_fround($0 - Math_fround(~~$0 >>> 0 >>> 0)) / Math_fround(4294967296.0)))) >>> 0) : 0)) | 0; + return !((Math_fround(Math_abs($0)) >= Math_fround(1.0) ? ($0 > Math_fround(0.0) ? ~~Math_fround(Math_min(Math_fround(Math_floor(Math_fround($0 / Math_fround(4294967296.0)))), Math_fround(4294967296.0))) >>> 0 : ~~Math_fround(Math_ceil(Math_fround(Math_fround($0 - Math_fround(~~$0 >>> 0 >>> 0)) / Math_fround(4294967296.0)))) >>> 0) : 0) | ~~$0 >>> 0) | 0; } function $48($0) { $0 = +$0; - return !(~~$0 >>> 0 | (Math_abs($0) >= 1.0 ? ($0 > 0.0 ? ~~Math_min(Math_floor($0 / 4294967296.0), 4294967295.0) >>> 0 : ~~Math_ceil(($0 - +(~~$0 >>> 0 >>> 0)) / 4294967296.0) >>> 0) : 0)) | 0; + return !((Math_abs($0) >= 1.0 ? ($0 > 0.0 ? ~~Math_min(Math_floor($0 / 4294967296.0), 4294967295.0) >>> 0 : ~~Math_ceil(($0 - +(~~$0 >>> 0 >>> 0)) / 4294967296.0) >>> 0) : 0) | ~~$0 >>> 0) | 0; } function legalstub$43($0, $1_1) { diff --git a/test/wasm2js/get-set-local.2asm.js.opt b/test/wasm2js/get-set-local.2asm.js.opt index 40a422604..134da55b0 100644 --- a/test/wasm2js/get-set-local.2asm.js.opt +++ b/test/wasm2js/get-set-local.2asm.js.opt @@ -21,7 +21,11 @@ function asmFunc(global, env, buffer) { var nan = global.NaN; var infinity = global.Infinity; function legalstub$1($0, $1, $2) { - return !$2 & ($0 | 0) == ($1 | 0); + var $3 = 0; + $3 = $1; + $1 = $2; + $2 = $3 | 0; + return !$1 & ($0 | 0) == ($2 | 0); } var FUNCTION_TABLE = []; diff --git a/test/wasm2js/i64-add-sub.2asm.js.opt b/test/wasm2js/i64-add-sub.2asm.js.opt index a663c5394..3f4ba759a 100644 --- a/test/wasm2js/i64-add-sub.2asm.js.opt +++ b/test/wasm2js/i64-add-sub.2asm.js.opt @@ -36,52 +36,48 @@ function asmFunc(global, env, buffer) { } function legalstub$1($0, $1_1, $2, $3, $4, $5) { - var $6 = 0, $7 = 0, $8 = 0, $9 = 0, $10 = 0, $11 = 0; - $6 = $0; - $8 = 32; - $0 = $8 & 31; - if (32 >>> 0 <= $8 >>> 0) { - $7 = $1_1 << $0; + var $6 = 0, $7 = 0; + $7 = $0; + $6 = 32; + $0 = $6 & 31; + if (32 >>> 0 <= $6 >>> 0) { + $6 = $1_1 << $0; $0 = 0; } else { - $7 = (1 << $0) - 1 & $1_1 >>> 32 - $0 | $7 << $0; + $6 = (1 << $0) - 1 & $1_1 >>> 32 - $0; $0 = $1_1 << $0; } - $8 = $6 | $0; - $7 = $7 | $9; - $6 = $2; - $2 = 0; - $1_1 = $3; - $3 = 32; - $0 = $3 & 31; - if (32 >>> 0 <= $3 >>> 0) { - $2 = $1_1 << $0; + $7 = $7 | $0; + $1_1 = 32; + $0 = $1_1 & 31; + if (32 >>> 0 <= $1_1 >>> 0) { + $1_1 = $3 << $0; $0 = 0; } else { - $2 = (1 << $0) - 1 & $1_1 >>> 32 - $0 | $2 << $0; - $0 = $1_1 << $0; + $1_1 = (1 << $0) - 1 & $3 >>> 32 - $0; + $0 = $3 << $0; } - $6 = $6 | $0; - $9 = $2 | $10; - $2 = 0; - $1_1 = $5; - $0 = 32 & 31; - if (32 >>> 0 <= $3 >>> 0) { - $2 = $1_1 << $0; + $3 = $0 | $2; + $2 = $1_1; + $1_1 = 32; + $0 = $1_1 & 31; + if (32 >>> 0 <= $1_1 >>> 0) { + $1_1 = $5 << $0; $0 = 0; } else { - $2 = (1 << $0) - 1 & $1_1 >>> 32 - $0 | $2 << $0; - $0 = $1_1 << $0; + $1_1 = (1 << $0) - 1 & $5 >>> 32 - $0; + $0 = $5 << $0; } - return $1($8, $7, $6, $9, $0 | $4, $2 | $11); + return $1($7, $6, $3, $2, $0 | $4, $1_1); } function legalstub$2($0, $1_1, $2, $3, $4, $5) { var $6 = 0; - $6 = $2; - $2 = $3; - $3 = $6 | 0; - return ($4 | 0) == ($0 - $3 | 0) & ($5 | 0) == ($1_1 - (($0 >>> 0 < $3 >>> 0) + $2 | 0) | 0); + $6 = $0; + $0 = $1_1; + $1_1 = $3; + $3 = $2; + return ($4 | 0) == ($6 - $3 | 0) & ($5 | 0) == ($0 - (($6 >>> 0 < $3 >>> 0) + $1_1 | 0) | 0); } var FUNCTION_TABLE = []; diff --git a/test/wasm2js/i64-lowering.2asm.js.opt b/test/wasm2js/i64-lowering.2asm.js.opt index 99d9885ae..e948447ce 100644 --- a/test/wasm2js/i64-lowering.2asm.js.opt +++ b/test/wasm2js/i64-lowering.2asm.js.opt @@ -61,151 +61,135 @@ function asmFunc(global, env, buffer) { } function legalstub$3($0, $1, $2, $3_1) { - var $4_1 = 0, $5_1 = 0, $6_1 = 0, $7 = 0, $8 = 0; - $6_1 = $0; - $5_1 = 32; - $0 = $5_1 & 31; - if (32 >>> 0 <= $5_1 >>> 0) { + var $4_1 = 0, $5_1 = 0; + $5_1 = $0; + $4_1 = 32; + $0 = $4_1 & 31; + if (32 >>> 0 <= $4_1 >>> 0) { $4_1 = $1 << $0; $0 = 0; } else { - $4_1 = (1 << $0) - 1 & $1 >>> 32 - $0 | $4_1 << $0; + $4_1 = (1 << $0) - 1 & $1 >>> 32 - $0; $0 = $1 << $0; } - $5_1 = $6_1 | $0; - $4_1 = $4_1 | $7; - $6_1 = $2; - $2 = 0; - $1 = $3_1; - $3_1 = 32; - $0 = $3_1 & 31; - if (32 >>> 0 <= $3_1 >>> 0) { - $2 = $1 << $0; + $5_1 = $5_1 | $0; + $1 = 32; + $0 = $1 & 31; + if (32 >>> 0 <= $1 >>> 0) { + $1 = $3_1 << $0; $0 = 0; } else { - $2 = (1 << $0) - 1 & $1 >>> 32 - $0 | $2 << $0; - $0 = $1 << $0; + $1 = (1 << $0) - 1 & $3_1 >>> 32 - $0; + $0 = $3_1 << $0; } - return $3($5_1, $4_1, $6_1 | $0, $2 | $8); + return $3($5_1, $4_1, $0 | $2, $1); } function legalstub$4($0, $1, $2, $3_1) { - var $4_1 = 0, $5_1 = 0, $6_1 = 0, $7 = 0, $8 = 0; - $6_1 = $0; - $5_1 = 32; - $0 = $5_1 & 31; - if (32 >>> 0 <= $5_1 >>> 0) { + var $4_1 = 0, $5_1 = 0; + $5_1 = $0; + $4_1 = 32; + $0 = $4_1 & 31; + if (32 >>> 0 <= $4_1 >>> 0) { $4_1 = $1 << $0; $0 = 0; } else { - $4_1 = (1 << $0) - 1 & $1 >>> 32 - $0 | $4_1 << $0; + $4_1 = (1 << $0) - 1 & $1 >>> 32 - $0; $0 = $1 << $0; } - $5_1 = $6_1 | $0; - $4_1 = $4_1 | $7; - $6_1 = $2; - $2 = 0; - $1 = $3_1; - $3_1 = 32; - $0 = $3_1 & 31; - if (32 >>> 0 <= $3_1 >>> 0) { - $2 = $1 << $0; + $5_1 = $5_1 | $0; + $1 = 32; + $0 = $1 & 31; + if (32 >>> 0 <= $1 >>> 0) { + $1 = $3_1 << $0; $0 = 0; } else { - $2 = (1 << $0) - 1 & $1 >>> 32 - $0 | $2 << $0; - $0 = $1 << $0; + $1 = (1 << $0) - 1 & $3_1 >>> 32 - $0; + $0 = $3_1 << $0; } - return $4($5_1, $4_1, $6_1 | $0, $2 | $8); + return $4($5_1, $4_1, $0 | $2, $1); } function legalstub$5($0, $1, $2, $3_1) { - var $4_1 = 0, $5_1 = 0, $6_1 = 0, $7 = 0, $8 = 0; - $6_1 = $0; - $5_1 = 32; - $0 = $5_1 & 31; - if (32 >>> 0 <= $5_1 >>> 0) { + var $4_1 = 0, $5_1 = 0; + $5_1 = $0; + $4_1 = 32; + $0 = $4_1 & 31; + if (32 >>> 0 <= $4_1 >>> 0) { $4_1 = $1 << $0; $0 = 0; } else { - $4_1 = (1 << $0) - 1 & $1 >>> 32 - $0 | $4_1 << $0; + $4_1 = (1 << $0) - 1 & $1 >>> 32 - $0; $0 = $1 << $0; } - $5_1 = $6_1 | $0; - $4_1 = $4_1 | $7; - $6_1 = $2; - $2 = 0; - $1 = $3_1; - $3_1 = 32; - $0 = $3_1 & 31; - if (32 >>> 0 <= $3_1 >>> 0) { - $2 = $1 << $0; + $5_1 = $5_1 | $0; + $1 = 32; + $0 = $1 & 31; + if (32 >>> 0 <= $1 >>> 0) { + $1 = $3_1 << $0; $0 = 0; } else { - $2 = (1 << $0) - 1 & $1 >>> 32 - $0 | $2 << $0; - $0 = $1 << $0; + $1 = (1 << $0) - 1 & $3_1 >>> 32 - $0; + $0 = $3_1 << $0; } - return $5($5_1, $4_1, $6_1 | $0, $2 | $8); + return $5($5_1, $4_1, $0 | $2, $1); } function legalstub$6($0, $1, $2, $3_1) { - var $4_1 = 0, $5_1 = 0, $6_1 = 0, $7 = 0, $8 = 0; - $6_1 = $0; - $5_1 = 32; - $0 = $5_1 & 31; - if (32 >>> 0 <= $5_1 >>> 0) { + var $4_1 = 0, $5_1 = 0; + $5_1 = $0; + $4_1 = 32; + $0 = $4_1 & 31; + if (32 >>> 0 <= $4_1 >>> 0) { $4_1 = $1 << $0; $0 = 0; } else { - $4_1 = (1 << $0) - 1 & $1 >>> 32 - $0 | $4_1 << $0; + $4_1 = (1 << $0) - 1 & $1 >>> 32 - $0; $0 = $1 << $0; } - $5_1 = $6_1 | $0; - $4_1 = $4_1 | $7; - $6_1 = $2; - $2 = 0; - $1 = $3_1; - $3_1 = 32; - $0 = $3_1 & 31; - if (32 >>> 0 <= $3_1 >>> 0) { - $2 = $1 << $0; + $5_1 = $5_1 | $0; + $1 = 32; + $0 = $1 & 31; + if (32 >>> 0 <= $1 >>> 0) { + $1 = $3_1 << $0; $0 = 0; } else { - $2 = (1 << $0) - 1 & $1 >>> 32 - $0 | $2 << $0; - $0 = $1 << $0; + $1 = (1 << $0) - 1 & $3_1 >>> 32 - $0; + $0 = $3_1 << $0; } - return $6($5_1, $4_1, $6_1 | $0, $2 | $8); + return $6($5_1, $4_1, $0 | $2, $1); } function legalstub$7($0, $1, $2, $3_1) { var $4_1 = 0; - $4_1 = $2; - $2 = $3_1; - $3_1 = $4_1 | 0; - return ($1 | 0) == ($2 | 0) & $0 >>> 0 >= $3_1 >>> 0 | $1 >>> 0 > $2 >>> 0; + $4_1 = $0; + $0 = $1; + $1 = $3_1; + return ($0 | 0) == ($1 | 0) & $4_1 >>> 0 >= $2 >>> 0 | $0 >>> 0 > $1 >>> 0; } function legalstub$8($0, $1, $2, $3_1) { var $4_1 = 0; - $4_1 = $2; - $2 = $3_1; - $3_1 = $4_1 | 0; - return ($1 | 0) == ($2 | 0) & $0 >>> 0 > $3_1 >>> 0 | $1 >>> 0 > $2 >>> 0; + $4_1 = $0; + $0 = $1; + $1 = $3_1; + return ($0 | 0) == ($1 | 0) & $4_1 >>> 0 > $2 >>> 0 | $0 >>> 0 > $1 >>> 0; } function legalstub$9($0, $1, $2, $3_1) { var $4_1 = 0; - $4_1 = $2; - $2 = $3_1; - $3_1 = $4_1 | 0; - return ($1 | 0) == ($2 | 0) & $0 >>> 0 <= $3_1 >>> 0 | $1 >>> 0 < $2 >>> 0; + $4_1 = $0; + $0 = $1; + $1 = $3_1; + return ($0 | 0) == ($1 | 0) & $4_1 >>> 0 <= $2 >>> 0 | $0 >>> 0 < $1 >>> 0; } function legalstub$10($0, $1, $2, $3_1) { var $4_1 = 0; - $4_1 = $2; - $2 = $3_1; - $3_1 = $4_1 | 0; - return ($1 | 0) == ($2 | 0) & $0 >>> 0 < $3_1 >>> 0 | $1 >>> 0 < $2 >>> 0; + $4_1 = $0; + $0 = $1; + $1 = $3_1; + return ($0 | 0) == ($1 | 0) & $4_1 >>> 0 < $2 >>> 0 | $0 >>> 0 < $1 >>> 0; } var FUNCTION_TABLE = []; diff --git a/test/wasm2js/i64-rotate.2asm.js.opt b/test/wasm2js/i64-rotate.2asm.js.opt index 238728c4e..d2a2c81ad 100644 --- a/test/wasm2js/i64-rotate.2asm.js.opt +++ b/test/wasm2js/i64-rotate.2asm.js.opt @@ -54,7 +54,7 @@ function asmFunc(global, env, buffer) { $4 = 0 - $2 & 63; $3 = $4; $2 = $3 & 31; - if (32 >>> 0 <= ($3 & 63) >>> 0) { + if (32 >>> 0 <= $3 >>> 0) { $3 = -1 << $2; $2 = 0; } else { @@ -100,7 +100,7 @@ function asmFunc(global, env, buffer) { $7 = $4; $3 = 0 - $2 & 63; $5 = $3 & 31; - if (32 >>> 0 <= ($3 & 63) >>> 0) { + if (32 >>> 0 <= $3 >>> 0) { $4 = 0; $2 = -1 >>> $5; } else { diff --git a/test/wasm2js/i64-shifts.2asm.js.opt b/test/wasm2js/i64-shifts.2asm.js.opt index bd51d9273..a6606ec41 100644 --- a/test/wasm2js/i64-shifts.2asm.js.opt +++ b/test/wasm2js/i64-shifts.2asm.js.opt @@ -57,79 +57,69 @@ function asmFunc(global, env, buffer) { } function legalstub$1($0, $1_1, $2_1, $3, $4, $5) { - var $6 = 0, $7 = 0, $8 = 0, $9 = 0, $10 = 0; - $6 = $0; - $8 = 32; - $0 = $8 & 31; - if (32 >>> 0 <= $8 >>> 0) { - $7 = $1_1 << $0; + var $6 = 0, $7 = 0; + $7 = $0; + $6 = 32; + $0 = $6 & 31; + if (32 >>> 0 <= $6 >>> 0) { + $6 = $1_1 << $0; $0 = 0; } else { - $7 = (1 << $0) - 1 & $1_1 >>> 32 - $0 | $7 << $0; + $6 = (1 << $0) - 1 & $1_1 >>> 32 - $0; $0 = $1_1 << $0; } - $8 = $6 | $0; - $7 = $7 | $9; - $6 = $2_1; - $2_1 = 0; - $1_1 = $3; - $3 = 32; - $0 = $3 & 31; - if (32 >>> 0 <= $3 >>> 0) { + $7 = $7 | $0; + $1_1 = 32; + $0 = $1_1 & 31; + if (32 >>> 0 <= $1_1 >>> 0) { $0 = 0 } else { - $0 = $1_1 << $0 + $0 = $3 << $0 } - $6 = $6 | $0; - $2_1 = 0; - $1_1 = $5; - $0 = 32 & 31; - if (32 >>> 0 <= $3 >>> 0) { - $2_1 = $1_1 << $0; + $2_1 = $0 | $2_1; + $1_1 = 32; + $0 = $1_1 & 31; + if (32 >>> 0 <= $1_1 >>> 0) { + $1_1 = $5 << $0; $0 = 0; } else { - $2_1 = (1 << $0) - 1 & $1_1 >>> 32 - $0 | $2_1 << $0; - $0 = $1_1 << $0; + $1_1 = (1 << $0) - 1 & $5 >>> 32 - $0; + $0 = $5 << $0; } - return $1($8, $7, $6, $0 | $4, $2_1 | $10); + return $1($7, $6, $2_1, $0 | $4, $1_1); } function legalstub$2($0, $1_1, $2_1, $3, $4, $5) { - var $6 = 0, $7 = 0, $8 = 0, $9 = 0, $10 = 0; - $6 = $0; - $8 = 32; - $0 = $8 & 31; - if (32 >>> 0 <= $8 >>> 0) { - $7 = $1_1 << $0; + var $6 = 0, $7 = 0; + $7 = $0; + $6 = 32; + $0 = $6 & 31; + if (32 >>> 0 <= $6 >>> 0) { + $6 = $1_1 << $0; $0 = 0; } else { - $7 = (1 << $0) - 1 & $1_1 >>> 32 - $0 | $7 << $0; + $6 = (1 << $0) - 1 & $1_1 >>> 32 - $0; $0 = $1_1 << $0; } - $8 = $6 | $0; - $7 = $7 | $9; - $6 = $2_1; - $2_1 = 0; - $1_1 = $3; - $3 = 32; - $0 = $3 & 31; - if (32 >>> 0 <= $3 >>> 0) { + $7 = $7 | $0; + $1_1 = 32; + $0 = $1_1 & 31; + if (32 >>> 0 <= $1_1 >>> 0) { $0 = 0 } else { - $0 = $1_1 << $0 + $0 = $3 << $0 } - $6 = $6 | $0; - $2_1 = 0; - $1_1 = $5; - $0 = 32 & 31; - if (32 >>> 0 <= $3 >>> 0) { - $2_1 = $1_1 << $0; + $2_1 = $0 | $2_1; + $1_1 = 32; + $0 = $1_1 & 31; + if (32 >>> 0 <= $1_1 >>> 0) { + $1_1 = $5 << $0; $0 = 0; } else { - $2_1 = (1 << $0) - 1 & $1_1 >>> 32 - $0 | $2_1 << $0; - $0 = $1_1 << $0; + $1_1 = (1 << $0) - 1 & $5 >>> 32 - $0; + $0 = $5 << $0; } - return $2($8, $7, $6, $0 | $4, $2_1 | $10); + return $2($7, $6, $2_1, $0 | $4, $1_1); } var FUNCTION_TABLE = []; diff --git a/test/wasm2js/reinterpret.2asm.js.opt b/test/wasm2js/reinterpret.2asm.js.opt index 0088be0be..4c9856ca0 100644 --- a/test/wasm2js/reinterpret.2asm.js.opt +++ b/test/wasm2js/reinterpret.2asm.js.opt @@ -52,7 +52,7 @@ function asmFunc(global, env, buffer) { var infinity = global.Infinity; function $1($0) { $0 = $0 | 0; - return ($0 | 0) == ((wasm2js_scratch_store_f32((wasm2js_scratch_store_i32(0, $0), wasm2js_scratch_load_f32())), wasm2js_scratch_load_i32(0)) | 0) | 0; + return ((wasm2js_scratch_store_f32((wasm2js_scratch_store_i32(0, $0), wasm2js_scratch_load_f32())), wasm2js_scratch_load_i32(0)) | 0) == ($0 | 0) | 0; } function $2($0, $1_1) { @@ -67,18 +67,18 @@ function asmFunc(global, env, buffer) { } function legalstub$2($0, $1_1) { - var $2_1 = 0, $3 = 0, $4 = 0, $5 = 0; - $4 = $0; - $3 = 32; - $0 = $3 & 31; - if (32 >>> 0 <= $3 >>> 0) { + var $2_1 = 0, $3 = 0; + $3 = $0; + $2_1 = 32; + $0 = $2_1 & 31; + if (32 >>> 0 <= $2_1 >>> 0) { $2_1 = $1_1 << $0; $0 = 0; } else { - $2_1 = (1 << $0) - 1 & $1_1 >>> 32 - $0 | $2_1 << $0; + $2_1 = (1 << $0) - 1 & $1_1 >>> 32 - $0; $0 = $1_1 << $0; } - return $2($4 | $0, $2_1 | $5); + return $2($3 | $0, $2_1); } var FUNCTION_TABLE = []; diff --git a/test/wasm2js/stack-modified.2asm.js.opt b/test/wasm2js/stack-modified.2asm.js.opt index b31f4f147..baabfe868 100644 --- a/test/wasm2js/stack-modified.2asm.js.opt +++ b/test/wasm2js/stack-modified.2asm.js.opt @@ -45,53 +45,53 @@ function asmFunc(global, env, buffer) { } function legalstub$0($0_1, $1) { - var $2 = 0, $3 = 0, $4 = 0, $5 = 0; - $4 = $0_1; - $3 = 32; - $0_1 = $3 & 31; - if (32 >>> 0 <= $3 >>> 0) { + var $2 = 0, $3 = 0; + $3 = $0_1; + $2 = 32; + $0_1 = $2 & 31; + if (32 >>> 0 <= $2 >>> 0) { $2 = $1 << $0_1; $0_1 = 0; } else { - $2 = (1 << $0_1) - 1 & $1 >>> 32 - $0_1 | $2 << $0_1; + $2 = (1 << $0_1) - 1 & $1 >>> 32 - $0_1; $0_1 = $1 << $0_1; } - $1 = $0($4 | $0_1, $2 | $5); - $2 = i64toi32_i32$HIGH_BITS; - $0_1 = 32 & 31; - setTempRet0((32 >>> 0 <= $3 >>> 0 ? $2 >>> $0_1 : ((1 << $0_1) - 1 & $2) << 32 - $0_1 | $1 >>> $0_1) | 0); - return $1; + $0_1 = $0($3 | $0_1, $2); + $1 = i64toi32_i32$HIGH_BITS; + $3 = 32; + $2 = $3 & 31; + setTempRet0((32 >>> 0 <= $3 >>> 0 ? $1 >>> $2 : ((1 << $2) - 1 & $1) << 32 - $2 | $0_1 >>> $2) | 0); + return $0_1; } function _ZN17compiler_builtins3int3mul3Mul3mul17h070e9a1c69faec5bE($0_1, $1, $2, $3) { var $4 = 0, $5 = 0, $6 = 0, $7 = 0, $8 = 0, $9 = 0, $10 = 0; - $5 = $2 >>> 16; - $6 = $0_1 >>> 16; - $4 = Math_imul($5, $6); - $8 = $2 & 65535; - $7 = $0_1 & 65535; - $9 = Math_imul($8, $7); - $6 = ($9 >>> 16) + Math_imul($6, $8) | 0; - $5 = ($6 & 65535) + Math_imul($5, $7) | 0; - $8 = 0; - $10 = $4; - $7 = $0_1; - $4 = 32; - $0_1 = $4 & 31; - $4 = $10 + Math_imul(32 >>> 0 <= $4 >>> 0 ? $1 >>> $0_1 : ((1 << $0_1) - 1 & $1) << 32 - $0_1 | $7 >>> $0_1, $2) | 0; + $6 = $2 >>> 16; + $10 = $0_1; + $7 = $0_1 >>> 16; + $5 = Math_imul($6, $7); + $4 = $2 & 65535; + $8 = $0_1 & 65535; + $9 = Math_imul($4, $8); + $7 = ($9 >>> 16) + Math_imul($4, $7) | 0; + $6 = ($7 & 65535) + Math_imul($6, $8) | 0; + $8 = $5; + $5 = 32; + $4 = $5 & 31; + $5 = $8 + Math_imul(32 >>> 0 <= $5 >>> 0 ? $1 >>> $4 : ((1 << $4) - 1 & $1) << 32 - $4 | $0_1 >>> $4, $2) | 0; $1 = $2; $2 = 32; $0_1 = $2 & 31; - $1 = (($4 + Math_imul($7, 32 >>> 0 <= $2 >>> 0 ? $3 >>> $0_1 : ((1 << $0_1) - 1 & $3) << 32 - $0_1 | $1 >>> $0_1) | 0) + ($6 >>> 16) | 0) + ($5 >>> 16) | 0; + $1 = (($5 + Math_imul($10, 32 >>> 0 <= $2 >>> 0 ? $3 >>> $0_1 : ((1 << $0_1) - 1 & $3) << 32 - $0_1 | $1 >>> $0_1) | 0) + ($7 >>> 16) | 0) + ($6 >>> 16) | 0; $0_1 = 32 & 31; if (32 >>> 0 <= $2 >>> 0) { $2 = $1 << $0_1; $0_1 = 0; } else { - $2 = (1 << $0_1) - 1 & $1 >>> 32 - $0_1 | $8 << $0_1; + $2 = (1 << $0_1) - 1 & $1 >>> 32 - $0_1; $0_1 = $1 << $0_1; } - $0_1 = $0_1 | ($9 & 65535 | $5 << 16); + $0_1 = $0_1 | ($9 & 65535 | $6 << 16); i64toi32_i32$HIGH_BITS = $2; return $0_1; } diff --git a/test/wasm2js/unaligned.2asm.js.opt b/test/wasm2js/unaligned.2asm.js.opt index 379067cca..bbca2c8bf 100644 --- a/test/wasm2js/unaligned.2asm.js.opt +++ b/test/wasm2js/unaligned.2asm.js.opt @@ -50,64 +50,57 @@ function asmFunc(global, env, buffer) { var setTempRet0 = env.setTempRet0; var i64toi32_i32$HIGH_BITS = 0; function $0() { - var $0_1 = 0; - return HEAPU8[0 | 0] | HEAPU8[$0_1 + 1 | 0] << 8 | (HEAPU8[$0_1 + 2 | 0] << 16 | HEAPU8[$0_1 + 3 | 0] << 24); + return HEAPU8[0 | 0] | HEAPU8[1 | 0] << 8 | (HEAPU8[2 | 0] << 16 | HEAPU8[3 | 0] << 24); } function $1() { - var $0_1 = 0, $1_1 = 0; - $0_1 = HEAPU8[0 | 0] | HEAPU8[$0_1 + 1 | 0] << 8 | (HEAPU8[$0_1 + 2 | 0] << 16 | HEAPU8[$0_1 + 3 | 0] << 24); - i64toi32_i32$HIGH_BITS = HEAPU8[$1_1 + 4 | 0] | HEAPU8[$1_1 + 5 | 0] << 8 | (HEAPU8[$1_1 + 6 | 0] << 16 | HEAPU8[$1_1 + 7 | 0] << 24); - return $0_1 | 0; + i64toi32_i32$HIGH_BITS = HEAPU8[4 | 0] | HEAPU8[5 | 0] << 8 | (HEAPU8[6 | 0] << 16 | HEAPU8[7 | 0] << 24); + return HEAPU8[0 | 0] | HEAPU8[1 | 0] << 8 | (HEAPU8[2 | 0] << 16 | HEAPU8[3 | 0] << 24); } function $2() { - var $0_1 = 0; - return Math_fround((wasm2js_scratch_store_i32(0, HEAPU8[0 | 0] | HEAPU8[$0_1 + 1 | 0] << 8 | (HEAPU8[$0_1 + 2 | 0] << 16 | HEAPU8[$0_1 + 3 | 0] << 24)), wasm2js_scratch_load_f32())); + return Math_fround((wasm2js_scratch_store_i32(0, HEAPU8[0 | 0] | HEAPU8[1 | 0] << 8 | (HEAPU8[2 | 0] << 16 | HEAPU8[3 | 0] << 24)), wasm2js_scratch_load_f32())); } function $3() { - var $0_1 = 0, $1_1 = 0; - $1_1 = HEAPU8[0 | 0] | HEAPU8[$1_1 + 1 | 0] << 8 | (HEAPU8[$1_1 + 2 | 0] << 16 | HEAPU8[$1_1 + 3 | 0] << 24); - $0_1 = HEAPU8[$0_1 + 4 | 0] | HEAPU8[$0_1 + 5 | 0] << 8 | (HEAPU8[$0_1 + 6 | 0] << 16 | HEAPU8[$0_1 + 7 | 0] << 24); - wasm2js_scratch_store_i32(0 | 0, $1_1 | 0); + var $0_1 = 0; + $0_1 = HEAPU8[4 | 0] | HEAPU8[5 | 0] << 8 | (HEAPU8[6 | 0] << 16 | HEAPU8[7 | 0] << 24); + wasm2js_scratch_store_i32(0 | 0, HEAPU8[0 | 0] | HEAPU8[1 | 0] << 8 | (HEAPU8[2 | 0] << 16 | HEAPU8[3 | 0] << 24)); wasm2js_scratch_store_i32(1 | 0, $0_1 | 0); return +wasm2js_scratch_load_f64(); } function $4() { - var $0_1 = 0, $1_1 = 0; HEAP8[0 | 0] = 0; - HEAP8[$0_1 + 1 | 0] = $1_1 >>> 8; - HEAP8[$0_1 + 2 | 0] = $1_1 >>> 16; - HEAP8[$0_1 + 3 | 0] = $1_1 >>> 24; + HEAP8[1 | 0] = 0; + HEAP8[2 | 0] = 0; + HEAP8[3 | 0] = 0; } function $5() { - var $0_1 = 0, $1_1 = 0, $2_1 = 0; HEAP8[0 | 0] = 0; - HEAP8[$0_1 + 1 | 0] = $2_1 >>> 8; - HEAP8[$0_1 + 2 | 0] = $2_1 >>> 16; - HEAP8[$0_1 + 3 | 0] = $2_1 >>> 24; - HEAP8[$1_1 + 4 | 0] = 0; - HEAP8[$1_1 + 5 | 0] = $0_1 >>> 8; - HEAP8[$1_1 + 6 | 0] = $0_1 >>> 16; - HEAP8[$1_1 + 7 | 0] = $0_1 >>> 24; + HEAP8[1 | 0] = 0; + HEAP8[2 | 0] = 0; + HEAP8[3 | 0] = 0; + HEAP8[4 | 0] = 0; + HEAP8[5 | 0] = 0; + HEAP8[6 | 0] = 0; + HEAP8[7 | 0] = 0; } function $7() { - var $0_1 = 0, $1_1 = 0, $2_1 = 0, $3_1 = 0; + var $0_1 = 0, $1_1 = 0; wasm2js_scratch_store_f64(0.0); $0_1 = wasm2js_scratch_load_i32(1 | 0) | 0; $1_1 = wasm2js_scratch_load_i32(0 | 0) | 0; HEAP8[0 | 0] = $1_1; - HEAP8[$3_1 + 1 | 0] = $1_1 >>> 8; - HEAP8[$3_1 + 2 | 0] = $1_1 >>> 16; - HEAP8[$3_1 + 3 | 0] = $1_1 >>> 24; - HEAP8[$2_1 + 4 | 0] = $0_1; - HEAP8[$2_1 + 5 | 0] = $0_1 >>> 8; - HEAP8[$2_1 + 6 | 0] = $0_1 >>> 16; - HEAP8[$2_1 + 7 | 0] = $0_1 >>> 24; + HEAP8[1 | 0] = $1_1 >>> 8; + HEAP8[2 | 0] = $1_1 >>> 16; + HEAP8[3 | 0] = $1_1 >>> 24; + HEAP8[4 | 0] = $0_1; + HEAP8[5 | 0] = $0_1 >>> 8; + HEAP8[6 | 0] = $0_1 >>> 16; + HEAP8[7 | 0] = $0_1 >>> 24; } function legalstub$1() { diff --git a/test/wasm2js/unary-ops.2asm.js.opt b/test/wasm2js/unary-ops.2asm.js.opt index 56bf1eae2..7dcc1c85c 100644 --- a/test/wasm2js/unary-ops.2asm.js.opt +++ b/test/wasm2js/unary-ops.2asm.js.opt @@ -34,7 +34,7 @@ function asmFunc(global, env, buffer) { function $7($0) { $0 = $0 | 0; if ($0) { - $0 = 31 - Math_clz32($0 ^ $0 + -1) | 0 + $0 = 31 - Math_clz32($0 + -1 ^ $0) | 0 } else { $0 = 32 } @@ -57,7 +57,11 @@ function asmFunc(global, env, buffer) { } function legalstub$3($0, $1_1, $2) { - return !$2 & ($0 | 0) == ($1_1 | 0); + var $3 = 0; + $3 = $1_1; + $1_1 = $2; + $2 = $3 | 0; + return !$1_1 & ($0 | 0) == ($2 | 0); } function legalstub$4($0, $1_1, $2) { @@ -69,32 +73,28 @@ function asmFunc(global, env, buffer) { } function legalstub$8($0, $1_1, $2, $3) { - var $4 = 0, $5 = 0, $6_1 = 0, $7_1 = 0, $8_1 = 0; - $6_1 = $0; - $5 = 32; - $0 = $5 & 31; - if (32 >>> 0 <= $5 >>> 0) { + var $4 = 0, $5 = 0; + $5 = $0; + $4 = 32; + $0 = $4 & 31; + if (32 >>> 0 <= $4 >>> 0) { $4 = $1_1 << $0; $0 = 0; } else { - $4 = (1 << $0) - 1 & $1_1 >>> 32 - $0 | $4 << $0; + $4 = (1 << $0) - 1 & $1_1 >>> 32 - $0; $0 = $1_1 << $0; } - $5 = $6_1 | $0; - $4 = $4 | $7_1; - $6_1 = $2; - $2 = 0; - $1_1 = $3; - $3 = 32; - $0 = $3 & 31; - if (32 >>> 0 <= $3 >>> 0) { - $2 = $1_1 << $0; + $5 = $5 | $0; + $1_1 = 32; + $0 = $1_1 & 31; + if (32 >>> 0 <= $1_1 >>> 0) { + $1_1 = $3 << $0; $0 = 0; } else { - $2 = (1 << $0) - 1 & $1_1 >>> 32 - $0 | $2 << $0; - $0 = $1_1 << $0; + $1_1 = (1 << $0) - 1 & $3 >>> 32 - $0; + $0 = $3 << $0; } - return $8($5, $4, $6_1 | $0, $2 | $8_1); + return $8($5, $4, $0 | $2, $1_1); } function legalstub$9($0, $1_1, $2, $3) { |