summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2017-10-03 15:20:42 -0700
committerGitHub <noreply@github.com>2017-10-03 15:20:42 -0700
commit7c491995ea89685f1381bd37227857820dbc0a34 (patch)
tree52c44bcdefe8eea33a33d227761475f2718eba12
parent47c37d0c4457ede9f4343abca0d56e2baa7f3d8a (diff)
downloadbinaryen-7c491995ea89685f1381bd37227857820dbc0a34.tar.gz
binaryen-7c491995ea89685f1381bd37227857820dbc0a34.tar.bz2
binaryen-7c491995ea89685f1381bd37227857820dbc0a34.zip
Flattening rewrite (#1201)
Rename flatten-control-flow to flatten, which now flattens everything, not just control flow, so e.g. (i32.add (call $x) (call $y) ) ==> (block (set_local $temp_x (call $x)) (set_local $temp_y (call $y)) (i32.add (get_local $x) (get_local $y) ) ) This uses more locals than before, but is much simpler and avoids a bunch of corner cases and fuzz bugs the old one hit. We can optimize later if necessary.
-rwxr-xr-xauto_update_tests.py31
-rw-r--r--src/passes/CMakeLists.txt2
-rw-r--r--src/passes/Flatten.cpp337
-rw-r--r--src/passes/FlattenControlFlow.cpp476
-rw-r--r--src/passes/ReReloop.cpp2
-rw-r--r--src/passes/pass.cpp2
-rw-r--r--src/passes/passes.h98
-rw-r--r--src/wasm-traversal.h6
-rw-r--r--src/wasm2asm.h2
-rw-r--r--test/address.2asm.js143
-rw-r--r--test/br_table_temp.2asm.js675
-rw-r--r--test/empty_imported_table.2asm.js85
-rw-r--r--test/empty_table.2asm.js85
-rw-r--r--test/forward.2asm.js113
-rw-r--r--test/hello_world.2asm.js91
-rw-r--r--test/i32.2asm.js255
-rw-r--r--test/passes/flatten-control-flow.bin.txt123
-rw-r--r--test/passes/flatten-control-flow.txt1184
-rw-r--r--test/passes/flatten.bin.txt276
-rw-r--r--test/passes/flatten.txt2402
-rw-r--r--test/passes/flatten.wasm (renamed from test/passes/flatten-control-flow.wasm)bin458 -> 458 bytes
-rw-r--r--test/passes/flatten.wast (renamed from test/passes/flatten-control-flow.wast)231
-rw-r--r--test/passes/flatten_rereloop.txt45
-rw-r--r--test/passes/flatten_rereloop.wast12
-rw-r--r--test/wasm2asm.asserts.js97
-rw-r--r--test/wasm2asm.traps.js97
26 files changed, 4625 insertions, 2245 deletions
diff --git a/auto_update_tests.py b/auto_update_tests.py
index 47060edfe..93fe732d7 100755
--- a/auto_update_tests.py
+++ b/auto_update_tests.py
@@ -7,7 +7,7 @@ from scripts.test.shared import (
ASM2WASM, MOZJS, S2WASM, WASM_SHELL, WASM_OPT, WASM_AS, WASM_DIS,
WASM_CTOR_EVAL, WASM_MERGE, WASM_REDUCE, WASM2ASM,
BINARYEN_INSTALL_DIR, has_shell_timeout)
-from scripts.test.wasm2asm import tests, spec_tests, extra_tests
+from scripts.test.wasm2asm import tests, spec_tests, extra_tests, assert_tests
print '[ processing and updating testcases... ]\n'
@@ -64,19 +64,6 @@ for dot_s_dir in ['dot_s', 'llvm_autogenerated']:
expected_file = os.path.join('test', dot_s_dir, wasm)
with open(expected_file, 'w') as o: o.write(actual)
-'''
-for wasm in ['address.wast']:#os.listdir(os.path.join('test', 'spec')):
- if wasm.endswith('.wast'):
- print '..', wasm
- asm = wasm.replace('.wast', '.2asm.js')
- proc = subprocess.Popen([os.path.join('bin', 'wasm2asm'), os.path.join('test', 'spec', wasm)], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- actual, err = proc.communicate()
- assert proc.returncode == 0, err
- assert err == '', 'bad err:' + err
- expected_file = os.path.join('test', asm)
- open(expected_file, 'w').write(actual)
-'''
-
for t in sorted(os.listdir(os.path.join('test', 'print'))):
if t.endswith('.wast'):
print '..', t
@@ -281,6 +268,22 @@ for wasm in tests + spec_tests + extra_tests:
out = run_command(cmd)
with open(expected_file, 'w') as o: o.write(out)
+for wasm in assert_tests:
+ print '..', wasm
+
+ asserts = os.path.basename(wasm).replace('.wast.asserts', '.asserts.js')
+ traps = os.path.basename(wasm).replace('.wast.asserts', '.traps.js')
+ asserts_expected_file = os.path.join('test', asserts)
+ traps_expected_file = os.path.join('test', traps)
+
+ cmd = WASM2ASM + [os.path.join('test', wasm), '--allow-asserts']
+ out = run_command(cmd)
+ with open(asserts_expected_file, 'w') as o: o.write(out)
+
+ cmd += ['--pedantic']
+ out = run_command(cmd)
+ with open(traps_expected_file, 'w') as o: o.write(out)
+
if has_shell_timeout():
print '\n[ checking wasm-reduce ]\n'
diff --git a/src/passes/CMakeLists.txt b/src/passes/CMakeLists.txt
index 3cb00b796..168af2761 100644
--- a/src/passes/CMakeLists.txt
+++ b/src/passes/CMakeLists.txt
@@ -7,7 +7,7 @@ SET(passes_SOURCES
DeadCodeElimination.cpp
DuplicateFunctionElimination.cpp
ExtractFunction.cpp
- FlattenControlFlow.cpp
+ Flatten.cpp
Inlining.cpp
LegalizeJSInterface.cpp
LocalCSE.cpp
diff --git a/src/passes/Flatten.cpp b/src/passes/Flatten.cpp
new file mode 100644
index 000000000..b16d9df3f
--- /dev/null
+++ b/src/passes/Flatten.cpp
@@ -0,0 +1,337 @@
+/*
+ * 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.
+ */
+
+//
+// Flattens code, removing nesting.e.g. an if return value would be
+// converted to a local
+//
+// (i32.add
+// (if (..condition..)
+// (..if true..)
+// (..if false..)
+// )
+// (i32.const 1)
+// )
+// =>
+// (if (..condition..)
+// (set_local $temp
+// (..if true..)
+// )
+// (set_local $temp
+// (..if false..)
+// )
+// )
+// (i32.add
+// (get_local $temp)
+// (i32.const 1)
+// )
+//
+// Formally, this pass flattens in the precise sense of
+// making the AST have these properties:
+//
+// 1. The operands of an instruction must be a get_local or a const.
+// anything else is written to a local earlier.
+// 2. Disallow block, loop, and if return values, i.e., do not use
+// control flow to pass around values.
+//
+
+#include <wasm.h>
+#include <pass.h>
+#include <wasm-builder.h>
+#include <ast_utils.h>
+#include <ast/effects.h>
+
+namespace wasm {
+
+// We use the following algorithm: we maintain a list of "preludes", code
+// that runs right before an expression. When we visit an expression we
+// must handle it and its preludes. If the expression has side effects,
+// we reduce it to a get_local and add a prelude for that. We then handle
+// the preludes, by moving them to the parent or handling them directly.
+// we can move them to the parent if the parent is not a control flow
+// structure. Otherwise, if the parent is a control flow structure, it
+// will incorporate the preludes of its children accordingly.
+// As a result, when we reach a node, we know its children have no
+// side effects (they have been moved to a prelude), or we are a
+// control flow structure (which allows children with side effects,
+// e.g. a return as a block element).
+// Once exception is that we allow an (unreachable) node, which is used
+// when we move something unreachable to another place, and need a
+// placeholder. We will never reach that (unreachable) anyhow
+struct Flatten : public WalkerPass<ExpressionStackWalker<Flatten, UnifiedExpressionVisitor<Flatten>>> {
+ bool isFunctionParallel() override { return true; }
+
+ Pass* create() override { return new Flatten; }
+
+ // For each expression, a bunch of expressions that should execute right before it
+ std::unordered_map<Expression*, std::vector<Expression*>> preludes;
+
+ // Break values are sent through a temp local
+ std::unordered_map<Name, Index> breakTemps;
+
+ void visitExpression(Expression* curr) {
+ std::vector<Expression*> ourPreludes;
+ Builder builder(*getModule());
+
+ if (isControlFlowStructure(curr)) {
+ // handle control flow explicitly. our children do not have control flow,
+ // but they do have preludes which we need to set up in the right place
+ assert(preludes.find(curr) == preludes.end()); // no one should have given us preludes, they are on the children
+ if (auto* block = curr->dynCast<Block>()) {
+ // make a new list, where each item's preludes are added before it
+ ExpressionList newList(getModule()->allocator);
+ for (auto* item : block->list) {
+ auto iter = preludes.find(item);
+ if (iter != preludes.end()) {
+ auto& itemPreludes = iter->second;
+ for (auto* prelude : itemPreludes) {
+ newList.push_back(prelude);
+ }
+ itemPreludes.clear();
+ }
+ newList.push_back(item);
+ }
+ block->list.swap(newList);
+ // remove a block return value
+ auto type = block->type;
+ if (isConcreteWasmType(type)) {
+ // if there is a temp index for breaking to the block, use that
+ Index temp;
+ auto iter = breakTemps.find(block->name);
+ if (iter != breakTemps.end()) {
+ temp = iter->second;
+ } else {
+ temp = builder.addVar(getFunction(), type);
+ }
+ auto*& last = block->list.back();
+ if (isConcreteWasmType(last->type)) {
+ last = builder.makeSetLocal(temp, last);
+ }
+ block->finalize(none);
+ // and we leave just a get of the value
+ auto* rep = builder.makeGetLocal(temp, type);
+ replaceCurrent(rep);
+ // the whole block is now a prelude
+ ourPreludes.push_back(block);
+ }
+ // the block now has no return value, and may have become unreachable
+ block->finalize(none);
+ } else if (auto* iff = curr->dynCast<If>()) {
+ // condition preludes go before the entire if
+ auto* rep = getPreludesWithExpression(iff->condition, iff);
+ // arm preludes go in the arms. we must also remove an if value
+ auto* originalIfTrue = iff->ifTrue;
+ auto* originalIfFalse = iff->ifFalse;
+ auto type = iff->type;
+ Expression* prelude = nullptr;
+ if (isConcreteWasmType(type)) {
+ Index temp = builder.addVar(getFunction(), type);
+ if (isConcreteWasmType(iff->ifTrue->type)) {
+ iff->ifTrue = builder.makeSetLocal(temp, iff->ifTrue);
+ }
+ if (iff->ifFalse && isConcreteWasmType(iff->ifFalse->type)) {
+ iff->ifFalse = builder.makeSetLocal(temp, iff->ifFalse);
+ }
+ // the whole if (+any preludes from the condition) is now a prelude
+ prelude = rep;
+ // and we leave just a get of the value
+ rep = builder.makeGetLocal(temp, type);
+ }
+ iff->ifTrue = getPreludesWithExpression(originalIfTrue, iff->ifTrue);
+ if (iff->ifFalse) iff->ifFalse = getPreludesWithExpression(originalIfFalse, iff->ifFalse);
+ iff->finalize();
+ if (prelude) {
+ ReFinalizeNode().visit(prelude);
+ ourPreludes.push_back(prelude);
+ }
+ replaceCurrent(rep);
+ } else if (auto* loop = curr->dynCast<Loop>()) {
+ // remove a loop value
+ Expression* rep = loop;
+ auto* originalBody = loop->body;
+ auto type = loop->type;
+ if (isConcreteWasmType(type)) {
+ Index temp = builder.addVar(getFunction(), type);
+ loop->body = builder.makeSetLocal(temp, loop->body);
+ // and we leave just a get of the value
+ rep = builder.makeGetLocal(temp, type);
+ // the whole if is now a prelude
+ ourPreludes.push_back(loop);
+ loop->type = none;
+ }
+ loop->body = getPreludesWithExpression(originalBody, loop->body);
+ loop->finalize();
+ replaceCurrent(rep);
+ } else {
+ WASM_UNREACHABLE();
+ }
+ } else {
+ // for anything else, there may be existing preludes
+ auto iter = preludes.find(curr);
+ if (iter != preludes.end()) {
+ ourPreludes.swap(iter->second);
+ }
+ // special handling
+ if (auto* br = curr->dynCast<Break>()) {
+ if (br->value) {
+ auto type = br->value->type;
+ if (isConcreteWasmType(type)) {
+ // we are sending a value. use a local instead
+ Index temp = getTempForBreakTarget(br->name, type);
+ ourPreludes.push_back(builder.makeSetLocal(temp, br->value));
+ if (br->condition) {
+ // the value must also flow out
+ ourPreludes.push_back(br);
+ if (isConcreteWasmType(br->type)) {
+ replaceCurrent(builder.makeGetLocal(temp, type));
+ } else {
+ assert(br->type == unreachable);
+ replaceCurrent(builder.makeUnreachable());
+ }
+ }
+ br->value = nullptr;
+ br->finalize();
+ } else {
+ assert(type == unreachable);
+ // we don't need the br at all
+ replaceCurrent(br->value);
+ }
+ }
+ } else if (auto* sw = curr->dynCast<Switch>()) {
+ if (sw->value) {
+ auto type = sw->value->type;
+ if (isConcreteWasmType(type)) {
+ // we are sending a value. use a local instead
+ Index temp = builder.addVar(getFunction(), type);
+ ourPreludes.push_back(builder.makeSetLocal(temp, sw->value));
+ // we don't know which break target will be hit - assign to them all
+ std::set<Name> names;
+ for (auto target : sw->targets) {
+ names.insert(target);
+ }
+ names.insert(sw->default_);
+ for (auto name : names) {
+ ourPreludes.push_back(builder.makeSetLocal(
+ getTempForBreakTarget(name, type),
+ builder.makeGetLocal(temp, type)
+ ));
+ }
+ sw->value = nullptr;
+ sw->finalize();
+ } else {
+ assert(type == unreachable);
+ // we don't need the br at all
+ replaceCurrent(sw->value);
+ }
+ }
+ }
+ }
+ // continue for general handling of everything, control flow or otherwise
+ curr = getCurrent(); // we may have replaced it
+ // we have changed children
+ ReFinalizeNode().visit(curr);
+ // handle side effects and control flow, things we need to be
+ // in the prelude. note that we must handle anything here, not just
+ // side effects, as a sibling after us may have side effect for us,
+ // and thus we need to move in anticipation of that (e.g., we are
+ // a get, and a later sibling is a tee - if just the tee moves,
+ // that is bade) TODO optimize
+ if (isControlFlowStructure(curr) || EffectAnalyzer(getPassOptions(), curr).hasAnything()) {
+ // we need to move the side effects to the prelude
+ if (curr->type == unreachable) {
+ ourPreludes.push_back(curr);
+ replaceCurrent(builder.makeUnreachable());
+ } else if (curr->type == none) {
+ if (!curr->is<Nop>()) {
+ ourPreludes.push_back(curr);
+ replaceCurrent(builder.makeNop());
+ }
+ } else {
+ // use a local
+ auto type = curr->type;
+ Index temp = builder.addVar(getFunction(), type);
+ ourPreludes.push_back(builder.makeSetLocal(temp, curr));
+ replaceCurrent(builder.makeGetLocal(temp, type));
+ }
+ }
+ // next, finish up: migrate our preludes if we can
+ if (!ourPreludes.empty()) {
+ auto* parent = getParent();
+ if (parent && !isControlFlowStructure(parent)) {
+ auto& parentPreludes = preludes[parent];
+ for (auto* prelude : ourPreludes) {
+ parentPreludes.push_back(prelude);
+ }
+ } else {
+ // keep our preludes, parent will handle them
+ preludes[getCurrent()].swap(ourPreludes);
+ }
+ }
+ }
+
+ void visitFunction(Function* curr) {
+ auto* originalBody = curr->body;
+ // if the body is a block with a result, turn that into a return
+ if (isConcreteWasmType(curr->body->type)) {
+ curr->body = Builder(*getModule()).makeReturn(curr->body);
+ }
+ // the body may have preludes
+ curr->body = getPreludesWithExpression(originalBody, curr->body);
+ }
+
+private:
+ bool isControlFlowStructure(Expression* curr) {
+ return curr->is<Block>() || curr->is<If>() || curr->is<Loop>();
+ }
+
+ // gets an expression, either by itself, or in a block with its
+ // preludes (which we use up) before it
+ Expression* getPreludesWithExpression(Expression* curr) {
+ return getPreludesWithExpression(curr, curr);
+ }
+
+ // gets an expression, either by itself, or in a block with some
+ // preludes (which we use up) for another expression before it
+ Expression* getPreludesWithExpression(Expression* preluder, Expression* after) {
+ auto iter = preludes.find(preluder);
+ if (iter == preludes.end()) return after;
+ // we have preludes
+ auto& thePreludes = iter->second;
+ auto* ret = Builder(*getModule()).makeBlock(thePreludes);
+ thePreludes.clear();
+ ret->list.push_back(after);
+ ret->finalize();
+ return ret;
+ }
+
+ // get the temp local to be used for breaks to that target. allocates
+ // one if there isn't one yet
+ Index getTempForBreakTarget(Name name, WasmType type) {
+ auto iter = breakTemps.find(name);
+ if (iter != breakTemps.end()) {
+ return iter->second;
+ } else {
+ return breakTemps[name] = Builder(*getModule()).addVar(getFunction(), type);
+ }
+ }
+};
+
+Pass *createFlattenPass() {
+ return new Flatten();
+}
+
+} // namespace wasm
+
diff --git a/src/passes/FlattenControlFlow.cpp b/src/passes/FlattenControlFlow.cpp
deleted file mode 100644
index dce8e6345..000000000
--- a/src/passes/FlattenControlFlow.cpp
+++ /dev/null
@@ -1,476 +0,0 @@
-/*
- * 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.
- */
-
-//
-// Flattens control flow, e.g.
-//
-// (i32.add
-// (if (..condition..)
-// (..if true..)
-// (..if false..)
-// )
-// (i32.const 1)
-// )
-// =>
-// (if (..condition..)
-// (set_local $temp
-// (..if true..)
-// )
-// (set_local $temp
-// (..if false..)
-// )
-// )
-// (i32.add
-// (get_local $temp)
-// (i32.const 1)
-// )
-//
-// Formally, this pass flattens control flow in the precise sense of
-// making the AST have these properties:
-//
-// 1. Control flow structures (block, loop, if) and control flow
-// operations (br, br_if, br_table, return, unreachable) may
-// only be block children, a loop body, or an if-true or if-false.
-// (I.e., they cannot be nested inside an i32.add, a drop, a
-// call, an if-condition, etc.)
-// 2. Disallow block, loop, and if return values, i.e., do not use
-// control flow to pass around values.
-//
-// Note that we do still allow normal arbitrary nesting of expressions
-// *without* control flow (i.e., this is not a reduction to 3-address
-// code form). We also allow nesting of control flow, but just nested
-// in other control flow, like an if in the true arm of an if, and
-// so forth. What we achieve here is that when you see an expression,
-// you know it has no control flow inside it, it will be fully
-// executed.
-//
-
-#include <wasm.h>
-#include <pass.h>
-#include <wasm-builder.h>
-#include <ast_utils.h>
-
-namespace wasm {
-
-// Looks for control flow changes and structures, excluding blocks (as we
-// want to put all control flow on them)
-struct ControlFlowChecker : public Visitor<ControlFlowChecker> {
- static bool is(Expression* node) {
- ControlFlowChecker finder;
- finder.visit(node);
- return finder.hasControlFlow;
- }
-
- bool hasControlFlow = false;
-
- void visitBreak(Break *curr) { hasControlFlow = true; }
- void visitSwitch(Switch *curr) { hasControlFlow = true; }
- void visitBlock(Block *curr) { hasControlFlow = true; }
- void visitLoop(Loop* curr) { hasControlFlow = true; }
- void visitIf(If* curr) { hasControlFlow = true; }
- void visitReturn(Return *curr) { hasControlFlow = true; }
- void visitUnreachable(Unreachable *curr) { hasControlFlow = true; }
-};
-
-struct FlattenControlFlow : public WalkerPass<PostWalker<FlattenControlFlow>> {
- bool isFunctionParallel() override { return true; }
-
- Pass* create() override { return new FlattenControlFlow; }
-
- std::unique_ptr<Builder> builder;
- // we get rid of block/if/loop values. this map tells us for
- // each break target what local index to use.
- // if this is a flowing value, there might not be a name assigned
- // (block ending, block with no name; or if value), so we use
- // the expr (and there will be exactly one set and get of it,
- // so we don't need a name)
- std::map<Name, Index> breakNameIndexes;
- std::map<Expression*, Index> breakExprIndexes;
-
- void doWalkFunction(Function* func) {
- builder = make_unique<Builder>(*getModule());
- walk(func->body);
- if (func->result != none) {
- // if the body had a fallthrough, receive it and return it
- auto iter = breakExprIndexes.find(func->body);
- if (iter != breakExprIndexes.end()) {
- func->body = builder->makeSequence(
- func->body,
- builder->makeReturn(
- builder->makeGetLocal(iter->second, func->result)
- )
- );
- }
- }
- }
-
- // returns the index to assign values to for a break target. allocates
- // the local if this is the first time we see it.
- // expr is used if this is a flowing value.
- Index getBreakTargetIndex(Name name, WasmType type, Expression* expr = nullptr, Index index = -1) {
- assert(isConcreteWasmType(type)); // we shouldn't get here if the value ins't actually set
- if (name.is()) {
- auto iter = breakNameIndexes.find(name);
- if (iter == breakNameIndexes.end()) {
- if (index == Index(-1)) {
- index = builder->addVar(getFunction(), type);
- }
- breakNameIndexes[name] = index;
- if (expr) {
- breakExprIndexes[expr] = index;
- }
- return index;
- }
- if (expr) {
- breakExprIndexes[expr] = iter->second;
- }
- return iter->second;
- } else {
- assert(expr);
- auto iter = breakExprIndexes.find(expr);
- if (iter == breakExprIndexes.end()) {
- if (index == Index(-1)) {
- index = builder->addVar(getFunction(), type);
- }
- return breakExprIndexes[expr] = index;
- }
- return iter->second;
- }
- }
-
- // When we reach a fallthrough value, it has already been flattened, and its value
- // assigned to the proper local. Or, it may not have needed to be flattened,
- // and we can just assign to a local. This method simply returns the fallthrough
- // replacement code.
- Expression* getFallthroughReplacement(Expression* child, Index myIndex) {
- auto iter = breakExprIndexes.find(child);
- if (iter != breakExprIndexes.end()) {
- // it was flattened and saved to a local
- return builder->makeSequence(
- child, // which no longer flows a value, now it sets the child index
- builder->makeSetLocal(
- myIndex,
- builder->makeGetLocal(iter->second, getFunction()->getLocalType(iter->second))
- )
- );
- }
- // a simple expression
- if (child->type == unreachable) {
- // no need to even set the local
- return child;
- } else {
- assert(!ControlFlowChecker::is(child));
- return builder->makeSetLocal(
- myIndex,
- child
- );
- }
- }
-
- // flattening fallthroughs makes them have type none. this gets their true type
- WasmType getFallthroughType(Expression* child) {
- auto iter = breakExprIndexes.find(child);
- if (iter != breakExprIndexes.end()) {
- // it was flattened and saved to a local
- return getFunction()->getLocalType(iter->second);
- }
- assert(child->type != none);
- return child->type;
- }
-
- // Splitter helper
- struct Splitter {
- Splitter(FlattenControlFlow& parent, Expression* node) : parent(parent), node(node) {}
-
- ~Splitter() {
- finish();
- }
-
- FlattenControlFlow& parent;
- Expression* node;
-
- std::vector<Expression**> children; // TODO: reuse in parent, avoiding mallocing on each node
-
- void note(Expression*& child) {
- // we accept nullptr inputs, for a non-existing child
- if (!child) return;
- children.push_back(&child);
- }
-
- Expression* replacement; // the final replacement for the current node
- bool stop = false; // if a child is unreachable, we can stop
-
- void finish() {
- if (children.empty()) return;
- // first, scan the list
- bool hasControlFlowChild = false;
- bool hasUnreachableChild = false;
- for (auto** childp : children) {
- // it's enough to look at the child, ignoring the contents, as the contents
- // have already been processed before we got here, so they must have been
- // flattened if necessary.
- auto* child = *childp;
- if (ControlFlowChecker::is(child)) {
- hasControlFlowChild = true;
- }
- if (child->type == unreachable) {
- hasUnreachableChild = true;
- }
- }
- if (!hasControlFlowChild) {
- // nothing to do here.
- assert(!hasUnreachableChild); // all of them should be executed
- return;
- }
- // we have at least one child we need to split out, so to preserve the order of operations,
- // split them all out
- Builder* builder = parent.builder.get();
- std::vector<Index> tempIndexes;
- for (auto** childp : children) {
- auto* child = *childp;
- if (isConcreteWasmType(child->type)) {
- tempIndexes.push_back(builder->addVar(parent.getFunction(), child->type));
- } else {
- tempIndexes.push_back(-1);
- }
- }
- // create a new replacement block
- auto* block = builder->makeBlock();
- for (Index i = 0; i < children.size(); i++) {
- auto* child = *children[i];
- auto type = child->type;
- if (isConcreteWasmType(type)) {
- // set the child to a local, and use it later
- block->list.push_back(builder->makeSetLocal(tempIndexes[i], child));
- *children[i] = builder->makeGetLocal(tempIndexes[i], type);
- } else if (type == none) {
- // a nested none can not happen normally, here it occurs after we flattened a nested
- // we can use the local it already assigned to. TODO: don't even allocate one here
- block->list.push_back(child);
- assert(parent.breakExprIndexes.count(child) > 0);
- auto index = parent.breakExprIndexes[child];
- *children[i] = builder->makeGetLocal(
- index,
- parent.getFunction()->getLocalType(index)
- );
- } else if (type == unreachable) {
- block->list.push_back(child);
- break; // no need to push any more
- } else {
- WASM_UNREACHABLE();
- }
- }
- if (!hasUnreachableChild) {
- // we reached the end, so we need to emit the expression itself
- // (which has been modified to replace children usages with get_locals)
- block->list.push_back(node);
- }
- block->finalize();
- // finally, we just created a new block, ending in node. If node is e.g.
- // i32.add, then our block would return a value. so we must convert
- // this new block to return a value through a local
- parent.visitBlock(block);
- // the block is now done
- parent.replaceCurrent(block);
- // if the node was potentially a flowthrough value, then it has an entry
- // in breakExprIndexes, and since we are replacing it with this block,
- // we must note it's index as the same, so it is found by the parent.
- if (parent.breakExprIndexes.find(node) != parent.breakExprIndexes.end()) {
- parent.breakExprIndexes[block] = parent.breakExprIndexes[node];
- }
- }
- };
-
- void visitBlock(Block* curr) {
- if (isConcreteWasmType(curr->type)) {
- curr->list.back() = getFallthroughReplacement(curr->list.back(), getBreakTargetIndex(curr->name, curr->type, curr));
- curr->finalize();
- }
- }
- void visitLoop(Loop* curr) {
- if (isConcreteWasmType(curr->type)) {
- curr->body = getFallthroughReplacement(curr->body, getBreakTargetIndex(Name(), curr->type, curr));
- curr->finalize();
- }
- }
- void visitIf(If* curr) {
- if (isConcreteWasmType(curr->type)) {
- auto targetIndex = getBreakTargetIndex(Name(), curr->type, curr);
- curr->ifTrue = getFallthroughReplacement(curr->ifTrue, targetIndex);
- curr->ifFalse = getFallthroughReplacement(curr->ifFalse, targetIndex);
- curr->finalize();
- }
- Splitter splitter(*this, curr);
- splitter.note(curr->condition);
- }
- void visitBreak(Break* curr) {
- Expression* processed = curr;
- // first of all, get rid of the value if there is one
- if (curr->value) {
- if (curr->value->type != unreachable) {
- auto type = getFallthroughType(curr->value);
- auto index = getBreakTargetIndex(curr->name, type);
- auto* value = getFallthroughReplacement(curr->value, index);
- curr->value = nullptr;
- curr->finalize();
- processed = builder->makeSequence(
- value,
- curr
- );
- replaceCurrent(processed);
- if (curr->condition) {
- // we already called getBreakTargetIndex for the value we send to our
- // break target if we break. as this is a br_if with a value, it also
- // flows out that value, so our parent needs to know how to receive it.
- // we note the already-existing index we prepared before, for that value.
- getBreakTargetIndex(Name(), type, processed, index);
- }
- } else {
- // we have a value, but it has unreachable type. we can just replace
- // ourselves with it, we won't reach a condition (if there is one) or the br
- // itself
- replaceCurrent(curr->value);
- return;
- }
- }
- Splitter splitter(*this, processed);
- splitter.note(curr->condition);
- }
- void visitSwitch(Switch* curr) {
- Expression* processed = curr;
-
- // first of all, get rid of the value if there is one
- if (curr->value) {
- if (curr->value->type != unreachable) {
- auto type = getFallthroughType(curr->value);
- // we must assign the value to *all* the targets
- auto temp = builder->addVar(getFunction(), type);
- auto* value = getFallthroughReplacement(curr->value, temp);
- curr->value = nullptr;
- auto* block = builder->makeBlock();
- block->list.push_back(value);
- std::set<Name> names;
- for (auto target : curr->targets) {
- if (names.insert(target).second) {
- block->list.push_back(
- builder->makeSetLocal(
- getBreakTargetIndex(target, type),
- builder->makeGetLocal(temp, type)
- )
- );
- }
- }
- if (names.insert(curr->default_).second) {
- block->list.push_back(
- builder->makeSetLocal(
- getBreakTargetIndex(curr->default_, type),
- builder->makeGetLocal(temp, type)
- )
- );
- }
- block->list.push_back(curr);
- block->finalize();
- replaceCurrent(block);
- } else {
- // we have a value, but it has unreachable type. we can just replace
- // ourselves with it, we won't reach a condition (if there is one) or the br
- // itself
- replaceCurrent(curr->value);
- return;
- }
- }
- Splitter splitter(*this, processed);
- splitter.note(curr->value);
- splitter.note(curr->condition);
- }
- void visitCall(Call* curr) {
- Splitter splitter(*this, curr);
- for (auto*& operand : curr->operands) {
- splitter.note(operand);
- }
- }
- void visitCallImport(CallImport* curr) {
- Splitter splitter(*this, curr);
- for (auto*& operand : curr->operands) {
- splitter.note(operand);
- }
- }
- void visitCallIndirect(CallIndirect* curr) {
- Splitter splitter(*this, curr);
- for (auto*& operand : curr->operands) {
- splitter.note(operand);
- }
- splitter.note(curr->target);
- }
- void visitSetLocal(SetLocal* curr) {
- Splitter splitter(*this, curr);
- splitter.note(curr->value);
- }
- void visitSetGlobal(SetGlobal* curr) {
- Splitter splitter(*this, curr);
- splitter.note(curr->value);
- }
- void visitLoad(Load* curr) {
- Splitter splitter(*this, curr);
- splitter.note(curr->ptr);
- }
- void visitStore(Store* curr) {
- Splitter splitter(*this, curr);
- splitter.note(curr->ptr);
- splitter.note(curr->value);
- }
- void visitUnary(Unary* curr) {
- Splitter splitter(*this, curr);
- splitter.note(curr->value);
- }
- void visitBinary(Binary* curr) {
- Splitter splitter(*this, curr);
- splitter.note(curr->left);
- splitter.note(curr->right);
- }
- void visitSelect(Select* curr) {
- Splitter splitter(*this, curr);
- splitter.note(curr->ifTrue);
- splitter.note(curr->ifFalse);
- splitter.note(curr->condition);
- }
- void visitDrop(Drop* curr) {
- Splitter splitter(*this, curr);
- splitter.note(curr->value);
- }
- void visitReturn(Return* curr) {
- Splitter splitter(*this, curr);
- splitter.note(curr->value);
- }
- void visitHost(Host* curr) {
- Splitter splitter(*this, curr);
- for (auto*& operand : curr->operands) {
- splitter.note(operand);
- }
- }
-
- void visitFunction(Function* curr) {
- // removing breaks can alter types
- ReFinalize().walkFunctionInModule(curr, getModule());
- }
-};
-
-Pass *createFlattenControlFlowPass() {
- return new FlattenControlFlow();
-}
-
-} // namespace wasm
-
diff --git a/src/passes/ReReloop.cpp b/src/passes/ReReloop.cpp
index 2c212e628..7e202b002 100644
--- a/src/passes/ReReloop.cpp
+++ b/src/passes/ReReloop.cpp
@@ -18,7 +18,7 @@
// Convert the AST to a CFG, and optimize+convert it back to the AST
// using the relooper.
//
-// This pass depends on flatten-control-flow being run before it.
+// This pass depends on flatten being run before it.
//
#include <memory>
diff --git a/src/passes/pass.cpp b/src/passes/pass.cpp
index 044a97833..4e105f71d 100644
--- a/src/passes/pass.cpp
+++ b/src/passes/pass.cpp
@@ -72,7 +72,7 @@ void PassRegistry::registerPasses() {
registerPass("dce", "removes unreachable code", createDeadCodeEliminationPass);
registerPass("duplicate-function-elimination", "removes duplicate functions", createDuplicateFunctionEliminationPass);
registerPass("extract-function", "leaves just one function (useful for debugging)", createExtractFunctionPass);
- registerPass("flatten-control-flow", "flattens out control flow to be only on blocks, not nested as expressions", createFlattenControlFlowPass);
+ registerPass("flatten", "flattens out code, removing nesting", createFlattenPass);
registerPass("inlining", "inlines functions", createInliningPass);
registerPass("inlining-optimizing", "inlines functions and optimizes where we inlined", createInliningOptimizingPass);
registerPass("legalize-js-interface", "legalizes i64 types on the import/export boundary", createLegalizeJSInterfacePass);
diff --git a/src/passes/passes.h b/src/passes/passes.h
index 58a9e2b27..957ca2d68 100644
--- a/src/passes/passes.h
+++ b/src/passes/passes.h
@@ -22,55 +22,55 @@ namespace wasm {
class Pass;
// All passes:
-Pass *createCoalesceLocalsPass();
-Pass *createCoalesceLocalsWithLearningPass();
-Pass *createCodeFoldingPass();
-Pass *createCodePushingPass();
-Pass *createConstHoistingPass();
-Pass *createDeadCodeEliminationPass();
-Pass *createDuplicateFunctionEliminationPass();
-Pass *createExtractFunctionPass();
-Pass *createFlattenControlFlowPass();
-Pass *createFullPrinterPass();
-Pass *createI64ToI32LoweringPass();
-Pass *createInliningPass();
-Pass *createInliningOptimizingPass();
-Pass *createLegalizeJSInterfacePass();
-Pass *createLocalCSEPass();
-Pass *createLogExecutionPass();
-Pass *createInstrumentLocalsPass();
-Pass *createInstrumentMemoryPass();
-Pass *createMemoryPackingPass();
-Pass *createMergeBlocksPass();
-Pass *createMinifiedPrinterPass();
-Pass *createMetricsPass();
-Pass *createNameListPass();
-Pass *createOptimizeInstructionsPass();
-Pass *createPickLoadSignsPass();
-Pass *createPostEmscriptenPass();
-Pass *createPrecomputePass();
-Pass *createPrecomputePropagatePass();
-Pass *createPrinterPass();
-Pass *createPrintCallGraphPass();
-Pass *createRelooperJumpThreadingPass();
-Pass *createRemoveImportsPass();
-Pass *createRemoveMemoryPass();
-Pass *createRemoveUnusedBrsPass();
-Pass *createRemoveUnusedModuleElementsPass();
-Pass *createRemoveUnusedNamesPass();
-Pass *createReorderFunctionsPass();
-Pass *createReorderLocalsPass();
-Pass *createReReloopPass();
-Pass *createSafeHeapPass();
-Pass *createSimplifyLocalsPass();
-Pass *createSimplifyLocalsNoTeePass();
-Pass *createSimplifyLocalsNoStructurePass();
-Pass *createSimplifyLocalsNoTeeNoStructurePass();
-Pass *createSSAifyPass();
-Pass *createTrapModeClamp();
-Pass *createTrapModeJS();
-Pass *createUnteePass();
-Pass *createVacuumPass();
+Pass* createCoalesceLocalsPass();
+Pass* createCoalesceLocalsWithLearningPass();
+Pass* createCodeFoldingPass();
+Pass* createCodePushingPass();
+Pass* createConstHoistingPass();
+Pass* createDeadCodeEliminationPass();
+Pass* createDuplicateFunctionEliminationPass();
+Pass* createExtractFunctionPass();
+Pass* createFlattenPass();
+Pass* createFullPrinterPass();
+Pass* createI64ToI32LoweringPass();
+Pass* createInliningPass();
+Pass* createInliningOptimizingPass();
+Pass* createLegalizeJSInterfacePass();
+Pass* createLocalCSEPass();
+Pass* createLogExecutionPass();
+Pass* createInstrumentLocalsPass();
+Pass* createInstrumentMemoryPass();
+Pass* createMemoryPackingPass();
+Pass* createMergeBlocksPass();
+Pass* createMinifiedPrinterPass();
+Pass* createMetricsPass();
+Pass* createNameListPass();
+Pass* createOptimizeInstructionsPass();
+Pass* createPickLoadSignsPass();
+Pass* createPostEmscriptenPass();
+Pass* createPrecomputePass();
+Pass* createPrecomputePropagatePass();
+Pass* createPrinterPass();
+Pass* createPrintCallGraphPass();
+Pass* createRelooperJumpThreadingPass();
+Pass* createRemoveImportsPass();
+Pass* createRemoveMemoryPass();
+Pass* createRemoveUnusedBrsPass();
+Pass* createRemoveUnusedModuleElementsPass();
+Pass* createRemoveUnusedNamesPass();
+Pass* createReorderFunctionsPass();
+Pass* createReorderLocalsPass();
+Pass* createReReloopPass();
+Pass* createSafeHeapPass();
+Pass* createSimplifyLocalsPass();
+Pass* createSimplifyLocalsNoTeePass();
+Pass* createSimplifyLocalsNoStructurePass();
+Pass* createSimplifyLocalsNoTeeNoStructurePass();
+Pass* createSSAifyPass();
+Pass* createTrapModeClamp();
+Pass* createTrapModeJS();
+Pass* createUnteePass();
+Pass* createVacuumPass();
}
diff --git a/src/wasm-traversal.h b/src/wasm-traversal.h
index 44bd6ed3d..8384c6a6f 100644
--- a/src/wasm-traversal.h
+++ b/src/wasm-traversal.h
@@ -613,6 +613,12 @@ struct ExpressionStackWalker : public PostWalker<SubType, VisitorType> {
}
}
+ Expression* getParent() {
+ if (expressionStack.size() == 1) return nullptr;
+ assert(expressionStack.size() >= 2);
+ return expressionStack[expressionStack.size() - 2];
+ }
+
static void doPreVisit(SubType* self, Expression** currp) {
self->expressionStack.push_back(*currp);
}
diff --git a/src/wasm2asm.h b/src/wasm2asm.h
index 7be5c72f6..5d0058f26 100644
--- a/src/wasm2asm.h
+++ b/src/wasm2asm.h
@@ -386,7 +386,7 @@ Ref Wasm2AsmBuilder::processWasm(Module* wasm) {
PassRunner runner(wasm);
runner.add<AutoDrop>();
runner.add("i64-to-i32-lowering");
- runner.add("flatten-control-flow");
+ runner.add("flatten");
runner.add("vacuum");
runner.setDebug(flags.debug);
runner.run();
diff --git a/test/address.2asm.js b/test/address.2asm.js
index b2c78fca9..8dfe2dce9 100644
--- a/test/address.2asm.js
+++ b/test/address.2asm.js
@@ -15,62 +15,153 @@ function asmFunc(global, env, buffer) {
var print = env.print;
function $$0(i) {
i = i | 0;
- var wasm2asm_i32$0 = 0;
- print(HEAPU8[i >> 0] | 0 | 0);
- print(HEAPU8[(i + 1 | 0) >> 0] | 0 | 0);
- print(HEAPU8[(i + 2 | 0) >> 0] | 0 | 0);
- print(HEAPU8[(i + 25 | 0) >> 0] | 0 | 0);
- print(HEAPU16[i >> 1] | 0 | 0);
- print((wasm2asm_i32$0 = i, HEAPU8[wasm2asm_i32$0 >> 0] | 0 | 0 | (HEAPU8[(wasm2asm_i32$0 + 1 | 0) >> 0] | 0 | 0) << 8) | 0);
- print((wasm2asm_i32$0 = i, HEAPU8[(wasm2asm_i32$0 + 1 | 0) >> 0] | 0 | 0 | (HEAPU8[(wasm2asm_i32$0 + 2 | 0) >> 0] | 0 | 0) << 8) | 0);
- print(HEAPU16[(i + 2 | 0) >> 1] | 0 | 0);
- print((wasm2asm_i32$0 = i, HEAPU8[(wasm2asm_i32$0 + 25 | 0) >> 0] | 0 | 0 | (HEAPU8[(wasm2asm_i32$0 + 26 | 0) >> 0] | 0 | 0) << 8) | 0);
- print(HEAPU32[i >> 2] | 0 | 0);
- print((wasm2asm_i32$0 = i, HEAPU8[(wasm2asm_i32$0 + 1 | 0) >> 0] | 0 | 0 | (HEAPU8[(wasm2asm_i32$0 + 2 | 0) >> 0] | 0 | 0) << 8 | (HEAPU8[(wasm2asm_i32$0 + 3 | 0) >> 0] | 0 | 0) << 16 | (HEAPU8[(wasm2asm_i32$0 + 4 | 0) >> 0] | 0 | 0) << 24) | 0);
- print((wasm2asm_i32$0 = i, HEAPU8[(wasm2asm_i32$0 + 2 | 0) >> 0] | 0 | 0 | (HEAPU8[(wasm2asm_i32$0 + 3 | 0) >> 0] | 0 | 0) << 8 | (HEAPU8[(wasm2asm_i32$0 + 4 | 0) >> 0] | 0 | 0) << 16 | (HEAPU8[(wasm2asm_i32$0 + 5 | 0) >> 0] | 0 | 0) << 24) | 0);
- print((wasm2asm_i32$0 = i, HEAPU8[(wasm2asm_i32$0 + 25 | 0) >> 0] | 0 | 0 | (HEAPU8[(wasm2asm_i32$0 + 26 | 0) >> 0] | 0 | 0) << 8 | (HEAPU8[(wasm2asm_i32$0 + 27 | 0) >> 0] | 0 | 0) << 16 | (HEAPU8[(wasm2asm_i32$0 + 28 | 0) >> 0] | 0 | 0) << 24) | 0);
+ var $$1 = 0, $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0, $$11 = 0, $$12 = 0, $$13 = 0, $$14 = 0, $$15 = 0, $$16 = 0, $$17 = 0, $$18 = 0, $$19 = 0, $$20 = 0, $$21 = 0, $$22 = 0, $$23 = 0, $$24 = 0, $$25 = 0, $$26 = 0, wasm2asm_i32$0 = 0;
+ $$1 = i;
+ $$2 = HEAPU8[$$1 >> 0] | 0;
+ print($$2 | 0);
+ $$3 = i;
+ $$4 = HEAPU8[($$3 + 1 | 0) >> 0] | 0;
+ print($$4 | 0);
+ $$5 = i;
+ $$6 = HEAPU8[($$5 + 2 | 0) >> 0] | 0;
+ print($$6 | 0);
+ $$7 = i;
+ $$8 = HEAPU8[($$7 + 25 | 0) >> 0] | 0;
+ print($$8 | 0);
+ $$9 = i;
+ $$10 = HEAPU16[$$9 >> 1] | 0;
+ print($$10 | 0);
+ $$11 = i;
+ $$12 = (wasm2asm_i32$0 = $$11, HEAPU8[wasm2asm_i32$0 >> 0] | 0 | 0 | (HEAPU8[(wasm2asm_i32$0 + 1 | 0) >> 0] | 0 | 0) << 8);
+ print($$12 | 0);
+ $$13 = i;
+ $$14 = (wasm2asm_i32$0 = $$13, HEAPU8[(wasm2asm_i32$0 + 1 | 0) >> 0] | 0 | 0 | (HEAPU8[(wasm2asm_i32$0 + 2 | 0) >> 0] | 0 | 0) << 8);
+ print($$14 | 0);
+ $$15 = i;
+ $$16 = HEAPU16[($$15 + 2 | 0) >> 1] | 0;
+ print($$16 | 0);
+ $$17 = i;
+ $$18 = (wasm2asm_i32$0 = $$17, HEAPU8[(wasm2asm_i32$0 + 25 | 0) >> 0] | 0 | 0 | (HEAPU8[(wasm2asm_i32$0 + 26 | 0) >> 0] | 0 | 0) << 8);
+ print($$18 | 0);
+ $$19 = i;
+ $$20 = HEAPU32[$$19 >> 2] | 0;
+ print($$20 | 0);
+ $$21 = i;
+ $$22 = (wasm2asm_i32$0 = $$21, HEAPU8[(wasm2asm_i32$0 + 1 | 0) >> 0] | 0 | 0 | (HEAPU8[(wasm2asm_i32$0 + 2 | 0) >> 0] | 0 | 0) << 8 | (HEAPU8[(wasm2asm_i32$0 + 3 | 0) >> 0] | 0 | 0) << 16 | (HEAPU8[(wasm2asm_i32$0 + 4 | 0) >> 0] | 0 | 0) << 24);
+ print($$22 | 0);
+ $$23 = i;
+ $$24 = (wasm2asm_i32$0 = $$23, HEAPU8[(wasm2asm_i32$0 + 2 | 0) >> 0] | 0 | 0 | (HEAPU8[(wasm2asm_i32$0 + 3 | 0) >> 0] | 0 | 0) << 8 | (HEAPU8[(wasm2asm_i32$0 + 4 | 0) >> 0] | 0 | 0) << 16 | (HEAPU8[(wasm2asm_i32$0 + 5 | 0) >> 0] | 0 | 0) << 24);
+ print($$24 | 0);
+ $$25 = i;
+ $$26 = (wasm2asm_i32$0 = $$25, HEAPU8[(wasm2asm_i32$0 + 25 | 0) >> 0] | 0 | 0 | (HEAPU8[(wasm2asm_i32$0 + 26 | 0) >> 0] | 0 | 0) << 8 | (HEAPU8[(wasm2asm_i32$0 + 27 | 0) >> 0] | 0 | 0) << 16 | (HEAPU8[(wasm2asm_i32$0 + 28 | 0) >> 0] | 0 | 0) << 24);
+ print($$26 | 0);
}
function $$1(i) {
i = i | 0;
- HEAPU32[(i + 4294967295 | 0) >> 2] | 0;
+ var $$1 = 0, $$2 = 0;
+ $$1 = i;
+ $$2 = HEAPU32[($$1 + 4294967295 | 0) >> 2] | 0;
}
function __wasm_ctz_i32(x) {
x = x | 0;
- var $$1 = 0;
- if ((x | 0) == (0 | 0)) $$1 = 32; else $$1 = 31 - Math_clz32(x ^ (x - 1 | 0) | 0) | 0;
- return $$1 | 0;
+ var $$1 = 0, $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0;
+ $$1 = x;
+ $$2 = ($$1 | 0) == (0 | 0);
+ if ($$2) $$9 = 32; else {
+ $$3 = x;
+ $$4 = x;
+ $$5 = $$4 - 1 | 0;
+ $$6 = $$3 ^ $$5 | 0;
+ $$7 = Math_clz32($$6);
+ $$8 = 31 - $$7 | 0;
+ $$9 = $$8;
+ }
+ $$10 = $$9;
+ return $$10 | 0;
}
function __wasm_popcnt_i32(x) {
x = x | 0;
- var count = 0, $$2 = 0, $$3 = 0;
+ var count = 0, $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0, $$11 = 0, $$12 = 0, $$13 = 0, $$14 = 0, $$15 = 0;
count = 0;
b : {
l : do {
$$2 = count;
- if ((x | 0) == (0 | 0)) break b;
- x = x & (x - 1 | 0) | 0;
- count = count + 1 | 0;
+ $$3 = x;
+ $$4 = ($$3 | 0) == (0 | 0);
+ $$5 = $$2;
+ if ($$4) break b;
+ $$6 = $$5;
+ $$7 = x;
+ $$8 = x;
+ $$9 = $$8 - 1 | 0;
+ $$10 = $$7 & $$9 | 0;
+ x = $$10;
+ $$11 = count;
+ $$12 = $$11 + 1 | 0;
+ count = $$12;
continue l;
break l;
} while (1);
};
- $$3 = $$2;
- return $$3 | 0;
+ $$13 = $$5;
+ $$14 = $$13;
+ $$15 = $$14;
+ return $$15 | 0;
}
function __wasm_rotl_i32(x, k) {
x = x | 0;
k = k | 0;
- return ((4294967295 >>> (k & 31 | 0) | 0) & x | 0) << (k & 31 | 0) | 0 | (((4294967295 << (32 - (k & 31 | 0) | 0) | 0) & x | 0) >>> (32 - (k & 31 | 0) | 0) | 0) | 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0, $$11 = 0, $$12 = 0, $$13 = 0, $$14 = 0, $$15 = 0, $$16 = 0, $$17 = 0, $$18 = 0, $$19 = 0, $$20 = 0;
+ $$2 = k;
+ $$3 = $$2 & 31 | 0;
+ $$4 = 4294967295 >>> $$3 | 0;
+ $$5 = x;
+ $$6 = $$4 & $$5 | 0;
+ $$7 = k;
+ $$8 = $$7 & 31 | 0;
+ $$9 = $$6 << $$8 | 0;
+ $$10 = k;
+ $$11 = $$10 & 31 | 0;
+ $$12 = 32 - $$11 | 0;
+ $$13 = 4294967295 << $$12 | 0;
+ $$14 = x;
+ $$15 = $$13 & $$14 | 0;
+ $$16 = k;
+ $$17 = $$16 & 31 | 0;
+ $$18 = 32 - $$17 | 0;
+ $$19 = $$15 >>> $$18 | 0;
+ $$20 = $$9 | $$19 | 0;
+ return $$20 | 0;
}
function __wasm_rotr_i32(x, k) {
x = x | 0;
k = k | 0;
- return ((4294967295 << (k & 31 | 0) | 0) & x | 0) >>> (k & 31 | 0) | 0 | (((4294967295 >>> (32 - (k & 31 | 0) | 0) | 0) & x | 0) << (32 - (k & 31 | 0) | 0) | 0) | 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0, $$11 = 0, $$12 = 0, $$13 = 0, $$14 = 0, $$15 = 0, $$16 = 0, $$17 = 0, $$18 = 0, $$19 = 0, $$20 = 0;
+ $$2 = k;
+ $$3 = $$2 & 31 | 0;
+ $$4 = 4294967295 << $$3 | 0;
+ $$5 = x;
+ $$6 = $$4 & $$5 | 0;
+ $$7 = k;
+ $$8 = $$7 & 31 | 0;
+ $$9 = $$6 >>> $$8 | 0;
+ $$10 = k;
+ $$11 = $$10 & 31 | 0;
+ $$12 = 32 - $$11 | 0;
+ $$13 = 4294967295 >>> $$12 | 0;
+ $$14 = x;
+ $$15 = $$13 & $$14 | 0;
+ $$16 = k;
+ $$17 = $$16 & 31 | 0;
+ $$18 = 32 - $$17 | 0;
+ $$19 = $$15 << $$18 | 0;
+ $$20 = $$9 | $$19 | 0;
+ return $$20 | 0;
}
return {
diff --git a/test/br_table_temp.2asm.js b/test/br_table_temp.2asm.js
index 5089246e1..748f1eec9 100644
--- a/test/br_table_temp.2asm.js
+++ b/test/br_table_temp.2asm.js
@@ -33,7 +33,7 @@ function asmFunc(global, env, buffer) {
}
function $$5() {
- var $$0 = 0, $$1 = 0;
+ var $$0 = 0, $$1 = 0, $$2 = 0;
block : {
$$0 = 1;
$$1 = $$0;
@@ -44,11 +44,12 @@ function asmFunc(global, env, buffer) {
break block;
};
};
- return $$1 | 0;
+ $$2 = $$1;
+ return $$2 | 0;
}
function $$6() {
- var i64toi32_i32$0 = 0, i64toi32_i32$1 = 0, i64toi32_i32$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0;
+ var i64toi32_i32$0 = 0, i64toi32_i32$1 = 0, i64toi32_i32$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0, $$11 = 0, $$12 = 0, $$13 = 0, $$14 = 0, $$15 = 0;
block : {
$i64toi32_block_1 : {
$i64toi32_block_0 : {
@@ -56,7 +57,8 @@ function asmFunc(global, env, buffer) {
$$3 = 2;
$$4 = $$3;
$$5 = $$4;
- $$6 = $$4;
+ $$6 = $$5;
+ $$7 = $$5;
switch (0 | 0) {
case 0:
break $i64toi32_block_0;
@@ -64,21 +66,28 @@ function asmFunc(global, env, buffer) {
break $i64toi32_block_1;
};
};
- i64toi32_i32$1 = $$5;
- i64toi32_i32$2 = i64toi32_i32$0;
- $$7 = i64toi32_i32$1;
+ $$8 = $$6;
+ i64toi32_i32$1 = $$8;
+ $$9 = i64toi32_i32$0;
+ i64toi32_i32$2 = $$9;
+ $$10 = i64toi32_i32$1;
+ $$11 = $$10;
break block;
};
- i64toi32_i32$1 = $$6;
- i64toi32_i32$2 = i64toi32_i32$0;
- $$7 = i64toi32_i32$1;
+ $$12 = $$7;
+ i64toi32_i32$1 = $$12;
+ $$13 = i64toi32_i32$0;
+ i64toi32_i32$2 = $$13;
+ $$14 = i64toi32_i32$1;
+ $$11 = $$14;
break block;
};
- return $$7 | 0;
+ $$15 = $$11;
+ return $$15 | 0;
}
function $$7() {
- var $$0 = Math_fround(0), $$1 = Math_fround(0);
+ var $$0 = Math_fround(0), $$1 = Math_fround(0), $$2 = Math_fround(0);
block : {
$$0 = Math_fround(3.0);
$$1 = $$0;
@@ -89,11 +98,12 @@ function asmFunc(global, env, buffer) {
break block;
};
};
- return Math_fround($$1);
+ $$2 = $$1;
+ return Math_fround($$2);
}
function $$8() {
- var $$0 = 0.0, $$1 = 0.0;
+ var $$0 = 0.0, $$1 = 0.0, $$2 = 0.0;
block : {
$$0 = 4.0;
$$1 = $$0;
@@ -104,42 +114,48 @@ function asmFunc(global, env, buffer) {
break block;
};
};
- return +$$1;
+ $$2 = $$1;
+ return +$$2;
}
function $$9($$0) {
$$0 = $$0 | 0;
- var $$1 = 0;
+ var $$1 = 0, $$2 = 0, $$3 = 0;
block : {
- switch ($$0 | 0) {
+ $$1 = $$0;
+ switch ($$1 | 0) {
default:
break block;
};
};
- $$1 = 22;
- return $$1 | 0;
+ $$2 = 22;
+ $$3 = $$2;
+ return $$3 | 0;
}
function $$10($$0) {
$$0 = $$0 | 0;
- var $$1 = 0, $$2 = 0;
+ var $$1 = 0, $$2 = 0, $$3 = 0, $$4 = 0;
block : {
- $$1 = 33;
- $$2 = $$1;
- switch ($$0 | 0) {
+ $$1 = $$0;
+ $$2 = 33;
+ $$3 = $$2;
+ switch ($$1 | 0) {
default:
break block;
};
};
- return $$2 | 0;
+ $$4 = $$3;
+ return $$4 | 0;
}
function $$11($$0) {
$$0 = $$0 | 0;
- var $$1 = 0;
+ var $$1 = 0, $$2 = 0, $$3 = 0;
block : {
block0 : {
- switch ($$0 | 0) {
+ $$1 = $$0;
+ switch ($$1 | 0) {
case 0:
break block;
default:
@@ -148,39 +164,44 @@ function asmFunc(global, env, buffer) {
};
return 20 | 0;
};
- $$1 = 22;
- return $$1 | 0;
+ $$2 = 22;
+ $$3 = $$2;
+ return $$3 | 0;
}
function $$12($$0) {
$$0 = $$0 | 0;
- var $$1 = 0, $$2 = 0, $$3 = 0;
+ var $$1 = 0, $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0;
block : {
block1 : {
- $$1 = 33;
- $$2 = $$1;
- $$3 = $$1;
- switch ($$0 | 0) {
+ $$1 = $$0;
+ $$2 = 33;
+ $$3 = $$2;
+ $$4 = $$2;
+ switch ($$1 | 0) {
case 0:
break block1;
default:
break block;
};
};
+ $$5 = $$4;
$$3 = 32;
};
- return $$3 | 0;
+ $$6 = $$3;
+ return $$6 | 0;
}
function $$13($$0) {
$$0 = $$0 | 0;
- var $$1 = 0;
+ var $$1 = 0, $$2 = 0, $$3 = 0;
block : {
block2 : {
block3 : {
block4 : {
block5 : {
- switch ($$0 | 0) {
+ $$1 = $$0;
+ switch ($$1 | 0) {
case 0:
break block2;
case 1:
@@ -201,25 +222,27 @@ function asmFunc(global, env, buffer) {
};
return 103 | 0;
};
- $$1 = 104;
- return $$1 | 0;
+ $$2 = 104;
+ $$3 = $$2;
+ return $$3 | 0;
}
function $$14($$0) {
$$0 = $$0 | 0;
- var $$1 = 0, $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0;
+ var $$1 = 0, $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0, $$11 = 0, $$12 = 0, $$13 = 0, $$14 = 0, $$15 = 0, $$16 = 0, $$17 = 0, $$18 = 0, $$19 = 0, $$20 = 0, $$21 = 0, $$22 = 0, $$23 = 0, $$24 = 0, $$25 = 0, $$26 = 0, $$27 = 0;
block : {
block6 : {
block7 : {
block8 : {
block9 : {
- $$2 = 200;
- $$3 = $$2;
- $$4 = $$2;
- $$5 = $$2;
- $$6 = $$2;
- $$7 = $$2;
- switch ($$0 | 0) {
+ $$2 = $$0;
+ $$3 = 200;
+ $$4 = $$3;
+ $$5 = $$3;
+ $$6 = $$3;
+ $$7 = $$3;
+ $$8 = $$3;
+ switch ($$2 | 0) {
case 0:
break block6;
case 1:
@@ -232,28 +255,46 @@ function asmFunc(global, env, buffer) {
break block;
};
};
- $$1 = $$6;
- return $$1 + 10 | 0 | 0;
+ $$11 = $$8;
+ $$1 = $$11;
+ $$12 = $$1;
+ $$13 = $$12 + 10 | 0;
+ return $$13 | 0;
};
- $$1 = $$5;
- return $$1 + 11 | 0 | 0;
+ $$14 = $$7;
+ $$1 = $$14;
+ $$15 = $$1;
+ $$16 = $$15 + 11 | 0;
+ return $$16 | 0;
};
- $$1 = $$4;
- return $$1 + 12 | 0 | 0;
+ $$17 = $$6;
+ $$1 = $$17;
+ $$18 = $$1;
+ $$19 = $$18 + 12 | 0;
+ return $$19 | 0;
};
- $$1 = $$3;
- return $$1 + 13 | 0 | 0;
+ $$20 = $$5;
+ $$1 = $$20;
+ $$21 = $$1;
+ $$22 = $$21 + 13 | 0;
+ return $$22 | 0;
};
- $$1 = $$7;
- $$8 = $$1 + 14 | 0;
- return $$8 | 0;
+ $$23 = $$4;
+ $$1 = $$23;
+ $$24 = $$1;
+ $$25 = $$24 + 14 | 0;
+ $$26 = $$25;
+ $$27 = $$26;
+ return $$27 | 0;
}
function $$15($$0) {
$$0 = $$0 | 0;
+ var $$1 = 0;
block : {
block10 : {
- switch ($$0 | 0) {
+ $$1 = $$0;
+ switch ($$1 | 0) {
case 0:
break block10;
case 1:
@@ -49526,7 +49567,7 @@ function asmFunc(global, env, buffer) {
}
function $$19() {
- var $$0 = 0, $$1 = 0;
+ var $$0 = 0, $$1 = 0, $$2 = 0;
block : {
dummy();
$$0 = 2;
@@ -49540,11 +49581,12 @@ function asmFunc(global, env, buffer) {
break block;
};
};
- return $$1 | 0;
+ $$2 = $$1;
+ return $$2 | 0;
}
function $$20() {
- var $$0 = 0, $$1 = 0, $$2 = 0, $$3 = 0;
+ var $$0 = 0, $$1 = 0, $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0;
fake_return_waka123 : {
loop_in : do {
$$0 = 3;
@@ -49558,11 +49600,12 @@ function asmFunc(global, env, buffer) {
break loop_in;
} while (1);
};
- return $$1 | 0;
+ $$6 = $$1;
+ return $$6 | 0;
}
function $$21() {
- var $$0 = 0, $$1 = 0, $$2 = 0, $$3 = 0;
+ var $$0 = 0, $$1 = 0, $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0;
fake_return_waka123 : {
loop_in : do {
dummy();
@@ -49579,11 +49622,12 @@ function asmFunc(global, env, buffer) {
break loop_in;
} while (1);
};
- return $$1 | 0;
+ $$6 = $$1;
+ return $$6 | 0;
}
function $$22() {
- var $$0 = 0, $$1 = 0;
+ var $$0 = 0, $$1 = 0, $$2 = 0;
fake_return_waka123 : {
loop_in : do {
dummy();
@@ -49600,16 +49644,18 @@ function asmFunc(global, env, buffer) {
break loop_in;
} while (1);
};
- return $$1 | 0;
+ $$2 = $$1;
+ return $$2 | 0;
}
function $$23() {
- var $$0 = 0;
+ var $$0 = 0, $$1 = 0;
block : {
$$0 = 9;
break block;
};
- return $$0 | 0;
+ $$1 = $$0;
+ return $$1 | 0;
}
function $$24() {
@@ -49617,7 +49663,7 @@ function asmFunc(global, env, buffer) {
}
function $$25() {
- var $$0 = 0, $$1 = 0;
+ var $$0 = 0, $$1 = 0, $$2 = 0;
block : {
$$0 = 8;
$$1 = $$0;
@@ -49626,11 +49672,12 @@ function asmFunc(global, env, buffer) {
break block;
};
};
- return $$1 | 0;
+ $$2 = $$1;
+ return $$2 | 0;
}
function $$26() {
- var $$0 = 0, $$1 = 0;
+ var $$0 = 0, $$1 = 0, $$2 = 0;
block : {
$$0 = 9;
$$1 = $$0;
@@ -49641,7 +49688,8 @@ function asmFunc(global, env, buffer) {
break block;
};
};
- return $$1 | 0;
+ $$2 = $$1;
+ return $$2 | 0;
}
function $$27() {
@@ -49649,7 +49697,7 @@ function asmFunc(global, env, buffer) {
}
function $$28() {
- var $$0 = 0, $$1 = 0;
+ var $$0 = 0, $$1 = 0, $$2 = 0;
block : {
$$0 = 10;
$$1 = $$0;
@@ -49658,11 +49706,12 @@ function asmFunc(global, env, buffer) {
break block;
};
};
- return $$1 | 0;
+ $$2 = $$1;
+ return $$2 | 0;
}
function $$29() {
- var $$0 = 0, $$1 = 0, $$2 = 0;
+ var $$0 = 0, $$1 = 0, $$2 = 0, $$3 = 0;
block : {
$$0 = 11;
$$1 = $$0;
@@ -49671,72 +49720,92 @@ function asmFunc(global, env, buffer) {
break block;
};
};
- return $$1 | 0;
+ $$3 = $$1;
+ return $$3 | 0;
}
function $$30() {
- var i64toi32_i32$0 = 0, i64toi32_i32$1 = 0, i64toi32_i32$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0;
+ var i64toi32_i32$0 = 0, i64toi32_i32$1 = 0, i64toi32_i32$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0, $$11 = 0;
block : {
$i64toi32_block_0 : {
i64toi32_i32$0 = 0;
$$3 = 7;
$$4 = $$3;
$$5 = $$4;
+ $$6 = $$5;
switch (0 | 0) {
default:
break $i64toi32_block_0;
};
};
- i64toi32_i32$1 = $$5;
- i64toi32_i32$2 = i64toi32_i32$0;
- $$6 = i64toi32_i32$1;
+ $$7 = $$6;
+ i64toi32_i32$1 = $$7;
+ $$8 = i64toi32_i32$0;
+ i64toi32_i32$2 = $$8;
+ $$9 = i64toi32_i32$1;
+ $$10 = $$9;
break block;
};
- return $$6 | 0;
+ $$11 = $$10;
+ return $$11 | 0;
}
function $$31() {
- var $$0 = 0, $$1 = 0, $$2 = 0, $$3 = 0;
- $$if : {
- $$0 = 2;
- $$1 = $$0;
- switch (0 | 0) {
- default:
- break $$if;
+ var $$0 = 0, $$1 = 0, $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0;
+ block : {
+ $$if : {
+ $$0 = 2;
+ $$1 = $$0;
+ switch (0 | 0) {
+ default:
+ break $$if;
+ };
};
+ $$4 = $$1;
+ $$5 = $$4;
};
- $$3 = $$1;
- return $$3 | 0;
+ $$6 = $$5;
+ return $$6 | 0;
}
function $$32($$0, $$1) {
$$0 = $$0 | 0;
$$1 = $$1 | 0;
- var $$2 = 0, $$3 = 0, $$4 = 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0;
block : {
- if ($$0) {
- $$2 = 3;
- $$3 = $$2;
+ $$2 = $$0;
+ if ($$2) {
+ $$3 = 3;
+ $$4 = $$3;
switch (0 | 0) {
default:
break block;
};
- } else $$4 = $$1;
- $$3 = $$4;
+ } else {
+ $$5 = $$1;
+ $$6 = $$5;
+ }
+ $$7 = $$6;
+ $$4 = $$7;
};
- return $$3 | 0;
+ $$8 = $$4;
+ return $$8 | 0;
}
function $$33($$0, $$1) {
$$0 = $$0 | 0;
$$1 = $$1 | 0;
- var $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0;
block : {
$$if : {
- if ($$0) $$5 = $$1; else {
- $$2 = 4;
- $$3 = $$2;
- $$4 = $$2;
+ $$2 = $$0;
+ if ($$2) {
+ $$3 = $$1;
+ $$7 = $$3;
+ } else {
+ $$4 = 4;
+ $$5 = $$4;
+ $$6 = $$4;
switch (0 | 0) {
case 0:
break block;
@@ -49744,17 +49813,20 @@ function asmFunc(global, env, buffer) {
break $$if;
};
}
- $$4 = $$5;
+ $$8 = $$7;
+ $$6 = $$8;
};
- $$3 = $$4;
+ $$9 = $$6;
+ $$5 = $$9;
};
- return $$3 | 0;
+ $$10 = $$5;
+ return $$10 | 0;
}
function $$34($$0, $$1) {
$$0 = $$0 | 0;
$$1 = $$1 | 0;
- var $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0;
block : {
$$2 = 5;
$$3 = $$2;
@@ -49763,30 +49835,30 @@ function asmFunc(global, env, buffer) {
break block;
};
};
- return $$3 | 0;
+ $$6 = $$3;
+ return $$6 | 0;
}
function $$35($$0, $$1) {
$$0 = $$0 | 0;
$$1 = $$1 | 0;
- var $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0;
block : {
- $$4 = $$0;
- $$2 = 6;
- $$3 = $$2;
+ $$2 = $$0;
+ $$3 = 6;
+ $$4 = $$3;
switch (1 | 0) {
default:
break block;
};
};
- return $$3 | 0;
+ $$6 = $$4;
+ return $$6 | 0;
}
function $$36() {
- var $$0 = 0, $$1 = 0, $$2 = 0, $$3 = 0;
+ var $$0 = 0, $$1 = 0, $$2 = 0;
block : {
- $$2 = 0;
- $$3 = 1;
$$0 = 7;
$$1 = $$0;
switch (1 | 0) {
@@ -49794,18 +49866,21 @@ function asmFunc(global, env, buffer) {
break block;
};
};
- return $$1 | 0;
+ $$2 = $$1;
+ return $$2 | 0;
}
function f($$0, $$1, $$2) {
$$0 = $$0 | 0;
$$1 = $$1 | 0;
$$2 = $$2 | 0;
+ var wasm2asm_i32$0 = 0;
return 4294967295 | 0;
+ return wasm2asm_i32$0 | 0;
}
function $$38() {
- var $$0 = 0, $$1 = 0, $$2 = 0, $$3 = 0;
+ var $$0 = 0, $$1 = 0, $$2 = 0;
block : {
$$0 = 12;
$$1 = $$0;
@@ -49814,13 +49889,13 @@ function asmFunc(global, env, buffer) {
break block;
};
};
- return $$1 | 0;
+ $$2 = $$1;
+ return $$2 | 0;
}
function $$39() {
- var $$0 = 0, $$1 = 0, $$2 = 0, $$3 = 0;
+ var $$0 = 0, $$1 = 0, $$2 = 0;
block : {
- $$2 = 1;
$$0 = 13;
$$1 = $$0;
switch (1 | 0) {
@@ -49828,14 +49903,13 @@ function asmFunc(global, env, buffer) {
break block;
};
};
- return $$1 | 0;
+ $$2 = $$1;
+ return $$2 | 0;
}
function $$40() {
- var $$0 = 0, $$1 = 0, $$2 = 0, $$3 = 0;
+ var $$0 = 0, $$1 = 0, $$2 = 0;
block : {
- $$2 = 1;
- $$3 = 2;
$$0 = 14;
$$1 = $$0;
switch (1 | 0) {
@@ -49843,11 +49917,12 @@ function asmFunc(global, env, buffer) {
break block;
};
};
- return $$1 | 0;
+ $$2 = $$1;
+ return $$2 | 0;
}
function $$41() {
- var $$0 = 0, $$1 = 0, $$2 = 0, $$3 = 0, $$4 = 0;
+ var $$0 = 0, $$1 = 0, $$2 = 0;
block : {
$$0 = 20;
$$1 = $$0;
@@ -49856,13 +49931,13 @@ function asmFunc(global, env, buffer) {
break block;
};
};
- return $$1 | 0;
+ $$2 = $$1;
+ return $$2 | 0;
}
function $$42() {
- var $$0 = 0, $$1 = 0, $$2 = 0, $$3 = 0, $$4 = 0;
+ var $$0 = 0, $$1 = 0, $$2 = 0;
block : {
- $$2 = 0;
$$0 = 21;
$$1 = $$0;
switch (1 | 0) {
@@ -49870,14 +49945,13 @@ function asmFunc(global, env, buffer) {
break block;
};
};
- return $$1 | 0;
+ $$2 = $$1;
+ return $$2 | 0;
}
function $$43() {
- var $$0 = 0, $$1 = 0, $$2 = 0, $$3 = 0, $$4 = 0;
+ var $$0 = 0, $$1 = 0, $$2 = 0;
block : {
- $$2 = 0;
- $$3 = 1;
$$0 = 22;
$$1 = $$0;
switch (1 | 0) {
@@ -49885,15 +49959,13 @@ function asmFunc(global, env, buffer) {
break block;
};
};
- return $$1 | 0;
+ $$2 = $$1;
+ return $$2 | 0;
}
function $$44() {
- var $$0 = 0, $$1 = 0, $$2 = 0, $$3 = 0, $$4 = 0;
+ var $$0 = 0, $$1 = 0, $$2 = 0;
block : {
- $$2 = 0;
- $$3 = 1;
- $$4 = 2;
$$0 = 23;
$$1 = $$0;
switch (1 | 0) {
@@ -49901,11 +49973,12 @@ function asmFunc(global, env, buffer) {
break block;
};
};
- return $$1 | 0;
+ $$2 = $$1;
+ return $$2 | 0;
}
function $$45() {
- var $$0 = Math_fround(0), $$1 = 0, $$2 = 0;
+ var $$0 = Math_fround(0), $$1 = 0, $$2 = 0, $$3 = 0;
block : {
$$1 = 17;
$$2 = $$1;
@@ -49914,11 +49987,12 @@ function asmFunc(global, env, buffer) {
break block;
};
};
- return $$2 | 0;
+ $$3 = $$2;
+ return $$3 | 0;
}
function $$46() {
- var $$0 = 0, $$1 = 0;
+ var $$0 = 0, $$1 = 0, $$2 = 0;
block : {
$$0 = 2;
$$1 = $$0;
@@ -49927,32 +50001,38 @@ function asmFunc(global, env, buffer) {
break block;
};
};
- return $$1 | 0;
+ $$2 = $$1;
+ return $$2 | 0;
}
function $$47() {
- var i64toi32_i32$0 = 0, i64toi32_i32$1 = 0, i64toi32_i32$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0;
+ var i64toi32_i32$0 = 0, i64toi32_i32$1 = 0, i64toi32_i32$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0, $$11 = 0;
block : {
$i64toi32_block_0 : {
i64toi32_i32$0 = 0;
$$3 = 30;
$$4 = $$3;
$$5 = $$4;
+ $$6 = $$5;
switch (1 | 0) {
default:
break $i64toi32_block_0;
};
};
- i64toi32_i32$1 = $$5;
- i64toi32_i32$2 = i64toi32_i32$0;
- $$6 = i64toi32_i32$1;
+ $$7 = $$6;
+ i64toi32_i32$1 = $$7;
+ $$8 = i64toi32_i32$0;
+ i64toi32_i32$2 = $$8;
+ $$9 = i64toi32_i32$1;
+ $$10 = $$9;
break block;
};
- return $$6 | 0;
+ $$11 = $$10;
+ return $$11 | 0;
}
function $$48() {
- var $$0 = 0, $$1 = 0, $$2 = 0.0;
+ var $$0 = 0, $$1 = 0, $$2 = 0;
block : {
$$0 = 30;
$$1 = $$0;
@@ -49961,13 +50041,13 @@ function asmFunc(global, env, buffer) {
break block;
};
};
- return $$1 | 0;
+ $$2 = $$1;
+ return $$2 | 0;
}
function $$49() {
var $$0 = 0, $$1 = 0, $$2 = 0;
block : {
- $$2 = 2;
$$0 = 31;
$$1 = $$0;
switch (1 | 0) {
@@ -49975,7 +50055,8 @@ function asmFunc(global, env, buffer) {
break block;
};
};
- return $$1 | 0;
+ $$2 = $$1;
+ return $$2 | 0;
}
function $$50() {
@@ -49988,13 +50069,13 @@ function asmFunc(global, env, buffer) {
break block;
};
};
- return $$1 | 0;
+ $$2 = $$1;
+ return $$2 | 0;
}
function $$51() {
var $$0 = 0, $$1 = 0, $$2 = 0;
block : {
- $$2 = 2;
$$0 = 33;
$$1 = $$0;
switch (0 | 0) {
@@ -50002,11 +50083,12 @@ function asmFunc(global, env, buffer) {
break block;
};
};
- return $$1 | 0;
+ $$2 = $$1;
+ return $$2 | 0;
}
function $$52() {
- var $$0 = 0, $$1 = 0;
+ var $$0 = 0, $$1 = 0, $$2 = 0;
block : {
$$0 = 3;
$$1 = $$0;
@@ -50015,7 +50097,8 @@ function asmFunc(global, env, buffer) {
break block;
};
};
- return $$1 | 0;
+ $$2 = $$1;
+ return $$2 | 0;
}
function $$53() {
@@ -50030,34 +50113,41 @@ function asmFunc(global, env, buffer) {
break block;
};
};
- return $$1 | 0;
+ $$2 = $$1;
+ return $$2 | 0;
}
function $$54() {
- var i64toi32_i32$0 = 0, i64toi32_i32$1 = 0, i64toi32_i32$2 = 0, i64toi32_i32$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0;
+ var i64toi32_i32$0 = 0, i64toi32_i32$1 = 0, i64toi32_i32$2 = 0, i64toi32_i32$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0, $$11 = 0, $$12 = 0, $$13 = 0, $$14 = 0;
block : {
i64toi32_i32$0 = 0;
$$4 = 10;
+ $$5 = $$4;
$i64toi32_block_0 : {
i64toi32_i32$1 = 0;
- $$5 = 45;
- $$6 = $$5;
+ $$6 = 45;
$$7 = $$6;
+ $$8 = $$7;
+ $$9 = $$8;
switch (0 | 0) {
default:
break $i64toi32_block_0;
};
};
- i64toi32_i32$2 = $$7;
- i64toi32_i32$3 = i64toi32_i32$1;
- $$8 = i64toi32_i32$2;
+ $$10 = $$9;
+ i64toi32_i32$2 = $$10;
+ $$11 = i64toi32_i32$1;
+ i64toi32_i32$3 = $$11;
+ $$12 = i64toi32_i32$2;
+ $$13 = $$12;
break block;
};
- return $$8 | 0;
+ $$14 = $$13;
+ return $$14 | 0;
}
function $$55() {
- var $$0 = 0, $$1 = 0;
+ var $$0 = 0, $$1 = 0, $$2 = 0;
block : {
$$0 = 44;
$$1 = $$0;
@@ -50066,11 +50156,12 @@ function asmFunc(global, env, buffer) {
break block;
};
};
- return $$1 | 0;
+ $$2 = $$1;
+ return $$2 | 0;
}
function $$56() {
- var $$0 = 0, $$1 = 0, $$2 = 0.0;
+ var $$0 = 0, $$1 = 0, $$2 = 0;
block : {
$$0 = 43;
$$1 = $$0;
@@ -50081,13 +50172,13 @@ function asmFunc(global, env, buffer) {
break block;
};
};
- return $$1 | 0;
+ $$2 = $$1;
+ return $$2 | 0;
}
function $$57() {
- var $$0 = 0, $$1 = 0, $$2 = Math_fround(0);
+ var $$0 = 0, $$1 = 0, $$2 = 0;
block : {
- $$2 = Math_fround(10.0);
$$0 = 42;
$$1 = $$0;
switch (0 | 0) {
@@ -50095,11 +50186,12 @@ function asmFunc(global, env, buffer) {
break block;
};
};
- return $$1 | 0;
+ $$2 = $$1;
+ return $$2 | 0;
}
function $$58() {
- var $$0 = 0, $$1 = 0;
+ var $$0 = 0, $$1 = 0, $$2 = 0;
block : {
$$0 = 41;
$$1 = $$0;
@@ -50108,11 +50200,12 @@ function asmFunc(global, env, buffer) {
break block;
};
};
- return $$1 | 0;
+ $$2 = $$1;
+ return $$2 | 0;
}
function $$59() {
- var $$0 = 0, $$1 = 0;
+ var $$0 = 0, $$1 = 0, $$2 = 0;
block : {
$$0 = 40;
$$1 = $$0;
@@ -50121,23 +50214,22 @@ function asmFunc(global, env, buffer) {
break block;
};
};
- return $$1 | 0;
+ $$2 = $$1;
+ return $$2 | 0;
}
function $$60($$0) {
$$0 = $$0 | 0;
- var $$1 = 0, $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0;
+ var $$1 = 0, $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0;
block : {
- $$8 = 1;
block11 : {
- $$6 = 2;
block12 : {
- $$5 = 8;
- $$1 = 16;
- $$2 = $$1;
- $$3 = $$1;
- $$4 = $$1;
- switch ($$0 | 0) {
+ $$1 = $$0;
+ $$2 = 16;
+ $$3 = $$2;
+ $$4 = $$2;
+ $$5 = $$2;
+ switch ($$1 | 0) {
case 0:
break block12;
case 1:
@@ -50146,27 +50238,30 @@ function asmFunc(global, env, buffer) {
break block;
};
};
- $$7 = $$6 + $$2 | 0;
- $$3 = $$7;
+ $$6 = $$5;
+ $$7 = 2 + $$6 | 0;
+ $$4 = $$7;
};
- $$9 = $$8 + $$3 | 0;
- $$4 = $$9;
+ $$8 = $$4;
+ $$9 = 1 + $$8 | 0;
+ $$3 = $$9;
};
- return $$4 | 0;
+ $$10 = $$3;
+ return $$10 | 0;
}
function $$61($$0) {
$$0 = $$0 | 0;
- var $$1 = 0, $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0;
+ var $$1 = 0, $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0;
block : {
- $$5 = 1;
block13 : {
block14 : {
- $$1 = 8;
- $$2 = $$1;
- $$3 = $$1;
- $$4 = $$1;
- switch ($$0 | 0) {
+ $$1 = $$0;
+ $$2 = 8;
+ $$3 = $$2;
+ $$4 = $$2;
+ $$5 = $$2;
+ switch ($$1 | 0) {
case 0:
break block;
case 1:
@@ -50175,26 +50270,29 @@ function asmFunc(global, env, buffer) {
break block14;
};
};
- $$3 = 16;
+ $$6 = $$5;
+ $$4 = 16;
};
- $$6 = $$5 + $$3 | 0;
- $$2 = $$6;
+ $$7 = $$4;
+ $$8 = 1 + $$7 | 0;
+ $$3 = $$8;
};
- return $$2 | 0;
+ $$9 = $$3;
+ return $$9 | 0;
}
function $$62($$0) {
$$0 = $$0 | 0;
- var $$1 = 0, $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0;
+ var $$1 = 0, $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0;
block : {
- $$5 = 1;
block15 : {
block16 : {
- $$1 = 8;
- $$2 = $$1;
- $$3 = $$1;
- $$4 = $$1;
- switch ($$0 | 0) {
+ $$1 = $$0;
+ $$2 = 8;
+ $$3 = $$2;
+ $$4 = $$2;
+ $$5 = $$2;
+ switch ($$1 | 0) {
case 0:
break block16;
case 1:
@@ -50203,24 +50301,27 @@ function asmFunc(global, env, buffer) {
break block;
};
};
- $$3 = 16;
+ $$6 = $$5;
+ $$4 = 16;
};
- $$6 = $$5 + $$3 | 0;
- $$4 = $$6;
+ $$7 = $$4;
+ $$8 = 1 + $$7 | 0;
+ $$3 = $$8;
};
- return $$4 | 0;
+ $$9 = $$3;
+ return $$9 | 0;
}
function $$63($$0) {
$$0 = $$0 | 0;
- var $$1 = 0, $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0;
+ var $$1 = 0, $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0;
block : {
- $$4 = 1;
block17 : {
- $$1 = 8;
- $$2 = $$1;
- $$3 = $$1;
- switch ($$0 | 0) {
+ $$1 = $$0;
+ $$2 = 8;
+ $$3 = $$2;
+ $$4 = $$2;
+ switch ($$1 | 0) {
case 0:
break block17;
case 1:
@@ -50229,24 +50330,26 @@ function asmFunc(global, env, buffer) {
break block17;
};
};
- $$5 = $$4 + $$2 | 0;
- $$3 = $$5;
+ $$5 = $$4;
+ $$6 = 1 + $$5 | 0;
+ $$3 = $$6;
};
- return $$3 | 0;
+ $$7 = $$3;
+ return $$7 | 0;
}
function $$64($$0) {
$$0 = $$0 | 0;
- var $$1 = 0, $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0;
+ var $$1 = 0, $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0;
block : {
- $$5 = 1;
block18 : {
block19 : {
- $$1 = 8;
- $$2 = $$1;
- $$3 = $$1;
- $$4 = $$1;
- switch ($$0 | 0) {
+ $$1 = $$0;
+ $$2 = 8;
+ $$3 = $$2;
+ $$4 = $$2;
+ $$5 = $$2;
+ switch ($$1 | 0) {
case 0:
break block19;
case 1:
@@ -50255,24 +50358,27 @@ function asmFunc(global, env, buffer) {
break block;
};
};
- $$3 = 16;
+ $$6 = $$5;
+ $$4 = 16;
};
- $$6 = $$5 + $$3 | 0;
- $$4 = $$6;
+ $$7 = $$4;
+ $$8 = 1 + $$7 | 0;
+ $$3 = $$8;
};
- return $$4 | 0;
+ $$9 = $$3;
+ return $$9 | 0;
}
function $$65($$0) {
$$0 = $$0 | 0;
- var $$1 = 0, $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0;
+ var $$1 = 0, $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0;
block : {
- $$5 = 1;
block20 : {
- $$1 = 8;
- $$2 = $$1;
- $$3 = $$1;
- switch ($$0 | 0) {
+ $$1 = $$0;
+ $$2 = 8;
+ $$3 = $$2;
+ $$4 = $$2;
+ switch ($$1 | 0) {
case 0:
break block20;
case 1:
@@ -50281,47 +50387,112 @@ function asmFunc(global, env, buffer) {
break block20;
};
};
- $$6 = $$5 + $$2 | 0;
- $$3 = $$6;
+ $$6 = $$4;
+ $$7 = 1 + $$6 | 0;
+ $$3 = $$7;
};
- return $$3 | 0;
+ $$8 = $$3;
+ return $$8 | 0;
}
function __wasm_ctz_i32(x) {
x = x | 0;
- var $$1 = 0;
- if ((x | 0) == (0 | 0)) $$1 = 32; else $$1 = 31 - Math_clz32(x ^ (x - 1 | 0) | 0) | 0;
- return $$1 | 0;
+ var $$1 = 0, $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0;
+ $$1 = x;
+ $$2 = ($$1 | 0) == (0 | 0);
+ if ($$2) $$9 = 32; else {
+ $$3 = x;
+ $$4 = x;
+ $$5 = $$4 - 1 | 0;
+ $$6 = $$3 ^ $$5 | 0;
+ $$7 = Math_clz32($$6);
+ $$8 = 31 - $$7 | 0;
+ $$9 = $$8;
+ }
+ $$10 = $$9;
+ return $$10 | 0;
}
function __wasm_popcnt_i32(x) {
x = x | 0;
- var count = 0, $$2 = 0, $$3 = 0;
+ var count = 0, $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0, $$11 = 0, $$12 = 0, $$13 = 0, $$14 = 0, $$15 = 0;
count = 0;
b : {
l : do {
$$2 = count;
- if ((x | 0) == (0 | 0)) break b;
- x = x & (x - 1 | 0) | 0;
- count = count + 1 | 0;
+ $$3 = x;
+ $$4 = ($$3 | 0) == (0 | 0);
+ $$5 = $$2;
+ if ($$4) break b;
+ $$6 = $$5;
+ $$7 = x;
+ $$8 = x;
+ $$9 = $$8 - 1 | 0;
+ $$10 = $$7 & $$9 | 0;
+ x = $$10;
+ $$11 = count;
+ $$12 = $$11 + 1 | 0;
+ count = $$12;
continue l;
break l;
} while (1);
};
- $$3 = $$2;
- return $$3 | 0;
+ $$13 = $$5;
+ $$14 = $$13;
+ $$15 = $$14;
+ return $$15 | 0;
}
function __wasm_rotl_i32(x, k) {
x = x | 0;
k = k | 0;
- return ((4294967295 >>> (k & 31 | 0) | 0) & x | 0) << (k & 31 | 0) | 0 | (((4294967295 << (32 - (k & 31 | 0) | 0) | 0) & x | 0) >>> (32 - (k & 31 | 0) | 0) | 0) | 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0, $$11 = 0, $$12 = 0, $$13 = 0, $$14 = 0, $$15 = 0, $$16 = 0, $$17 = 0, $$18 = 0, $$19 = 0, $$20 = 0;
+ $$2 = k;
+ $$3 = $$2 & 31 | 0;
+ $$4 = 4294967295 >>> $$3 | 0;
+ $$5 = x;
+ $$6 = $$4 & $$5 | 0;
+ $$7 = k;
+ $$8 = $$7 & 31 | 0;
+ $$9 = $$6 << $$8 | 0;
+ $$10 = k;
+ $$11 = $$10 & 31 | 0;
+ $$12 = 32 - $$11 | 0;
+ $$13 = 4294967295 << $$12 | 0;
+ $$14 = x;
+ $$15 = $$13 & $$14 | 0;
+ $$16 = k;
+ $$17 = $$16 & 31 | 0;
+ $$18 = 32 - $$17 | 0;
+ $$19 = $$15 >>> $$18 | 0;
+ $$20 = $$9 | $$19 | 0;
+ return $$20 | 0;
}
function __wasm_rotr_i32(x, k) {
x = x | 0;
k = k | 0;
- return ((4294967295 << (k & 31 | 0) | 0) & x | 0) >>> (k & 31 | 0) | 0 | (((4294967295 >>> (32 - (k & 31 | 0) | 0) | 0) & x | 0) << (32 - (k & 31 | 0) | 0) | 0) | 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0, $$11 = 0, $$12 = 0, $$13 = 0, $$14 = 0, $$15 = 0, $$16 = 0, $$17 = 0, $$18 = 0, $$19 = 0, $$20 = 0;
+ $$2 = k;
+ $$3 = $$2 & 31 | 0;
+ $$4 = 4294967295 << $$3 | 0;
+ $$5 = x;
+ $$6 = $$4 & $$5 | 0;
+ $$7 = k;
+ $$8 = $$7 & 31 | 0;
+ $$9 = $$6 >>> $$8 | 0;
+ $$10 = k;
+ $$11 = $$10 & 31 | 0;
+ $$12 = 32 - $$11 | 0;
+ $$13 = 4294967295 >>> $$12 | 0;
+ $$14 = x;
+ $$15 = $$13 & $$14 | 0;
+ $$16 = k;
+ $$17 = $$16 & 31 | 0;
+ $$18 = 32 - $$17 | 0;
+ $$19 = $$15 << $$18 | 0;
+ $$20 = $$9 | $$19 | 0;
+ return $$20 | 0;
}
var FUNCTION_TABLE_iiii = [f];
diff --git a/test/empty_imported_table.2asm.js b/test/empty_imported_table.2asm.js
index 3f93e9568..9dcdcad54 100644
--- a/test/empty_imported_table.2asm.js
+++ b/test/empty_imported_table.2asm.js
@@ -15,39 +15,102 @@ function asmFunc(global, env, buffer) {
var import$table$0 = env.table;
function __wasm_ctz_i32(x) {
x = x | 0;
- var $$1 = 0;
- if ((x | 0) == (0 | 0)) $$1 = 32; else $$1 = 31 - Math_clz32(x ^ (x - 1 | 0) | 0) | 0;
- return $$1 | 0;
+ var $$1 = 0, $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0;
+ $$1 = x;
+ $$2 = ($$1 | 0) == (0 | 0);
+ if ($$2) $$9 = 32; else {
+ $$3 = x;
+ $$4 = x;
+ $$5 = $$4 - 1 | 0;
+ $$6 = $$3 ^ $$5 | 0;
+ $$7 = Math_clz32($$6);
+ $$8 = 31 - $$7 | 0;
+ $$9 = $$8;
+ }
+ $$10 = $$9;
+ return $$10 | 0;
}
function __wasm_popcnt_i32(x) {
x = x | 0;
- var count = 0, $$2 = 0, $$3 = 0;
+ var count = 0, $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0, $$11 = 0, $$12 = 0, $$13 = 0, $$14 = 0, $$15 = 0;
count = 0;
b : {
l : do {
$$2 = count;
- if ((x | 0) == (0 | 0)) break b;
- x = x & (x - 1 | 0) | 0;
- count = count + 1 | 0;
+ $$3 = x;
+ $$4 = ($$3 | 0) == (0 | 0);
+ $$5 = $$2;
+ if ($$4) break b;
+ $$6 = $$5;
+ $$7 = x;
+ $$8 = x;
+ $$9 = $$8 - 1 | 0;
+ $$10 = $$7 & $$9 | 0;
+ x = $$10;
+ $$11 = count;
+ $$12 = $$11 + 1 | 0;
+ count = $$12;
continue l;
break l;
} while (1);
};
- $$3 = $$2;
- return $$3 | 0;
+ $$13 = $$5;
+ $$14 = $$13;
+ $$15 = $$14;
+ return $$15 | 0;
}
function __wasm_rotl_i32(x, k) {
x = x | 0;
k = k | 0;
- return ((4294967295 >>> (k & 31 | 0) | 0) & x | 0) << (k & 31 | 0) | 0 | (((4294967295 << (32 - (k & 31 | 0) | 0) | 0) & x | 0) >>> (32 - (k & 31 | 0) | 0) | 0) | 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0, $$11 = 0, $$12 = 0, $$13 = 0, $$14 = 0, $$15 = 0, $$16 = 0, $$17 = 0, $$18 = 0, $$19 = 0, $$20 = 0;
+ $$2 = k;
+ $$3 = $$2 & 31 | 0;
+ $$4 = 4294967295 >>> $$3 | 0;
+ $$5 = x;
+ $$6 = $$4 & $$5 | 0;
+ $$7 = k;
+ $$8 = $$7 & 31 | 0;
+ $$9 = $$6 << $$8 | 0;
+ $$10 = k;
+ $$11 = $$10 & 31 | 0;
+ $$12 = 32 - $$11 | 0;
+ $$13 = 4294967295 << $$12 | 0;
+ $$14 = x;
+ $$15 = $$13 & $$14 | 0;
+ $$16 = k;
+ $$17 = $$16 & 31 | 0;
+ $$18 = 32 - $$17 | 0;
+ $$19 = $$15 >>> $$18 | 0;
+ $$20 = $$9 | $$19 | 0;
+ return $$20 | 0;
}
function __wasm_rotr_i32(x, k) {
x = x | 0;
k = k | 0;
- return ((4294967295 << (k & 31 | 0) | 0) & x | 0) >>> (k & 31 | 0) | 0 | (((4294967295 >>> (32 - (k & 31 | 0) | 0) | 0) & x | 0) << (32 - (k & 31 | 0) | 0) | 0) | 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0, $$11 = 0, $$12 = 0, $$13 = 0, $$14 = 0, $$15 = 0, $$16 = 0, $$17 = 0, $$18 = 0, $$19 = 0, $$20 = 0;
+ $$2 = k;
+ $$3 = $$2 & 31 | 0;
+ $$4 = 4294967295 << $$3 | 0;
+ $$5 = x;
+ $$6 = $$4 & $$5 | 0;
+ $$7 = k;
+ $$8 = $$7 & 31 | 0;
+ $$9 = $$6 >>> $$8 | 0;
+ $$10 = k;
+ $$11 = $$10 & 31 | 0;
+ $$12 = 32 - $$11 | 0;
+ $$13 = 4294967295 >>> $$12 | 0;
+ $$14 = x;
+ $$15 = $$13 & $$14 | 0;
+ $$16 = k;
+ $$17 = $$16 & 31 | 0;
+ $$18 = 32 - $$17 | 0;
+ $$19 = $$15 << $$18 | 0;
+ $$20 = $$9 | $$19 | 0;
+ return $$20 | 0;
}
return {
diff --git a/test/empty_table.2asm.js b/test/empty_table.2asm.js
index b3f981530..3c68223df 100644
--- a/test/empty_table.2asm.js
+++ b/test/empty_table.2asm.js
@@ -14,39 +14,102 @@ function asmFunc(global, env, buffer) {
var Math_clz32 = global.Math.clz32;
function __wasm_ctz_i32(x) {
x = x | 0;
- var $$1 = 0;
- if ((x | 0) == (0 | 0)) $$1 = 32; else $$1 = 31 - Math_clz32(x ^ (x - 1 | 0) | 0) | 0;
- return $$1 | 0;
+ var $$1 = 0, $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0;
+ $$1 = x;
+ $$2 = ($$1 | 0) == (0 | 0);
+ if ($$2) $$9 = 32; else {
+ $$3 = x;
+ $$4 = x;
+ $$5 = $$4 - 1 | 0;
+ $$6 = $$3 ^ $$5 | 0;
+ $$7 = Math_clz32($$6);
+ $$8 = 31 - $$7 | 0;
+ $$9 = $$8;
+ }
+ $$10 = $$9;
+ return $$10 | 0;
}
function __wasm_popcnt_i32(x) {
x = x | 0;
- var count = 0, $$2 = 0, $$3 = 0;
+ var count = 0, $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0, $$11 = 0, $$12 = 0, $$13 = 0, $$14 = 0, $$15 = 0;
count = 0;
b : {
l : do {
$$2 = count;
- if ((x | 0) == (0 | 0)) break b;
- x = x & (x - 1 | 0) | 0;
- count = count + 1 | 0;
+ $$3 = x;
+ $$4 = ($$3 | 0) == (0 | 0);
+ $$5 = $$2;
+ if ($$4) break b;
+ $$6 = $$5;
+ $$7 = x;
+ $$8 = x;
+ $$9 = $$8 - 1 | 0;
+ $$10 = $$7 & $$9 | 0;
+ x = $$10;
+ $$11 = count;
+ $$12 = $$11 + 1 | 0;
+ count = $$12;
continue l;
break l;
} while (1);
};
- $$3 = $$2;
- return $$3 | 0;
+ $$13 = $$5;
+ $$14 = $$13;
+ $$15 = $$14;
+ return $$15 | 0;
}
function __wasm_rotl_i32(x, k) {
x = x | 0;
k = k | 0;
- return ((4294967295 >>> (k & 31 | 0) | 0) & x | 0) << (k & 31 | 0) | 0 | (((4294967295 << (32 - (k & 31 | 0) | 0) | 0) & x | 0) >>> (32 - (k & 31 | 0) | 0) | 0) | 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0, $$11 = 0, $$12 = 0, $$13 = 0, $$14 = 0, $$15 = 0, $$16 = 0, $$17 = 0, $$18 = 0, $$19 = 0, $$20 = 0;
+ $$2 = k;
+ $$3 = $$2 & 31 | 0;
+ $$4 = 4294967295 >>> $$3 | 0;
+ $$5 = x;
+ $$6 = $$4 & $$5 | 0;
+ $$7 = k;
+ $$8 = $$7 & 31 | 0;
+ $$9 = $$6 << $$8 | 0;
+ $$10 = k;
+ $$11 = $$10 & 31 | 0;
+ $$12 = 32 - $$11 | 0;
+ $$13 = 4294967295 << $$12 | 0;
+ $$14 = x;
+ $$15 = $$13 & $$14 | 0;
+ $$16 = k;
+ $$17 = $$16 & 31 | 0;
+ $$18 = 32 - $$17 | 0;
+ $$19 = $$15 >>> $$18 | 0;
+ $$20 = $$9 | $$19 | 0;
+ return $$20 | 0;
}
function __wasm_rotr_i32(x, k) {
x = x | 0;
k = k | 0;
- return ((4294967295 << (k & 31 | 0) | 0) & x | 0) >>> (k & 31 | 0) | 0 | (((4294967295 >>> (32 - (k & 31 | 0) | 0) | 0) & x | 0) << (32 - (k & 31 | 0) | 0) | 0) | 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0, $$11 = 0, $$12 = 0, $$13 = 0, $$14 = 0, $$15 = 0, $$16 = 0, $$17 = 0, $$18 = 0, $$19 = 0, $$20 = 0;
+ $$2 = k;
+ $$3 = $$2 & 31 | 0;
+ $$4 = 4294967295 << $$3 | 0;
+ $$5 = x;
+ $$6 = $$4 & $$5 | 0;
+ $$7 = k;
+ $$8 = $$7 & 31 | 0;
+ $$9 = $$6 >>> $$8 | 0;
+ $$10 = k;
+ $$11 = $$10 & 31 | 0;
+ $$12 = 32 - $$11 | 0;
+ $$13 = 4294967295 >>> $$12 | 0;
+ $$14 = x;
+ $$15 = $$13 & $$14 | 0;
+ $$16 = k;
+ $$17 = $$16 & 31 | 0;
+ $$18 = 32 - $$17 | 0;
+ $$19 = $$15 << $$18 | 0;
+ $$20 = $$9 | $$19 | 0;
+ return $$20 | 0;
}
return {
diff --git a/test/forward.2asm.js b/test/forward.2asm.js
index fdfd8684a..479f560d4 100644
--- a/test/forward.2asm.js
+++ b/test/forward.2asm.js
@@ -14,53 +14,132 @@ function asmFunc(global, env, buffer) {
var Math_clz32 = global.Math.clz32;
function even(n) {
n = n | 0;
- var $$1 = 0;
- if ((n | 0) == (0 | 0)) $$1 = 1; else $$1 = odd(n - 1 | 0 | 0) | 0;
- return $$1 | 0;
+ var $$1 = 0, $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0;
+ $$1 = n;
+ $$2 = ($$1 | 0) == (0 | 0);
+ if ($$2) $$6 = 1; else {
+ $$3 = n;
+ $$4 = $$3 - 1 | 0;
+ $$5 = odd($$4 | 0) | 0;
+ $$6 = $$5;
+ }
+ $$7 = $$6;
+ return $$7 | 0;
}
function odd(n) {
n = n | 0;
- var $$1 = 0;
- if ((n | 0) == (0 | 0)) $$1 = 0; else $$1 = even(n - 1 | 0 | 0) | 0;
- return $$1 | 0;
+ var $$1 = 0, $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0;
+ $$1 = n;
+ $$2 = ($$1 | 0) == (0 | 0);
+ if ($$2) $$6 = 0; else {
+ $$3 = n;
+ $$4 = $$3 - 1 | 0;
+ $$5 = even($$4 | 0) | 0;
+ $$6 = $$5;
+ }
+ $$7 = $$6;
+ return $$7 | 0;
}
function __wasm_ctz_i32(x) {
x = x | 0;
- var $$1 = 0;
- if ((x | 0) == (0 | 0)) $$1 = 32; else $$1 = 31 - Math_clz32(x ^ (x - 1 | 0) | 0) | 0;
- return $$1 | 0;
+ var $$1 = 0, $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0;
+ $$1 = x;
+ $$2 = ($$1 | 0) == (0 | 0);
+ if ($$2) $$9 = 32; else {
+ $$3 = x;
+ $$4 = x;
+ $$5 = $$4 - 1 | 0;
+ $$6 = $$3 ^ $$5 | 0;
+ $$7 = Math_clz32($$6);
+ $$8 = 31 - $$7 | 0;
+ $$9 = $$8;
+ }
+ $$10 = $$9;
+ return $$10 | 0;
}
function __wasm_popcnt_i32(x) {
x = x | 0;
- var count = 0, $$2 = 0, $$3 = 0;
+ var count = 0, $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0, $$11 = 0, $$12 = 0, $$13 = 0, $$14 = 0, $$15 = 0;
count = 0;
b : {
l : do {
$$2 = count;
- if ((x | 0) == (0 | 0)) break b;
- x = x & (x - 1 | 0) | 0;
- count = count + 1 | 0;
+ $$3 = x;
+ $$4 = ($$3 | 0) == (0 | 0);
+ $$5 = $$2;
+ if ($$4) break b;
+ $$6 = $$5;
+ $$7 = x;
+ $$8 = x;
+ $$9 = $$8 - 1 | 0;
+ $$10 = $$7 & $$9 | 0;
+ x = $$10;
+ $$11 = count;
+ $$12 = $$11 + 1 | 0;
+ count = $$12;
continue l;
break l;
} while (1);
};
- $$3 = $$2;
- return $$3 | 0;
+ $$13 = $$5;
+ $$14 = $$13;
+ $$15 = $$14;
+ return $$15 | 0;
}
function __wasm_rotl_i32(x, k) {
x = x | 0;
k = k | 0;
- return ((4294967295 >>> (k & 31 | 0) | 0) & x | 0) << (k & 31 | 0) | 0 | (((4294967295 << (32 - (k & 31 | 0) | 0) | 0) & x | 0) >>> (32 - (k & 31 | 0) | 0) | 0) | 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0, $$11 = 0, $$12 = 0, $$13 = 0, $$14 = 0, $$15 = 0, $$16 = 0, $$17 = 0, $$18 = 0, $$19 = 0, $$20 = 0;
+ $$2 = k;
+ $$3 = $$2 & 31 | 0;
+ $$4 = 4294967295 >>> $$3 | 0;
+ $$5 = x;
+ $$6 = $$4 & $$5 | 0;
+ $$7 = k;
+ $$8 = $$7 & 31 | 0;
+ $$9 = $$6 << $$8 | 0;
+ $$10 = k;
+ $$11 = $$10 & 31 | 0;
+ $$12 = 32 - $$11 | 0;
+ $$13 = 4294967295 << $$12 | 0;
+ $$14 = x;
+ $$15 = $$13 & $$14 | 0;
+ $$16 = k;
+ $$17 = $$16 & 31 | 0;
+ $$18 = 32 - $$17 | 0;
+ $$19 = $$15 >>> $$18 | 0;
+ $$20 = $$9 | $$19 | 0;
+ return $$20 | 0;
}
function __wasm_rotr_i32(x, k) {
x = x | 0;
k = k | 0;
- return ((4294967295 << (k & 31 | 0) | 0) & x | 0) >>> (k & 31 | 0) | 0 | (((4294967295 >>> (32 - (k & 31 | 0) | 0) | 0) & x | 0) << (32 - (k & 31 | 0) | 0) | 0) | 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0, $$11 = 0, $$12 = 0, $$13 = 0, $$14 = 0, $$15 = 0, $$16 = 0, $$17 = 0, $$18 = 0, $$19 = 0, $$20 = 0;
+ $$2 = k;
+ $$3 = $$2 & 31 | 0;
+ $$4 = 4294967295 << $$3 | 0;
+ $$5 = x;
+ $$6 = $$4 & $$5 | 0;
+ $$7 = k;
+ $$8 = $$7 & 31 | 0;
+ $$9 = $$6 >>> $$8 | 0;
+ $$10 = k;
+ $$11 = $$10 & 31 | 0;
+ $$12 = 32 - $$11 | 0;
+ $$13 = 4294967295 >>> $$12 | 0;
+ $$14 = x;
+ $$15 = $$13 & $$14 | 0;
+ $$16 = k;
+ $$17 = $$16 & 31 | 0;
+ $$18 = 32 - $$17 | 0;
+ $$19 = $$15 << $$18 | 0;
+ $$20 = $$9 | $$19 | 0;
+ return $$20 | 0;
}
return {
diff --git a/test/hello_world.2asm.js b/test/hello_world.2asm.js
index 05c7a5343..b12c6ed10 100644
--- a/test/hello_world.2asm.js
+++ b/test/hello_world.2asm.js
@@ -15,44 +15,111 @@ function asmFunc(global, env, buffer) {
function add(x, y) {
x = x | 0;
y = y | 0;
- return x + y | 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0;
+ $$2 = x;
+ $$3 = y;
+ $$4 = $$2 + $$3 | 0;
+ return $$4 | 0;
}
function __wasm_ctz_i32(x) {
x = x | 0;
- var $$1 = 0;
- if ((x | 0) == (0 | 0)) $$1 = 32; else $$1 = 31 - Math_clz32(x ^ (x - 1 | 0) | 0) | 0;
- return $$1 | 0;
+ var $$1 = 0, $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0;
+ $$1 = x;
+ $$2 = ($$1 | 0) == (0 | 0);
+ if ($$2) $$9 = 32; else {
+ $$3 = x;
+ $$4 = x;
+ $$5 = $$4 - 1 | 0;
+ $$6 = $$3 ^ $$5 | 0;
+ $$7 = Math_clz32($$6);
+ $$8 = 31 - $$7 | 0;
+ $$9 = $$8;
+ }
+ $$10 = $$9;
+ return $$10 | 0;
}
function __wasm_popcnt_i32(x) {
x = x | 0;
- var count = 0, $$2 = 0, $$3 = 0;
+ var count = 0, $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0, $$11 = 0, $$12 = 0, $$13 = 0, $$14 = 0, $$15 = 0;
count = 0;
b : {
l : do {
$$2 = count;
- if ((x | 0) == (0 | 0)) break b;
- x = x & (x - 1 | 0) | 0;
- count = count + 1 | 0;
+ $$3 = x;
+ $$4 = ($$3 | 0) == (0 | 0);
+ $$5 = $$2;
+ if ($$4) break b;
+ $$6 = $$5;
+ $$7 = x;
+ $$8 = x;
+ $$9 = $$8 - 1 | 0;
+ $$10 = $$7 & $$9 | 0;
+ x = $$10;
+ $$11 = count;
+ $$12 = $$11 + 1 | 0;
+ count = $$12;
continue l;
break l;
} while (1);
};
- $$3 = $$2;
- return $$3 | 0;
+ $$13 = $$5;
+ $$14 = $$13;
+ $$15 = $$14;
+ return $$15 | 0;
}
function __wasm_rotl_i32(x, k) {
x = x | 0;
k = k | 0;
- return ((4294967295 >>> (k & 31 | 0) | 0) & x | 0) << (k & 31 | 0) | 0 | (((4294967295 << (32 - (k & 31 | 0) | 0) | 0) & x | 0) >>> (32 - (k & 31 | 0) | 0) | 0) | 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0, $$11 = 0, $$12 = 0, $$13 = 0, $$14 = 0, $$15 = 0, $$16 = 0, $$17 = 0, $$18 = 0, $$19 = 0, $$20 = 0;
+ $$2 = k;
+ $$3 = $$2 & 31 | 0;
+ $$4 = 4294967295 >>> $$3 | 0;
+ $$5 = x;
+ $$6 = $$4 & $$5 | 0;
+ $$7 = k;
+ $$8 = $$7 & 31 | 0;
+ $$9 = $$6 << $$8 | 0;
+ $$10 = k;
+ $$11 = $$10 & 31 | 0;
+ $$12 = 32 - $$11 | 0;
+ $$13 = 4294967295 << $$12 | 0;
+ $$14 = x;
+ $$15 = $$13 & $$14 | 0;
+ $$16 = k;
+ $$17 = $$16 & 31 | 0;
+ $$18 = 32 - $$17 | 0;
+ $$19 = $$15 >>> $$18 | 0;
+ $$20 = $$9 | $$19 | 0;
+ return $$20 | 0;
}
function __wasm_rotr_i32(x, k) {
x = x | 0;
k = k | 0;
- return ((4294967295 << (k & 31 | 0) | 0) & x | 0) >>> (k & 31 | 0) | 0 | (((4294967295 >>> (32 - (k & 31 | 0) | 0) | 0) & x | 0) << (32 - (k & 31 | 0) | 0) | 0) | 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0, $$11 = 0, $$12 = 0, $$13 = 0, $$14 = 0, $$15 = 0, $$16 = 0, $$17 = 0, $$18 = 0, $$19 = 0, $$20 = 0;
+ $$2 = k;
+ $$3 = $$2 & 31 | 0;
+ $$4 = 4294967295 << $$3 | 0;
+ $$5 = x;
+ $$6 = $$4 & $$5 | 0;
+ $$7 = k;
+ $$8 = $$7 & 31 | 0;
+ $$9 = $$6 >>> $$8 | 0;
+ $$10 = k;
+ $$11 = $$10 & 31 | 0;
+ $$12 = 32 - $$11 | 0;
+ $$13 = 4294967295 >>> $$12 | 0;
+ $$14 = x;
+ $$15 = $$13 & $$14 | 0;
+ $$16 = k;
+ $$17 = $$16 & 31 | 0;
+ $$18 = 32 - $$17 | 0;
+ $$19 = $$15 << $$18 | 0;
+ $$20 = $$9 | $$19 | 0;
+ return $$20 | 0;
}
return {
diff --git a/test/i32.2asm.js b/test/i32.2asm.js
index 0c94f23b7..4e3532a09 100644
--- a/test/i32.2asm.js
+++ b/test/i32.2asm.js
@@ -15,208 +15,383 @@ function asmFunc(global, env, buffer) {
function $$0(x, y) {
x = x | 0;
y = y | 0;
- return x + y | 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0;
+ $$2 = x;
+ $$3 = y;
+ $$4 = $$2 + $$3 | 0;
+ return $$4 | 0;
}
function $$1(x, y) {
x = x | 0;
y = y | 0;
- return x - y | 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0;
+ $$2 = x;
+ $$3 = y;
+ $$4 = $$2 - $$3 | 0;
+ return $$4 | 0;
}
function $$2(x, y) {
x = x | 0;
y = y | 0;
- return Math_imul(x, y) | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0;
+ $$2 = x;
+ $$3 = y;
+ $$4 = Math_imul($$2, $$3);
+ return $$4 | 0;
}
function $$3(x, y) {
x = x | 0;
y = y | 0;
- return (x | 0) / (y | 0) | 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0;
+ $$2 = x;
+ $$3 = y;
+ $$4 = ($$2 | 0) / ($$3 | 0) | 0;
+ return $$4 | 0;
}
function $$4(x, y) {
x = x | 0;
y = y | 0;
- return (x >>> 0) / (y >>> 0) | 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0;
+ $$2 = x;
+ $$3 = y;
+ $$4 = ($$2 >>> 0) / ($$3 >>> 0) | 0;
+ return $$4 | 0;
}
function $$5(x, y) {
x = x | 0;
y = y | 0;
- return (x | 0) % (y | 0) | 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0;
+ $$2 = x;
+ $$3 = y;
+ $$4 = ($$2 | 0) % ($$3 | 0) | 0;
+ return $$4 | 0;
}
function $$6(x, y) {
x = x | 0;
y = y | 0;
- return (x >>> 0) % (y >>> 0) | 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0;
+ $$2 = x;
+ $$3 = y;
+ $$4 = ($$2 >>> 0) % ($$3 >>> 0) | 0;
+ return $$4 | 0;
}
function $$7(x, y) {
x = x | 0;
y = y | 0;
- return x & y | 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0;
+ $$2 = x;
+ $$3 = y;
+ $$4 = $$2 & $$3 | 0;
+ return $$4 | 0;
}
function $$8(x, y) {
x = x | 0;
y = y | 0;
- return x | y | 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0;
+ $$2 = x;
+ $$3 = y;
+ $$4 = $$2 | $$3 | 0;
+ return $$4 | 0;
}
function $$9(x, y) {
x = x | 0;
y = y | 0;
- return x ^ y | 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0;
+ $$2 = x;
+ $$3 = y;
+ $$4 = $$2 ^ $$3 | 0;
+ return $$4 | 0;
}
function $$10(x, y) {
x = x | 0;
y = y | 0;
- return x << y | 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0;
+ $$2 = x;
+ $$3 = y;
+ $$4 = $$2 << $$3 | 0;
+ return $$4 | 0;
}
function $$11(x, y) {
x = x | 0;
y = y | 0;
- return x >> y | 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0;
+ $$2 = x;
+ $$3 = y;
+ $$4 = $$2 >> $$3 | 0;
+ return $$4 | 0;
}
function $$12(x, y) {
x = x | 0;
y = y | 0;
- return x >>> y | 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0;
+ $$2 = x;
+ $$3 = y;
+ $$4 = $$2 >>> $$3 | 0;
+ return $$4 | 0;
}
function $$13(x, y) {
x = x | 0;
y = y | 0;
- return __wasm_rotl_i32(x, y) | 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0;
+ $$2 = x;
+ $$3 = y;
+ $$4 = __wasm_rotl_i32($$2, $$3) | 0;
+ return $$4 | 0;
}
function $$14(x, y) {
x = x | 0;
y = y | 0;
- return __wasm_rotr_i32(x, y) | 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0;
+ $$2 = x;
+ $$3 = y;
+ $$4 = __wasm_rotr_i32($$2, $$3) | 0;
+ return $$4 | 0;
}
function $$15(x) {
x = x | 0;
- return Math_clz32(x) | 0;
+ var $$1 = 0, $$2 = 0;
+ $$1 = x;
+ $$2 = Math_clz32($$1);
+ return $$2 | 0;
}
function $$16(x) {
x = x | 0;
- return __wasm_ctz_i32(x) | 0 | 0;
+ var $$1 = 0, $$2 = 0;
+ $$1 = x;
+ $$2 = __wasm_ctz_i32($$1) | 0;
+ return $$2 | 0;
}
function $$17(x) {
x = x | 0;
- return __wasm_popcnt_i32(x) | 0 | 0;
+ var $$1 = 0, $$2 = 0;
+ $$1 = x;
+ $$2 = __wasm_popcnt_i32($$1) | 0;
+ return $$2 | 0;
}
function $$18(x) {
x = x | 0;
- return (x | 0) == (0 | 0) | 0;
+ var $$1 = 0, $$2 = 0;
+ $$1 = x;
+ $$2 = ($$1 | 0) == (0 | 0);
+ return $$2 | 0;
}
function $$19(x, y) {
x = x | 0;
y = y | 0;
- return (x | 0) == (y | 0) | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0;
+ $$2 = x;
+ $$3 = y;
+ $$4 = ($$2 | 0) == ($$3 | 0);
+ return $$4 | 0;
}
function $$20(x, y) {
x = x | 0;
y = y | 0;
- return (x | 0) != (y | 0) | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0;
+ $$2 = x;
+ $$3 = y;
+ $$4 = ($$2 | 0) != ($$3 | 0);
+ return $$4 | 0;
}
function $$21(x, y) {
x = x | 0;
y = y | 0;
- return (x | 0) < (y | 0) | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0;
+ $$2 = x;
+ $$3 = y;
+ $$4 = ($$2 | 0) < ($$3 | 0);
+ return $$4 | 0;
}
function $$22(x, y) {
x = x | 0;
y = y | 0;
- return x >>> 0 < y >>> 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0;
+ $$2 = x;
+ $$3 = y;
+ $$4 = $$2 >>> 0 < $$3 >>> 0;
+ return $$4 | 0;
}
function $$23(x, y) {
x = x | 0;
y = y | 0;
- return (x | 0) <= (y | 0) | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0;
+ $$2 = x;
+ $$3 = y;
+ $$4 = ($$2 | 0) <= ($$3 | 0);
+ return $$4 | 0;
}
function $$24(x, y) {
x = x | 0;
y = y | 0;
- return x >>> 0 <= y >>> 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0;
+ $$2 = x;
+ $$3 = y;
+ $$4 = $$2 >>> 0 <= $$3 >>> 0;
+ return $$4 | 0;
}
function $$25(x, y) {
x = x | 0;
y = y | 0;
- return (x | 0) > (y | 0) | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0;
+ $$2 = x;
+ $$3 = y;
+ $$4 = ($$2 | 0) > ($$3 | 0);
+ return $$4 | 0;
}
function $$26(x, y) {
x = x | 0;
y = y | 0;
- return x >>> 0 > y >>> 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0;
+ $$2 = x;
+ $$3 = y;
+ $$4 = $$2 >>> 0 > $$3 >>> 0;
+ return $$4 | 0;
}
function $$27(x, y) {
x = x | 0;
y = y | 0;
- return (x | 0) >= (y | 0) | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0;
+ $$2 = x;
+ $$3 = y;
+ $$4 = ($$2 | 0) >= ($$3 | 0);
+ return $$4 | 0;
}
function $$28(x, y) {
x = x | 0;
y = y | 0;
- return x >>> 0 >= y >>> 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0;
+ $$2 = x;
+ $$3 = y;
+ $$4 = $$2 >>> 0 >= $$3 >>> 0;
+ return $$4 | 0;
}
function __wasm_ctz_i32(x) {
x = x | 0;
- var $$1 = 0;
- if ((x | 0) == (0 | 0)) $$1 = 32; else $$1 = 31 - Math_clz32(x ^ (x - 1 | 0) | 0) | 0;
- return $$1 | 0;
+ var $$1 = 0, $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0;
+ $$1 = x;
+ $$2 = ($$1 | 0) == (0 | 0);
+ if ($$2) $$9 = 32; else {
+ $$3 = x;
+ $$4 = x;
+ $$5 = $$4 - 1 | 0;
+ $$6 = $$3 ^ $$5 | 0;
+ $$7 = Math_clz32($$6);
+ $$8 = 31 - $$7 | 0;
+ $$9 = $$8;
+ }
+ $$10 = $$9;
+ return $$10 | 0;
}
function __wasm_popcnt_i32(x) {
x = x | 0;
- var count = 0, $$2 = 0, $$3 = 0;
+ var count = 0, $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0, $$11 = 0, $$12 = 0, $$13 = 0, $$14 = 0, $$15 = 0;
count = 0;
b : {
l : do {
$$2 = count;
- if ((x | 0) == (0 | 0)) break b;
- x = x & (x - 1 | 0) | 0;
- count = count + 1 | 0;
+ $$3 = x;
+ $$4 = ($$3 | 0) == (0 | 0);
+ $$5 = $$2;
+ if ($$4) break b;
+ $$6 = $$5;
+ $$7 = x;
+ $$8 = x;
+ $$9 = $$8 - 1 | 0;
+ $$10 = $$7 & $$9 | 0;
+ x = $$10;
+ $$11 = count;
+ $$12 = $$11 + 1 | 0;
+ count = $$12;
continue l;
break l;
} while (1);
};
- $$3 = $$2;
- return $$3 | 0;
+ $$13 = $$5;
+ $$14 = $$13;
+ $$15 = $$14;
+ return $$15 | 0;
}
function __wasm_rotl_i32(x, k) {
x = x | 0;
k = k | 0;
- return ((4294967295 >>> (k & 31 | 0) | 0) & x | 0) << (k & 31 | 0) | 0 | (((4294967295 << (32 - (k & 31 | 0) | 0) | 0) & x | 0) >>> (32 - (k & 31 | 0) | 0) | 0) | 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0, $$11 = 0, $$12 = 0, $$13 = 0, $$14 = 0, $$15 = 0, $$16 = 0, $$17 = 0, $$18 = 0, $$19 = 0, $$20 = 0;
+ $$2 = k;
+ $$3 = $$2 & 31 | 0;
+ $$4 = 4294967295 >>> $$3 | 0;
+ $$5 = x;
+ $$6 = $$4 & $$5 | 0;
+ $$7 = k;
+ $$8 = $$7 & 31 | 0;
+ $$9 = $$6 << $$8 | 0;
+ $$10 = k;
+ $$11 = $$10 & 31 | 0;
+ $$12 = 32 - $$11 | 0;
+ $$13 = 4294967295 << $$12 | 0;
+ $$14 = x;
+ $$15 = $$13 & $$14 | 0;
+ $$16 = k;
+ $$17 = $$16 & 31 | 0;
+ $$18 = 32 - $$17 | 0;
+ $$19 = $$15 >>> $$18 | 0;
+ $$20 = $$9 | $$19 | 0;
+ return $$20 | 0;
}
function __wasm_rotr_i32(x, k) {
x = x | 0;
k = k | 0;
- return ((4294967295 << (k & 31 | 0) | 0) & x | 0) >>> (k & 31 | 0) | 0 | (((4294967295 >>> (32 - (k & 31 | 0) | 0) | 0) & x | 0) << (32 - (k & 31 | 0) | 0) | 0) | 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0, $$11 = 0, $$12 = 0, $$13 = 0, $$14 = 0, $$15 = 0, $$16 = 0, $$17 = 0, $$18 = 0, $$19 = 0, $$20 = 0;
+ $$2 = k;
+ $$3 = $$2 & 31 | 0;
+ $$4 = 4294967295 << $$3 | 0;
+ $$5 = x;
+ $$6 = $$4 & $$5 | 0;
+ $$7 = k;
+ $$8 = $$7 & 31 | 0;
+ $$9 = $$6 >>> $$8 | 0;
+ $$10 = k;
+ $$11 = $$10 & 31 | 0;
+ $$12 = 32 - $$11 | 0;
+ $$13 = 4294967295 >>> $$12 | 0;
+ $$14 = x;
+ $$15 = $$13 & $$14 | 0;
+ $$16 = k;
+ $$17 = $$16 & 31 | 0;
+ $$18 = 32 - $$17 | 0;
+ $$19 = $$15 << $$18 | 0;
+ $$20 = $$9 | $$19 | 0;
+ return $$20 | 0;
}
return {
diff --git a/test/passes/flatten-control-flow.bin.txt b/test/passes/flatten-control-flow.bin.txt
deleted file mode 100644
index 93fbff864..000000000
--- a/test/passes/flatten-control-flow.bin.txt
+++ /dev/null
@@ -1,123 +0,0 @@
-(module
- (type $0 (func (result i32)))
- (type $1 (func (result i64)))
- (type $2 (func (result f32)))
- (type $3 (func (result f64)))
- (type $4 (func (param i32) (result i32)))
- (type $5 (func (param i64) (result i64)))
- (type $6 (func (param f32) (result f32)))
- (type $7 (func (param f64) (result f64)))
- (type $8 (func (param i64 f32 f64 i32 i32)))
- (type $9 (func (param i64 f32 f64 i32 i32) (result f64)))
- (memory $0 0)
- (export "type-local-i32" (func $0))
- (export "type-local-i64" (func $1))
- (export "type-local-f32" (func $2))
- (export "type-local-f64" (func $3))
- (export "type-param-i32" (func $4))
- (export "type-param-i64" (func $5))
- (export "tÿÿe-param-f32" (func $6))
- (export "type-param-f64" (func $7))
- (export "type-mixed" (func $8))
- (export "read" (func $9))
- (func $0 (type $0) (result i32)
- (local $var$0 i32)
- (get_local $var$0)
- )
- (func $1 (type $1) (result i64)
- (local $var$0 i64)
- (get_local $var$0)
- )
- (func $2 (type $2) (result f32)
- (local $var$0 f32)
- (get_local $var$0)
- )
- (func $3 (type $3) (result f64)
- (local $var$0 f64)
- (get_local $var$0)
- )
- (func $4 (type $4) (param $var$0 i32) (result i32)
- (get_local $var$0)
- )
- (func $5 (type $5) (param $var$0 i64) (result i64)
- (get_local $var$0)
- )
- (func $6 (type $6) (param $var$0 f32) (result f32)
- (get_local $var$0)
- )
- (func $7 (type $7) (param $var$0 f64) (result f64)
- (get_local $var$0)
- )
- (func $8 (type $8) (param $var$0 i64) (param $var$1 f32) (param $var$2 f64) (param $var$3 i32) (param $var$4 i32)
- (local $var$5 i64)
- (local $var$6 i64)
- (local $var$7 f32)
- (local $var$8 f64)
- (block $label$1
- (nop)
- (unreachable)
- )
- )
- (func $9 (type $9) (param $var$0 i64) (param $var$1 f32) (param $var$2 f64) (param $var$3 i32) (param $var$4 i32) (result f64)
- (local $var$5 i64)
- (local $var$6 i64)
- (local $var$7 f32)
- (local $var$8 f64)
- (local $9 f64)
- (block $label$1
- (set_local $var$7
- (f32.const 5.5)
- )
- (set_local $var$5
- (i64.const 6)
- )
- (set_local $var$8
- (f64.const 8)
- )
- (set_local $9
- (f64.add
- (f64.convert_u/i64
- (get_local $var$0)
- )
- (f64.add
- (f64.promote/f32
- (get_local $var$1)
- )
- (f64.add
- (get_local $var$2)
- (f64.add
- (f64.convert_u/i32
- (get_local $var$3)
- )
- (f64.add
- (f64.convert_s/i32
- (get_local $var$4)
- )
- (f64.add
- (f64.promote/f32
- (get_local $var$7)
- )
- (f64.add
- (f64.convert_u/i64
- (get_local $var$5)
- )
- (f64.add
- (f64.convert_u/i64
- (get_local $var$6)
- )
- (get_local $var$8)
- )
- )
- )
- )
- )
- )
- )
- )
- )
- )
- (return
- (get_local $9)
- )
- )
-)
diff --git a/test/passes/flatten-control-flow.txt b/test/passes/flatten-control-flow.txt
deleted file mode 100644
index 65e7196fb..000000000
--- a/test/passes/flatten-control-flow.txt
+++ /dev/null
@@ -1,1184 +0,0 @@
-(module
- (type $ii (func (param i32 i32)))
- (type $1 (func))
- (type $2 (func (result i32)))
- (type $3 (func (param i32) (result i32)))
- (type $4 (func (param i64 i64) (result i64)))
- (global $x (mut i32) (i32.const 0))
- (table 1 1 anyfunc)
- (elem (i32.const 0) $call-me)
- (memory $0 10)
- (func $call-me (type $ii) (param $0 i32) (param $1 i32)
- (nop)
- )
- (func $code-to-kill (type $1)
- (local $x i32)
- (local $1 i32)
- (local $2 i32)
- (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)
- (block $out
- (br $out)
- (drop
- (i32.const 0)
- )
- (if
- (i32.const 1)
- (drop
- (i32.const 2)
- )
- )
- (br_table $out $out $out $out
- (i32.const 3)
- )
- (call $code-to-kill)
- )
- (if
- (i32.const 0)
- (block $out1
- (unreachable)
- (drop
- (i32.const 0)
- )
- )
- )
- (if
- (i32.const 0)
- (block $out3
- (return)
- (drop
- (i32.const 0)
- )
- )
- )
- (block $out4
- (br_table $out4 $out4 $out4 $out4
- (i32.const 4)
- )
- (drop
- (i32.const 0)
- )
- )
- (block $out5
- (br_if $out5
- (i32.const 3)
- )
- (drop
- (i32.const 0)
- )
- )
- (if
- (i32.const 0)
- (block $block4
- (if
- (i32.const 0)
- (block $out8
- (unreachable)
- (drop
- (i32.const 0)
- )
- )
- (block $out9
- (unreachable)
- (drop
- (i32.const 0)
- )
- )
- )
- (drop
- (i32.const 0)
- )
- )
- )
- (if
- (i32.const 0)
- (block $out11
- (unreachable)
- (drop
- (i32.const 0)
- )
- (unreachable)
- )
- )
- (if
- (i32.const 0)
- (block $out13
- (unreachable)
- (drop
- (i32.const 0)
- )
- (unreachable)
- )
- )
- (if
- (i32.const 0)
- (block $out15
- (unreachable)
- (drop
- (i32.const 0)
- )
- (unreachable)
- )
- )
- (block $out16
- (block $in
- (br_if $out16
- (i32.const 1)
- )
- )
- (unreachable)
- )
- (if
- (i32.const 0)
- (block $block11
- (block $out18
- (block $in19
- (br_if $in19
- (i32.const 1)
- )
- )
- (unreachable)
- )
- (drop
- (i32.const 10)
- )
- )
- )
- (block $out20
- (block $in21
- (br_table $out20 $in21
- (i32.const 1)
- )
- )
- (unreachable)
- )
- (block $out22
- (block $in23
- (br_table $in23 $out22
- (i32.const 1)
- )
- )
- (unreachable)
- )
- (if
- (i32.const 0)
- (block $block13
- (block $out25
- (block $in26
- (br_table $in26 $in26
- (i32.const 1)
- )
- )
- (unreachable)
- )
- (drop
- (i32.const 10)
- )
- )
- )
- (if
- (i32.const 0)
- (block $block15
- (drop
- (i32.const 10)
- )
- (drop
- (i32.const 42)
- )
- (unreachable)
- (block
- (unreachable)
- )
- (unreachable)
- (return)
- )
- )
- (if
- (i32.const 0)
- (loop $loop-in18
- (unreachable)
- )
- )
- (block $out29
- (loop $in30
- (br_if $out29
- (i32.const 1)
- )
- (unreachable)
- )
- )
- (if
- (i32.const 0)
- (block $block20
- (loop $in32
- (br_if $in32
- (i32.const 1)
- )
- (unreachable)
- )
- (drop
- (i32.const 10)
- )
- )
- )
- (if
- (i32.const 1)
- (block
- (set_local $4
- (i32.const 123)
- )
- (unreachable)
- )
- )
- (if
- (i32.const 2)
- (unreachable)
- )
- (if
- (i32.const 3)
- (unreachable)
- )
- (if
- (i32.const -1)
- (block
- (set_local $6
- (i32.const 123)
- )
- (set_local $7
- (i32.const 456)
- )
- (unreachable)
- )
- )
- (if
- (i32.const -2)
- (block
- (set_local $8
- (i32.const 139)
- )
- (unreachable)
- )
- )
- (if
- (i32.const -3)
- (block
- (set_local $10
- (i32.const 246)
- )
- (unreachable)
- )
- )
- (if
- (i32.const -4)
- (unreachable)
- )
- (if
- (i32.const 11)
- (unreachable)
- )
- (if
- (i32.const 22)
- (block
- (unreachable)
- )
- )
- (if
- (i32.const 33)
- (block
- (set_local $11
- (i32.const 0)
- )
- (unreachable)
- )
- )
- (if
- (i32.const 44)
- (unreachable)
- )
- (if
- (i32.const 55)
- (unreachable)
- )
- (if
- (i32.const 66)
- (block
- (unreachable)
- )
- )
- (if
- (i32.const 77)
- (block
- (unreachable)
- )
- )
- (if
- (i32.const 88)
- (block
- (set_local $14
- (i32.const 0)
- )
- (unreachable)
- )
- )
- (if
- (i32.const 99)
- (unreachable)
- )
- (if
- (i32.const 100)
- (block
- (set_local $15
- (i32.const 123)
- )
- (set_local $16
- (i32.const 456)
- )
- (unreachable)
- )
- )
- (if
- (i32.const 101)
- (block
- (set_local $17
- (i32.const 123)
- )
- (unreachable)
- )
- )
- (if
- (i32.const 102)
- (block
- (unreachable)
- )
- )
- (drop
- (i32.const 1337)
- )
- )
- (func $killer (type $1)
- (unreachable)
- (drop
- (i32.const 1000)
- )
- )
- (func $target (type $1)
- (drop
- (i32.const 2000)
- )
- )
- (func $typed-block-none-then-unreachable (type $2) (result i32)
- (local $0 i32)
- (block $top-typed
- (block $switch$0
- (return
- (i32.const 0)
- )
- (br $switch$0)
- )
- (return
- (i32.const 1)
- )
- )
- (return
- (get_local $0)
- )
- )
- (func $typed-block-remove-br-changes-type (type $3) (param $$$0 i32) (result i32)
- (local $1 i32)
- (block
- (block $switch$7
- (block $switch-default$10
- (block $switch-case$9
- (block $switch-case$8
- (br_table $switch-case$9 $switch-case$8 $switch-default$10
- (i32.const -1)
- )
- )
- )
- (return
- (get_local $$$0)
- )
- (br $switch$7)
- )
- (return
- (get_local $$$0)
- )
- )
- (return
- (i32.const 0)
- )
- )
- (return
- (get_local $1)
- )
- )
- (func $global (type $1)
- (unreachable)
- (drop
- (get_global $x)
- )
- (set_global $x
- (i32.const 1)
- )
- )
- (func $ret (type $2) (result i32)
- (local $0 i32)
- (block
- (return
- (i32.const 0)
- )
- (nop)
- (set_local $0
- (i32.const 0)
- )
- )
- (return
- (get_local $0)
- )
- )
- (func $unreachable-br (type $2) (result i32)
- (local $0 i32)
- (block $out
- (block
- (set_local $0
- (i32.const 0)
- )
- (br $out)
- )
- )
- (return
- (get_local $0)
- )
- )
- (func $unreachable-br-loop (type $2) (result i32)
- (loop $out
- (br $out)
- )
- )
- (func $unreachable-block-ends-switch (type $2) (result i32)
- (local $0 i32)
- (block $label$0
- (block $label$3
- (nop)
- (block
- (unreachable)
- )
- (unreachable)
- )
- (set_local $0
- (i32.const 19)
- )
- )
- (return
- (get_local $0)
- )
- )
- (func $unreachable-block-ends-br_if (type $2) (result i32)
- (local $0 i32)
- (block $label$0
- (block $label$2
- (nop)
- (block
- (unreachable)
- )
- (unreachable)
- )
- (set_local $0
- (i32.const 19)
- )
- )
- (return
- (get_local $0)
- )
- )
- (func $unreachable-brs-3 (type $2) (result i32)
- (local $0 i32)
- (block $label$0
- (block
- (block
- (set_local $0
- (i32.const 18)
- )
- (br $label$0)
- )
- )
- (set_local $0
- (i32.const 21)
- )
- )
- (return
- (get_local $0)
- )
- )
- (func $unreachable-brs-4 (type $3) (param $var$0 i32) (result i32)
- (local $1 i32)
- (local $2 i32)
- (local $3 i32)
- (set_local $3
- (i32.const 1)
- )
- (block $label$0
- (block $label$1
- (block
- (block
- (unreachable)
- )
- )
- (set_local $2
- (i32.const 4)
- )
- )
- (set_local $1
- (i32.const 16)
- )
- )
- )
- (func $call-unreach (type $4) (param $var$0 i64) (param $var$1 i64) (result i64)
- (local $2 i64)
- (local $3 i64)
- (local $4 i64)
- (local $5 i64)
- (local $6 i64)
- (local $7 i64)
- (if
- (i64.eqz
- (get_local $var$0)
- )
- (block
- (block $label$0
- (set_local $3
- (get_local $var$1)
- )
- )
- (set_local $7
- (get_local $3)
- )
- )
- (block
- (block $label$1
- (block
- (set_local $5
- (i64.sub
- (get_local $var$0)
- (i64.const 1)
- )
- )
- (block
- (block $block
- (set_local $2
- (get_local $var$0)
- )
- (nop)
- (set_local $4
- (get_local $2)
- )
- )
- (unreachable)
- )
- )
- )
- (set_local $7
- (get_local $6)
- )
- )
- )
- (return
- (get_local $7)
- )
- )
- (func $test-flatten (type $1)
- (local $0 i32)
- (local $1 i32)
- (local $2 i32)
- (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)
- (local $40 i32)
- (local $41 i32)
- (local $42 i32)
- (local $43 i32)
- (local $44 i32)
- (block $out
- (drop
- (i32.add
- (i32.const 1)
- (i32.const 2)
- )
- )
- (block
- (block
- (set_local $0
- (i32.const 1)
- )
- (br $out)
- )
- )
- (block
- (block
- (br $out)
- )
- )
- (block
- (block
- (set_local $2
- (i32.const 1)
- )
- (br_table $out $out $out $out
- (i32.const 3)
- )
- )
- )
- (block
- (block
- (set_local $4
- (i32.const 1)
- )
- (block $block
- (drop
- (i32.const 2)
- )
- (drop
- (i32.const 3)
- )
- (set_local $3
- (i32.const 4)
- )
- )
- (set_local $5
- (i32.add
- (get_local $4)
- (get_local $3)
- )
- )
- )
- (drop
- (get_local $5)
- )
- )
- (block
- (block
- (set_local $9
- (i32.const 1)
- )
- (block $in
- (block
- (block $switch-in
- (block
- (set_local $6
- (i32.const 2)
- )
- (set_local $7
- (get_local $6)
- )
- (set_local $8
- (get_local $6)
- )
- (br_table $in $switch-in $in
- (i32.const 777)
- )
- )
- )
- (drop
- (get_local $8)
- )
- )
- (block
- (set_local $7
- (i32.const 3)
- )
- (br $in)
- )
- (set_local $7
- (i32.const 4)
- )
- )
- (set_local $10
- (i32.add
- (get_local $9)
- (get_local $7)
- )
- )
- )
- (drop
- (get_local $10)
- )
- )
- (block
- (block
- (set_local $12
- (i32.const 1)
- )
- (loop $loop-in
- (set_local $11
- (i32.const 5)
- )
- )
- (set_local $13
- (i32.add
- (get_local $12)
- (get_local $11)
- )
- )
- )
- (drop
- (get_local $13)
- )
- )
- (block
- (block
- (set_local $15
- (i32.const 1)
- )
- (if
- (i32.const 6)
- (set_local $14
- (i32.const 7)
- )
- (set_local $14
- (i32.const 8)
- )
- )
- (set_local $16
- (i32.add
- (get_local $15)
- (get_local $14)
- )
- )
- )
- (drop
- (get_local $16)
- )
- )
- (drop
- (select
- (i32.const 9)
- (i32.const 10)
- (i32.const 11)
- )
- )
- (block
- (block
- (br $out)
- )
- )
- (block
- (block
- (set_local $19
- (i32.const 9)
- )
- (br $out)
- )
- )
- (block
- (block
- (set_local $21
- (i32.const 9)
- )
- (set_local $22
- (i32.const 10)
- )
- (br $out)
- )
- )
- (block
- (block
- (if
- (i32.const 11)
- (set_local $23
- (i32.const 12)
- )
- (set_local $23
- (i32.const 13)
- )
- )
- (set_local $24
- (i32.const 9)
- )
- (set_local $25
- (i32.const 10)
- )
- (set_local $26
- (select
- (get_local $23)
- (get_local $24)
- (get_local $25)
- )
- )
- )
- (drop
- (get_local $26)
- )
- )
- (block
- (block
- (set_local $28
- (i32.const 9)
- )
- (if
- (i32.const 11)
- (set_local $27
- (i32.const 12)
- )
- (set_local $27
- (i32.const 13)
- )
- )
- (set_local $29
- (i32.const 10)
- )
- (set_local $30
- (select
- (get_local $28)
- (get_local $27)
- (get_local $29)
- )
- )
- )
- (drop
- (get_local $30)
- )
- )
- (block
- (block
- (set_local $32
- (i32.const 9)
- )
- (set_local $33
- (i32.const 10)
- )
- (if
- (i32.const 11)
- (set_local $31
- (i32.const 12)
- )
- (set_local $31
- (i32.const 13)
- )
- )
- (set_local $34
- (select
- (get_local $32)
- (get_local $33)
- (get_local $31)
- )
- )
- )
- (drop
- (get_local $34)
- )
- )
- (block
- (block
- (if
- (i32.const 11)
- (set_local $35
- (i32.const 12)
- )
- (set_local $35
- (i32.const 13)
- )
- )
- (set_local $37
- (i32.const 14)
- )
- (if
- (i32.const 15)
- (set_local $36
- (i32.const 16)
- )
- (set_local $36
- (i32.const 17)
- )
- )
- (set_local $38
- (select
- (get_local $35)
- (get_local $37)
- (get_local $36)
- )
- )
- )
- (drop
- (get_local $38)
- )
- )
- (block
- (block
- (set_local $39
- (i32.const 1)
- )
- (return)
- )
- )
- (block
- (block
- (set_local $40
- (i32.const 1)
- )
- (unreachable)
- )
- )
- (block
- (block
- (if
- (i32.const 5)
- (set_local $41
- (i32.const 6)
- )
- (set_local $41
- (i32.const 7)
- )
- )
- (if
- (get_local $41)
- (set_local $43
- (i32.const 8)
- )
- (block
- (if
- (i32.const 9)
- (set_local $42
- (i32.const 10)
- )
- (set_local $42
- (i32.const 11)
- )
- )
- (set_local $43
- (get_local $42)
- )
- )
- )
- )
- (drop
- (get_local $43)
- )
- )
- (block
- (block $temp
- (block
- (block
- (set_local $44
- (i32.const 1)
- )
- (br_if $temp
- (i32.const 2)
- )
- )
- (set_local $44
- (get_local $44)
- )
- )
- )
- (drop
- (get_local $44)
- )
- )
- )
- )
- (func $flatten-return-value (type $2) (result i32)
- (local $0 i32)
- (local $1 i32)
- (block
- (block
- (block
- (set_local $0
- (i32.const 1)
- )
- (return
- (i32.const 2)
- )
- )
- )
- (set_local $1
- (i32.const 3)
- )
- )
- (return
- (get_local $1)
- )
- )
- (func $unbug (type $1)
- (local $12 i32)
- (local $432 i32)
- (local $430 i32)
- (local $431 i32)
- (local $9 i32)
- (local $5 i32)
- (local $433 i32)
- (local $7 i32)
- (block $block
- (if
- (i32.eq
- (get_local $12)
- (i32.const 65535)
- )
- (block $block39
- (block $label$78
- (set_local $430
- (i32.const 0)
- )
- )
- (set_local $432
- (get_local $430)
- )
- )
- (block $block40
- (block $label$79
- (set_local $431
- (i32.lt_u
- (get_local $9)
- (i32.load16_u offset=2
- (i32.add
- (get_local $5)
- (i32.mul
- (get_local $12)
- (i32.const 12)
- )
- )
- )
- )
- )
- )
- (set_local $432
- (get_local $431)
- )
- )
- )
- (set_local $433
- (i32.const 1)
- )
- (set_local $7
- (i32.xor
- (get_local $432)
- (get_local $433)
- )
- )
- )
- (drop
- (get_local $7)
- )
- )
- (func $outer-block-typed (type $3) (param $var$0 i32) (result i32)
- (local $1 i32)
- (local $2 i32)
- (local $3 i32)
- (local $4 i32)
- (block $block
- (block
- (block
- (set_local $2
- (i32.const 1)
- )
- (block $label$0
- (set_local $1
- (i32.const 16)
- )
- )
- (set_local $3
- (i32.add
- (get_local $2)
- (get_local $1)
- )
- )
- )
- (set_local $4
- (get_local $3)
- )
- )
- )
- (return
- (get_local $4)
- )
- )
- (func $nested-br_if-with-value (type $2) (result i32)
- (local $0 i32)
- (local $1 i32)
- (local $2 i32)
- (block $label$0
- (block
- (block
- (block $block
- (set_local $1
- (get_local $0)
- )
- )
- (block
- (set_local $2
- (i32.const 0)
- )
- (br_if $label$0
- (get_local $1)
- )
- )
- )
- (drop
- (get_local $2)
- )
- )
- (set_local $2
- (i32.const 1)
- )
- )
- (return
- (get_local $2)
- )
- )
- (func $switch-unreachable (type $1)
- (block $label$3
- (block
- (unreachable)
- )
- )
- )
-)
diff --git a/test/passes/flatten.bin.txt b/test/passes/flatten.bin.txt
new file mode 100644
index 000000000..049bd361b
--- /dev/null
+++ b/test/passes/flatten.bin.txt
@@ -0,0 +1,276 @@
+(module
+ (type $0 (func (result i32)))
+ (type $1 (func (result i64)))
+ (type $2 (func (result f32)))
+ (type $3 (func (result f64)))
+ (type $4 (func (param i32) (result i32)))
+ (type $5 (func (param i64) (result i64)))
+ (type $6 (func (param f32) (result f32)))
+ (type $7 (func (param f64) (result f64)))
+ (type $8 (func (param i64 f32 f64 i32 i32)))
+ (type $9 (func (param i64 f32 f64 i32 i32) (result f64)))
+ (memory $0 0)
+ (export "type-local-i32" (func $0))
+ (export "type-local-i64" (func $1))
+ (export "type-local-f32" (func $2))
+ (export "type-local-f64" (func $3))
+ (export "type-param-i32" (func $4))
+ (export "type-param-i64" (func $5))
+ (export "tÿÿe-param-f32" (func $6))
+ (export "type-param-f64" (func $7))
+ (export "type-mixed" (func $8))
+ (export "read" (func $9))
+ (func $0 (type $0) (result i32)
+ (local $var$0 i32)
+ (local $1 i32)
+ (set_local $1
+ (get_local $var$0)
+ )
+ (return
+ (get_local $1)
+ )
+ )
+ (func $1 (type $1) (result i64)
+ (local $var$0 i64)
+ (local $1 i64)
+ (set_local $1
+ (get_local $var$0)
+ )
+ (return
+ (get_local $1)
+ )
+ )
+ (func $2 (type $2) (result f32)
+ (local $var$0 f32)
+ (local $1 f32)
+ (set_local $1
+ (get_local $var$0)
+ )
+ (return
+ (get_local $1)
+ )
+ )
+ (func $3 (type $3) (result f64)
+ (local $var$0 f64)
+ (local $1 f64)
+ (set_local $1
+ (get_local $var$0)
+ )
+ (return
+ (get_local $1)
+ )
+ )
+ (func $4 (type $4) (param $var$0 i32) (result i32)
+ (local $1 i32)
+ (set_local $1
+ (get_local $var$0)
+ )
+ (return
+ (get_local $1)
+ )
+ )
+ (func $5 (type $5) (param $var$0 i64) (result i64)
+ (local $1 i64)
+ (set_local $1
+ (get_local $var$0)
+ )
+ (return
+ (get_local $1)
+ )
+ )
+ (func $6 (type $6) (param $var$0 f32) (result f32)
+ (local $1 f32)
+ (set_local $1
+ (get_local $var$0)
+ )
+ (return
+ (get_local $1)
+ )
+ )
+ (func $7 (type $7) (param $var$0 f64) (result f64)
+ (local $1 f64)
+ (set_local $1
+ (get_local $var$0)
+ )
+ (return
+ (get_local $1)
+ )
+ )
+ (func $8 (type $8) (param $var$0 i64) (param $var$1 f32) (param $var$2 f64) (param $var$3 i32) (param $var$4 i32)
+ (local $var$5 i64)
+ (local $var$6 i64)
+ (local $var$7 f32)
+ (local $var$8 f64)
+ (block $label$1
+ (nop)
+ (unreachable)
+ (unreachable)
+ )
+ (unreachable)
+ )
+ (func $9 (type $9) (param $var$0 i64) (param $var$1 f32) (param $var$2 f64) (param $var$3 i32) (param $var$4 i32) (result f64)
+ (local $var$5 i64)
+ (local $var$6 i64)
+ (local $var$7 f32)
+ (local $var$8 f64)
+ (local $9 i64)
+ (local $10 f64)
+ (local $11 f32)
+ (local $12 f64)
+ (local $13 f64)
+ (local $14 i32)
+ (local $15 f64)
+ (local $16 i32)
+ (local $17 f64)
+ (local $18 f32)
+ (local $19 f64)
+ (local $20 i64)
+ (local $21 f64)
+ (local $22 i64)
+ (local $23 f64)
+ (local $24 f64)
+ (local $25 f64)
+ (local $26 f64)
+ (local $27 f64)
+ (local $28 f64)
+ (local $29 f64)
+ (local $30 f64)
+ (local $31 f64)
+ (local $32 f64)
+ (local $33 f64)
+ (local $34 f64)
+ (block $label$1
+ (set_local $var$7
+ (f32.const 5.5)
+ )
+ (nop)
+ (set_local $var$5
+ (i64.const 6)
+ )
+ (nop)
+ (set_local $var$8
+ (f64.const 8)
+ )
+ (nop)
+ (set_local $9
+ (get_local $var$0)
+ )
+ (set_local $10
+ (f64.convert_u/i64
+ (get_local $9)
+ )
+ )
+ (set_local $11
+ (get_local $var$1)
+ )
+ (set_local $12
+ (f64.promote/f32
+ (get_local $11)
+ )
+ )
+ (set_local $13
+ (get_local $var$2)
+ )
+ (set_local $14
+ (get_local $var$3)
+ )
+ (set_local $15
+ (f64.convert_u/i32
+ (get_local $14)
+ )
+ )
+ (set_local $16
+ (get_local $var$4)
+ )
+ (set_local $17
+ (f64.convert_s/i32
+ (get_local $16)
+ )
+ )
+ (set_local $18
+ (get_local $var$7)
+ )
+ (set_local $19
+ (f64.promote/f32
+ (get_local $18)
+ )
+ )
+ (set_local $20
+ (get_local $var$5)
+ )
+ (set_local $21
+ (f64.convert_u/i64
+ (get_local $20)
+ )
+ )
+ (set_local $22
+ (get_local $var$6)
+ )
+ (set_local $23
+ (f64.convert_u/i64
+ (get_local $22)
+ )
+ )
+ (set_local $24
+ (get_local $var$8)
+ )
+ (set_local $25
+ (f64.add
+ (get_local $23)
+ (get_local $24)
+ )
+ )
+ (set_local $26
+ (f64.add
+ (get_local $21)
+ (get_local $25)
+ )
+ )
+ (set_local $27
+ (f64.add
+ (get_local $19)
+ (get_local $26)
+ )
+ )
+ (set_local $28
+ (f64.add
+ (get_local $17)
+ (get_local $27)
+ )
+ )
+ (set_local $29
+ (f64.add
+ (get_local $15)
+ (get_local $28)
+ )
+ )
+ (set_local $30
+ (f64.add
+ (get_local $13)
+ (get_local $29)
+ )
+ )
+ (set_local $31
+ (f64.add
+ (get_local $12)
+ (get_local $30)
+ )
+ )
+ (set_local $32
+ (f64.add
+ (get_local $10)
+ (get_local $31)
+ )
+ )
+ (set_local $33
+ (get_local $32)
+ )
+ )
+ (set_local $34
+ (get_local $33)
+ )
+ (return
+ (get_local $34)
+ )
+ )
+)
diff --git a/test/passes/flatten.txt b/test/passes/flatten.txt
new file mode 100644
index 000000000..76089bdb0
--- /dev/null
+++ b/test/passes/flatten.txt
@@ -0,0 +1,2402 @@
+(module
+ (type $ii (func (param i32 i32)))
+ (type $1 (func))
+ (type $2 (func (result i32)))
+ (type $3 (func (param i32) (result i32)))
+ (type $4 (func (param i64 i64) (result i64)))
+ (type $5 (func (result f32)))
+ (global $x (mut i32) (i32.const 0))
+ (table 1 1 anyfunc)
+ (elem (i32.const 0) $call-me)
+ (memory $0 10)
+ (func $a1 (type $1)
+ (drop
+ (i32.add
+ (i32.const 0)
+ (i32.const 1)
+ )
+ )
+ )
+ (func $a2 (type $2) (result i32)
+ (return
+ (i32.add
+ (i32.const 0)
+ (i32.const 1)
+ )
+ )
+ )
+ (func $a3 (type $2) (result i32)
+ (local $0 i32)
+ (local $1 i32)
+ (local $2 i32)
+ (block $block
+ (set_local $0
+ (i32.const 1)
+ )
+ )
+ (set_local $1
+ (get_local $0)
+ )
+ (set_local $2
+ (i32.add
+ (i32.const 0)
+ (get_local $1)
+ )
+ )
+ (return
+ (get_local $2)
+ )
+ )
+ (func $a4 (type $1)
+ (local $0 i32)
+ (local $1 i32)
+ (local $2 i32)
+ (block $block
+ (set_local $0
+ (i32.const 1)
+ )
+ )
+ (set_local $1
+ (get_local $0)
+ )
+ (set_local $2
+ (i32.add
+ (i32.const 0)
+ (get_local $1)
+ )
+ )
+ (drop
+ (get_local $2)
+ )
+ (nop)
+ )
+ (func $a5 (type $2) (result i32)
+ (local $0 i32)
+ (local $1 i32)
+ (local $2 i32)
+ (local $3 i32)
+ (local $4 i32)
+ (block $block
+ (set_local $0
+ (i32.const 0)
+ )
+ )
+ (set_local $1
+ (get_local $0)
+ )
+ (block $block0
+ (set_local $2
+ (i32.const 1)
+ )
+ )
+ (set_local $3
+ (get_local $2)
+ )
+ (set_local $4
+ (i32.add
+ (get_local $1)
+ (get_local $3)
+ )
+ )
+ (return
+ (get_local $4)
+ )
+ )
+ (func $a6 (type $2) (result i32)
+ (local $x i32)
+ (local $1 i32)
+ (local $2 i32)
+ (local $3 i32)
+ (local $4 i32)
+ (local $5 i32)
+ (local $6 i32)
+ (local $7 i32)
+ (block $block
+ (set_local $1
+ (tee_local $x
+ (i32.const 0)
+ )
+ )
+ (set_local $2
+ (get_local $1)
+ )
+ )
+ (set_local $3
+ (get_local $2)
+ )
+ (block $block1
+ (set_local $4
+ (tee_local $x
+ (i32.const 1)
+ )
+ )
+ (set_local $5
+ (get_local $4)
+ )
+ )
+ (set_local $6
+ (get_local $5)
+ )
+ (set_local $7
+ (i32.add
+ (get_local $3)
+ (get_local $6)
+ )
+ )
+ (return
+ (get_local $7)
+ )
+ )
+ (func $a7 (type $2) (result i32)
+ (local $x i32)
+ (local $1 i32)
+ (local $2 i32)
+ (local $3 i32)
+ (local $4 i32)
+ (local $5 i32)
+ (local $6 i32)
+ (local $7 i32)
+ (local $8 i32)
+ (local $9 i32)
+ (block $block
+ (block $block2
+ (set_local $1
+ (tee_local $x
+ (i32.const 0)
+ )
+ )
+ (set_local $2
+ (get_local $1)
+ )
+ )
+ (set_local $3
+ (get_local $2)
+ )
+ (block $block3
+ (set_local $4
+ (tee_local $x
+ (i32.const 1)
+ )
+ )
+ (set_local $5
+ (get_local $4)
+ )
+ )
+ (set_local $6
+ (get_local $5)
+ )
+ (set_local $7
+ (i32.add
+ (get_local $3)
+ (get_local $6)
+ )
+ )
+ (set_local $8
+ (get_local $7)
+ )
+ )
+ (set_local $9
+ (get_local $8)
+ )
+ (return
+ (get_local $9)
+ )
+ )
+ (func $a8 (type $2) (result i32)
+ (local $x i32)
+ (local $1 i32)
+ (local $2 i32)
+ (local $3 i32)
+ (local $4 i32)
+ (local $5 i32)
+ (local $6 i32)
+ (local $7 i32)
+ (local $8 i32)
+ (local $9 i32)
+ (local $10 i32)
+ (block $outer
+ (block $inner
+ (block $block
+ (set_local $1
+ (i32.const -1)
+ )
+ (br $inner)
+ (unreachable)
+ (set_local $2
+ (i32.const 0)
+ )
+ (br $outer)
+ (unreachable)
+ (set_local $3
+ (i32.const 1)
+ )
+ )
+ (set_local $4
+ (get_local $3)
+ )
+ (block $block4
+ (set_local $2
+ (i32.const 2)
+ )
+ (br $outer)
+ (unreachable)
+ (set_local $5
+ (tee_local $x
+ (i32.const 3)
+ )
+ )
+ (set_local $6
+ (get_local $5)
+ )
+ )
+ (set_local $7
+ (get_local $6)
+ )
+ (set_local $8
+ (i32.add
+ (get_local $4)
+ (get_local $7)
+ )
+ )
+ (set_local $1
+ (get_local $8)
+ )
+ )
+ (set_local $9
+ (get_local $1)
+ )
+ (set_local $2
+ (get_local $9)
+ )
+ )
+ (set_local $10
+ (get_local $2)
+ )
+ (return
+ (get_local $10)
+ )
+ )
+ (func $a9 (type $2) (result i32)
+ (local $0 i32)
+ (local $1 i32)
+ (local $2 i32)
+ (local $3 i32)
+ (local $4 i32)
+ (local $5 i32)
+ (loop $outer
+ (loop $inner
+ (block
+ (br_if $outer
+ (i32.const -1)
+ )
+ (nop)
+ (set_local $0
+ (i32.add
+ (i32.const 0)
+ (i32.const 1)
+ )
+ )
+ )
+ (set_local $1
+ (get_local $0)
+ )
+ (set_local $2
+ (get_local $1)
+ )
+ )
+ (set_local $3
+ (get_local $2)
+ )
+ (set_local $4
+ (get_local $3)
+ )
+ )
+ (set_local $5
+ (get_local $4)
+ )
+ (return
+ (get_local $5)
+ )
+ )
+ (func $a10 (type $2) (result i32)
+ (local $x i32)
+ (local $1 i32)
+ (local $2 i32)
+ (local $3 i32)
+ (local $4 i32)
+ (local $5 i32)
+ (local $6 i32)
+ (local $7 i32)
+ (local $8 i32)
+ (local $9 i32)
+ (local $10 i32)
+ (block $outer
+ (set_local $1
+ (i32.const 0)
+ )
+ (br_if $outer
+ (i32.const 1)
+ )
+ (set_local $2
+ (get_local $1)
+ )
+ (drop
+ (get_local $2)
+ )
+ (nop)
+ (set_local $3
+ (tee_local $x
+ (i32.const 2)
+ )
+ )
+ (set_local $1
+ (get_local $3)
+ )
+ (br_if $outer
+ (i32.const 3)
+ )
+ (set_local $4
+ (get_local $1)
+ )
+ (drop
+ (get_local $4)
+ )
+ (nop)
+ (set_local $5
+ (tee_local $x
+ (i32.const 5)
+ )
+ )
+ (set_local $1
+ (i32.const 4)
+ )
+ (br_if $outer
+ (get_local $5)
+ )
+ (set_local $6
+ (get_local $1)
+ )
+ (drop
+ (get_local $6)
+ )
+ (nop)
+ (set_local $7
+ (tee_local $x
+ (i32.const 6)
+ )
+ )
+ (set_local $8
+ (tee_local $x
+ (i32.const 7)
+ )
+ )
+ (set_local $1
+ (get_local $7)
+ )
+ (br_if $outer
+ (get_local $8)
+ )
+ (set_local $9
+ (get_local $1)
+ )
+ (drop
+ (get_local $9)
+ )
+ (nop)
+ (set_local $1
+ (i32.const 8)
+ )
+ (br $outer)
+ (unreachable)
+ )
+ (set_local $10
+ (get_local $1)
+ )
+ (return
+ (get_local $10)
+ )
+ )
+ (func $a11 (type $1)
+ (if
+ (i32.const 0)
+ (drop
+ (i32.const 1)
+ )
+ )
+ (nop)
+ )
+ (func $a12 (type $2) (result i32)
+ (local $0 i32)
+ (local $1 i32)
+ (if
+ (i32.const 0)
+ (set_local $0
+ (i32.const 1)
+ )
+ (set_local $0
+ (i32.const 2)
+ )
+ )
+ (set_local $1
+ (get_local $0)
+ )
+ (return
+ (get_local $1)
+ )
+ )
+ (func $a13 (type $2) (result i32)
+ (local $0 i32)
+ (local $1 i32)
+ (local $2 i32)
+ (local $3 i32)
+ (local $4 i32)
+ (block $x
+ (block
+ (set_local $0
+ (i32.const 2)
+ )
+ (set_local $1
+ (get_local $0)
+ )
+ (br_table $x
+ (i32.const 0)
+ )
+ (if
+ (unreachable)
+ (set_local $2
+ (i32.const 0)
+ )
+ (set_local $2
+ (i32.const 1)
+ )
+ )
+ )
+ (set_local $3
+ (get_local $2)
+ )
+ (set_local $1
+ (get_local $3)
+ )
+ )
+ (set_local $4
+ (get_local $1)
+ )
+ (return
+ (get_local $4)
+ )
+ )
+ (func $a14 (type $2) (result i32)
+ (local $0 i32)
+ (local $1 i32)
+ (local $2 i32)
+ (block $block
+ (set_local $0
+ (i32.const 7)
+ )
+ (set_local $1
+ (get_local $0)
+ )
+ (br_table $block
+ (i32.const 1)
+ )
+ (select
+ (i32.const 0)
+ (i32.const 1)
+ (unreachable)
+ )
+ (unreachable)
+ )
+ (set_local $2
+ (get_local $1)
+ )
+ (return
+ (get_local $2)
+ )
+ )
+ (func $a15 (type $1)
+ (local $0 i32)
+ (local $1 f32)
+ (local $2 f32)
+ (block
+ (set_local $0
+ (i32.load16_u
+ (i32.const 53)
+ )
+ )
+ (if
+ (get_local $0)
+ (block
+ (unreachable)
+ (unreachable)
+ )
+ (block
+ (block $label$3
+ (unreachable)
+ (unreachable)
+ )
+ (set_local $2
+ (get_local $1)
+ )
+ (drop
+ (get_local $2)
+ )
+ (nop)
+ )
+ )
+ )
+ (unreachable)
+ )
+ (func $a16 (type $2) (result i32)
+ (local $x i32)
+ (local $1 i32)
+ (local $2 i32)
+ (local $3 i32)
+ (local $4 i32)
+ (local $5 i32)
+ (local $6 i32)
+ (local $7 i32)
+ (block $label$1
+ (set_local $1
+ (tee_local $x
+ (i32.const 1)
+ )
+ )
+ (block $label$2
+ (set_local $x
+ (i32.const 0)
+ )
+ (nop)
+ (set_local $2
+ (i32.const 0)
+ )
+ )
+ (set_local $3
+ (get_local $2)
+ )
+ (set_local $4
+ (i32.eqz
+ (get_local $3)
+ )
+ )
+ (set_local $5
+ (get_local $1)
+ )
+ (br_if $label$1
+ (get_local $4)
+ )
+ (set_local $6
+ (get_local $5)
+ )
+ (drop
+ (get_local $6)
+ )
+ (nop)
+ (set_local $5
+ (i32.const 0)
+ )
+ )
+ (set_local $7
+ (get_local $5)
+ )
+ (return
+ (get_local $7)
+ )
+ )
+ (func $a17 (type $5) (result f32)
+ (local $var$0 f32)
+ (local $1 f32)
+ (local $2 f32)
+ (local $3 f32)
+ (local $4 f32)
+ (local $5 f32)
+ (set_local $1
+ (get_local $var$0)
+ )
+ (set_local $2
+ (tee_local $var$0
+ (f32.const -137438953472)
+ )
+ )
+ (set_local $3
+ (get_local $var$0)
+ )
+ (set_local $4
+ (select
+ (get_local $2)
+ (get_local $3)
+ (i32.const 0)
+ )
+ )
+ (set_local $5
+ (f32.max
+ (get_local $1)
+ (get_local $4)
+ )
+ )
+ (return
+ (get_local $5)
+ )
+ )
+ (func $a18 (type $2) (result i32)
+ (local $0 i32)
+ (local $1 i32)
+ (block $label$1
+ (unreachable)
+ (set_local $0
+ (i32.const 1)
+ )
+ (br_if $label$1
+ (unreachable)
+ )
+ (unreachable)
+ (drop
+ (unreachable)
+ )
+ (unreachable.load16_s
+ (unreachable)
+ )
+ (unreachable)
+ )
+ (set_local $1
+ (get_local $0)
+ )
+ (return
+ (get_local $1)
+ )
+ )
+ (func $a19 (type $5) (result f32)
+ (block $label$0
+ (block $label$1
+ (unreachable)
+ (return
+ (f32.const 4289944320)
+ )
+ (select
+ (unreachable)
+ (unreachable)
+ (i32.const 65535)
+ )
+ (drop
+ (unreachable)
+ )
+ (unreachable)
+ )
+ (unreachable)
+ )
+ (unreachable)
+ )
+ (func $call-me (type $ii) (param $0 i32) (param $1 i32)
+ (nop)
+ )
+ (func $code-to-kill (type $1)
+ (local $x i32)
+ (local $1 i32)
+ (local $2 i32)
+ (local $3 i32)
+ (local $4 i32)
+ (local $5 i32)
+ (local $6 i32)
+ (block
+ (block $out
+ (br $out)
+ (unreachable)
+ (drop
+ (i32.const 0)
+ )
+ (if
+ (i32.const 1)
+ (drop
+ (i32.const 2)
+ )
+ )
+ (nop)
+ (br_table $out $out $out $out
+ (i32.const 3)
+ )
+ (unreachable)
+ (call $code-to-kill)
+ (nop)
+ )
+ (nop)
+ (if
+ (i32.const 0)
+ (block
+ (block $out1
+ (unreachable)
+ (unreachable)
+ (drop
+ (i32.const 0)
+ )
+ )
+ (unreachable)
+ )
+ )
+ (nop)
+ (if
+ (i32.const 0)
+ (block
+ (block $out3
+ (return)
+ (unreachable)
+ (drop
+ (i32.const 0)
+ )
+ )
+ (unreachable)
+ )
+ )
+ (nop)
+ (block $out4
+ (br_table $out4 $out4 $out4 $out4
+ (i32.const 4)
+ )
+ (unreachable)
+ (drop
+ (i32.const 0)
+ )
+ )
+ (nop)
+ (block $out5
+ (br_if $out5
+ (i32.const 3)
+ )
+ (nop)
+ (drop
+ (i32.const 0)
+ )
+ )
+ (nop)
+ (if
+ (i32.const 0)
+ (block
+ (block $block4
+ (if
+ (i32.const 0)
+ (block
+ (block $out8
+ (unreachable)
+ (unreachable)
+ (drop
+ (i32.const 0)
+ )
+ )
+ (unreachable)
+ )
+ (block
+ (block $out9
+ (unreachable)
+ (unreachable)
+ (drop
+ (i32.const 0)
+ )
+ )
+ (unreachable)
+ )
+ )
+ (unreachable)
+ (drop
+ (i32.const 0)
+ )
+ )
+ (unreachable)
+ )
+ )
+ (nop)
+ (if
+ (i32.const 0)
+ (block
+ (block $out11
+ (unreachable)
+ (unreachable)
+ (unreachable)
+ (drop
+ (i32.const 0)
+ )
+ (unreachable)
+ (unreachable)
+ )
+ (set_local $2
+ (get_local $1)
+ )
+ (drop
+ (get_local $2)
+ )
+ (nop)
+ )
+ )
+ (nop)
+ (if
+ (i32.const 0)
+ (block
+ (block $out13
+ (unreachable)
+ (unreachable)
+ (unreachable)
+ (drop
+ (i32.const 0)
+ )
+ (unreachable)
+ (unreachable)
+ )
+ (set_local $4
+ (get_local $3)
+ )
+ (drop
+ (get_local $4)
+ )
+ (nop)
+ )
+ )
+ (nop)
+ (if
+ (i32.const 0)
+ (block
+ (block $out15
+ (unreachable)
+ (unreachable)
+ (unreachable)
+ (unreachable)
+ (drop
+ (i32.const 0)
+ )
+ (unreachable)
+ (unreachable)
+ )
+ (set_local $6
+ (get_local $5)
+ )
+ (drop
+ (get_local $6)
+ )
+ (nop)
+ )
+ )
+ (nop)
+ (block $out16
+ (block $in
+ (br_if $out16
+ (i32.const 1)
+ )
+ (nop)
+ )
+ (nop)
+ (unreachable)
+ (unreachable)
+ )
+ (nop)
+ (if
+ (i32.const 0)
+ (block
+ (block $block11
+ (block $out18
+ (block $in19
+ (br_if $in19
+ (i32.const 1)
+ )
+ (nop)
+ )
+ (nop)
+ (unreachable)
+ (unreachable)
+ )
+ (unreachable)
+ (drop
+ (i32.const 10)
+ )
+ )
+ (unreachable)
+ )
+ )
+ (nop)
+ (block $out20
+ (block $in21
+ (br_table $out20 $in21
+ (i32.const 1)
+ )
+ (unreachable)
+ )
+ (nop)
+ (unreachable)
+ (unreachable)
+ )
+ (nop)
+ (block $out22
+ (block $in23
+ (br_table $in23 $out22
+ (i32.const 1)
+ )
+ (unreachable)
+ )
+ (nop)
+ (unreachable)
+ (unreachable)
+ )
+ (nop)
+ (if
+ (i32.const 0)
+ (block
+ (block $block13
+ (block $out25
+ (block $in26
+ (br_table $in26 $in26
+ (i32.const 1)
+ )
+ (unreachable)
+ )
+ (nop)
+ (unreachable)
+ (unreachable)
+ )
+ (unreachable)
+ (drop
+ (i32.const 10)
+ )
+ )
+ (unreachable)
+ )
+ )
+ (nop)
+ (if
+ (i32.const 0)
+ (block
+ (block $block15
+ (drop
+ (i32.const 10)
+ )
+ (drop
+ (i32.const 42)
+ )
+ (unreachable)
+ (unreachable)
+ (unreachable)
+ (return
+ (unreachable)
+ )
+ (unreachable)
+ (unreachable)
+ (unreachable)
+ (return)
+ (unreachable)
+ )
+ (unreachable)
+ )
+ )
+ (nop)
+ (if
+ (i32.const 0)
+ (block
+ (loop $loop-in18
+ (unreachable)
+ (unreachable)
+ )
+ (unreachable)
+ )
+ )
+ (nop)
+ (block $out29
+ (loop $in30
+ (block
+ (br_if $out29
+ (i32.const 1)
+ )
+ (nop)
+ (unreachable)
+ (unreachable)
+ )
+ (unreachable)
+ )
+ (unreachable)
+ )
+ (nop)
+ (if
+ (i32.const 0)
+ (block
+ (block $block20
+ (loop $in32
+ (block
+ (br_if $in32
+ (i32.const 1)
+ )
+ (nop)
+ (unreachable)
+ (unreachable)
+ )
+ (unreachable)
+ )
+ (unreachable)
+ (drop
+ (i32.const 10)
+ )
+ )
+ (unreachable)
+ )
+ )
+ (nop)
+ (if
+ (i32.const 1)
+ (block
+ (unreachable)
+ (call $call-me
+ (i32.const 123)
+ (unreachable)
+ )
+ (unreachable)
+ )
+ )
+ (nop)
+ (if
+ (i32.const 2)
+ (block
+ (unreachable)
+ (call $call-me
+ (unreachable)
+ (i32.const 0)
+ )
+ (unreachable)
+ )
+ )
+ (nop)
+ (if
+ (i32.const 3)
+ (block
+ (unreachable)
+ (unreachable)
+ (call $call-me
+ (unreachable)
+ (unreachable)
+ )
+ (unreachable)
+ )
+ )
+ (nop)
+ (if
+ (i32.const -1)
+ (block
+ (unreachable)
+ (call_indirect $ii
+ (i32.const 123)
+ (i32.const 456)
+ (unreachable)
+ )
+ (unreachable)
+ )
+ )
+ (nop)
+ (if
+ (i32.const -2)
+ (block
+ (unreachable)
+ (call_indirect $ii
+ (i32.const 139)
+ (unreachable)
+ (i32.const 0)
+ )
+ (unreachable)
+ )
+ )
+ (nop)
+ (if
+ (i32.const -3)
+ (block
+ (unreachable)
+ (unreachable)
+ (call_indirect $ii
+ (i32.const 246)
+ (unreachable)
+ (unreachable)
+ )
+ (unreachable)
+ )
+ )
+ (nop)
+ (if
+ (i32.const -4)
+ (block
+ (unreachable)
+ (unreachable)
+ (unreachable)
+ (call_indirect $ii
+ (unreachable)
+ (unreachable)
+ (unreachable)
+ )
+ (unreachable)
+ )
+ )
+ (nop)
+ (if
+ (i32.const 11)
+ (block
+ (unreachable)
+ (tee_local $x
+ (unreachable)
+ )
+ (unreachable)
+ )
+ )
+ (nop)
+ (if
+ (i32.const 22)
+ (block
+ (unreachable)
+ (unreachable.load
+ (unreachable)
+ )
+ (drop
+ (unreachable)
+ )
+ (unreachable)
+ )
+ )
+ (nop)
+ (if
+ (i32.const 33)
+ (block
+ (unreachable)
+ (i32.store
+ (i32.const 0)
+ (unreachable)
+ )
+ (unreachable)
+ )
+ )
+ (nop)
+ (if
+ (i32.const 44)
+ (block
+ (unreachable)
+ (i32.store
+ (unreachable)
+ (i32.const 0)
+ )
+ (unreachable)
+ )
+ )
+ (nop)
+ (if
+ (i32.const 55)
+ (block
+ (unreachable)
+ (unreachable)
+ (i32.store
+ (unreachable)
+ (unreachable)
+ )
+ (unreachable)
+ )
+ )
+ (nop)
+ (if
+ (i32.const 66)
+ (block
+ (unreachable)
+ (i32.eqz
+ (unreachable)
+ )
+ (drop
+ (unreachable)
+ )
+ (unreachable)
+ )
+ )
+ (nop)
+ (if
+ (i32.const 77)
+ (block
+ (unreachable)
+ (i32.add
+ (unreachable)
+ (i32.const 0)
+ )
+ (drop
+ (unreachable)
+ )
+ (unreachable)
+ )
+ )
+ (nop)
+ (if
+ (i32.const 88)
+ (block
+ (unreachable)
+ (i32.add
+ (i32.const 0)
+ (unreachable)
+ )
+ (drop
+ (unreachable)
+ )
+ (unreachable)
+ )
+ )
+ (nop)
+ (if
+ (i32.const 99)
+ (block
+ (unreachable)
+ (unreachable)
+ (i32.add
+ (unreachable)
+ (unreachable)
+ )
+ (unreachable)
+ )
+ )
+ (nop)
+ (if
+ (i32.const 100)
+ (block
+ (unreachable)
+ (select
+ (i32.const 123)
+ (i32.const 456)
+ (unreachable)
+ )
+ (drop
+ (unreachable)
+ )
+ (unreachable)
+ )
+ )
+ (nop)
+ (if
+ (i32.const 101)
+ (block
+ (unreachable)
+ (select
+ (i32.const 123)
+ (unreachable)
+ (i32.const 456)
+ )
+ (drop
+ (unreachable)
+ )
+ (unreachable)
+ )
+ )
+ (nop)
+ (if
+ (i32.const 102)
+ (block
+ (unreachable)
+ (select
+ (unreachable)
+ (i32.const 123)
+ (i32.const 456)
+ )
+ (drop
+ (unreachable)
+ )
+ (unreachable)
+ )
+ )
+ (nop)
+ (drop
+ (i32.const 1337)
+ )
+ )
+ (nop)
+ )
+ (func $killer (type $1)
+ (block
+ (unreachable)
+ (unreachable)
+ (drop
+ (i32.const 1000)
+ )
+ )
+ (unreachable)
+ )
+ (func $target (type $1)
+ (drop
+ (i32.const 2000)
+ )
+ )
+ (func $typed-block-none-then-unreachable (type $2) (result i32)
+ (local $0 i32)
+ (local $1 i32)
+ (block $top-typed
+ (block $switch$0
+ (return
+ (i32.const 0)
+ )
+ (unreachable)
+ (br $switch$0)
+ (unreachable)
+ )
+ (nop)
+ (return
+ (i32.const 1)
+ )
+ (unreachable)
+ )
+ (set_local $1
+ (get_local $0)
+ )
+ (return
+ (get_local $1)
+ )
+ )
+ (func $typed-block-remove-br-changes-type (type $3) (param $$$0 i32) (result i32)
+ (local $1 i32)
+ (local $2 i32)
+ (local $3 i32)
+ (local $4 i32)
+ (block
+ (block $switch$7
+ (block $switch-default$10
+ (block $switch-case$9
+ (block $switch-case$8
+ (br_table $switch-case$9 $switch-case$8 $switch-default$10
+ (i32.const -1)
+ )
+ (unreachable)
+ )
+ (nop)
+ )
+ (nop)
+ (set_local $1
+ (get_local $$$0)
+ )
+ (return
+ (get_local $1)
+ )
+ (unreachable)
+ (br $switch$7)
+ (unreachable)
+ )
+ (nop)
+ (set_local $2
+ (get_local $$$0)
+ )
+ (return
+ (get_local $2)
+ )
+ (unreachable)
+ )
+ (nop)
+ (return
+ (i32.const 0)
+ )
+ (unreachable)
+ )
+ (set_local $4
+ (get_local $3)
+ )
+ (return
+ (get_local $4)
+ )
+ )
+ (func $global (type $1)
+ (local $0 i32)
+ (block
+ (unreachable)
+ (unreachable)
+ (set_local $0
+ (get_global $x)
+ )
+ (drop
+ (get_local $0)
+ )
+ (nop)
+ (set_global $x
+ (i32.const 1)
+ )
+ (nop)
+ )
+ (unreachable)
+ )
+ (func $ret (type $2) (result i32)
+ (local $0 i32)
+ (local $1 i32)
+ (block
+ (return
+ (i32.const 0)
+ )
+ (unreachable)
+ (nop)
+ (set_local $0
+ (i32.const 0)
+ )
+ )
+ (set_local $1
+ (get_local $0)
+ )
+ (return
+ (get_local $1)
+ )
+ )
+ (func $unreachable-br (type $2) (result i32)
+ (local $0 i32)
+ (local $1 i32)
+ (block $out
+ (set_local $0
+ (i32.const 0)
+ )
+ (br $out)
+ (unreachable)
+ (unreachable)
+ )
+ (set_local $1
+ (get_local $0)
+ )
+ (return
+ (get_local $1)
+ )
+ )
+ (func $unreachable-br-loop (type $2) (result i32)
+ (loop $out
+ (br $out)
+ (unreachable)
+ )
+ (unreachable)
+ )
+ (func $unreachable-block-ends-switch (type $2) (result i32)
+ (local $0 i32)
+ (local $1 i32)
+ (block $label$0
+ (block $label$3
+ (nop)
+ (unreachable)
+ (br_table $label$3
+ (unreachable)
+ )
+ (unreachable)
+ (unreachable)
+ (unreachable)
+ )
+ (nop)
+ (set_local $0
+ (i32.const 19)
+ )
+ )
+ (set_local $1
+ (get_local $0)
+ )
+ (return
+ (get_local $1)
+ )
+ )
+ (func $unreachable-block-ends-br_if (type $2) (result i32)
+ (local $0 i32)
+ (local $1 i32)
+ (block $label$0
+ (block $label$2
+ (nop)
+ (unreachable)
+ (br_if $label$2
+ (unreachable)
+ )
+ (unreachable)
+ (unreachable)
+ (unreachable)
+ )
+ (nop)
+ (set_local $0
+ (i32.const 19)
+ )
+ )
+ (set_local $1
+ (get_local $0)
+ )
+ (return
+ (get_local $1)
+ )
+ )
+ (func $unreachable-brs-3 (type $2) (result i32)
+ (local $0 i32)
+ (local $1 i32)
+ (block $label$0
+ (set_local $0
+ (i32.const 18)
+ )
+ (br $label$0)
+ (grow_memory
+ (unreachable)
+ )
+ (unreachable)
+ (unreachable)
+ (set_local $0
+ (i32.const 21)
+ )
+ )
+ (set_local $1
+ (get_local $0)
+ )
+ (return
+ (get_local $1)
+ )
+ )
+ (func $unreachable-brs-4 (type $3) (param $var$0 i32) (result i32)
+ (local $1 i32)
+ (local $2 i32)
+ (local $3 i32)
+ (local $4 i32)
+ (local $5 i32)
+ (block $label$0
+ (block $label$1
+ (unreachable)
+ (set_local $1
+ (i32.const 4104)
+ )
+ (br_if $label$0
+ (unreachable)
+ )
+ (unreachable)
+ (drop
+ (unreachable)
+ )
+ (unreachable)
+ (set_local $2
+ (i32.const 4)
+ )
+ )
+ (set_local $3
+ (get_local $2)
+ )
+ (set_local $1
+ (get_local $3)
+ )
+ (br $label$0)
+ (unreachable)
+ (set_local $1
+ (i32.const 16)
+ )
+ )
+ (set_local $4
+ (get_local $1)
+ )
+ (set_local $5
+ (i32.add
+ (i32.const 1)
+ (get_local $4)
+ )
+ )
+ (return
+ (get_local $5)
+ )
+ )
+ (func $call-unreach (type $4) (param $var$0 i64) (param $var$1 i64) (result i64)
+ (local $2 i64)
+ (local $3 i64)
+ (local $4 i32)
+ (local $5 i64)
+ (local $6 i64)
+ (local $7 i64)
+ (local $8 i64)
+ (local $9 i64)
+ (local $10 i64)
+ (local $11 i64)
+ (local $12 i64)
+ (local $13 i64)
+ (local $14 i64)
+ (local $15 i64)
+ (local $16 i64)
+ (local $17 i64)
+ (block
+ (set_local $3
+ (get_local $var$0)
+ )
+ (set_local $4
+ (i64.eqz
+ (get_local $3)
+ )
+ )
+ (if
+ (get_local $4)
+ (block
+ (block $label$0
+ (set_local $5
+ (get_local $var$1)
+ )
+ (set_local $6
+ (get_local $5)
+ )
+ )
+ (set_local $7
+ (get_local $6)
+ )
+ (set_local $16
+ (get_local $7)
+ )
+ )
+ (block
+ (block $label$1
+ (set_local $8
+ (get_local $var$0)
+ )
+ (set_local $9
+ (i64.sub
+ (get_local $8)
+ (i64.const 1)
+ )
+ )
+ (block $block
+ (set_local $10
+ (get_local $var$0)
+ )
+ (set_local $2
+ (get_local $10)
+ )
+ (nop)
+ (nop)
+ (set_local $11
+ (get_local $2)
+ )
+ (set_local $12
+ (get_local $11)
+ )
+ )
+ (set_local $13
+ (get_local $12)
+ )
+ (unreachable)
+ (i64.mul
+ (get_local $13)
+ (unreachable)
+ )
+ (call $call-unreach
+ (get_local $9)
+ (unreachable)
+ )
+ (unreachable)
+ )
+ (set_local $15
+ (get_local $14)
+ )
+ (set_local $16
+ (get_local $15)
+ )
+ )
+ )
+ )
+ (set_local $17
+ (get_local $16)
+ )
+ (return
+ (get_local $17)
+ )
+ )
+ (func $test-flatten (type $1)
+ (local $0 i32)
+ (local $1 i32)
+ (local $2 i32)
+ (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)
+ (block $out
+ (drop
+ (i32.add
+ (i32.const 1)
+ (i32.const 2)
+ )
+ )
+ (br $out)
+ (i32.add
+ (i32.const 1)
+ (unreachable)
+ )
+ (drop
+ (unreachable)
+ )
+ (unreachable)
+ (br $out)
+ (i32.add
+ (unreachable)
+ (i32.const 1)
+ )
+ (drop
+ (unreachable)
+ )
+ (unreachable)
+ (br_table $out $out $out $out
+ (i32.const 3)
+ )
+ (i32.add
+ (i32.const 1)
+ (unreachable)
+ )
+ (drop
+ (unreachable)
+ )
+ (unreachable)
+ (block $block
+ (drop
+ (i32.const 2)
+ )
+ (drop
+ (i32.const 3)
+ )
+ (set_local $0
+ (i32.const 4)
+ )
+ )
+ (set_local $1
+ (get_local $0)
+ )
+ (set_local $2
+ (i32.add
+ (i32.const 1)
+ (get_local $1)
+ )
+ )
+ (drop
+ (get_local $2)
+ )
+ (nop)
+ (block $in
+ (block $switch-in
+ (set_local $3
+ (i32.const 2)
+ )
+ (set_local $4
+ (get_local $3)
+ )
+ (set_local $5
+ (get_local $3)
+ )
+ (br_table $in $switch-in $in
+ (i32.const 777)
+ )
+ (unreachable)
+ )
+ (set_local $6
+ (get_local $5)
+ )
+ (drop
+ (get_local $6)
+ )
+ (nop)
+ (set_local $4
+ (i32.const 3)
+ )
+ (br $in)
+ (unreachable)
+ (set_local $4
+ (i32.const 4)
+ )
+ )
+ (set_local $7
+ (get_local $4)
+ )
+ (set_local $8
+ (i32.add
+ (i32.const 1)
+ (get_local $7)
+ )
+ )
+ (drop
+ (get_local $8)
+ )
+ (nop)
+ (loop $loop-in
+ (set_local $9
+ (i32.const 5)
+ )
+ )
+ (set_local $10
+ (get_local $9)
+ )
+ (set_local $11
+ (i32.add
+ (i32.const 1)
+ (get_local $10)
+ )
+ )
+ (drop
+ (get_local $11)
+ )
+ (nop)
+ (if
+ (i32.const 6)
+ (set_local $12
+ (i32.const 7)
+ )
+ (set_local $12
+ (i32.const 8)
+ )
+ )
+ (set_local $13
+ (get_local $12)
+ )
+ (set_local $14
+ (i32.add
+ (i32.const 1)
+ (get_local $13)
+ )
+ )
+ (drop
+ (get_local $14)
+ )
+ (nop)
+ (drop
+ (select
+ (i32.const 9)
+ (i32.const 10)
+ (i32.const 11)
+ )
+ )
+ (br $out)
+ (select
+ (unreachable)
+ (i32.const 10)
+ (i32.const 11)
+ )
+ (drop
+ (unreachable)
+ )
+ (unreachable)
+ (br $out)
+ (select
+ (i32.const 9)
+ (unreachable)
+ (i32.const 11)
+ )
+ (drop
+ (unreachable)
+ )
+ (unreachable)
+ (br $out)
+ (select
+ (i32.const 9)
+ (i32.const 10)
+ (unreachable)
+ )
+ (drop
+ (unreachable)
+ )
+ (unreachable)
+ (if
+ (i32.const 11)
+ (set_local $15
+ (i32.const 12)
+ )
+ (set_local $15
+ (i32.const 13)
+ )
+ )
+ (set_local $16
+ (get_local $15)
+ )
+ (set_local $17
+ (select
+ (get_local $16)
+ (i32.const 9)
+ (i32.const 10)
+ )
+ )
+ (drop
+ (get_local $17)
+ )
+ (nop)
+ (if
+ (i32.const 11)
+ (set_local $18
+ (i32.const 12)
+ )
+ (set_local $18
+ (i32.const 13)
+ )
+ )
+ (set_local $19
+ (get_local $18)
+ )
+ (set_local $20
+ (select
+ (i32.const 9)
+ (get_local $19)
+ (i32.const 10)
+ )
+ )
+ (drop
+ (get_local $20)
+ )
+ (nop)
+ (if
+ (i32.const 11)
+ (set_local $21
+ (i32.const 12)
+ )
+ (set_local $21
+ (i32.const 13)
+ )
+ )
+ (set_local $22
+ (get_local $21)
+ )
+ (set_local $23
+ (select
+ (i32.const 9)
+ (i32.const 10)
+ (get_local $22)
+ )
+ )
+ (drop
+ (get_local $23)
+ )
+ (nop)
+ (if
+ (i32.const 11)
+ (set_local $24
+ (i32.const 12)
+ )
+ (set_local $24
+ (i32.const 13)
+ )
+ )
+ (set_local $25
+ (get_local $24)
+ )
+ (if
+ (i32.const 15)
+ (set_local $26
+ (i32.const 16)
+ )
+ (set_local $26
+ (i32.const 17)
+ )
+ )
+ (set_local $27
+ (get_local $26)
+ )
+ (set_local $28
+ (select
+ (get_local $25)
+ (i32.const 14)
+ (get_local $27)
+ )
+ )
+ (drop
+ (get_local $28)
+ )
+ (nop)
+ (return)
+ (i32.add
+ (i32.const 1)
+ (unreachable)
+ )
+ (drop
+ (unreachable)
+ )
+ (unreachable)
+ (unreachable)
+ (i32.add
+ (i32.const 1)
+ (unreachable)
+ )
+ (drop
+ (unreachable)
+ )
+ (unreachable)
+ (block
+ (if
+ (i32.const 5)
+ (set_local $29
+ (i32.const 6)
+ )
+ (set_local $29
+ (i32.const 7)
+ )
+ )
+ (set_local $30
+ (get_local $29)
+ )
+ (if
+ (get_local $30)
+ (set_local $33
+ (i32.const 8)
+ )
+ (block
+ (if
+ (i32.const 9)
+ (set_local $31
+ (i32.const 10)
+ )
+ (set_local $31
+ (i32.const 11)
+ )
+ )
+ (set_local $32
+ (get_local $31)
+ )
+ (set_local $33
+ (get_local $32)
+ )
+ )
+ )
+ )
+ (set_local $34
+ (get_local $33)
+ )
+ (drop
+ (get_local $34)
+ )
+ (nop)
+ (block $temp
+ (set_local $35
+ (i32.const 1)
+ )
+ (br_if $temp
+ (i32.const 2)
+ )
+ (set_local $36
+ (get_local $35)
+ )
+ (set_local $35
+ (get_local $36)
+ )
+ )
+ (set_local $37
+ (get_local $35)
+ )
+ (drop
+ (get_local $37)
+ )
+ (nop)
+ )
+ (nop)
+ )
+ (func $flatten-return-value (type $2) (result i32)
+ (local $0 i32)
+ (local $1 i32)
+ (block
+ (return
+ (i32.const 2)
+ )
+ (i32.add
+ (i32.const 1)
+ (unreachable)
+ )
+ (drop
+ (unreachable)
+ )
+ (unreachable)
+ (set_local $0
+ (i32.const 3)
+ )
+ )
+ (set_local $1
+ (get_local $0)
+ )
+ (return
+ (get_local $1)
+ )
+ )
+ (func $unbug (type $1)
+ (local $12 i32)
+ (local $432 i32)
+ (local $430 i32)
+ (local $431 i32)
+ (local $9 i32)
+ (local $5 i32)
+ (local $433 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)
+ (block $block
+ (block
+ (set_local $7
+ (get_local $12)
+ )
+ (set_local $8
+ (i32.eq
+ (get_local $7)
+ (i32.const 65535)
+ )
+ )
+ (if
+ (get_local $8)
+ (block
+ (block $block44
+ (block $label$78
+ (set_local $430
+ (i32.const 0)
+ )
+ (nop)
+ )
+ (nop)
+ (set_local $9
+ (get_local $430)
+ )
+ (set_local $432
+ (get_local $9)
+ )
+ (nop)
+ )
+ (nop)
+ )
+ (block
+ (block $block45
+ (block $label$79
+ (set_local $10
+ (get_local $9)
+ )
+ (set_local $11
+ (get_local $5)
+ )
+ (set_local $12
+ (get_local $12)
+ )
+ (set_local $13
+ (i32.mul
+ (get_local $12)
+ (i32.const 12)
+ )
+ )
+ (set_local $14
+ (i32.add
+ (get_local $11)
+ (get_local $13)
+ )
+ )
+ (set_local $15
+ (i32.load16_u offset=2
+ (get_local $14)
+ )
+ )
+ (set_local $16
+ (i32.lt_u
+ (get_local $10)
+ (get_local $15)
+ )
+ )
+ (set_local $431
+ (get_local $16)
+ )
+ (nop)
+ )
+ (nop)
+ (set_local $17
+ (get_local $431)
+ )
+ (set_local $432
+ (get_local $17)
+ )
+ (nop)
+ )
+ (nop)
+ )
+ )
+ )
+ (nop)
+ (set_local $433
+ (i32.const 1)
+ )
+ (nop)
+ (set_local $18
+ (get_local $432)
+ )
+ (set_local $19
+ (get_local $433)
+ )
+ (set_local $20
+ (i32.xor
+ (get_local $18)
+ (get_local $19)
+ )
+ )
+ (set_local $21
+ (get_local $20)
+ )
+ )
+ (set_local $22
+ (get_local $21)
+ )
+ (drop
+ (get_local $22)
+ )
+ (nop)
+ )
+ (func $outer-block-typed (type $3) (param $var$0 i32) (result i32)
+ (local $1 i32)
+ (local $2 i32)
+ (local $3 i32)
+ (local $4 i32)
+ (local $5 i32)
+ (block $block
+ (block $label$0
+ (set_local $1
+ (i32.const 16)
+ )
+ )
+ (set_local $2
+ (get_local $1)
+ )
+ (set_local $3
+ (i32.add
+ (i32.const 1)
+ (get_local $2)
+ )
+ )
+ (set_local $4
+ (get_local $3)
+ )
+ )
+ (set_local $5
+ (get_local $4)
+ )
+ (return
+ (get_local $5)
+ )
+ )
+ (func $nested-br_if-with-value (type $2) (result i32)
+ (local $0 i32)
+ (local $1 i32)
+ (local $2 i32)
+ (local $3 i32)
+ (local $4 i32)
+ (local $5 i32)
+ (local $6 i32)
+ (block $label$0
+ (block $block
+ (set_local $1
+ (get_local $0)
+ )
+ (set_local $2
+ (get_local $1)
+ )
+ )
+ (set_local $3
+ (get_local $2)
+ )
+ (set_local $4
+ (i32.const 0)
+ )
+ (br_if $label$0
+ (get_local $3)
+ )
+ (set_local $5
+ (get_local $4)
+ )
+ (drop
+ (get_local $5)
+ )
+ (nop)
+ (set_local $4
+ (i32.const 1)
+ )
+ )
+ (set_local $6
+ (get_local $4)
+ )
+ (return
+ (get_local $6)
+ )
+ )
+ (func $switch-unreachable (type $1)
+ (block $label$3
+ (unreachable)
+ (br_table $label$3
+ (unreachable)
+ )
+ (unreachable)
+ )
+ (nop)
+ )
+ (func $br_if_order (type $3) (param $x i32) (result i32)
+ (local $1 i32)
+ (local $2 i32)
+ (local $3 i32)
+ (local $4 i32)
+ (local $5 i32)
+ (local $6 i32)
+ (local $7 i32)
+ (local $8 i32)
+ (local $9 i32)
+ (block $outer
+ (block $inner
+ (set_local $1
+ (i32.const 0)
+ )
+ (br_if $outer
+ (i32.const 1)
+ )
+ (set_local $2
+ (get_local $1)
+ )
+ (block $block
+ (set_local $3
+ (i32.const -16)
+ )
+ )
+ (set_local $4
+ (get_local $3)
+ )
+ (set_local $5
+ (call $br_if_order
+ (get_local $4)
+ )
+ )
+ (set_local $6
+ (get_local $2)
+ )
+ (br_if $inner
+ (get_local $5)
+ )
+ (set_local $7
+ (get_local $6)
+ )
+ (set_local $6
+ (get_local $7)
+ )
+ )
+ (set_local $8
+ (get_local $6)
+ )
+ (set_local $1
+ (get_local $8)
+ )
+ )
+ (set_local $9
+ (get_local $1)
+ )
+ (return
+ (get_local $9)
+ )
+ )
+)
diff --git a/test/passes/flatten-control-flow.wasm b/test/passes/flatten.wasm
index 0ba6a86fe..0ba6a86fe 100644
--- a/test/passes/flatten-control-flow.wasm
+++ b/test/passes/flatten.wasm
Binary files differ
diff --git a/test/passes/flatten-control-flow.wast b/test/passes/flatten.wast
index 97ecf74c7..92edd354d 100644
--- a/test/passes/flatten-control-flow.wast
+++ b/test/passes/flatten.wast
@@ -8,6 +8,220 @@
(table 1 1 anyfunc)
(elem (i32.const 0) $call-me)
(memory $0 10)
+ (func $a1
+ (drop (i32.add (i32.const 0) (i32.const 1)))
+ )
+ (func $a2 (result i32)
+ (i32.add (i32.const 0) (i32.const 1))
+ )
+ (func $a3 (result i32)
+ (i32.add
+ (i32.const 0)
+ (block (result i32)
+ (i32.const 1)
+ )
+ )
+ )
+ (func $a4
+ (drop
+ (i32.add
+ (i32.const 0)
+ (block (result i32)
+ (i32.const 1)
+ )
+ )
+ )
+ )
+ (func $a5 (result i32)
+ (i32.add
+ (block (result i32)
+ (i32.const 0)
+ )
+ (block (result i32)
+ (i32.const 1)
+ )
+ )
+ )
+ (func $a6 (result i32)
+ (local $x i32)
+ (i32.add
+ (block (result i32)
+ (tee_local $x
+ (i32.const 0)
+ )
+ )
+ (block (result i32)
+ (tee_local $x
+ (i32.const 1)
+ )
+ )
+ )
+ )
+ (func $a7 (result i32)
+ (local $x i32)
+ (block (result i32)
+ (i32.add
+ (block (result i32)
+ (tee_local $x
+ (i32.const 0)
+ )
+ )
+ (block (result i32)
+ (tee_local $x
+ (i32.const 1)
+ )
+ )
+ )
+ )
+ )
+ (func $a8 (result i32)
+ (local $x i32)
+ (block $outer (result i32)
+ (block $inner (result i32)
+ (i32.add
+ (block (result i32)
+ (br $inner
+ (i32.const -1)
+ )
+ (br $outer
+ (i32.const 0)
+ )
+ (i32.const 1)
+ )
+ (block (result i32)
+ (br $outer
+ (i32.const 2)
+ )
+ (tee_local $x
+ (i32.const 3)
+ )
+ )
+ )
+ )
+ )
+ )
+ (func $a9 (result i32)
+ (loop $outer (result i32)
+ (loop $inner (result i32)
+ (br_if $outer (i32.const -1))
+ (i32.add
+ (i32.const 0)
+ (i32.const 1)
+ )
+ )
+ )
+ )
+ (func $a10 (result i32)
+ (local $x i32)
+ (block $outer (result i32)
+ (drop (br_if $outer (i32.const 0) (i32.const 1)))
+ (drop (br_if $outer (tee_local $x (i32.const 2)) (i32.const 3)))
+ (drop (br_if $outer (i32.const 4) (tee_local $x (i32.const 5))))
+ (drop (br_if $outer (tee_local $x (i32.const 6)) (tee_local $x (i32.const 7))))
+ (br $outer (i32.const 8))
+ )
+ )
+ (func $a11
+ (if (i32.const 0)
+ (drop (i32.const 1))
+ )
+ )
+ (func $a12 (result i32)
+ (if (result i32) (i32.const 0)
+ (i32.const 1)
+ (i32.const 2)
+ )
+ )
+ (func $a13 (result i32)
+ (block $x i32
+ (if i32
+ (br_table $x (i32.const 2) (i32.const 0))
+ (i32.const 0)
+ (i32.const 1)
+ )
+ )
+ )
+ (func $a14 (result i32)
+ (block i32
+ (select
+ (i32.const 0) (i32.const 1) (br_table 0 (i32.const 7) (i32.const 1))
+ )
+ )
+ )
+ (func $a15
+ (if
+ (i32.load16_u
+ (i32.const 53)
+ )
+ (unreachable)
+ (drop
+ (block $label$3 (result f32)
+ (unreachable)
+ )
+ )
+ )
+ )
+ (func $a16 (result i32)
+ (local $x i32)
+ (block $label$1 (result i32)
+ (drop
+ (br_if $label$1
+ (tee_local $x ;; set here, then it is undone later, but this value is used, not the contents of $x!
+ (i32.const 1)
+ )
+ (i32.eqz ;; 0 into 1, so take the br_if
+ (block $label$2 (result i32)
+ (set_local $x
+ (i32.const 0) ;; undo the above tee
+ )
+ (i32.const 0)
+ )
+ )
+ )
+ )
+ (i32.const 0)
+ )
+ )
+ (func $a17 (result f32)
+ (local $var$0 f32)
+ (f32.max
+ (get_local $var$0)
+ (select
+ (tee_local $var$0
+ (f32.const -137438953472)
+ )
+ (get_local $var$0)
+ (i32.const 0)
+ )
+ )
+ )
+ (func $a18 (result i32)
+ (block $label$1 (result i32)
+ (i32.load16_s
+ (drop ;; an unreachable drop. one we move its contents outside, it should stay unreachable
+ (br_if $label$1
+ (i32.const 1)
+ (unreachable)
+ )
+ )
+ )
+ )
+ )
+ (func $a19 (result f32)
+ (block $label$0
+ (block $label$1
+ (drop
+ (select
+ (unreachable) ;; move this out, so it happens before the return
+ (return
+ (f32.const 4289944320)
+ )
+ (i32.const 65535)
+ )
+ )
+ )
+ )
+ )
(func $call-me (param $0 i32) (param $1 i32)
(nop)
)
@@ -780,4 +994,21 @@
)
)
)
+ (func $br_if_order (param $x i32) (result i32)
+ (block $outer (result i32)
+ (block $inner (result i32)
+ (br_if $inner
+ (br_if $outer
+ (i32.const 0)
+ (i32.const 1)
+ )
+ (call $br_if_order
+ (block (result i32)
+ (i32.const -16)
+ )
+ )
+ )
+ )
+ )
+ )
)
diff --git a/test/passes/flatten_rereloop.txt b/test/passes/flatten_rereloop.txt
new file mode 100644
index 000000000..38dbabc7c
--- /dev/null
+++ b/test/passes/flatten_rereloop.txt
@@ -0,0 +1,45 @@
+(module
+ (type $0 (func (result f64)))
+ (memory $0 0)
+ (func $0 (type $0) (result f64)
+ (local $0 f64)
+ (local $1 f64)
+ (local $2 i32)
+ (block $block$2$break
+ (block
+ )
+ (if
+ (i32.const 0)
+ (br $block$2$break)
+ (block
+ (block
+ (nop)
+ (set_local $0
+ (f64.const -nan:0xfffffd63e4e5a)
+ )
+ (set_local $1
+ (get_local $0)
+ )
+ (return
+ (get_local $1)
+ )
+ )
+ )
+ )
+ )
+ (block
+ (block $block$3$break
+ (block
+ )
+ (block
+ (br $block$3$break)
+ )
+ )
+ (block
+ (block
+ (unreachable)
+ )
+ )
+ )
+ )
+)
diff --git a/test/passes/flatten_rereloop.wast b/test/passes/flatten_rereloop.wast
new file mode 100644
index 000000000..b575f9c55
--- /dev/null
+++ b/test/passes/flatten_rereloop.wast
@@ -0,0 +1,12 @@
+(module
+ (func $0 (result f64)
+ (if
+ (i32.const 0)
+ (loop $label$2
+ (unreachable)
+ )
+ )
+ (f64.const -nan:0xfffffd63e4e5a)
+ )
+)
+
diff --git a/test/wasm2asm.asserts.js b/test/wasm2asm.asserts.js
index db4612077..c9b28888e 100644
--- a/test/wasm2asm.asserts.js
+++ b/test/wasm2asm.asserts.js
@@ -19,50 +19,121 @@ function asmFunc(global, env, buffer) {
function $$1(x, y) {
x = x | 0;
y = y | 0;
- return x + y | 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0;
+ $$2 = x;
+ $$3 = y;
+ $$4 = $$2 + $$3 | 0;
+ return $$4 | 0;
}
function $$2(x, y) {
x = x | 0;
y = y | 0;
- return (x | 0) / (y | 0) | 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0;
+ $$2 = x;
+ $$3 = y;
+ $$4 = ($$2 | 0) / ($$3 | 0) | 0;
+ return $$4 | 0;
}
function __wasm_ctz_i32(x) {
x = x | 0;
- var $$1 = 0;
- if ((x | 0) == (0 | 0)) $$1 = 32; else $$1 = 31 - Math_clz32(x ^ (x - 1 | 0) | 0) | 0;
- return $$1 | 0;
+ var $$1 = 0, $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0;
+ $$1 = x;
+ $$2 = ($$1 | 0) == (0 | 0);
+ if ($$2) $$9 = 32; else {
+ $$3 = x;
+ $$4 = x;
+ $$5 = $$4 - 1 | 0;
+ $$6 = $$3 ^ $$5 | 0;
+ $$7 = Math_clz32($$6);
+ $$8 = 31 - $$7 | 0;
+ $$9 = $$8;
+ }
+ $$10 = $$9;
+ return $$10 | 0;
}
function __wasm_popcnt_i32(x) {
x = x | 0;
- var count = 0, $$2 = 0, $$3 = 0;
+ var count = 0, $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0, $$11 = 0, $$12 = 0, $$13 = 0, $$14 = 0, $$15 = 0;
count = 0;
b : {
l : do {
$$2 = count;
- if ((x | 0) == (0 | 0)) break b;
- x = x & (x - 1 | 0) | 0;
- count = count + 1 | 0;
+ $$3 = x;
+ $$4 = ($$3 | 0) == (0 | 0);
+ $$5 = $$2;
+ if ($$4) break b;
+ $$6 = $$5;
+ $$7 = x;
+ $$8 = x;
+ $$9 = $$8 - 1 | 0;
+ $$10 = $$7 & $$9 | 0;
+ x = $$10;
+ $$11 = count;
+ $$12 = $$11 + 1 | 0;
+ count = $$12;
continue l;
break l;
} while (1);
};
- $$3 = $$2;
- return $$3 | 0;
+ $$13 = $$5;
+ $$14 = $$13;
+ $$15 = $$14;
+ return $$15 | 0;
}
function __wasm_rotl_i32(x, k) {
x = x | 0;
k = k | 0;
- return ((4294967295 >>> (k & 31 | 0) | 0) & x | 0) << (k & 31 | 0) | 0 | (((4294967295 << (32 - (k & 31 | 0) | 0) | 0) & x | 0) >>> (32 - (k & 31 | 0) | 0) | 0) | 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0, $$11 = 0, $$12 = 0, $$13 = 0, $$14 = 0, $$15 = 0, $$16 = 0, $$17 = 0, $$18 = 0, $$19 = 0, $$20 = 0;
+ $$2 = k;
+ $$3 = $$2 & 31 | 0;
+ $$4 = 4294967295 >>> $$3 | 0;
+ $$5 = x;
+ $$6 = $$4 & $$5 | 0;
+ $$7 = k;
+ $$8 = $$7 & 31 | 0;
+ $$9 = $$6 << $$8 | 0;
+ $$10 = k;
+ $$11 = $$10 & 31 | 0;
+ $$12 = 32 - $$11 | 0;
+ $$13 = 4294967295 << $$12 | 0;
+ $$14 = x;
+ $$15 = $$13 & $$14 | 0;
+ $$16 = k;
+ $$17 = $$16 & 31 | 0;
+ $$18 = 32 - $$17 | 0;
+ $$19 = $$15 >>> $$18 | 0;
+ $$20 = $$9 | $$19 | 0;
+ return $$20 | 0;
}
function __wasm_rotr_i32(x, k) {
x = x | 0;
k = k | 0;
- return ((4294967295 << (k & 31 | 0) | 0) & x | 0) >>> (k & 31 | 0) | 0 | (((4294967295 >>> (32 - (k & 31 | 0) | 0) | 0) & x | 0) << (32 - (k & 31 | 0) | 0) | 0) | 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0, $$11 = 0, $$12 = 0, $$13 = 0, $$14 = 0, $$15 = 0, $$16 = 0, $$17 = 0, $$18 = 0, $$19 = 0, $$20 = 0;
+ $$2 = k;
+ $$3 = $$2 & 31 | 0;
+ $$4 = 4294967295 << $$3 | 0;
+ $$5 = x;
+ $$6 = $$4 & $$5 | 0;
+ $$7 = k;
+ $$8 = $$7 & 31 | 0;
+ $$9 = $$6 >>> $$8 | 0;
+ $$10 = k;
+ $$11 = $$10 & 31 | 0;
+ $$12 = 32 - $$11 | 0;
+ $$13 = 4294967295 >>> $$12 | 0;
+ $$14 = x;
+ $$15 = $$13 & $$14 | 0;
+ $$16 = k;
+ $$17 = $$16 & 31 | 0;
+ $$18 = 32 - $$17 | 0;
+ $$19 = $$15 << $$18 | 0;
+ $$20 = $$9 | $$19 | 0;
+ return $$20 | 0;
}
return {
diff --git a/test/wasm2asm.traps.js b/test/wasm2asm.traps.js
index 4b89f5b89..2f4ddb0d9 100644
--- a/test/wasm2asm.traps.js
+++ b/test/wasm2asm.traps.js
@@ -19,50 +19,121 @@ function asmFunc(global, env, buffer) {
function $$1(x, y) {
x = x | 0;
y = y | 0;
- return x + y | 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0;
+ $$2 = x;
+ $$3 = y;
+ $$4 = $$2 + $$3 | 0;
+ return $$4 | 0;
}
function $$2(x, y) {
x = x | 0;
y = y | 0;
- return (x | 0) / (y | 0) | 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0;
+ $$2 = x;
+ $$3 = y;
+ $$4 = ($$2 | 0) / ($$3 | 0) | 0;
+ return $$4 | 0;
}
function __wasm_ctz_i32(x) {
x = x | 0;
- var $$1 = 0;
- if ((x | 0) == (0 | 0)) $$1 = 32; else $$1 = 31 - Math_clz32(x ^ (x - 1 | 0) | 0) | 0;
- return $$1 | 0;
+ var $$1 = 0, $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0;
+ $$1 = x;
+ $$2 = ($$1 | 0) == (0 | 0);
+ if ($$2) $$9 = 32; else {
+ $$3 = x;
+ $$4 = x;
+ $$5 = $$4 - 1 | 0;
+ $$6 = $$3 ^ $$5 | 0;
+ $$7 = Math_clz32($$6);
+ $$8 = 31 - $$7 | 0;
+ $$9 = $$8;
+ }
+ $$10 = $$9;
+ return $$10 | 0;
}
function __wasm_popcnt_i32(x) {
x = x | 0;
- var count = 0, $$2 = 0, $$3 = 0;
+ var count = 0, $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0, $$11 = 0, $$12 = 0, $$13 = 0, $$14 = 0, $$15 = 0;
count = 0;
b : {
l : do {
$$2 = count;
- if ((x | 0) == (0 | 0)) break b;
- x = x & (x - 1 | 0) | 0;
- count = count + 1 | 0;
+ $$3 = x;
+ $$4 = ($$3 | 0) == (0 | 0);
+ $$5 = $$2;
+ if ($$4) break b;
+ $$6 = $$5;
+ $$7 = x;
+ $$8 = x;
+ $$9 = $$8 - 1 | 0;
+ $$10 = $$7 & $$9 | 0;
+ x = $$10;
+ $$11 = count;
+ $$12 = $$11 + 1 | 0;
+ count = $$12;
continue l;
break l;
} while (1);
};
- $$3 = $$2;
- return $$3 | 0;
+ $$13 = $$5;
+ $$14 = $$13;
+ $$15 = $$14;
+ return $$15 | 0;
}
function __wasm_rotl_i32(x, k) {
x = x | 0;
k = k | 0;
- return ((4294967295 >>> (k & 31 | 0) | 0) & x | 0) << (k & 31 | 0) | 0 | (((4294967295 << (32 - (k & 31 | 0) | 0) | 0) & x | 0) >>> (32 - (k & 31 | 0) | 0) | 0) | 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0, $$11 = 0, $$12 = 0, $$13 = 0, $$14 = 0, $$15 = 0, $$16 = 0, $$17 = 0, $$18 = 0, $$19 = 0, $$20 = 0;
+ $$2 = k;
+ $$3 = $$2 & 31 | 0;
+ $$4 = 4294967295 >>> $$3 | 0;
+ $$5 = x;
+ $$6 = $$4 & $$5 | 0;
+ $$7 = k;
+ $$8 = $$7 & 31 | 0;
+ $$9 = $$6 << $$8 | 0;
+ $$10 = k;
+ $$11 = $$10 & 31 | 0;
+ $$12 = 32 - $$11 | 0;
+ $$13 = 4294967295 << $$12 | 0;
+ $$14 = x;
+ $$15 = $$13 & $$14 | 0;
+ $$16 = k;
+ $$17 = $$16 & 31 | 0;
+ $$18 = 32 - $$17 | 0;
+ $$19 = $$15 >>> $$18 | 0;
+ $$20 = $$9 | $$19 | 0;
+ return $$20 | 0;
}
function __wasm_rotr_i32(x, k) {
x = x | 0;
k = k | 0;
- return ((4294967295 << (k & 31 | 0) | 0) & x | 0) >>> (k & 31 | 0) | 0 | (((4294967295 >>> (32 - (k & 31 | 0) | 0) | 0) & x | 0) << (32 - (k & 31 | 0) | 0) | 0) | 0 | 0;
+ var $$2 = 0, $$3 = 0, $$4 = 0, $$5 = 0, $$6 = 0, $$7 = 0, $$8 = 0, $$9 = 0, $$10 = 0, $$11 = 0, $$12 = 0, $$13 = 0, $$14 = 0, $$15 = 0, $$16 = 0, $$17 = 0, $$18 = 0, $$19 = 0, $$20 = 0;
+ $$2 = k;
+ $$3 = $$2 & 31 | 0;
+ $$4 = 4294967295 << $$3 | 0;
+ $$5 = x;
+ $$6 = $$4 & $$5 | 0;
+ $$7 = k;
+ $$8 = $$7 & 31 | 0;
+ $$9 = $$6 >>> $$8 | 0;
+ $$10 = k;
+ $$11 = $$10 & 31 | 0;
+ $$12 = 32 - $$11 | 0;
+ $$13 = 4294967295 >>> $$12 | 0;
+ $$14 = x;
+ $$15 = $$13 & $$14 | 0;
+ $$16 = k;
+ $$17 = $$16 & 31 | 0;
+ $$18 = 32 - $$17 | 0;
+ $$19 = $$15 << $$18 | 0;
+ $$20 = $$9 | $$19 | 0;
+ return $$20 | 0;
}
return {