summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2017-08-07 15:43:36 -0700
committerGitHub <noreply@github.com>2017-08-07 15:43:36 -0700
commit4f0bf336e0e04ec349c7524d86ffd2c4066cb644 (patch)
treed50a12f9701f8eb4b5f28770cf43a55877c931a8
parentb93ea39b239052314123d3641df29ff5c5730515 (diff)
downloadbinaryen-4f0bf336e0e04ec349c7524d86ffd2c4066cb644.tar.gz
binaryen-4f0bf336e0e04ec349c7524d86ffd2c4066cb644.tar.bz2
binaryen-4f0bf336e0e04ec349c7524d86ffd2c4066cb644.zip
Improve and enable inlining pass (#966)
* improve inlining pass to inline single-use functions that are fairly small, which makes it useful for removing unnecessary global constructors from clang. add an inlining-optimizing pass that also optimizes where it inlined, as new opportunities arise. enable that it by default in O2+ * fix a bug where we didn't run all passes properly - refactor addDefaultGlobalOptimizationPasses() into a pre and post version. we can only run the post version in incremental optimizing builds (functions appear one by one, we optimize them first, and do global stuff when all are done), but can run both when doing a full optimize * copy in inlining, allowing multiple inlinings of the same function in the future
-rw-r--r--src/pass.h10
-rw-r--r--src/passes/Inlining.cpp173
-rw-r--r--src/passes/pass.cpp16
-rw-r--r--src/passes/passes.h1
-rw-r--r--src/tools/wasm-merge.cpp2
-rw-r--r--src/wasm-module-building.h4
-rw-r--r--test/debugInfo.fromasm25
-rw-r--r--test/debugInfo.fromasm.clamp25
-rw-r--r--test/debugInfo.fromasm.clamp.map2
-rw-r--r--test/debugInfo.fromasm.map2
-rw-r--r--test/dynamicLibrary.fromasm18
-rw-r--r--test/dynamicLibrary.fromasm.clamp18
-rw-r--r--test/dynamicLibrary.fromasm.imprecise18
-rw-r--r--test/emcc_O2_hello_world.fromasm44
-rw-r--r--test/emcc_O2_hello_world.fromasm.clamp44
-rw-r--r--test/emcc_O2_hello_world.fromasm.imprecise26
-rw-r--r--test/emcc_hello_world.fromasm670
-rw-r--r--test/emcc_hello_world.fromasm.clamp670
-rw-r--r--test/emcc_hello_world.fromasm.imprecise648
-rw-r--r--test/memorygrowth.fromasm54
-rw-r--r--test/memorygrowth.fromasm.clamp54
-rw-r--r--test/memorygrowth.fromasm.imprecise36
-rw-r--r--test/passes/inlining-optimizing.txt35
-rw-r--r--test/passes/inlining-optimizing.wast79
-rw-r--r--test/passes/inlining.txt111
-rw-r--r--test/passes/inlining.wast10
-rw-r--r--test/unit.asm.js1
-rw-r--r--test/unit.fromasm89
-rw-r--r--test/unit.fromasm.clamp89
-rw-r--r--test/unit.fromasm.clamp.no-opts5
-rw-r--r--test/unit.fromasm.imprecise70
-rw-r--r--test/unit.fromasm.imprecise.no-opts5
-rw-r--r--test/unit.fromasm.no-opts5
-rw-r--r--test/wasm-only.asm.js12
-rw-r--r--test/wasm-only.fromasm165
-rw-r--r--test/wasm-only.fromasm.clamp165
-rw-r--r--test/wasm-only.fromasm.clamp.no-opts44
-rw-r--r--test/wasm-only.fromasm.imprecise44
-rw-r--r--test/wasm-only.fromasm.imprecise.no-opts44
-rw-r--r--test/wasm-only.fromasm.no-opts44
40 files changed, 1964 insertions, 1613 deletions
diff --git a/src/pass.h b/src/pass.h
index 21836ebf9..2f3bca078 100644
--- a/src/pass.h
+++ b/src/pass.h
@@ -109,8 +109,14 @@ struct PassRunner {
void addDefaultFunctionOptimizationPasses();
// Adds the default optimization passes that work on
- // entire modules as a whole.
- void addDefaultGlobalOptimizationPasses();
+ // entire modules as a whole, and make sense to
+ // run before function passes.
+ void addDefaultGlobalOptimizationPrePasses();
+
+ // Adds the default optimization passes that work on
+ // entire modules as a whole, and make sense to
+ // run after function passes.
+ void addDefaultGlobalOptimizationPostPasses();
// Run the passes on the module
void run();
diff --git a/src/passes/Inlining.cpp b/src/passes/Inlining.cpp
index c352a704a..377aa5247 100644
--- a/src/passes/Inlining.cpp
+++ b/src/passes/Inlining.cpp
@@ -18,45 +18,68 @@
// Inlining.
//
// For now, this does a conservative inlining of all functions that have
-// exactly one use. That should not increase code size, and may have
-// speed benefits.
+// exactly one use, and are fairly small. That should not increase code
+// size, and may have speed benefits.
//
+#include <atomic>
+
#include <wasm.h>
#include <pass.h>
#include <wasm-builder.h>
+#include <ast_utils.h>
#include <parsing.h>
namespace wasm {
+// A limit on how big a function to inline.
+static const int INLINING_SIZE_LIMIT = 15;
+
+// We only inline a function with a single use.
+static const int SINGLE_USE = 1;
+
+// A number of uses of a function that is too high for us to
+// inline it to all those locations.
+static const int TOO_MANY_USES_TO_INLINE = SINGLE_USE + 1;
+
+// Map of function name => number of uses. We build the values in
+// parallel, using atomic increments. This is safe because we never
+// update the map itself in parallel, we only update the values,
+// and so the map never allocates or moves values which could be
+// a problem with atomics (in fact it would be a problem in general
+// as well, not just with atomics, as we don't use a lock in
+// parallel access, we depend on the map itself being constant
+// when running multiple threads).
+typedef std::map<Name, std::atomic<Index>> NameToAtomicIndexMap;
+
struct FunctionUseCounter : public WalkerPass<PostWalker<FunctionUseCounter>> {
bool isFunctionParallel() override { return true; }
- FunctionUseCounter(std::map<Name, Index>* output) : output(output) {}
+ FunctionUseCounter(NameToAtomicIndexMap* uses) : uses(uses) {}
FunctionUseCounter* create() override {
- return new FunctionUseCounter(output);
+ return new FunctionUseCounter(uses);
}
void visitCall(Call *curr) {
- (*output)[curr->target]++;
+ assert(uses->count(curr->target) > 0); // can't add a new element in parallel
+ (*uses)[curr->target]++;
}
private:
- std::map<Name, Index>* output;
+ NameToAtomicIndexMap* uses;
};
-struct Action {
- Call* call;
- Block* block; // the replacement for the call, into which we should inline
+struct InliningAction {
+ Expression** callSite;
Function* contents;
- Action(Call* call, Block* block, Function* contents) : call(call), block(block), contents(contents) {}
+ InliningAction(Expression** callSite, Function* contents) : callSite(callSite), contents(contents) {}
};
struct InliningState {
std::set<Name> canInline;
- std::map<Name, std::vector<Action>> actionsForFunction; // function name => actions that can be performed in it
+ std::map<Name, std::vector<InliningAction>> actionsForFunction; // function name => actions that can be performed in it
};
struct Planner : public WalkerPass<PostWalker<Planner>> {
@@ -68,12 +91,18 @@ struct Planner : public WalkerPass<PostWalker<Planner>> {
return new Planner(state);
}
- void visitCall(Call *curr) {
- if (state->canInline.count(curr->target)) {
- auto* block = Builder(*getModule()).makeBlock();
- block->type = curr->type;
+ void visitCall(Call* curr) {
+ // plan to inline if we know this is valid to inline, and if the call is
+ // actually performed - if it is dead code, it's pointless to inline
+ if (state->canInline.count(curr->target) &&
+ curr->type != unreachable) {
+ // nest the call in a block. that way the location of the pointer to the call will not
+ // change even if we inline multiple times into the same function, otherwise
+ // call1(call2()) might be a problem
+ auto* block = Builder(*getModule()).makeBlock(curr);
replaceCurrent(block);
- state->actionsForFunction[getFunction()->name].emplace_back(curr, block, getModule()->getFunction(curr->target));
+ assert(state->actionsForFunction.count(getFunction()->name) > 0); // can't add a new element in parallel
+ state->actionsForFunction[getFunction()->name].emplace_back(&block->list[0], getModule()->getFunction(curr->target));
}
}
@@ -91,13 +120,13 @@ private:
// Core inlining logic. Modifies the outside function (adding locals as
// needed), and returns the inlined code.
-// Since we only inline once, and do not need the function afterwards, we
-// can just reuse all the nodes and even avoid copying.
-static Expression* doInlining(Module* module, Function* into, Action& action) {
+static Expression* doInlining(Module* module, Function* into, InliningAction& action) {
+ auto* call = (*action.callSite)->cast<Call>();
Builder builder(*module);
- auto* block = action.block;
+ auto* block = Builder(*module).makeBlock();
+ block->type = call->type;
block->name = Name(std::string("__inlined_func$") + action.contents->name.str);
- block->type = action.contents->result;
+ *action.callSite = block;
// set up a locals mapping
struct Updater : public PostWalker<Updater> {
std::map<Index, Index> localMapping;
@@ -121,49 +150,59 @@ static Expression* doInlining(Module* module, Function* into, Action& action) {
}
// assign the operands into the params
for (Index i = 0; i < action.contents->params.size(); i++) {
- block->list.push_back(builder.makeSetLocal(updater.localMapping[i], action.call->operands[i]));
+ block->list.push_back(builder.makeSetLocal(updater.localMapping[i], call->operands[i]));
}
- // update the inlined contents
- updater.walk(action.contents->body);
- block->list.push_back(action.contents->body);
- action.contents->body = builder.makeUnreachable(); // not strictly needed, since it's going away
+ // generate and update the inlined contents
+ auto* contents = ExpressionManipulator::copy(action.contents->body, *module);
+ updater.walk(contents);
+ block->list.push_back(contents);
return block;
}
struct Inlining : public Pass {
+ // whether to optimize where we inline
+ bool optimize = false;
+
+ NameToAtomicIndexMap uses;
+
void run(PassRunner* runner, Module* module) override {
// keep going while we inline, to handle nesting. TODO: optimize
+ calculateUses(module);
while (iteration(runner, module)) {}
}
- bool iteration(PassRunner* runner, Module* module) {
- // Count uses
- std::map<Name, Index> uses;
+ void calculateUses(Module* module) {
// fill in uses, as we operate on it in parallel (each function to its own entry)
for (auto& func : module->functions) {
- uses[func->name] = 0;
- }
- {
- PassRunner runner(module);
- runner.setIsNested(true);
- runner.add<FunctionUseCounter>(&uses);
- runner.run();
+ uses[func->name].store(0);
}
+ PassRunner runner(module);
+ runner.setIsNested(true);
+ runner.add<FunctionUseCounter>(&uses);
+ runner.run();
+ // anything exported or used in a table should not be inlined
for (auto& ex : module->exports) {
if (ex->kind == ExternalKind::Function) {
- uses[ex->value] = 2; // too many, so we ignore it
+ uses[ex->value].store(TOO_MANY_USES_TO_INLINE);
}
}
for (auto& segment : module->table.segments) {
for (auto name : segment.data) {
- uses[name]++;
+ if (module->getFunctionOrNull(name)) {
+ uses[name].store(TOO_MANY_USES_TO_INLINE);
+ }
}
}
+ }
+
+ bool iteration(PassRunner* runner, Module* module) {
// decide which to inline
InliningState state;
- for (auto iter : uses) {
- if (iter.second == 1) {
- state.canInline.insert(iter.first);
+ for (auto& func : module->functions) {
+ auto name = func->name;
+ auto numUses = uses[name].load();
+ if (canInline(numUses) && worthInlining(module->getFunction(name))) {
+ state.canInline.insert(name);
}
}
// fill in actionsForFunction, as we operate on it in parallel (each function to its own entry)
@@ -182,15 +221,21 @@ struct Inlining : public Pass {
std::set<Function*> inlinedInto;
for (auto& func : module->functions) {
for (auto& action : state.actionsForFunction[func->name]) {
+ Name inlinedName = action.contents->name;
doInlining(module, func.get(), action);
- inlined.insert(action.contents->name);
+ inlined.insert(inlinedName);
inlinedInto.insert(func.get());
+ uses[inlinedName]--;
+ assert(uses[inlinedName].load() == 0);
}
}
// anything we inlined into may now have non-unique label names, fix it up
for (auto func : inlinedInto) {
wasm::UniqueNameMapper::uniquify(func->body);
}
+ if (optimize && inlinedInto.size() > 0) {
+ doOptimize(inlinedInto, module, runner);
+ }
// remove functions that we managed to inline, their one use is gone
auto& funcs = module->functions;
funcs.erase(std::remove_if(funcs.begin(), funcs.end(), [&inlined](const std::unique_ptr<Function>& curr) {
@@ -199,11 +244,55 @@ struct Inlining : public Pass {
// return whether we did any work
return inlined.size() > 0;
}
+
+ bool canInline(int numUses) {
+ return numUses == SINGLE_USE;
+ }
+
+ bool worthInlining(Function* func) {
+ return Measurer::measure(func->body) <= INLINING_SIZE_LIMIT;
+ }
+
+ // Run useful optimizations after inlining, things like removing
+ // unnecessary new blocks, sharing variables, etc.
+ void doOptimize(std::set<Function*>& funcs, Module* module, PassRunner* parentRunner) {
+ // save the full list of functions on the side
+ std::vector<std::unique_ptr<Function>> all;
+ all.swap(module->functions);
+ module->updateMaps();
+ for (auto& func : funcs) {
+ module->addFunction(func);
+ }
+ PassRunner runner(module, parentRunner->options);
+ runner.setIsNested(true);
+ runner.setValidateGlobally(false); // not a full valid module
+ runner.add("remove-unused-brs");
+ runner.add("remove-unused-names");
+ runner.add("coalesce-locals");
+ runner.add("simplify-locals");
+ runner.add("vacuum");
+ runner.add("reorder-locals");
+ runner.add("remove-unused-brs");
+ runner.add("merge-blocks");
+ runner.run();
+ // restore all the funcs
+ for (auto& func : module->functions) {
+ func.release();
+ }
+ all.swap(module->functions);
+ module->updateMaps();
+ }
};
Pass *createInliningPass() {
return new Inlining();
}
+Pass *createInliningOptimizingPass() {
+ auto* ret = new Inlining();
+ ret->optimize = true;
+ return ret;
+}
+
} // namespace wasm
diff --git a/src/passes/pass.cpp b/src/passes/pass.cpp
index fc0a583fb..37eb50a0b 100644
--- a/src/passes/pass.cpp
+++ b/src/passes/pass.cpp
@@ -73,6 +73,7 @@ void PassRegistry::registerPasses() {
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("inlining", "inlines functions (currently only ones with a single use)", createInliningPass);
+ registerPass("inlining-optimizing", "inlines functions (currently only ones with a single use) and optimizes where we inlined", createInliningOptimizingPass);
registerPass("legalize-js-interface", "legalizes i64 types on the import/export boundary", createLegalizeJSInterfacePass);
registerPass("local-cse", "common subexpression elimination inside basic blocks", createLocalCSEPass);
registerPass("log-execution", "instrument the build with logging of where execution goes", createLogExecutionPass);
@@ -110,11 +111,9 @@ void PassRegistry::registerPasses() {
}
void PassRunner::addDefaultOptimizationPasses() {
- add("duplicate-function-elimination");
+ addDefaultGlobalOptimizationPrePasses();
addDefaultFunctionOptimizationPasses();
- add("duplicate-function-elimination"); // optimizations show more functions as duplicate
- add("remove-unused-module-elements");
- add("memory-packing");
+ addDefaultGlobalOptimizationPostPasses();
}
void PassRunner::addDefaultFunctionOptimizationPasses() {
@@ -154,9 +153,16 @@ void PassRunner::addDefaultFunctionOptimizationPasses() {
add("vacuum"); // just to be safe
}
-void PassRunner::addDefaultGlobalOptimizationPasses() {
+void PassRunner::addDefaultGlobalOptimizationPrePasses() {
add("duplicate-function-elimination");
+}
+
+void PassRunner::addDefaultGlobalOptimizationPostPasses() {
+ add("duplicate-function-elimination"); // optimizations show more functions as duplicate
add("remove-unused-module-elements");
+ if (options.optimizeLevel >= 2 || options.shrinkLevel >= 2) {
+ add("inlining-optimizing");
+ }
add("memory-packing");
}
diff --git a/src/passes/passes.h b/src/passes/passes.h
index 7a40b7da4..5e7eba540 100644
--- a/src/passes/passes.h
+++ b/src/passes/passes.h
@@ -32,6 +32,7 @@ Pass *createExtractFunctionPass();
Pass *createFlattenControlFlowPass();
Pass *createFullPrinterPass();
Pass *createInliningPass();
+Pass *createInliningOptimizingPass();
Pass *createLegalizeJSInterfacePass();
Pass *createLocalCSEPass();
Pass *createLogExecutionPass();
diff --git a/src/tools/wasm-merge.cpp b/src/tools/wasm-merge.cpp
index fa2b195c9..441cdc0f7 100644
--- a/src/tools/wasm-merge.cpp
+++ b/src/tools/wasm-merge.cpp
@@ -622,7 +622,7 @@ int main(int argc, const char* argv[]) {
PassRunner passRunner(&output);
passRunner.add("precompute");
passRunner.add("optimize-instructions"); // things now-constant may be further optimized
- passRunner.addDefaultGlobalOptimizationPasses();
+ passRunner.addDefaultGlobalOptimizationPostPasses();
passRunner.run();
}
diff --git a/src/wasm-module-building.h b/src/wasm-module-building.h
index b501a1ab6..c52cea9f9 100644
--- a/src/wasm-module-building.h
+++ b/src/wasm-module-building.h
@@ -165,7 +165,7 @@ public:
}
addPrePasses(passRunner);
passRunner.addDefaultFunctionOptimizationPasses();
- passRunner.addDefaultGlobalOptimizationPasses();
+ passRunner.addDefaultGlobalOptimizationPostPasses();
passRunner.run();
return;
}
@@ -226,7 +226,7 @@ private:
void optimizeGlobally() {
PassRunner passRunner(wasm, passOptions);
- passRunner.addDefaultGlobalOptimizationPasses();
+ passRunner.addDefaultGlobalOptimizationPostPasses();
passRunner.run();
}
diff --git a/test/debugInfo.fromasm b/test/debugInfo.fromasm
index f11000841..16033f98a 100644
--- a/test/debugInfo.fromasm
+++ b/test/debugInfo.fromasm
@@ -31,17 +31,8 @@
(i32.const 1)
)
)
- (func $i32s-rem (param $0 i32) (param $1 i32) (result i32)
- (if (result i32)
- (get_local $1)
- (i32.rem_s
- (get_local $0)
- (get_local $1)
- )
- (i32.const 0)
- )
- )
(func $opts (param $0 i32) (param $1 i32) (result i32)
+ (local $2 i32)
;;@ even-opted.cpp:1:0
(set_local $0
(i32.add
@@ -56,11 +47,17 @@
(get_local $0)
)
)
- ;;@ even-opted.cpp:3:0
(i32.add
- (call $i32s-rem
- (get_local $0)
- (get_local $1)
+ (if (result i32)
+ ;;@ even-opted.cpp:3:0
+ (tee_local $2
+ (get_local $1)
+ )
+ (i32.rem_s
+ (get_local $0)
+ (get_local $2)
+ )
+ (i32.const 0)
)
(get_local $1)
)
diff --git a/test/debugInfo.fromasm.clamp b/test/debugInfo.fromasm.clamp
index f11000841..16033f98a 100644
--- a/test/debugInfo.fromasm.clamp
+++ b/test/debugInfo.fromasm.clamp
@@ -31,17 +31,8 @@
(i32.const 1)
)
)
- (func $i32s-rem (param $0 i32) (param $1 i32) (result i32)
- (if (result i32)
- (get_local $1)
- (i32.rem_s
- (get_local $0)
- (get_local $1)
- )
- (i32.const 0)
- )
- )
(func $opts (param $0 i32) (param $1 i32) (result i32)
+ (local $2 i32)
;;@ even-opted.cpp:1:0
(set_local $0
(i32.add
@@ -56,11 +47,17 @@
(get_local $0)
)
)
- ;;@ even-opted.cpp:3:0
(i32.add
- (call $i32s-rem
- (get_local $0)
- (get_local $1)
+ (if (result i32)
+ ;;@ even-opted.cpp:3:0
+ (tee_local $2
+ (get_local $1)
+ )
+ (i32.rem_s
+ (get_local $0)
+ (get_local $2)
+ )
+ (i32.const 0)
)
(get_local $1)
)
diff --git a/test/debugInfo.fromasm.clamp.map b/test/debugInfo.fromasm.clamp.map
index 5680294cd..5fb3151c9 100644
--- a/test/debugInfo.fromasm.clamp.map
+++ b/test/debugInfo.fromasm.clamp.map
@@ -1 +1 @@
-{"version":3,"sources":["tests/hello_world.c","tests/other_file.cpp","return.cpp","even-opted.cpp","fib.c","/tmp/emscripten_test_binaryen2_28hnAe/src.c"],"names":[],"mappings":"yLC8ylTA,cC7vlTA,OAkDA,mCCnGA,OACA,OACA,qBCAA,wBAKA,MAJA,OADA,0BAKA,iGCsi1DA"} \ No newline at end of file
+{"version":3,"sources":["tests/hello_world.c","tests/other_file.cpp","return.cpp","even-opted.cpp","fib.c","/tmp/emscripten_test_binaryen2_28hnAe/src.c"],"names":[],"mappings":"wLC8ylTA,cC7vlTA,OAkDA,iBCnGA,OACA,OACA,8BCAA,wBAKA,MAJA,OADA,0BAKA,iGCsi1DA"} \ No newline at end of file
diff --git a/test/debugInfo.fromasm.map b/test/debugInfo.fromasm.map
index 5680294cd..5fb3151c9 100644
--- a/test/debugInfo.fromasm.map
+++ b/test/debugInfo.fromasm.map
@@ -1 +1 @@
-{"version":3,"sources":["tests/hello_world.c","tests/other_file.cpp","return.cpp","even-opted.cpp","fib.c","/tmp/emscripten_test_binaryen2_28hnAe/src.c"],"names":[],"mappings":"yLC8ylTA,cC7vlTA,OAkDA,mCCnGA,OACA,OACA,qBCAA,wBAKA,MAJA,OADA,0BAKA,iGCsi1DA"} \ No newline at end of file
+{"version":3,"sources":["tests/hello_world.c","tests/other_file.cpp","return.cpp","even-opted.cpp","fib.c","/tmp/emscripten_test_binaryen2_28hnAe/src.c"],"names":[],"mappings":"wLC8ylTA,cC7vlTA,OAkDA,iBCnGA,OACA,OACA,8BCAA,wBAKA,MAJA,OADA,0BAKA,iGCsi1DA"} \ No newline at end of file
diff --git a/test/dynamicLibrary.fromasm b/test/dynamicLibrary.fromasm
index cd0d1d224..4456edfa2 100644
--- a/test/dynamicLibrary.fromasm
+++ b/test/dynamicLibrary.fromasm
@@ -15,14 +15,6 @@
(export "__post_instantiate" (func $__post_instantiate))
(export "runPostSets" (func $runPostSets))
(export "_global" (global $_global))
- (func $___cxx_global_var_init
- (call $__ZN3FooC2Ev
- (i32.add
- (get_global $memoryBase)
- (i32.const 5242912)
- )
- )
- )
(func $__ZN3FooC2Ev (param $0 i32)
(local $1 i32)
(set_local $1
@@ -52,9 +44,6 @@
(get_local $1)
)
)
- (func $__GLOBAL__sub_I_liblib_cpp
- (call $___cxx_global_var_init)
- )
(func $runPostSets
(nop)
)
@@ -72,6 +61,11 @@
)
)
(call $runPostSets)
- (call $__GLOBAL__sub_I_liblib_cpp)
+ (call $__ZN3FooC2Ev
+ (i32.add
+ (get_global $memoryBase)
+ (i32.const 5242912)
+ )
+ )
)
)
diff --git a/test/dynamicLibrary.fromasm.clamp b/test/dynamicLibrary.fromasm.clamp
index cd0d1d224..4456edfa2 100644
--- a/test/dynamicLibrary.fromasm.clamp
+++ b/test/dynamicLibrary.fromasm.clamp
@@ -15,14 +15,6 @@
(export "__post_instantiate" (func $__post_instantiate))
(export "runPostSets" (func $runPostSets))
(export "_global" (global $_global))
- (func $___cxx_global_var_init
- (call $__ZN3FooC2Ev
- (i32.add
- (get_global $memoryBase)
- (i32.const 5242912)
- )
- )
- )
(func $__ZN3FooC2Ev (param $0 i32)
(local $1 i32)
(set_local $1
@@ -52,9 +44,6 @@
(get_local $1)
)
)
- (func $__GLOBAL__sub_I_liblib_cpp
- (call $___cxx_global_var_init)
- )
(func $runPostSets
(nop)
)
@@ -72,6 +61,11 @@
)
)
(call $runPostSets)
- (call $__GLOBAL__sub_I_liblib_cpp)
+ (call $__ZN3FooC2Ev
+ (i32.add
+ (get_global $memoryBase)
+ (i32.const 5242912)
+ )
+ )
)
)
diff --git a/test/dynamicLibrary.fromasm.imprecise b/test/dynamicLibrary.fromasm.imprecise
index d30a1c912..f575c9781 100644
--- a/test/dynamicLibrary.fromasm.imprecise
+++ b/test/dynamicLibrary.fromasm.imprecise
@@ -14,14 +14,6 @@
(export "__post_instantiate" (func $__post_instantiate))
(export "runPostSets" (func $runPostSets))
(export "_global" (global $_global))
- (func $___cxx_global_var_init
- (call $__ZN3FooC2Ev
- (i32.add
- (get_global $memoryBase)
- (i32.const 5242912)
- )
- )
- )
(func $__ZN3FooC2Ev (param $0 i32)
(local $1 i32)
(set_local $1
@@ -51,9 +43,6 @@
(get_local $1)
)
)
- (func $__GLOBAL__sub_I_liblib_cpp
- (call $___cxx_global_var_init)
- )
(func $runPostSets
(nop)
)
@@ -71,6 +60,11 @@
)
)
(call $runPostSets)
- (call $__GLOBAL__sub_I_liblib_cpp)
+ (call $__ZN3FooC2Ev
+ (i32.add
+ (get_global $memoryBase)
+ (i32.const 5242912)
+ )
+ )
)
)
diff --git a/test/emcc_O2_hello_world.fromasm b/test/emcc_O2_hello_world.fromasm
index b0128b509..71b52c753 100644
--- a/test/emcc_O2_hello_world.fromasm
+++ b/test/emcc_O2_hello_world.fromasm
@@ -9185,9 +9185,16 @@
(block $do-once (result i32)
(if (result i32)
(i32.lt_s
- (call $_fputs
- (get_local $0)
- (get_local $1)
+ (i32.add
+ (call $_fwrite
+ (get_local $0)
+ (call $_strlen
+ (get_local $0)
+ )
+ (i32.const 1)
+ (get_local $1)
+ )
+ (i32.const -1)
)
(i32.const 0)
)
@@ -9407,16 +9414,6 @@
)
)
)
- (func $i32u-div (param $0 i32) (param $1 i32) (result i32)
- (if (result i32)
- (get_local $1)
- (i32.div_u
- (get_local $0)
- (get_local $1)
- )
- (i32.const 0)
- )
- )
(func $_fwrite (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32)
(local $4 i32)
(local $5 i32)
@@ -9471,9 +9468,13 @@
(get_local $4)
)
(set_local $2
- (call $i32u-div
- (get_local $0)
+ (if (result i32)
(get_local $1)
+ (i32.div_u
+ (get_local $0)
+ (get_local $1)
+ )
+ (i32.const 0)
)
)
)
@@ -9662,19 +9663,6 @@
)
)
)
- (func $_fputs (param $0 i32) (param $1 i32) (result i32)
- (i32.add
- (call $_fwrite
- (get_local $0)
- (call $_strlen
- (get_local $0)
- )
- (i32.const 1)
- (get_local $1)
- )
- (i32.const -1)
- )
- )
(func $dynCall_ii (param $0 i32) (param $1 i32) (result i32)
(call_indirect $FUNCSIG$ii
(get_local $1)
diff --git a/test/emcc_O2_hello_world.fromasm.clamp b/test/emcc_O2_hello_world.fromasm.clamp
index b0128b509..71b52c753 100644
--- a/test/emcc_O2_hello_world.fromasm.clamp
+++ b/test/emcc_O2_hello_world.fromasm.clamp
@@ -9185,9 +9185,16 @@
(block $do-once (result i32)
(if (result i32)
(i32.lt_s
- (call $_fputs
- (get_local $0)
- (get_local $1)
+ (i32.add
+ (call $_fwrite
+ (get_local $0)
+ (call $_strlen
+ (get_local $0)
+ )
+ (i32.const 1)
+ (get_local $1)
+ )
+ (i32.const -1)
)
(i32.const 0)
)
@@ -9407,16 +9414,6 @@
)
)
)
- (func $i32u-div (param $0 i32) (param $1 i32) (result i32)
- (if (result i32)
- (get_local $1)
- (i32.div_u
- (get_local $0)
- (get_local $1)
- )
- (i32.const 0)
- )
- )
(func $_fwrite (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32)
(local $4 i32)
(local $5 i32)
@@ -9471,9 +9468,13 @@
(get_local $4)
)
(set_local $2
- (call $i32u-div
- (get_local $0)
+ (if (result i32)
(get_local $1)
+ (i32.div_u
+ (get_local $0)
+ (get_local $1)
+ )
+ (i32.const 0)
)
)
)
@@ -9662,19 +9663,6 @@
)
)
)
- (func $_fputs (param $0 i32) (param $1 i32) (result i32)
- (i32.add
- (call $_fwrite
- (get_local $0)
- (call $_strlen
- (get_local $0)
- )
- (i32.const 1)
- (get_local $1)
- )
- (i32.const -1)
- )
- )
(func $dynCall_ii (param $0 i32) (param $1 i32) (result i32)
(call_indirect $FUNCSIG$ii
(get_local $1)
diff --git a/test/emcc_O2_hello_world.fromasm.imprecise b/test/emcc_O2_hello_world.fromasm.imprecise
index 824fcd3da..dd8457376 100644
--- a/test/emcc_O2_hello_world.fromasm.imprecise
+++ b/test/emcc_O2_hello_world.fromasm.imprecise
@@ -9184,9 +9184,16 @@
(block $do-once (result i32)
(if (result i32)
(i32.lt_s
- (call $_fputs
- (get_local $0)
- (get_local $1)
+ (i32.add
+ (call $_fwrite
+ (get_local $0)
+ (call $_strlen
+ (get_local $0)
+ )
+ (i32.const 1)
+ (get_local $1)
+ )
+ (i32.const -1)
)
(i32.const 0)
)
@@ -9651,19 +9658,6 @@
)
)
)
- (func $_fputs (param $0 i32) (param $1 i32) (result i32)
- (i32.add
- (call $_fwrite
- (get_local $0)
- (call $_strlen
- (get_local $0)
- )
- (i32.const 1)
- (get_local $1)
- )
- (i32.const -1)
- )
- )
(func $dynCall_ii (param $0 i32) (param $1 i32) (result i32)
(call_indirect $FUNCSIG$ii
(get_local $1)
diff --git a/test/emcc_hello_world.fromasm b/test/emcc_hello_world.fromasm
index 10d0f69e9..e96288365 100644
--- a/test/emcc_hello_world.fromasm
+++ b/test/emcc_hello_world.fromasm
@@ -258,12 +258,6 @@
)
(get_local $0)
)
- (func $_frexpl (param $0 f64) (param $1 i32) (result f64)
- (call $_frexp
- (get_local $0)
- (get_local $1)
- )
- )
(func $_strerror (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
@@ -2219,16 +2213,6 @@
(i32.const 0)
)
)
- (func $i32s-rem (param $0 i32) (param $1 i32) (result i32)
- (if (result i32)
- (get_local $1)
- (i32.rem_s
- (get_local $0)
- (get_local $1)
- )
- (i32.const 0)
- )
- )
(func $i32u-rem (param $0 i32) (param $1 i32) (result i32)
(if (result i32)
(get_local $1)
@@ -2268,8 +2252,8 @@
(local $20 i32)
(local $21 i32)
(local $22 i32)
- (local $23 i32)
- (local $24 f64)
+ (local $23 f64)
+ (local $24 i32)
(local $25 i32)
(local $26 i32)
(local $27 i32)
@@ -2297,7 +2281,7 @@
(local $49 i32)
(local $50 i32)
(local $51 i32)
- (set_local $26
+ (set_local $25
(get_global $STACKTOP)
)
(set_global $STACKTOP
@@ -2313,18 +2297,18 @@
)
(call $abort)
)
- (set_local $21
+ (set_local $20
(i32.add
- (get_local $26)
+ (get_local $25)
(i32.const 16)
)
)
(set_local $19
- (get_local $26)
+ (get_local $25)
)
(set_local $36
(i32.add
- (get_local $26)
+ (get_local $25)
(i32.const 528)
)
)
@@ -2335,11 +2319,11 @@
)
)
(set_local $39
- (tee_local $22
+ (tee_local $26
(i32.add
(tee_local $5
(i32.add
- (get_local $26)
+ (get_local $25)
(i32.const 536)
)
)
@@ -2357,7 +2341,7 @@
(i32.add
(tee_local $41
(i32.add
- (get_local $26)
+ (get_local $25)
(i32.const 8)
)
)
@@ -2368,7 +2352,7 @@
(i32.add
(tee_local $5
(i32.add
- (get_local $26)
+ (get_local $25)
(i32.const 576)
)
)
@@ -2387,9 +2371,9 @@
(get_local $34)
)
(tee_local $37
- (tee_local $23
+ (tee_local $22
(i32.add
- (get_local $26)
+ (get_local $25)
(i32.const 588)
)
)
@@ -2412,7 +2396,7 @@
(i32.add
(tee_local $48
(i32.add
- (get_local $26)
+ (get_local $25)
(i32.const 24)
)
)
@@ -2422,14 +2406,14 @@
(set_local $43
(tee_local $30
(i32.add
- (get_local $23)
+ (get_local $22)
(i32.const 9)
)
)
)
(set_local $35
(i32.add
- (get_local $23)
+ (get_local $22)
(i32.const 8)
)
)
@@ -2909,26 +2893,24 @@
(get_local $6)
)
)
- (if
- (i32.lt_s
- (get_local $14)
- (i32.const 0)
- )
- (block
- (set_local $11
+ (set_local $11
+ (if (result i32)
+ (i32.lt_s
+ (get_local $14)
+ (i32.const 0)
+ )
+ (block (result i32)
+ (set_local $14
+ (i32.sub
+ (i32.const 0)
+ (get_local $14)
+ )
+ )
(i32.or
(get_local $1)
(i32.const 8192)
)
)
- (set_local $14
- (i32.sub
- (i32.const 0)
- (get_local $14)
- )
- )
- )
- (set_local $11
(get_local $1)
)
)
@@ -3032,8 +3014,8 @@
)
)
)
- (block $label$break$L46
- (set_local $6
+ (set_local $6
+ (block $label$break$L46 (result i32)
(if (result i32)
(i32.eq
(i32.load8_s
@@ -3082,38 +3064,39 @@
(set_local $10
(get_local $6)
)
- (set_local $6
+ (br $label$break$L46
(i32.const 0)
)
- (br $label$break$L46)
)
)
(loop $while-in11
- (set_local $6
- (i32.add
- (i32.mul
- (get_local $8)
- (i32.const 10)
- )
- (get_local $6)
- )
- )
- (br_if $label$break$L46
- (i32.ge_u
- (tee_local $9
+ (drop
+ (br_if $label$break$L46
+ (tee_local $6
(i32.add
- (i32.load8_s
- (tee_local $10
- (i32.add
- (get_local $10)
- (i32.const 1)
+ (i32.mul
+ (get_local $8)
+ (i32.const 10)
+ )
+ (get_local $6)
+ )
+ )
+ (i32.ge_u
+ (tee_local $9
+ (i32.add
+ (i32.load8_s
+ (tee_local $10
+ (i32.add
+ (get_local $10)
+ (i32.const 1)
+ )
)
)
+ (i32.const -48)
)
- (i32.const -48)
)
+ (i32.const 10)
)
- (i32.const 10)
)
)
(set_local $8
@@ -3185,12 +3168,11 @@
(i32.const 4)
)
)
- (set_local $6
+ (br $label$break$L46
(i32.load
(get_local $6)
)
)
- (br $label$break$L46)
)
)
)
@@ -3696,7 +3678,7 @@
)
)
(set_local $8
- (get_local $22)
+ (get_local $26)
)
(block
(set_local $5
@@ -3706,7 +3688,7 @@
(get_local $8)
)
(set_local $8
- (get_local $22)
+ (get_local $26)
)
(loop $while-in32
(i32.store8
@@ -3747,43 +3729,41 @@
)
)
)
- (if
- (i32.and
- (get_local $11)
- (i32.const 8)
- )
- (block
- (set_local $5
- (get_local $8)
- )
- (set_local $7
+ (set_local $5
+ (if (result i32)
+ (i32.and
(get_local $11)
+ (i32.const 8)
)
- (set_local $6
- (select
- (tee_local $11
- (i32.add
- (i32.sub
- (get_local $39)
- (get_local $8)
+ (block (result i32)
+ (set_local $7
+ (get_local $11)
+ )
+ (set_local $6
+ (select
+ (tee_local $11
+ (i32.add
+ (i32.sub
+ (get_local $39)
+ (get_local $8)
+ )
+ (i32.const 1)
)
- (i32.const 1)
)
- )
- (get_local $6)
- (i32.lt_s
(get_local $6)
- (get_local $11)
+ (i32.lt_s
+ (get_local $6)
+ (get_local $11)
+ )
)
)
- )
- )
- (block
- (set_local $5
(get_local $8)
)
- (set_local $7
- (get_local $11)
+ (block (result i32)
+ (set_local $7
+ (get_local $11)
+ )
+ (get_local $8)
)
)
)
@@ -3840,29 +3820,27 @@
(br $__rjti$4)
)
)
- (if
- (i32.and
- (get_local $11)
- (i32.const 2048)
- )
- (block
- (set_local $8
- (i32.const 1)
+ (set_local $9
+ (if (result i32)
+ (i32.and
+ (get_local $11)
+ (i32.const 2048)
)
- (set_local $9
+ (block (result i32)
+ (set_local $8
+ (i32.const 1)
+ )
(i32.const 4092)
)
- )
- (block
- (set_local $8
- (tee_local $9
- (i32.and
- (get_local $11)
- (i32.const 1)
+ (block (result i32)
+ (set_local $8
+ (tee_local $9
+ (i32.and
+ (get_local $11)
+ (i32.const 1)
+ )
)
)
- )
- (set_local $9
(select
(i32.const 4093)
(i32.const 4091)
@@ -3922,7 +3900,7 @@
(i32.const 4091)
)
(br $__rjto$8
- (get_local $22)
+ (get_local $26)
)
)
(set_local $5
@@ -4002,7 +3980,7 @@
)
)
(i32.store
- (get_local $21)
+ (get_local $20)
(i32.const 0)
)
(f64.store
@@ -4098,11 +4076,13 @@
(if
(tee_local $5
(f64.ne
- (tee_local $24
+ (tee_local $23
(f64.mul
- (call $_frexpl
+ (call $_frexp
(get_local $15)
- (get_local $21)
+ (tee_local $5
+ (get_local $20)
+ )
)
(f64.const 2)
)
@@ -4111,10 +4091,10 @@
)
)
(i32.store
- (get_local $21)
+ (get_local $20)
(i32.add
(i32.load
- (get_local $21)
+ (get_local $20)
)
(i32.const -1)
)
@@ -4122,7 +4102,7 @@
)
(if
(i32.eq
- (tee_local $25
+ (tee_local $24
(i32.or
(get_local $18)
(i32.const 32)
@@ -4162,7 +4142,7 @@
)
)
)
- (get_local $24)
+ (get_local $23)
(block (result f64)
(set_local $15
(f64.const 8)
@@ -4195,7 +4175,7 @@
(get_local $15)
(f64.sub
(f64.neg
- (get_local $24)
+ (get_local $23)
)
(get_local $15)
)
@@ -4203,7 +4183,7 @@
)
(f64.sub
(f64.add
- (get_local $24)
+ (get_local $23)
(get_local $15)
)
(get_local $15)
@@ -4222,7 +4202,7 @@
(i32.const 0)
(tee_local $7
(i32.load
- (get_local $21)
+ (get_local $20)
)
)
)
@@ -4307,7 +4287,7 @@
)
)
(set_local $5
- (get_local $23)
+ (get_local $22)
)
(loop $while-in56
(i32.store8
@@ -4474,7 +4454,7 @@
)
(drop
(call $___fwritex
- (get_local $23)
+ (get_local $22)
(get_local $5)
(get_local $0)
)
@@ -4542,28 +4522,28 @@
(get_local $5)
(block (result f64)
(i32.store
- (get_local $21)
+ (get_local $20)
(tee_local $5
(i32.add
(i32.load
- (get_local $21)
+ (get_local $20)
)
(i32.const -28)
)
)
)
(f64.mul
- (get_local $24)
+ (get_local $23)
(f64.const 268435456)
)
)
(block (result f64)
(set_local $5
(i32.load
- (get_local $21)
+ (get_local $20)
)
)
- (get_local $24)
+ (get_local $23)
)
)
)
@@ -4615,7 +4595,7 @@
(i32.gt_s
(tee_local $9
(i32.load
- (get_local $21)
+ (get_local $20)
)
)
(i32.const 0)
@@ -4653,28 +4633,26 @@
(loop $while-in66
(i32.store
(get_local $9)
- (tee_local $20
- (call $___uremdi3
- (tee_local $12
- (call $_i64Add
- (call $_bitshift64Shl
- (i32.load
- (get_local $9)
- )
- (i32.const 0)
- (get_local $13)
+ (call $___uremdi3
+ (tee_local $12
+ (call $_i64Add
+ (call $_bitshift64Shl
+ (i32.load
+ (get_local $9)
)
- (get_global $tempRet0)
- (get_local $12)
(i32.const 0)
+ (get_local $13)
)
- )
- (tee_local $17
(get_global $tempRet0)
+ (get_local $12)
+ (i32.const 0)
)
- (i32.const 1000000000)
- (i32.const 0)
)
+ (tee_local $17
+ (get_global $tempRet0)
+ )
+ (i32.const 1000000000)
+ (i32.const 0)
)
)
(set_local $12
@@ -4741,11 +4719,11 @@
)
)
(i32.store
- (get_local $21)
+ (get_local $20)
(tee_local $9
(i32.sub
(i32.load
- (get_local $21)
+ (get_local $20)
)
(get_local $13)
)
@@ -4779,7 +4757,7 @@
(i32.const 0)
)
(block
- (set_local $20
+ (set_local $21
(i32.add
(call $i32s-div
(i32.add
@@ -4793,7 +4771,7 @@
)
(set_local $32
(i32.eq
- (get_local $25)
+ (get_local $24)
(i32.const 102)
)
)
@@ -4936,7 +4914,7 @@
)
)
(i32.shl
- (get_local $20)
+ (get_local $21)
(i32.const 2)
)
)
@@ -4949,16 +4927,16 @@
)
(i32.const 2)
)
- (get_local $20)
+ (get_local $21)
)
)
)
(i32.store
- (get_local $21)
+ (get_local $20)
(tee_local $9
(i32.add
(i32.load
- (get_local $21)
+ (get_local $20)
)
(get_local $13)
)
@@ -4993,7 +4971,7 @@
(get_local $7)
)
)
- (set_local $20
+ (set_local $21
(get_local $8)
)
(block $do-once75
@@ -5007,7 +4985,7 @@
(i32.mul
(i32.shr_s
(i32.sub
- (get_local $20)
+ (get_local $21)
(get_local $5)
)
(i32.const 2)
@@ -5064,7 +5042,7 @@
(get_local $7)
(i32.const 0)
(i32.ne
- (get_local $25)
+ (get_local $24)
(i32.const 102)
)
)
@@ -5080,7 +5058,7 @@
)
(tee_local $38
(i32.eq
- (get_local $25)
+ (get_local $24)
(i32.const 103)
)
)
@@ -5096,7 +5074,7 @@
(i32.shr_s
(i32.sub
(get_local $9)
- (get_local $20)
+ (get_local $21)
)
(i32.const 2)
)
@@ -5121,9 +5099,15 @@
(i32.lt_s
(tee_local $6
(i32.add
- (call $i32s-rem
- (get_local $6)
- (i32.const 9)
+ (if (result i32)
+ (tee_local $12
+ (i32.const 9)
+ )
+ (i32.rem_s
+ (get_local $6)
+ (get_local $12)
+ )
+ (i32.const 0)
)
(i32.const 1)
)
@@ -5160,7 +5144,7 @@
)
(set_local $13
(call $i32u-rem
- (tee_local $25
+ (tee_local $24
(i32.load
(tee_local $6
(i32.add
@@ -5200,7 +5184,7 @@
(block
(set_local $50
(call $i32u-div
- (get_local $25)
+ (get_local $24)
(get_local $12)
)
)
@@ -5229,7 +5213,7 @@
)
)
)
- (set_local $24
+ (set_local $23
(select
(f64.const 9007199254740994)
(f64.const 9007199254740992)
@@ -5251,9 +5235,9 @@
(i32.const 45)
)
)
- (set_local $24
+ (set_local $23
(f64.neg
- (get_local $24)
+ (get_local $23)
)
)
(set_local $15
@@ -5268,7 +5252,7 @@
(get_local $6)
(tee_local $13
(i32.sub
- (get_local $25)
+ (get_local $24)
(get_local $13)
)
)
@@ -5276,10 +5260,10 @@
(br_if $do-once81
(f64.eq
(f64.add
- (get_local $24)
+ (get_local $23)
(get_local $15)
)
- (get_local $24)
+ (get_local $23)
)
)
(i32.store
@@ -5344,7 +5328,7 @@
(i32.mul
(i32.shr_s
(i32.sub
- (get_local $20)
+ (get_local $21)
(get_local $5)
)
(i32.const 2)
@@ -5432,7 +5416,7 @@
(get_local $12)
)
(block
- (set_local $25
+ (set_local $24
(i32.const 0)
)
(set_local $9
@@ -5451,7 +5435,7 @@
)
)
(block
- (set_local $25
+ (set_local $24
(i32.const 1)
)
(set_local $9
@@ -5541,7 +5525,7 @@
)
)
(block
- (set_local $20
+ (set_local $21
(get_local $5)
)
(br $do-once91
@@ -5551,7 +5535,7 @@
)
(block $do-once93
(if
- (get_local $25)
+ (get_local $24)
(block
(if
(i32.eqz
@@ -5624,7 +5608,7 @@
(i32.shr_s
(i32.sub
(get_local $9)
- (get_local $20)
+ (get_local $21)
)
(i32.const 2)
)
@@ -5642,7 +5626,7 @@
(i32.const 102)
)
(block (result i32)
- (set_local $20
+ (set_local $21
(i32.const 0)
)
(select
@@ -5669,7 +5653,7 @@
)
)
(block (result i32)
- (set_local $20
+ (set_local $21
(i32.const 0)
)
(select
@@ -5701,7 +5685,7 @@
)
)
(block (result i32)
- (set_local $20
+ (set_local $21
(i32.and
(get_local $11)
(i32.const 8)
@@ -5720,122 +5704,120 @@
(tee_local $32
(i32.or
(get_local $5)
- (get_local $20)
+ (get_local $21)
)
)
(i32.const 0)
)
)
- (tee_local $7
- (if (result i32)
- (tee_local $17
- (i32.eq
- (i32.or
- (get_local $7)
- (i32.const 32)
- )
- (i32.const 102)
+ (if (result i32)
+ (tee_local $17
+ (i32.eq
+ (i32.or
+ (get_local $7)
+ (i32.const 32)
)
+ (i32.const 102)
)
- (block (result i32)
- (set_local $18
- (i32.const 0)
- )
- (select
+ )
+ (block (result i32)
+ (set_local $18
+ (i32.const 0)
+ )
+ (select
+ (get_local $13)
+ (i32.const 0)
+ (i32.gt_s
(get_local $13)
(i32.const 0)
- (i32.gt_s
- (get_local $13)
- (i32.const 0)
- )
)
)
- (block (result i32)
- (if
- (i32.lt_s
- (i32.sub
- (get_local $28)
- (tee_local $6
- (call $_fmt_u
- (tee_local $6
- (select
- (get_local $33)
+ )
+ (block (result i32)
+ (if
+ (i32.lt_s
+ (i32.sub
+ (get_local $28)
+ (tee_local $6
+ (call $_fmt_u
+ (tee_local $6
+ (select
+ (get_local $33)
+ (get_local $13)
+ (i32.lt_s
(get_local $13)
- (i32.lt_s
- (get_local $13)
- (i32.const 0)
- )
+ (i32.const 0)
)
)
- (i32.shr_s
- (i32.shl
- (i32.lt_s
- (get_local $6)
- (i32.const 0)
- )
- (i32.const 31)
+ )
+ (i32.shr_s
+ (i32.shl
+ (i32.lt_s
+ (get_local $6)
+ (i32.const 0)
)
(i32.const 31)
)
- (get_local $34)
+ (i32.const 31)
)
+ (get_local $34)
)
)
- (i32.const 2)
)
- (loop $while-in98
- (i32.store8
- (tee_local $6
- (i32.add
- (get_local $6)
- (i32.const -1)
- )
- )
- (i32.const 48)
- )
- (br_if $while-in98
- (i32.lt_s
- (i32.sub
- (get_local $28)
- (get_local $6)
- )
- (i32.const 2)
+ (i32.const 2)
+ )
+ (loop $while-in98
+ (i32.store8
+ (tee_local $6
+ (i32.add
+ (get_local $6)
+ (i32.const -1)
)
)
+ (i32.const 48)
)
- )
- (i32.store8
- (i32.add
- (get_local $6)
- (i32.const -1)
- )
- (i32.add
- (i32.and
- (i32.shr_s
- (get_local $13)
- (i32.const 31)
+ (br_if $while-in98
+ (i32.lt_s
+ (i32.sub
+ (get_local $28)
+ (get_local $6)
)
(i32.const 2)
)
- (i32.const 43)
)
)
- (i32.store8
- (tee_local $6
- (i32.add
- (get_local $6)
- (i32.const -2)
+ )
+ (i32.store8
+ (i32.add
+ (get_local $6)
+ (i32.const -1)
+ )
+ (i32.add
+ (i32.and
+ (i32.shr_s
+ (get_local $13)
+ (i32.const 31)
)
+ (i32.const 2)
)
- (get_local $7)
+ (i32.const 43)
)
- (set_local $18
- (get_local $6)
- )
- (i32.sub
- (get_local $28)
- (get_local $6)
+ )
+ (i32.store8
+ (tee_local $6
+ (i32.add
+ (get_local $6)
+ (i32.const -2)
+ )
)
+ (get_local $7)
+ )
+ (set_local $18
+ (get_local $6)
+ )
+ (i32.sub
+ (get_local $28)
+ (get_local $6)
)
)
)
@@ -5921,7 +5903,7 @@
(br_if $do-once103
(i32.le_u
(get_local $7)
- (get_local $23)
+ (get_local $22)
)
)
(loop $while-in106
@@ -5937,7 +5919,7 @@
(br_if $while-in106
(i32.gt_u
(get_local $7)
- (get_local $23)
+ (get_local $22)
)
)
)
@@ -6027,7 +6009,7 @@
(get_local $30)
)
)
- (get_local $23)
+ (get_local $22)
)
(loop $while-in112
(i32.store8
@@ -6042,7 +6024,7 @@
(br_if $while-in112
(i32.gt_u
(get_local $6)
- (get_local $23)
+ (get_local $22)
)
)
)
@@ -6124,7 +6106,7 @@
(get_local $12)
(i32.const 4)
)
- (get_local $25)
+ (get_local $24)
)
)
(if
@@ -6135,7 +6117,7 @@
(block
(set_local $17
(i32.eqz
- (get_local $20)
+ (get_local $21)
)
)
(set_local $6
@@ -6227,7 +6209,7 @@
(br_if $do-once115
(i32.le_u
(get_local $5)
- (get_local $23)
+ (get_local $22)
)
)
(loop $while-in118
@@ -6243,7 +6225,7 @@
(br_if $while-in118
(i32.gt_u
(get_local $5)
- (get_local $23)
+ (get_local $22)
)
)
)
@@ -6492,7 +6474,7 @@
(i32.const 4091)
)
(br $__rjto$8
- (get_local $22)
+ (get_local $26)
)
)
(set_local $9
@@ -6522,7 +6504,7 @@
)
(block
(set_local $5
- (get_local $22)
+ (get_local $26)
)
(set_local $8
(i32.const 0)
@@ -6537,7 +6519,7 @@
(get_local $8)
)
(set_local $8
- (get_local $22)
+ (get_local $26)
)
(loop $while-in123
(i32.store8
@@ -6584,49 +6566,47 @@
(get_local $8)
)
)
- (if
- (i32.or
- (i32.eqz
- (i32.and
- (get_local $7)
- (i32.const 8)
- )
- )
- (i32.and
+ (set_local $8
+ (if (result i32)
+ (i32.or
(i32.eqz
- (i32.load
- (tee_local $11
- (get_local $19)
- )
+ (i32.and
+ (get_local $7)
+ (i32.const 8)
)
)
- (i32.eqz
- (i32.load offset=4
- (get_local $11)
+ (i32.and
+ (i32.eqz
+ (i32.load
+ (tee_local $11
+ (get_local $19)
+ )
+ )
+ )
+ (i32.eqz
+ (i32.load offset=4
+ (get_local $11)
+ )
)
)
)
- )
- (block
- (set_local $8
+ (block (result i32)
+ (set_local $9
+ (i32.const 4091)
+ )
(i32.const 0)
)
- (set_local $9
- (i32.const 4091)
- )
- )
- (block
- (set_local $8
- (i32.const 2)
- )
- (set_local $9
- (i32.add
- (i32.shr_s
- (get_local $18)
- (i32.const 4)
+ (block (result i32)
+ (set_local $9
+ (i32.add
+ (i32.shr_s
+ (get_local $18)
+ (i32.const 4)
+ )
+ (i32.const 4091)
)
- (i32.const 4091)
)
+ (i32.const 2)
)
)
)
@@ -6638,7 +6618,7 @@
(call $_fmt_u
(get_local $5)
(get_local $7)
- (get_local $22)
+ (get_local $26)
)
)
(set_local $7
@@ -6896,33 +6876,33 @@
)
)
)
- (if
- (i32.or
- (get_local $6)
- (tee_local $12
- (i32.or
- (i32.ne
- (i32.load
- (tee_local $7
- (get_local $19)
+ (set_local $12
+ (if (result i32)
+ (i32.or
+ (get_local $6)
+ (tee_local $12
+ (i32.or
+ (i32.ne
+ (i32.load
+ (tee_local $7
+ (get_local $19)
+ )
)
+ (i32.const 0)
)
- (i32.const 0)
- )
- (i32.ne
- (i32.load offset=4
- (get_local $7)
+ (i32.ne
+ (i32.load offset=4
+ (get_local $7)
+ )
+ (i32.const 0)
)
- (i32.const 0)
)
)
)
- )
- (block
- (set_local $7
- (get_local $5)
- )
- (set_local $12
+ (block (result i32)
+ (set_local $7
+ (get_local $5)
+ )
(select
(get_local $6)
(tee_local $5
@@ -6946,17 +6926,15 @@
)
)
)
- )
- (block
- (set_local $7
- (get_local $22)
- )
- (set_local $12
+ (block (result i32)
+ (set_local $7
+ (get_local $26)
+ )
(i32.const 0)
)
)
)
- (get_local $22)
+ (get_local $26)
)
)
(call $_pad
@@ -7169,7 +7147,7 @@
)
)
(set_global $STACKTOP
- (get_local $26)
+ (get_local $25)
)
(get_local $16)
)
diff --git a/test/emcc_hello_world.fromasm.clamp b/test/emcc_hello_world.fromasm.clamp
index af2b8a467..7ae8bb801 100644
--- a/test/emcc_hello_world.fromasm.clamp
+++ b/test/emcc_hello_world.fromasm.clamp
@@ -256,12 +256,6 @@
)
(get_local $0)
)
- (func $_frexpl (param $0 f64) (param $1 i32) (result f64)
- (call $_frexp
- (get_local $0)
- (get_local $1)
- )
- )
(func $_strerror (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
@@ -2243,16 +2237,6 @@
(i32.const 0)
)
)
- (func $i32s-rem (param $0 i32) (param $1 i32) (result i32)
- (if (result i32)
- (get_local $1)
- (i32.rem_s
- (get_local $0)
- (get_local $1)
- )
- (i32.const 0)
- )
- )
(func $i32u-rem (param $0 i32) (param $1 i32) (result i32)
(if (result i32)
(get_local $1)
@@ -2292,8 +2276,8 @@
(local $20 i32)
(local $21 i32)
(local $22 i32)
- (local $23 i32)
- (local $24 f64)
+ (local $23 f64)
+ (local $24 i32)
(local $25 i32)
(local $26 i32)
(local $27 i32)
@@ -2321,7 +2305,7 @@
(local $49 i32)
(local $50 i32)
(local $51 i32)
- (set_local $26
+ (set_local $25
(get_global $STACKTOP)
)
(set_global $STACKTOP
@@ -2337,18 +2321,18 @@
)
(call $abort)
)
- (set_local $21
+ (set_local $20
(i32.add
- (get_local $26)
+ (get_local $25)
(i32.const 16)
)
)
(set_local $19
- (get_local $26)
+ (get_local $25)
)
(set_local $36
(i32.add
- (get_local $26)
+ (get_local $25)
(i32.const 528)
)
)
@@ -2359,11 +2343,11 @@
)
)
(set_local $39
- (tee_local $22
+ (tee_local $26
(i32.add
(tee_local $5
(i32.add
- (get_local $26)
+ (get_local $25)
(i32.const 536)
)
)
@@ -2381,7 +2365,7 @@
(i32.add
(tee_local $41
(i32.add
- (get_local $26)
+ (get_local $25)
(i32.const 8)
)
)
@@ -2392,7 +2376,7 @@
(i32.add
(tee_local $5
(i32.add
- (get_local $26)
+ (get_local $25)
(i32.const 576)
)
)
@@ -2411,9 +2395,9 @@
(get_local $34)
)
(tee_local $37
- (tee_local $23
+ (tee_local $22
(i32.add
- (get_local $26)
+ (get_local $25)
(i32.const 588)
)
)
@@ -2436,7 +2420,7 @@
(i32.add
(tee_local $48
(i32.add
- (get_local $26)
+ (get_local $25)
(i32.const 24)
)
)
@@ -2446,14 +2430,14 @@
(set_local $43
(tee_local $30
(i32.add
- (get_local $23)
+ (get_local $22)
(i32.const 9)
)
)
)
(set_local $35
(i32.add
- (get_local $23)
+ (get_local $22)
(i32.const 8)
)
)
@@ -2933,26 +2917,24 @@
(get_local $6)
)
)
- (if
- (i32.lt_s
- (get_local $14)
- (i32.const 0)
- )
- (block
- (set_local $11
+ (set_local $11
+ (if (result i32)
+ (i32.lt_s
+ (get_local $14)
+ (i32.const 0)
+ )
+ (block (result i32)
+ (set_local $14
+ (i32.sub
+ (i32.const 0)
+ (get_local $14)
+ )
+ )
(i32.or
(get_local $1)
(i32.const 8192)
)
)
- (set_local $14
- (i32.sub
- (i32.const 0)
- (get_local $14)
- )
- )
- )
- (set_local $11
(get_local $1)
)
)
@@ -3056,8 +3038,8 @@
)
)
)
- (block $label$break$L46
- (set_local $6
+ (set_local $6
+ (block $label$break$L46 (result i32)
(if (result i32)
(i32.eq
(i32.load8_s
@@ -3106,38 +3088,39 @@
(set_local $10
(get_local $6)
)
- (set_local $6
+ (br $label$break$L46
(i32.const 0)
)
- (br $label$break$L46)
)
)
(loop $while-in11
- (set_local $6
- (i32.add
- (i32.mul
- (get_local $8)
- (i32.const 10)
- )
- (get_local $6)
- )
- )
- (br_if $label$break$L46
- (i32.ge_u
- (tee_local $9
+ (drop
+ (br_if $label$break$L46
+ (tee_local $6
(i32.add
- (i32.load8_s
- (tee_local $10
- (i32.add
- (get_local $10)
- (i32.const 1)
+ (i32.mul
+ (get_local $8)
+ (i32.const 10)
+ )
+ (get_local $6)
+ )
+ )
+ (i32.ge_u
+ (tee_local $9
+ (i32.add
+ (i32.load8_s
+ (tee_local $10
+ (i32.add
+ (get_local $10)
+ (i32.const 1)
+ )
)
)
+ (i32.const -48)
)
- (i32.const -48)
)
+ (i32.const 10)
)
- (i32.const 10)
)
)
(set_local $8
@@ -3209,12 +3192,11 @@
(i32.const 4)
)
)
- (set_local $6
+ (br $label$break$L46
(i32.load
(get_local $6)
)
)
- (br $label$break$L46)
)
)
)
@@ -3720,7 +3702,7 @@
)
)
(set_local $8
- (get_local $22)
+ (get_local $26)
)
(block
(set_local $5
@@ -3730,7 +3712,7 @@
(get_local $8)
)
(set_local $8
- (get_local $22)
+ (get_local $26)
)
(loop $while-in32
(i32.store8
@@ -3771,43 +3753,41 @@
)
)
)
- (if
- (i32.and
- (get_local $11)
- (i32.const 8)
- )
- (block
- (set_local $5
- (get_local $8)
- )
- (set_local $7
+ (set_local $5
+ (if (result i32)
+ (i32.and
(get_local $11)
+ (i32.const 8)
)
- (set_local $6
- (select
- (tee_local $11
- (i32.add
- (i32.sub
- (get_local $39)
- (get_local $8)
+ (block (result i32)
+ (set_local $7
+ (get_local $11)
+ )
+ (set_local $6
+ (select
+ (tee_local $11
+ (i32.add
+ (i32.sub
+ (get_local $39)
+ (get_local $8)
+ )
+ (i32.const 1)
)
- (i32.const 1)
)
- )
- (get_local $6)
- (i32.lt_s
(get_local $6)
- (get_local $11)
+ (i32.lt_s
+ (get_local $6)
+ (get_local $11)
+ )
)
)
- )
- )
- (block
- (set_local $5
(get_local $8)
)
- (set_local $7
- (get_local $11)
+ (block (result i32)
+ (set_local $7
+ (get_local $11)
+ )
+ (get_local $8)
)
)
)
@@ -3864,29 +3844,27 @@
(br $__rjti$4)
)
)
- (if
- (i32.and
- (get_local $11)
- (i32.const 2048)
- )
- (block
- (set_local $8
- (i32.const 1)
+ (set_local $9
+ (if (result i32)
+ (i32.and
+ (get_local $11)
+ (i32.const 2048)
)
- (set_local $9
+ (block (result i32)
+ (set_local $8
+ (i32.const 1)
+ )
(i32.const 4092)
)
- )
- (block
- (set_local $8
- (tee_local $9
- (i32.and
- (get_local $11)
- (i32.const 1)
+ (block (result i32)
+ (set_local $8
+ (tee_local $9
+ (i32.and
+ (get_local $11)
+ (i32.const 1)
+ )
)
)
- )
- (set_local $9
(select
(i32.const 4093)
(i32.const 4091)
@@ -3946,7 +3924,7 @@
(i32.const 4091)
)
(br $__rjto$8
- (get_local $22)
+ (get_local $26)
)
)
(set_local $5
@@ -4026,7 +4004,7 @@
)
)
(i32.store
- (get_local $21)
+ (get_local $20)
(i32.const 0)
)
(f64.store
@@ -4122,11 +4100,13 @@
(if
(tee_local $5
(f64.ne
- (tee_local $24
+ (tee_local $23
(f64.mul
- (call $_frexpl
+ (call $_frexp
(get_local $15)
- (get_local $21)
+ (tee_local $5
+ (get_local $20)
+ )
)
(f64.const 2)
)
@@ -4135,10 +4115,10 @@
)
)
(i32.store
- (get_local $21)
+ (get_local $20)
(i32.add
(i32.load
- (get_local $21)
+ (get_local $20)
)
(i32.const -1)
)
@@ -4146,7 +4126,7 @@
)
(if
(i32.eq
- (tee_local $25
+ (tee_local $24
(i32.or
(get_local $18)
(i32.const 32)
@@ -4186,7 +4166,7 @@
)
)
)
- (get_local $24)
+ (get_local $23)
(block (result f64)
(set_local $15
(f64.const 8)
@@ -4219,7 +4199,7 @@
(get_local $15)
(f64.sub
(f64.neg
- (get_local $24)
+ (get_local $23)
)
(get_local $15)
)
@@ -4227,7 +4207,7 @@
)
(f64.sub
(f64.add
- (get_local $24)
+ (get_local $23)
(get_local $15)
)
(get_local $15)
@@ -4246,7 +4226,7 @@
(i32.const 0)
(tee_local $7
(i32.load
- (get_local $21)
+ (get_local $20)
)
)
)
@@ -4331,7 +4311,7 @@
)
)
(set_local $5
- (get_local $23)
+ (get_local $22)
)
(loop $while-in56
(i32.store8
@@ -4498,7 +4478,7 @@
)
(drop
(call $___fwritex
- (get_local $23)
+ (get_local $22)
(get_local $5)
(get_local $0)
)
@@ -4566,28 +4546,28 @@
(get_local $5)
(block (result f64)
(i32.store
- (get_local $21)
+ (get_local $20)
(tee_local $5
(i32.add
(i32.load
- (get_local $21)
+ (get_local $20)
)
(i32.const -28)
)
)
)
(f64.mul
- (get_local $24)
+ (get_local $23)
(f64.const 268435456)
)
)
(block (result f64)
(set_local $5
(i32.load
- (get_local $21)
+ (get_local $20)
)
)
- (get_local $24)
+ (get_local $23)
)
)
)
@@ -4639,7 +4619,7 @@
(i32.gt_s
(tee_local $9
(i32.load
- (get_local $21)
+ (get_local $20)
)
)
(i32.const 0)
@@ -4677,28 +4657,26 @@
(loop $while-in66
(i32.store
(get_local $9)
- (tee_local $20
- (call $___uremdi3
- (tee_local $12
- (call $_i64Add
- (call $_bitshift64Shl
- (i32.load
- (get_local $9)
- )
- (i32.const 0)
- (get_local $13)
+ (call $___uremdi3
+ (tee_local $12
+ (call $_i64Add
+ (call $_bitshift64Shl
+ (i32.load
+ (get_local $9)
)
- (get_global $tempRet0)
- (get_local $12)
(i32.const 0)
+ (get_local $13)
)
- )
- (tee_local $17
(get_global $tempRet0)
+ (get_local $12)
+ (i32.const 0)
)
- (i32.const 1000000000)
- (i32.const 0)
)
+ (tee_local $17
+ (get_global $tempRet0)
+ )
+ (i32.const 1000000000)
+ (i32.const 0)
)
)
(set_local $12
@@ -4765,11 +4743,11 @@
)
)
(i32.store
- (get_local $21)
+ (get_local $20)
(tee_local $9
(i32.sub
(i32.load
- (get_local $21)
+ (get_local $20)
)
(get_local $13)
)
@@ -4803,7 +4781,7 @@
(i32.const 0)
)
(block
- (set_local $20
+ (set_local $21
(i32.add
(call $i32s-div
(i32.add
@@ -4817,7 +4795,7 @@
)
(set_local $32
(i32.eq
- (get_local $25)
+ (get_local $24)
(i32.const 102)
)
)
@@ -4960,7 +4938,7 @@
)
)
(i32.shl
- (get_local $20)
+ (get_local $21)
(i32.const 2)
)
)
@@ -4973,16 +4951,16 @@
)
(i32.const 2)
)
- (get_local $20)
+ (get_local $21)
)
)
)
(i32.store
- (get_local $21)
+ (get_local $20)
(tee_local $9
(i32.add
(i32.load
- (get_local $21)
+ (get_local $20)
)
(get_local $13)
)
@@ -5017,7 +4995,7 @@
(get_local $7)
)
)
- (set_local $20
+ (set_local $21
(get_local $8)
)
(block $do-once75
@@ -5031,7 +5009,7 @@
(i32.mul
(i32.shr_s
(i32.sub
- (get_local $20)
+ (get_local $21)
(get_local $5)
)
(i32.const 2)
@@ -5088,7 +5066,7 @@
(get_local $7)
(i32.const 0)
(i32.ne
- (get_local $25)
+ (get_local $24)
(i32.const 102)
)
)
@@ -5104,7 +5082,7 @@
)
(tee_local $38
(i32.eq
- (get_local $25)
+ (get_local $24)
(i32.const 103)
)
)
@@ -5120,7 +5098,7 @@
(i32.shr_s
(i32.sub
(get_local $9)
- (get_local $20)
+ (get_local $21)
)
(i32.const 2)
)
@@ -5145,9 +5123,15 @@
(i32.lt_s
(tee_local $6
(i32.add
- (call $i32s-rem
- (get_local $6)
- (i32.const 9)
+ (if (result i32)
+ (tee_local $12
+ (i32.const 9)
+ )
+ (i32.rem_s
+ (get_local $6)
+ (get_local $12)
+ )
+ (i32.const 0)
)
(i32.const 1)
)
@@ -5184,7 +5168,7 @@
)
(set_local $13
(call $i32u-rem
- (tee_local $25
+ (tee_local $24
(i32.load
(tee_local $6
(i32.add
@@ -5224,7 +5208,7 @@
(block
(set_local $50
(call $i32u-div
- (get_local $25)
+ (get_local $24)
(get_local $12)
)
)
@@ -5253,7 +5237,7 @@
)
)
)
- (set_local $24
+ (set_local $23
(select
(f64.const 9007199254740994)
(f64.const 9007199254740992)
@@ -5275,9 +5259,9 @@
(i32.const 45)
)
)
- (set_local $24
+ (set_local $23
(f64.neg
- (get_local $24)
+ (get_local $23)
)
)
(set_local $15
@@ -5292,7 +5276,7 @@
(get_local $6)
(tee_local $13
(i32.sub
- (get_local $25)
+ (get_local $24)
(get_local $13)
)
)
@@ -5300,10 +5284,10 @@
(br_if $do-once81
(f64.eq
(f64.add
- (get_local $24)
+ (get_local $23)
(get_local $15)
)
- (get_local $24)
+ (get_local $23)
)
)
(i32.store
@@ -5368,7 +5352,7 @@
(i32.mul
(i32.shr_s
(i32.sub
- (get_local $20)
+ (get_local $21)
(get_local $5)
)
(i32.const 2)
@@ -5456,7 +5440,7 @@
(get_local $12)
)
(block
- (set_local $25
+ (set_local $24
(i32.const 0)
)
(set_local $9
@@ -5475,7 +5459,7 @@
)
)
(block
- (set_local $25
+ (set_local $24
(i32.const 1)
)
(set_local $9
@@ -5565,7 +5549,7 @@
)
)
(block
- (set_local $20
+ (set_local $21
(get_local $5)
)
(br $do-once91
@@ -5575,7 +5559,7 @@
)
(block $do-once93
(if
- (get_local $25)
+ (get_local $24)
(block
(if
(i32.eqz
@@ -5648,7 +5632,7 @@
(i32.shr_s
(i32.sub
(get_local $9)
- (get_local $20)
+ (get_local $21)
)
(i32.const 2)
)
@@ -5666,7 +5650,7 @@
(i32.const 102)
)
(block (result i32)
- (set_local $20
+ (set_local $21
(i32.const 0)
)
(select
@@ -5693,7 +5677,7 @@
)
)
(block (result i32)
- (set_local $20
+ (set_local $21
(i32.const 0)
)
(select
@@ -5725,7 +5709,7 @@
)
)
(block (result i32)
- (set_local $20
+ (set_local $21
(i32.and
(get_local $11)
(i32.const 8)
@@ -5744,122 +5728,120 @@
(tee_local $32
(i32.or
(get_local $5)
- (get_local $20)
+ (get_local $21)
)
)
(i32.const 0)
)
)
- (tee_local $7
- (if (result i32)
- (tee_local $17
- (i32.eq
- (i32.or
- (get_local $7)
- (i32.const 32)
- )
- (i32.const 102)
+ (if (result i32)
+ (tee_local $17
+ (i32.eq
+ (i32.or
+ (get_local $7)
+ (i32.const 32)
)
+ (i32.const 102)
)
- (block (result i32)
- (set_local $18
- (i32.const 0)
- )
- (select
+ )
+ (block (result i32)
+ (set_local $18
+ (i32.const 0)
+ )
+ (select
+ (get_local $13)
+ (i32.const 0)
+ (i32.gt_s
(get_local $13)
(i32.const 0)
- (i32.gt_s
- (get_local $13)
- (i32.const 0)
- )
)
)
- (block (result i32)
- (if
- (i32.lt_s
- (i32.sub
- (get_local $28)
- (tee_local $6
- (call $_fmt_u
- (tee_local $6
- (select
- (get_local $33)
+ )
+ (block (result i32)
+ (if
+ (i32.lt_s
+ (i32.sub
+ (get_local $28)
+ (tee_local $6
+ (call $_fmt_u
+ (tee_local $6
+ (select
+ (get_local $33)
+ (get_local $13)
+ (i32.lt_s
(get_local $13)
- (i32.lt_s
- (get_local $13)
- (i32.const 0)
- )
+ (i32.const 0)
)
)
- (i32.shr_s
- (i32.shl
- (i32.lt_s
- (get_local $6)
- (i32.const 0)
- )
- (i32.const 31)
+ )
+ (i32.shr_s
+ (i32.shl
+ (i32.lt_s
+ (get_local $6)
+ (i32.const 0)
)
(i32.const 31)
)
- (get_local $34)
+ (i32.const 31)
)
+ (get_local $34)
)
)
- (i32.const 2)
)
- (loop $while-in98
- (i32.store8
- (tee_local $6
- (i32.add
- (get_local $6)
- (i32.const -1)
- )
- )
- (i32.const 48)
- )
- (br_if $while-in98
- (i32.lt_s
- (i32.sub
- (get_local $28)
- (get_local $6)
- )
- (i32.const 2)
+ (i32.const 2)
+ )
+ (loop $while-in98
+ (i32.store8
+ (tee_local $6
+ (i32.add
+ (get_local $6)
+ (i32.const -1)
)
)
+ (i32.const 48)
)
- )
- (i32.store8
- (i32.add
- (get_local $6)
- (i32.const -1)
- )
- (i32.add
- (i32.and
- (i32.shr_s
- (get_local $13)
- (i32.const 31)
+ (br_if $while-in98
+ (i32.lt_s
+ (i32.sub
+ (get_local $28)
+ (get_local $6)
)
(i32.const 2)
)
- (i32.const 43)
)
)
- (i32.store8
- (tee_local $6
- (i32.add
- (get_local $6)
- (i32.const -2)
+ )
+ (i32.store8
+ (i32.add
+ (get_local $6)
+ (i32.const -1)
+ )
+ (i32.add
+ (i32.and
+ (i32.shr_s
+ (get_local $13)
+ (i32.const 31)
)
+ (i32.const 2)
)
- (get_local $7)
+ (i32.const 43)
)
- (set_local $18
- (get_local $6)
- )
- (i32.sub
- (get_local $28)
- (get_local $6)
+ )
+ (i32.store8
+ (tee_local $6
+ (i32.add
+ (get_local $6)
+ (i32.const -2)
+ )
)
+ (get_local $7)
+ )
+ (set_local $18
+ (get_local $6)
+ )
+ (i32.sub
+ (get_local $28)
+ (get_local $6)
)
)
)
@@ -5945,7 +5927,7 @@
(br_if $do-once103
(i32.le_u
(get_local $7)
- (get_local $23)
+ (get_local $22)
)
)
(loop $while-in106
@@ -5961,7 +5943,7 @@
(br_if $while-in106
(i32.gt_u
(get_local $7)
- (get_local $23)
+ (get_local $22)
)
)
)
@@ -6051,7 +6033,7 @@
(get_local $30)
)
)
- (get_local $23)
+ (get_local $22)
)
(loop $while-in112
(i32.store8
@@ -6066,7 +6048,7 @@
(br_if $while-in112
(i32.gt_u
(get_local $6)
- (get_local $23)
+ (get_local $22)
)
)
)
@@ -6148,7 +6130,7 @@
(get_local $12)
(i32.const 4)
)
- (get_local $25)
+ (get_local $24)
)
)
(if
@@ -6159,7 +6141,7 @@
(block
(set_local $17
(i32.eqz
- (get_local $20)
+ (get_local $21)
)
)
(set_local $6
@@ -6251,7 +6233,7 @@
(br_if $do-once115
(i32.le_u
(get_local $5)
- (get_local $23)
+ (get_local $22)
)
)
(loop $while-in118
@@ -6267,7 +6249,7 @@
(br_if $while-in118
(i32.gt_u
(get_local $5)
- (get_local $23)
+ (get_local $22)
)
)
)
@@ -6516,7 +6498,7 @@
(i32.const 4091)
)
(br $__rjto$8
- (get_local $22)
+ (get_local $26)
)
)
(set_local $9
@@ -6546,7 +6528,7 @@
)
(block
(set_local $5
- (get_local $22)
+ (get_local $26)
)
(set_local $8
(i32.const 0)
@@ -6561,7 +6543,7 @@
(get_local $8)
)
(set_local $8
- (get_local $22)
+ (get_local $26)
)
(loop $while-in123
(i32.store8
@@ -6608,49 +6590,47 @@
(get_local $8)
)
)
- (if
- (i32.or
- (i32.eqz
- (i32.and
- (get_local $7)
- (i32.const 8)
- )
- )
- (i32.and
+ (set_local $8
+ (if (result i32)
+ (i32.or
(i32.eqz
- (i32.load
- (tee_local $11
- (get_local $19)
- )
+ (i32.and
+ (get_local $7)
+ (i32.const 8)
)
)
- (i32.eqz
- (i32.load offset=4
- (get_local $11)
+ (i32.and
+ (i32.eqz
+ (i32.load
+ (tee_local $11
+ (get_local $19)
+ )
+ )
+ )
+ (i32.eqz
+ (i32.load offset=4
+ (get_local $11)
+ )
)
)
)
- )
- (block
- (set_local $8
+ (block (result i32)
+ (set_local $9
+ (i32.const 4091)
+ )
(i32.const 0)
)
- (set_local $9
- (i32.const 4091)
- )
- )
- (block
- (set_local $8
- (i32.const 2)
- )
- (set_local $9
- (i32.add
- (i32.shr_s
- (get_local $18)
- (i32.const 4)
+ (block (result i32)
+ (set_local $9
+ (i32.add
+ (i32.shr_s
+ (get_local $18)
+ (i32.const 4)
+ )
+ (i32.const 4091)
)
- (i32.const 4091)
)
+ (i32.const 2)
)
)
)
@@ -6662,7 +6642,7 @@
(call $_fmt_u
(get_local $5)
(get_local $7)
- (get_local $22)
+ (get_local $26)
)
)
(set_local $7
@@ -6920,33 +6900,33 @@
)
)
)
- (if
- (i32.or
- (get_local $6)
- (tee_local $12
- (i32.or
- (i32.ne
- (i32.load
- (tee_local $7
- (get_local $19)
+ (set_local $12
+ (if (result i32)
+ (i32.or
+ (get_local $6)
+ (tee_local $12
+ (i32.or
+ (i32.ne
+ (i32.load
+ (tee_local $7
+ (get_local $19)
+ )
)
+ (i32.const 0)
)
- (i32.const 0)
- )
- (i32.ne
- (i32.load offset=4
- (get_local $7)
+ (i32.ne
+ (i32.load offset=4
+ (get_local $7)
+ )
+ (i32.const 0)
)
- (i32.const 0)
)
)
)
- )
- (block
- (set_local $7
- (get_local $5)
- )
- (set_local $12
+ (block (result i32)
+ (set_local $7
+ (get_local $5)
+ )
(select
(get_local $6)
(tee_local $5
@@ -6970,17 +6950,15 @@
)
)
)
- )
- (block
- (set_local $7
- (get_local $22)
- )
- (set_local $12
+ (block (result i32)
+ (set_local $7
+ (get_local $26)
+ )
(i32.const 0)
)
)
)
- (get_local $22)
+ (get_local $26)
)
)
(call $_pad
@@ -7193,7 +7171,7 @@
)
)
(set_global $STACKTOP
- (get_local $26)
+ (get_local $25)
)
(get_local $16)
)
diff --git a/test/emcc_hello_world.fromasm.imprecise b/test/emcc_hello_world.fromasm.imprecise
index 96344b09d..e6caa9b58 100644
--- a/test/emcc_hello_world.fromasm.imprecise
+++ b/test/emcc_hello_world.fromasm.imprecise
@@ -255,12 +255,6 @@
)
(get_local $0)
)
- (func $_frexpl (param $0 f64) (param $1 i32) (result f64)
- (call $_frexp
- (get_local $0)
- (get_local $1)
- )
- )
(func $_strerror (param $0 i32) (result i32)
(local $1 i32)
(local $2 i32)
@@ -2212,8 +2206,8 @@
(local $20 i32)
(local $21 i32)
(local $22 i32)
- (local $23 i32)
- (local $24 f64)
+ (local $23 f64)
+ (local $24 i32)
(local $25 i32)
(local $26 i32)
(local $27 i32)
@@ -2240,7 +2234,7 @@
(local $48 i32)
(local $49 i32)
(local $50 i32)
- (set_local $26
+ (set_local $25
(get_global $STACKTOP)
)
(set_global $STACKTOP
@@ -2256,18 +2250,18 @@
)
(call $abort)
)
- (set_local $21
+ (set_local $20
(i32.add
- (get_local $26)
+ (get_local $25)
(i32.const 16)
)
)
(set_local $19
- (get_local $26)
+ (get_local $25)
)
(set_local $36
(i32.add
- (get_local $26)
+ (get_local $25)
(i32.const 528)
)
)
@@ -2278,11 +2272,11 @@
)
)
(set_local $39
- (tee_local $22
+ (tee_local $26
(i32.add
(tee_local $5
(i32.add
- (get_local $26)
+ (get_local $25)
(i32.const 536)
)
)
@@ -2300,7 +2294,7 @@
(i32.add
(tee_local $41
(i32.add
- (get_local $26)
+ (get_local $25)
(i32.const 8)
)
)
@@ -2311,7 +2305,7 @@
(i32.add
(tee_local $5
(i32.add
- (get_local $26)
+ (get_local $25)
(i32.const 576)
)
)
@@ -2330,9 +2324,9 @@
(get_local $34)
)
(tee_local $37
- (tee_local $23
+ (tee_local $22
(i32.add
- (get_local $26)
+ (get_local $25)
(i32.const 588)
)
)
@@ -2355,7 +2349,7 @@
(i32.add
(tee_local $48
(i32.add
- (get_local $26)
+ (get_local $25)
(i32.const 24)
)
)
@@ -2365,14 +2359,14 @@
(set_local $43
(tee_local $30
(i32.add
- (get_local $23)
+ (get_local $22)
(i32.const 9)
)
)
)
(set_local $35
(i32.add
- (get_local $23)
+ (get_local $22)
(i32.const 8)
)
)
@@ -2854,26 +2848,24 @@
(get_local $6)
)
)
- (if
- (i32.lt_s
- (get_local $14)
- (i32.const 0)
- )
- (block
- (set_local $11
+ (set_local $11
+ (if (result i32)
+ (i32.lt_s
+ (get_local $14)
+ (i32.const 0)
+ )
+ (block (result i32)
+ (set_local $14
+ (i32.sub
+ (i32.const 0)
+ (get_local $14)
+ )
+ )
(i32.or
(get_local $1)
(i32.const 8192)
)
)
- (set_local $14
- (i32.sub
- (i32.const 0)
- (get_local $14)
- )
- )
- )
- (set_local $11
(get_local $1)
)
)
@@ -2977,8 +2969,8 @@
)
)
)
- (block $label$break$L46
- (set_local $6
+ (set_local $6
+ (block $label$break$L46 (result i32)
(if (result i32)
(i32.eq
(i32.load8_s
@@ -3027,38 +3019,39 @@
(set_local $10
(get_local $6)
)
- (set_local $6
+ (br $label$break$L46
(i32.const 0)
)
- (br $label$break$L46)
)
)
(loop $while-in11
- (set_local $6
- (i32.add
- (i32.mul
- (get_local $8)
- (i32.const 10)
- )
- (get_local $6)
- )
- )
- (br_if $label$break$L46
- (i32.ge_u
- (tee_local $9
+ (drop
+ (br_if $label$break$L46
+ (tee_local $6
(i32.add
- (i32.load8_s
- (tee_local $10
- (i32.add
- (get_local $10)
- (i32.const 1)
+ (i32.mul
+ (get_local $8)
+ (i32.const 10)
+ )
+ (get_local $6)
+ )
+ )
+ (i32.ge_u
+ (tee_local $9
+ (i32.add
+ (i32.load8_s
+ (tee_local $10
+ (i32.add
+ (get_local $10)
+ (i32.const 1)
+ )
)
)
+ (i32.const -48)
)
- (i32.const -48)
)
+ (i32.const 10)
)
- (i32.const 10)
)
)
(set_local $8
@@ -3130,12 +3123,11 @@
(i32.const 4)
)
)
- (set_local $6
+ (br $label$break$L46
(i32.load
(get_local $6)
)
)
- (br $label$break$L46)
)
)
)
@@ -3641,7 +3633,7 @@
)
)
(set_local $8
- (get_local $22)
+ (get_local $26)
)
(block
(set_local $5
@@ -3651,7 +3643,7 @@
(get_local $8)
)
(set_local $8
- (get_local $22)
+ (get_local $26)
)
(loop $while-in32
(i32.store8
@@ -3692,43 +3684,41 @@
)
)
)
- (if
- (i32.and
- (get_local $11)
- (i32.const 8)
- )
- (block
- (set_local $5
- (get_local $8)
- )
- (set_local $7
+ (set_local $5
+ (if (result i32)
+ (i32.and
(get_local $11)
+ (i32.const 8)
)
- (set_local $6
- (select
- (tee_local $11
- (i32.add
- (i32.sub
- (get_local $39)
- (get_local $8)
+ (block (result i32)
+ (set_local $7
+ (get_local $11)
+ )
+ (set_local $6
+ (select
+ (tee_local $11
+ (i32.add
+ (i32.sub
+ (get_local $39)
+ (get_local $8)
+ )
+ (i32.const 1)
)
- (i32.const 1)
)
- )
- (get_local $6)
- (i32.lt_s
(get_local $6)
- (get_local $11)
+ (i32.lt_s
+ (get_local $6)
+ (get_local $11)
+ )
)
)
- )
- )
- (block
- (set_local $5
(get_local $8)
)
- (set_local $7
- (get_local $11)
+ (block (result i32)
+ (set_local $7
+ (get_local $11)
+ )
+ (get_local $8)
)
)
)
@@ -3785,29 +3775,27 @@
(br $__rjti$4)
)
)
- (if
- (i32.and
- (get_local $11)
- (i32.const 2048)
- )
- (block
- (set_local $8
- (i32.const 1)
+ (set_local $9
+ (if (result i32)
+ (i32.and
+ (get_local $11)
+ (i32.const 2048)
)
- (set_local $9
+ (block (result i32)
+ (set_local $8
+ (i32.const 1)
+ )
(i32.const 4092)
)
- )
- (block
- (set_local $8
- (tee_local $9
- (i32.and
- (get_local $11)
- (i32.const 1)
+ (block (result i32)
+ (set_local $8
+ (tee_local $9
+ (i32.and
+ (get_local $11)
+ (i32.const 1)
+ )
)
)
- )
- (set_local $9
(select
(i32.const 4093)
(i32.const 4091)
@@ -3867,7 +3855,7 @@
(i32.const 4091)
)
(br $__rjto$8
- (get_local $22)
+ (get_local $26)
)
)
(set_local $5
@@ -3947,7 +3935,7 @@
)
)
(i32.store
- (get_local $21)
+ (get_local $20)
(i32.const 0)
)
(f64.store
@@ -4033,11 +4021,13 @@
(if
(tee_local $5
(f64.ne
- (tee_local $24
+ (tee_local $23
(f64.mul
- (call $_frexpl
+ (call $_frexp
(get_local $15)
- (get_local $21)
+ (tee_local $5
+ (get_local $20)
+ )
)
(f64.const 2)
)
@@ -4046,10 +4036,10 @@
)
)
(i32.store
- (get_local $21)
+ (get_local $20)
(i32.add
(i32.load
- (get_local $21)
+ (get_local $20)
)
(i32.const -1)
)
@@ -4057,7 +4047,7 @@
)
(if
(i32.eq
- (tee_local $25
+ (tee_local $24
(i32.or
(get_local $18)
(i32.const 32)
@@ -4097,7 +4087,7 @@
)
)
)
- (get_local $24)
+ (get_local $23)
(block (result f64)
(set_local $15
(f64.const 8)
@@ -4124,7 +4114,7 @@
(get_local $15)
(f64.sub
(f64.neg
- (get_local $24)
+ (get_local $23)
)
(get_local $15)
)
@@ -4132,7 +4122,7 @@
)
(f64.sub
(f64.add
- (get_local $24)
+ (get_local $23)
(get_local $15)
)
(get_local $15)
@@ -4157,7 +4147,7 @@
(i32.const 0)
(tee_local $7
(i32.load
- (get_local $21)
+ (get_local $20)
)
)
)
@@ -4242,7 +4232,7 @@
)
)
(set_local $5
- (get_local $23)
+ (get_local $22)
)
(loop $while-in56
(i32.store8
@@ -4409,7 +4399,7 @@
)
(drop
(call $___fwritex
- (get_local $23)
+ (get_local $22)
(get_local $5)
(get_local $0)
)
@@ -4477,28 +4467,28 @@
(get_local $5)
(block (result f64)
(i32.store
- (get_local $21)
+ (get_local $20)
(tee_local $5
(i32.add
(i32.load
- (get_local $21)
+ (get_local $20)
)
(i32.const -28)
)
)
)
(f64.mul
- (get_local $24)
+ (get_local $23)
(f64.const 268435456)
)
)
(block (result f64)
(set_local $5
(i32.load
- (get_local $21)
+ (get_local $20)
)
)
- (get_local $24)
+ (get_local $23)
)
)
)
@@ -4550,7 +4540,7 @@
(i32.gt_s
(tee_local $9
(i32.load
- (get_local $21)
+ (get_local $20)
)
)
(i32.const 0)
@@ -4588,28 +4578,26 @@
(loop $while-in66
(i32.store
(get_local $9)
- (tee_local $20
- (call $___uremdi3
- (tee_local $12
- (call $_i64Add
- (call $_bitshift64Shl
- (i32.load
- (get_local $9)
- )
- (i32.const 0)
- (get_local $13)
+ (call $___uremdi3
+ (tee_local $12
+ (call $_i64Add
+ (call $_bitshift64Shl
+ (i32.load
+ (get_local $9)
)
- (get_global $tempRet0)
- (get_local $12)
(i32.const 0)
+ (get_local $13)
)
- )
- (tee_local $17
(get_global $tempRet0)
+ (get_local $12)
+ (i32.const 0)
)
- (i32.const 1000000000)
- (i32.const 0)
)
+ (tee_local $17
+ (get_global $tempRet0)
+ )
+ (i32.const 1000000000)
+ (i32.const 0)
)
)
(set_local $12
@@ -4676,11 +4664,11 @@
)
)
(i32.store
- (get_local $21)
+ (get_local $20)
(tee_local $9
(i32.sub
(i32.load
- (get_local $21)
+ (get_local $20)
)
(get_local $13)
)
@@ -4714,7 +4702,7 @@
(i32.const 0)
)
(block
- (set_local $20
+ (set_local $21
(i32.add
(i32.div_s
(i32.add
@@ -4728,7 +4716,7 @@
)
(set_local $32
(i32.eq
- (get_local $25)
+ (get_local $24)
(i32.const 102)
)
)
@@ -4871,7 +4859,7 @@
)
)
(i32.shl
- (get_local $20)
+ (get_local $21)
(i32.const 2)
)
)
@@ -4884,16 +4872,16 @@
)
(i32.const 2)
)
- (get_local $20)
+ (get_local $21)
)
)
)
(i32.store
- (get_local $21)
+ (get_local $20)
(tee_local $9
(i32.add
(i32.load
- (get_local $21)
+ (get_local $20)
)
(get_local $13)
)
@@ -4928,7 +4916,7 @@
(get_local $7)
)
)
- (set_local $20
+ (set_local $21
(get_local $8)
)
(block $do-once75
@@ -4942,7 +4930,7 @@
(i32.mul
(i32.shr_s
(i32.sub
- (get_local $20)
+ (get_local $21)
(get_local $5)
)
(i32.const 2)
@@ -4999,7 +4987,7 @@
(get_local $7)
(i32.const 0)
(i32.ne
- (get_local $25)
+ (get_local $24)
(i32.const 102)
)
)
@@ -5015,7 +5003,7 @@
)
(tee_local $38
(i32.eq
- (get_local $25)
+ (get_local $24)
(i32.const 103)
)
)
@@ -5031,7 +5019,7 @@
(i32.shr_s
(i32.sub
(get_local $9)
- (get_local $20)
+ (get_local $21)
)
(i32.const 2)
)
@@ -5089,7 +5077,7 @@
)
(set_local $13
(i32.rem_u
- (tee_local $25
+ (tee_local $24
(i32.load
(tee_local $6
(i32.add
@@ -5155,13 +5143,13 @@
)
)
)
- (set_local $24
+ (set_local $23
(select
(f64.const 9007199254740994)
(f64.const 9007199254740992)
(i32.and
(i32.div_u
- (get_local $25)
+ (get_local $24)
(get_local $12)
)
(i32.const 1)
@@ -5180,9 +5168,9 @@
(i32.const 45)
)
)
- (set_local $24
+ (set_local $23
(f64.neg
- (get_local $24)
+ (get_local $23)
)
)
(set_local $15
@@ -5197,7 +5185,7 @@
(get_local $6)
(tee_local $13
(i32.sub
- (get_local $25)
+ (get_local $24)
(get_local $13)
)
)
@@ -5205,10 +5193,10 @@
(br_if $do-once81
(f64.eq
(f64.add
- (get_local $24)
+ (get_local $23)
(get_local $15)
)
- (get_local $24)
+ (get_local $23)
)
)
(i32.store
@@ -5273,7 +5261,7 @@
(i32.mul
(i32.shr_s
(i32.sub
- (get_local $20)
+ (get_local $21)
(get_local $5)
)
(i32.const 2)
@@ -5361,7 +5349,7 @@
(get_local $12)
)
(block
- (set_local $25
+ (set_local $24
(i32.const 0)
)
(set_local $9
@@ -5380,7 +5368,7 @@
)
)
(block
- (set_local $25
+ (set_local $24
(i32.const 1)
)
(set_local $9
@@ -5470,7 +5458,7 @@
)
)
(block
- (set_local $20
+ (set_local $21
(get_local $5)
)
(br $do-once91
@@ -5480,7 +5468,7 @@
)
(block $do-once93
(if
- (get_local $25)
+ (get_local $24)
(block
(if
(i32.eqz
@@ -5553,7 +5541,7 @@
(i32.shr_s
(i32.sub
(get_local $9)
- (get_local $20)
+ (get_local $21)
)
(i32.const 2)
)
@@ -5571,7 +5559,7 @@
(i32.const 102)
)
(block (result i32)
- (set_local $20
+ (set_local $21
(i32.const 0)
)
(select
@@ -5598,7 +5586,7 @@
)
)
(block (result i32)
- (set_local $20
+ (set_local $21
(i32.const 0)
)
(select
@@ -5630,7 +5618,7 @@
)
)
(block (result i32)
- (set_local $20
+ (set_local $21
(i32.and
(get_local $11)
(i32.const 8)
@@ -5649,122 +5637,120 @@
(tee_local $32
(i32.or
(get_local $5)
- (get_local $20)
+ (get_local $21)
)
)
(i32.const 0)
)
)
- (tee_local $7
- (if (result i32)
- (tee_local $17
- (i32.eq
- (i32.or
- (get_local $7)
- (i32.const 32)
- )
- (i32.const 102)
+ (if (result i32)
+ (tee_local $17
+ (i32.eq
+ (i32.or
+ (get_local $7)
+ (i32.const 32)
)
+ (i32.const 102)
)
- (block (result i32)
- (set_local $18
- (i32.const 0)
- )
- (select
+ )
+ (block (result i32)
+ (set_local $18
+ (i32.const 0)
+ )
+ (select
+ (get_local $13)
+ (i32.const 0)
+ (i32.gt_s
(get_local $13)
(i32.const 0)
- (i32.gt_s
- (get_local $13)
- (i32.const 0)
- )
)
)
- (block (result i32)
- (if
- (i32.lt_s
- (i32.sub
- (get_local $28)
- (tee_local $6
- (call $_fmt_u
- (tee_local $6
- (select
- (get_local $33)
+ )
+ (block (result i32)
+ (if
+ (i32.lt_s
+ (i32.sub
+ (get_local $28)
+ (tee_local $6
+ (call $_fmt_u
+ (tee_local $6
+ (select
+ (get_local $33)
+ (get_local $13)
+ (i32.lt_s
(get_local $13)
- (i32.lt_s
- (get_local $13)
- (i32.const 0)
- )
+ (i32.const 0)
)
)
- (i32.shr_s
- (i32.shl
- (i32.lt_s
- (get_local $6)
- (i32.const 0)
- )
- (i32.const 31)
+ )
+ (i32.shr_s
+ (i32.shl
+ (i32.lt_s
+ (get_local $6)
+ (i32.const 0)
)
(i32.const 31)
)
- (get_local $34)
+ (i32.const 31)
)
+ (get_local $34)
)
)
- (i32.const 2)
)
- (loop $while-in98
- (i32.store8
- (tee_local $6
- (i32.add
- (get_local $6)
- (i32.const -1)
- )
- )
- (i32.const 48)
- )
- (br_if $while-in98
- (i32.lt_s
- (i32.sub
- (get_local $28)
- (get_local $6)
- )
- (i32.const 2)
+ (i32.const 2)
+ )
+ (loop $while-in98
+ (i32.store8
+ (tee_local $6
+ (i32.add
+ (get_local $6)
+ (i32.const -1)
)
)
+ (i32.const 48)
)
- )
- (i32.store8
- (i32.add
- (get_local $6)
- (i32.const -1)
- )
- (i32.add
- (i32.and
- (i32.shr_s
- (get_local $13)
- (i32.const 31)
+ (br_if $while-in98
+ (i32.lt_s
+ (i32.sub
+ (get_local $28)
+ (get_local $6)
)
(i32.const 2)
)
- (i32.const 43)
)
)
- (i32.store8
- (tee_local $6
- (i32.add
- (get_local $6)
- (i32.const -2)
+ )
+ (i32.store8
+ (i32.add
+ (get_local $6)
+ (i32.const -1)
+ )
+ (i32.add
+ (i32.and
+ (i32.shr_s
+ (get_local $13)
+ (i32.const 31)
)
+ (i32.const 2)
)
- (get_local $7)
+ (i32.const 43)
)
- (set_local $18
- (get_local $6)
- )
- (i32.sub
- (get_local $28)
- (get_local $6)
+ )
+ (i32.store8
+ (tee_local $6
+ (i32.add
+ (get_local $6)
+ (i32.const -2)
+ )
)
+ (get_local $7)
+ )
+ (set_local $18
+ (get_local $6)
+ )
+ (i32.sub
+ (get_local $28)
+ (get_local $6)
)
)
)
@@ -5850,7 +5836,7 @@
(br_if $do-once103
(i32.le_u
(get_local $7)
- (get_local $23)
+ (get_local $22)
)
)
(loop $while-in106
@@ -5866,7 +5852,7 @@
(br_if $while-in106
(i32.gt_u
(get_local $7)
- (get_local $23)
+ (get_local $22)
)
)
)
@@ -5956,7 +5942,7 @@
(get_local $30)
)
)
- (get_local $23)
+ (get_local $22)
)
(loop $while-in112
(i32.store8
@@ -5971,7 +5957,7 @@
(br_if $while-in112
(i32.gt_u
(get_local $6)
- (get_local $23)
+ (get_local $22)
)
)
)
@@ -6053,7 +6039,7 @@
(get_local $12)
(i32.const 4)
)
- (get_local $25)
+ (get_local $24)
)
)
(if
@@ -6064,7 +6050,7 @@
(block
(set_local $17
(i32.eqz
- (get_local $20)
+ (get_local $21)
)
)
(set_local $6
@@ -6156,7 +6142,7 @@
(br_if $do-once115
(i32.le_u
(get_local $5)
- (get_local $23)
+ (get_local $22)
)
)
(loop $while-in118
@@ -6172,7 +6158,7 @@
(br_if $while-in118
(i32.gt_u
(get_local $5)
- (get_local $23)
+ (get_local $22)
)
)
)
@@ -6421,7 +6407,7 @@
(i32.const 4091)
)
(br $__rjto$8
- (get_local $22)
+ (get_local $26)
)
)
(set_local $9
@@ -6451,7 +6437,7 @@
)
(block
(set_local $5
- (get_local $22)
+ (get_local $26)
)
(set_local $8
(i32.const 0)
@@ -6466,7 +6452,7 @@
(get_local $8)
)
(set_local $8
- (get_local $22)
+ (get_local $26)
)
(loop $while-in123
(i32.store8
@@ -6513,49 +6499,47 @@
(get_local $8)
)
)
- (if
- (i32.or
- (i32.eqz
- (i32.and
- (get_local $7)
- (i32.const 8)
- )
- )
- (i32.and
+ (set_local $8
+ (if (result i32)
+ (i32.or
(i32.eqz
- (i32.load
- (tee_local $11
- (get_local $19)
- )
+ (i32.and
+ (get_local $7)
+ (i32.const 8)
)
)
- (i32.eqz
- (i32.load offset=4
- (get_local $11)
+ (i32.and
+ (i32.eqz
+ (i32.load
+ (tee_local $11
+ (get_local $19)
+ )
+ )
+ )
+ (i32.eqz
+ (i32.load offset=4
+ (get_local $11)
+ )
)
)
)
- )
- (block
- (set_local $8
+ (block (result i32)
+ (set_local $9
+ (i32.const 4091)
+ )
(i32.const 0)
)
- (set_local $9
- (i32.const 4091)
- )
- )
- (block
- (set_local $8
- (i32.const 2)
- )
- (set_local $9
- (i32.add
- (i32.shr_s
- (get_local $18)
- (i32.const 4)
+ (block (result i32)
+ (set_local $9
+ (i32.add
+ (i32.shr_s
+ (get_local $18)
+ (i32.const 4)
+ )
+ (i32.const 4091)
)
- (i32.const 4091)
)
+ (i32.const 2)
)
)
)
@@ -6567,7 +6551,7 @@
(call $_fmt_u
(get_local $5)
(get_local $7)
- (get_local $22)
+ (get_local $26)
)
)
(set_local $7
@@ -6825,33 +6809,33 @@
)
)
)
- (if
- (i32.or
- (get_local $6)
- (tee_local $12
- (i32.or
- (i32.ne
- (i32.load
- (tee_local $7
- (get_local $19)
+ (set_local $12
+ (if (result i32)
+ (i32.or
+ (get_local $6)
+ (tee_local $12
+ (i32.or
+ (i32.ne
+ (i32.load
+ (tee_local $7
+ (get_local $19)
+ )
)
+ (i32.const 0)
)
- (i32.const 0)
- )
- (i32.ne
- (i32.load offset=4
- (get_local $7)
+ (i32.ne
+ (i32.load offset=4
+ (get_local $7)
+ )
+ (i32.const 0)
)
- (i32.const 0)
)
)
)
- )
- (block
- (set_local $7
- (get_local $5)
- )
- (set_local $12
+ (block (result i32)
+ (set_local $7
+ (get_local $5)
+ )
(select
(get_local $6)
(tee_local $5
@@ -6875,17 +6859,15 @@
)
)
)
- )
- (block
- (set_local $7
- (get_local $22)
- )
- (set_local $12
+ (block (result i32)
+ (set_local $7
+ (get_local $26)
+ )
(i32.const 0)
)
)
)
- (get_local $22)
+ (get_local $26)
)
)
(call $_pad
@@ -7098,7 +7080,7 @@
)
)
(set_global $STACKTOP
- (get_local $26)
+ (get_local $25)
)
(get_local $16)
)
diff --git a/test/memorygrowth.fromasm b/test/memorygrowth.fromasm
index 71c095deb..5f90519f0 100644
--- a/test/memorygrowth.fromasm
+++ b/test/memorygrowth.fromasm
@@ -9220,7 +9220,7 @@
(local $1 i32)
(local $2 i32)
(local $3 i32)
- (set_local $2
+ (set_local $3
(if (result i32)
(i32.gt_s
(i32.load offset=76
@@ -9242,9 +9242,18 @@
(block $do-once (result i32)
(if (result i32)
(i32.lt_s
- (call $cb
- (get_local $0)
- (get_local $1)
+ (i32.add
+ (call $bb
+ (get_local $0)
+ (call $Za
+ (get_local $0)
+ )
+ (i32.const 1)
+ (tee_local $2
+ (get_local $1)
+ )
+ )
+ (i32.const -1)
)
(i32.const 0)
)
@@ -9261,7 +9270,7 @@
(i32.lt_u
(tee_local $0
(i32.load
- (tee_local $3
+ (tee_local $2
(i32.add
(get_local $1)
(i32.const 20)
@@ -9275,7 +9284,7 @@
)
(block
(i32.store
- (get_local $3)
+ (get_local $2)
(i32.add
(get_local $0)
(i32.const 1)
@@ -9303,7 +9312,7 @@
)
)
(if
- (get_local $2)
+ (get_local $3)
(call $Ta
(get_local $1)
)
@@ -9394,16 +9403,6 @@
)
)
)
- (func $i32u-div (param $0 i32) (param $1 i32) (result i32)
- (if (result i32)
- (get_local $1)
- (i32.div_u
- (get_local $0)
- (get_local $1)
- )
- (i32.const 0)
- )
- )
(func $bb (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32)
(local $4 i32)
(local $5 i32)
@@ -9458,9 +9457,13 @@
(get_local $4)
)
(set_local $2
- (call $i32u-div
- (get_local $0)
+ (if (result i32)
(get_local $1)
+ (i32.div_u
+ (get_local $0)
+ (get_local $1)
+ )
+ (i32.const 0)
)
)
)
@@ -9704,19 +9707,6 @@
)
(get_local $1)
)
- (func $cb (param $0 i32) (param $1 i32) (result i32)
- (i32.add
- (call $bb
- (get_local $0)
- (call $Za
- (get_local $0)
- )
- (i32.const 1)
- (get_local $1)
- )
- (i32.const -1)
- )
- )
(func $ob (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(call $ja
(i32.const 1)
diff --git a/test/memorygrowth.fromasm.clamp b/test/memorygrowth.fromasm.clamp
index 71c095deb..5f90519f0 100644
--- a/test/memorygrowth.fromasm.clamp
+++ b/test/memorygrowth.fromasm.clamp
@@ -9220,7 +9220,7 @@
(local $1 i32)
(local $2 i32)
(local $3 i32)
- (set_local $2
+ (set_local $3
(if (result i32)
(i32.gt_s
(i32.load offset=76
@@ -9242,9 +9242,18 @@
(block $do-once (result i32)
(if (result i32)
(i32.lt_s
- (call $cb
- (get_local $0)
- (get_local $1)
+ (i32.add
+ (call $bb
+ (get_local $0)
+ (call $Za
+ (get_local $0)
+ )
+ (i32.const 1)
+ (tee_local $2
+ (get_local $1)
+ )
+ )
+ (i32.const -1)
)
(i32.const 0)
)
@@ -9261,7 +9270,7 @@
(i32.lt_u
(tee_local $0
(i32.load
- (tee_local $3
+ (tee_local $2
(i32.add
(get_local $1)
(i32.const 20)
@@ -9275,7 +9284,7 @@
)
(block
(i32.store
- (get_local $3)
+ (get_local $2)
(i32.add
(get_local $0)
(i32.const 1)
@@ -9303,7 +9312,7 @@
)
)
(if
- (get_local $2)
+ (get_local $3)
(call $Ta
(get_local $1)
)
@@ -9394,16 +9403,6 @@
)
)
)
- (func $i32u-div (param $0 i32) (param $1 i32) (result i32)
- (if (result i32)
- (get_local $1)
- (i32.div_u
- (get_local $0)
- (get_local $1)
- )
- (i32.const 0)
- )
- )
(func $bb (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32)
(local $4 i32)
(local $5 i32)
@@ -9458,9 +9457,13 @@
(get_local $4)
)
(set_local $2
- (call $i32u-div
- (get_local $0)
+ (if (result i32)
(get_local $1)
+ (i32.div_u
+ (get_local $0)
+ (get_local $1)
+ )
+ (i32.const 0)
)
)
)
@@ -9704,19 +9707,6 @@
)
(get_local $1)
)
- (func $cb (param $0 i32) (param $1 i32) (result i32)
- (i32.add
- (call $bb
- (get_local $0)
- (call $Za
- (get_local $0)
- )
- (i32.const 1)
- (get_local $1)
- )
- (i32.const -1)
- )
- )
(func $ob (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(call $ja
(i32.const 1)
diff --git a/test/memorygrowth.fromasm.imprecise b/test/memorygrowth.fromasm.imprecise
index 38e3724a5..be7c35289 100644
--- a/test/memorygrowth.fromasm.imprecise
+++ b/test/memorygrowth.fromasm.imprecise
@@ -9219,7 +9219,7 @@
(local $1 i32)
(local $2 i32)
(local $3 i32)
- (set_local $2
+ (set_local $3
(if (result i32)
(i32.gt_s
(i32.load offset=76
@@ -9241,9 +9241,18 @@
(block $do-once (result i32)
(if (result i32)
(i32.lt_s
- (call $cb
- (get_local $0)
- (get_local $1)
+ (i32.add
+ (call $bb
+ (get_local $0)
+ (call $Za
+ (get_local $0)
+ )
+ (i32.const 1)
+ (tee_local $2
+ (get_local $1)
+ )
+ )
+ (i32.const -1)
)
(i32.const 0)
)
@@ -9260,7 +9269,7 @@
(i32.lt_u
(tee_local $0
(i32.load
- (tee_local $3
+ (tee_local $2
(i32.add
(get_local $1)
(i32.const 20)
@@ -9274,7 +9283,7 @@
)
(block
(i32.store
- (get_local $3)
+ (get_local $2)
(i32.add
(get_local $0)
(i32.const 1)
@@ -9302,7 +9311,7 @@
)
)
(if
- (get_local $2)
+ (get_local $3)
(call $Ta
(get_local $1)
)
@@ -9693,19 +9702,6 @@
)
(get_local $1)
)
- (func $cb (param $0 i32) (param $1 i32) (result i32)
- (i32.add
- (call $bb
- (get_local $0)
- (call $Za
- (get_local $0)
- )
- (i32.const 1)
- (get_local $1)
- )
- (i32.const -1)
- )
- )
(func $ob (param $0 i32) (param $1 i32) (param $2 i32) (result i32)
(call $ja
(i32.const 1)
diff --git a/test/passes/inlining-optimizing.txt b/test/passes/inlining-optimizing.txt
new file mode 100644
index 000000000..e1f81e54f
--- /dev/null
+++ b/test/passes/inlining-optimizing.txt
@@ -0,0 +1,35 @@
+(module
+ (type $0 (func))
+ (type $1 (func (result i32)))
+ (type $2 (func (result f64)))
+ (type $3 (func (param f32 i64)))
+ (table 1 1 anyfunc)
+ (elem (i32.const 0) $tabled)
+ (memory $0 0)
+ (export "user" (func $user))
+ (export "exported" (func $exported))
+ (func $user (type $0)
+ (call $exported)
+ (call $tabled)
+ (call $multi)
+ (call $multi)
+ )
+ (func $exported (type $0)
+ (nop)
+ )
+ (func $recursive (type $0)
+ (call $recursive)
+ )
+ (func $tabled (type $0)
+ (nop)
+ )
+ (func $cycle1 (type $0)
+ (call $cycle2)
+ )
+ (func $cycle2 (type $0)
+ (call $cycle1)
+ )
+ (func $multi (type $0)
+ (nop)
+ )
+)
diff --git a/test/passes/inlining-optimizing.wast b/test/passes/inlining-optimizing.wast
new file mode 100644
index 000000000..082c4e98a
--- /dev/null
+++ b/test/passes/inlining-optimizing.wast
@@ -0,0 +1,79 @@
+(module
+ (table 1 1 anyfunc)
+ (elem (i32.const 0) $tabled)
+ (func $user (export "user")
+ (local $x i32)
+ (local $y f64)
+ (call $exported)
+ (call $tabled)
+ (call $multi)
+ (call $multi)
+ (call $ok)
+ (drop (call $int))
+ (drop (call $double))
+ (set_local $x (call $int2))
+ (set_local $y (call $double2))
+ (call $with-local)
+ (call $with-local2)
+ (drop (call $return))
+ (call $multipass)
+ (call $param (f32.const 12.34) (i64.const 890005350012))
+ )
+ (func $exported (export "exported")
+ (nop)
+ )
+ (func $recursive
+ (call $recursive)
+ )
+ (func $tabled
+ (nop)
+ )
+ (func $cycle1
+ (call $cycle2)
+ )
+ (func $cycle2
+ (call $cycle1)
+ )
+ (func $multi
+ (nop)
+ )
+ (func $ok
+ (drop (i32.const 1))
+ )
+ (func $int (result i32)
+ (i32.const 2)
+ )
+ (func $double (result f64)
+ (f64.const 3.14159)
+ )
+ (func $int2 (result i32)
+ (i32.const 112)
+ )
+ (func $double2 (result f64)
+ (f64.const 113.14159)
+ )
+ (func $with-local
+ (local $x f32)
+ (set_local $x (f32.const 2.141828))
+ )
+ (func $with-local2
+ (local $y i64)
+ (set_local $y (i64.const 4))
+ )
+ (func $return (result i32)
+ (return (i32.const 5))
+ )
+ (func $multipass
+ (call $multipass2)
+ )
+ (func $multipass2
+ (drop (i32.const 6))
+ )
+ (func $param (param $x f32) (param $y i64)
+ (local $z f32)
+ (drop (get_local $x))
+ (drop (get_local $y))
+ (drop (get_local $z))
+ )
+)
+
diff --git a/test/passes/inlining.txt b/test/passes/inlining.txt
index 80ee3acf3..99f764351 100644
--- a/test/passes/inlining.txt
+++ b/test/passes/inlining.txt
@@ -20,71 +20,93 @@
(call $tabled)
(call $multi)
(call $multi)
- (block $__inlined_func$ok
- (drop
- (i32.const 1)
+ (block
+ (block $__inlined_func$ok
+ (drop
+ (i32.const 1)
+ )
)
)
(drop
- (block $__inlined_func$int (result i32)
- (i32.const 2)
+ (block (result i32)
+ (block $__inlined_func$int (result i32)
+ (i32.const 2)
+ )
)
)
(drop
- (block $__inlined_func$double (result f64)
- (f64.const 3.14159)
+ (block (result f64)
+ (block $__inlined_func$double (result f64)
+ (f64.const 3.14159)
+ )
)
)
(set_local $x
- (block $__inlined_func$int2 (result i32)
- (i32.const 112)
+ (block (result i32)
+ (block $__inlined_func$int2 (result i32)
+ (i32.const 112)
+ )
)
)
(set_local $y
- (block $__inlined_func$double2 (result f64)
- (f64.const 113.14159)
+ (block (result f64)
+ (block $__inlined_func$double2 (result f64)
+ (f64.const 113.14159)
+ )
)
)
- (block $__inlined_func$with-local
- (set_local $2
- (f32.const 2.1418280601501465)
+ (block
+ (block $__inlined_func$with-local
+ (set_local $2
+ (f32.const 2.1418280601501465)
+ )
)
)
- (block $__inlined_func$with-local2
- (set_local $3
- (i64.const 4)
+ (block
+ (block $__inlined_func$with-local2
+ (set_local $3
+ (i64.const 4)
+ )
)
)
(drop
- (block $__inlined_func$return (result i32)
- (br $__inlined_func$return
- (i32.const 5)
+ (block (result i32)
+ (block $__inlined_func$return (result i32)
+ (br $__inlined_func$return
+ (i32.const 5)
+ )
)
)
)
- (block $__inlined_func$multipass
- (block $__inlined_func$multipass2
- (drop
- (i32.const 6)
+ (block
+ (block $__inlined_func$multipass
+ (block
+ (block $__inlined_func$multipass2
+ (drop
+ (i32.const 6)
+ )
+ )
)
)
)
- (block $__inlined_func$param
- (set_local $4
- (f32.const 12.34000015258789)
- )
- (set_local $5
- (i64.const 890005350012)
- )
- (block
- (drop
- (get_local $4)
+ (block
+ (block $__inlined_func$param
+ (set_local $4
+ (f32.const 12.34000015258789)
)
- (drop
- (get_local $5)
+ (set_local $5
+ (i64.const 890005350012)
)
- (drop
- (get_local $6)
+ (block
+ (drop
+ (get_local $4)
+ )
+ (drop
+ (get_local $5)
+ )
+ (drop
+ (get_local $6)
+ )
)
)
)
@@ -108,3 +130,16 @@
(nop)
)
)
+(module
+ (type $0 (func (param i32) (result i32)))
+ (type $1 (func (result i32)))
+ (memory $0 0)
+ (func $child (type $0) (param $0 i32) (result i32)
+ (i32.const 1234)
+ )
+ (func $parent (type $1) (result i32)
+ (call $child
+ (unreachable)
+ )
+ )
+)
diff --git a/test/passes/inlining.wast b/test/passes/inlining.wast
index 082c4e98a..ce8b1b8be 100644
--- a/test/passes/inlining.wast
+++ b/test/passes/inlining.wast
@@ -76,4 +76,14 @@
(drop (get_local $z))
)
)
+(module
+ (func $child (param i32) (result i32)
+ (i32.const 1234)
+ )
+ (func $parent (result i32)
+ (call $child
+ (unreachable) ;; call is not performed, no sense to inline
+ )
+ )
+)
diff --git a/test/unit.asm.js b/test/unit.asm.js
index 22e2cf9b4..a1accabf5 100644
--- a/test/unit.asm.js
+++ b/test/unit.asm.js
@@ -726,6 +726,7 @@ function asm(global, env, buffer) {
function keepAlive() {
sqrts(3.14159);
+ sqrts(2.18281); // don't inline it either
f2u(100.0);
f2s(100.0);
autoDrop(52) | 0;
diff --git a/test/unit.fromasm b/test/unit.fromasm
index 8e6cd5956..7ac63bfcc 100644
--- a/test/unit.fromasm
+++ b/test/unit.fromasm
@@ -255,9 +255,16 @@
)
)
)
- (func $i32u-div (param $0 i32) (param $1 i32) (result i32)
+ (func $big_uint_div_u (result i32)
+ (local $0 i32)
+ (local $1 i32)
+ (set_local $0
+ (i32.const -1)
+ )
(if (result i32)
- (get_local $1)
+ (tee_local $1
+ (i32.const 2)
+ )
(i32.div_u
(get_local $0)
(get_local $1)
@@ -265,12 +272,6 @@
(i32.const 0)
)
)
- (func $big_uint_div_u (result i32)
- (call $i32u-div
- (i32.const -1)
- (i32.const 2)
- )
- )
(func $fr (param $0 f32)
(nop)
)
@@ -1161,28 +1162,45 @@
(get_local $0)
)
)
- (func $autoDrop (param $0 i32) (result i32)
- (if
- (i32.eq
- (get_local $0)
- (i32.const 17)
+ (func $keepAlive
+ (local $0 i32)
+ (local $1 i32)
+ (drop
+ (call $sqrts
+ (f64.const 3.14159)
)
- (return
- (i32.const 5)
+ )
+ (drop
+ (call $sqrts
+ (f64.const 2.18281)
+ )
+ )
+ (drop
+ (call $f2u
+ (f64.const 100)
+ )
+ )
+ (drop
+ (call $f2u
+ (f64.const 100)
+ )
+ )
+ (block $__inlined_func$autoDrop
+ (br_if $__inlined_func$autoDrop
+ (i32.eq
+ (tee_local $0
+ (i32.const 52)
+ )
+ (i32.const 17)
+ )
)
)
- (get_local $0)
- )
- (func $indirectInSequence
(call_indirect $FUNCSIG$vi
(i32.const 0)
(i32.const 17)
)
- )
- (func $emterpretify_assertions_safeHeap
- (local $0 i32)
(call_indirect $FUNCSIG$vi
- (get_local $0)
+ (get_local $1)
(block (result i32)
(set_global $Int
(i32.const 1)
@@ -1196,8 +1214,6 @@
)
)
)
- )
- (func $call_emscripten_log
(call $emscripten_log)
(drop
(call $f64-to-int
@@ -1207,31 +1223,6 @@
)
)
)
- (func $keepAlive
- (drop
- (call $sqrts
- (f64.const 3.14159)
- )
- )
- (drop
- (call $f2u
- (f64.const 100)
- )
- )
- (drop
- (call $f2u
- (f64.const 100)
- )
- )
- (drop
- (call $autoDrop
- (i32.const 52)
- )
- )
- (call $indirectInSequence)
- (call $emterpretify_assertions_safeHeap)
- (call $call_emscripten_log)
- )
(func $vi (param $0 i32)
(nop)
)
diff --git a/test/unit.fromasm.clamp b/test/unit.fromasm.clamp
index 9ab53f183..8f3e387ae 100644
--- a/test/unit.fromasm.clamp
+++ b/test/unit.fromasm.clamp
@@ -279,9 +279,16 @@
)
)
)
- (func $i32u-div (param $0 i32) (param $1 i32) (result i32)
+ (func $big_uint_div_u (result i32)
+ (local $0 i32)
+ (local $1 i32)
+ (set_local $0
+ (i32.const -1)
+ )
(if (result i32)
- (get_local $1)
+ (tee_local $1
+ (i32.const 2)
+ )
(i32.div_u
(get_local $0)
(get_local $1)
@@ -289,12 +296,6 @@
(i32.const 0)
)
)
- (func $big_uint_div_u (result i32)
- (call $i32u-div
- (i32.const -1)
- (i32.const 2)
- )
- )
(func $fr (param $0 f32)
(nop)
)
@@ -1185,28 +1186,45 @@
(get_local $0)
)
)
- (func $autoDrop (param $0 i32) (result i32)
- (if
- (i32.eq
- (get_local $0)
- (i32.const 17)
+ (func $keepAlive
+ (local $0 i32)
+ (local $1 i32)
+ (drop
+ (call $sqrts
+ (f64.const 3.14159)
)
- (return
- (i32.const 5)
+ )
+ (drop
+ (call $sqrts
+ (f64.const 2.18281)
+ )
+ )
+ (drop
+ (call $f2u
+ (f64.const 100)
+ )
+ )
+ (drop
+ (call $f2u
+ (f64.const 100)
+ )
+ )
+ (block $__inlined_func$autoDrop
+ (br_if $__inlined_func$autoDrop
+ (i32.eq
+ (tee_local $0
+ (i32.const 52)
+ )
+ (i32.const 17)
+ )
)
)
- (get_local $0)
- )
- (func $indirectInSequence
(call_indirect $FUNCSIG$vi
(i32.const 0)
(i32.const 17)
)
- )
- (func $emterpretify_assertions_safeHeap
- (local $0 i32)
(call_indirect $FUNCSIG$vi
- (get_local $0)
+ (get_local $1)
(block (result i32)
(set_global $Int
(i32.const 1)
@@ -1220,8 +1238,6 @@
)
)
)
- )
- (func $call_emscripten_log
(call $emscripten_log)
(drop
(call $f64-to-int
@@ -1231,31 +1247,6 @@
)
)
)
- (func $keepAlive
- (drop
- (call $sqrts
- (f64.const 3.14159)
- )
- )
- (drop
- (call $f2u
- (f64.const 100)
- )
- )
- (drop
- (call $f2u
- (f64.const 100)
- )
- )
- (drop
- (call $autoDrop
- (i32.const 52)
- )
- )
- (call $indirectInSequence)
- (call $emterpretify_assertions_safeHeap)
- (call $call_emscripten_log)
- )
(func $vi (param $0 i32)
(nop)
)
diff --git a/test/unit.fromasm.clamp.no-opts b/test/unit.fromasm.clamp.no-opts
index 9055bda68..f4fe4bf83 100644
--- a/test/unit.fromasm.clamp.no-opts
+++ b/test/unit.fromasm.clamp.no-opts
@@ -2034,6 +2034,11 @@
)
)
(drop
+ (call $sqrts
+ (f64.const 2.18281)
+ )
+ )
+ (drop
(call $f2u
(f64.const 100)
)
diff --git a/test/unit.fromasm.imprecise b/test/unit.fromasm.imprecise
index f57931d20..17c9109c3 100644
--- a/test/unit.fromasm.imprecise
+++ b/test/unit.fromasm.imprecise
@@ -1124,38 +1124,35 @@
)
)
)
- (func $f2u (param $0 f64) (result i32)
- (i32.trunc_u/f64
- (get_local $0)
- )
- )
- (func $f2s (param $0 f64) (result i32)
- (i32.trunc_s/f64
- (get_local $0)
+ (func $keepAlive
+ (local $0 i32)
+ (local $1 i32)
+ (drop
+ (call $sqrts
+ (f64.const 3.14159)
+ )
)
- )
- (func $autoDrop (param $0 i32) (result i32)
- (if
- (i32.eq
- (get_local $0)
- (i32.const 17)
+ (drop
+ (call $sqrts
+ (f64.const 2.18281)
)
- (return
- (i32.const 5)
+ )
+ (block $__inlined_func$autoDrop
+ (br_if $__inlined_func$autoDrop
+ (i32.eq
+ (tee_local $0
+ (i32.const 52)
+ )
+ (i32.const 17)
+ )
)
)
- (get_local $0)
- )
- (func $indirectInSequence
(call_indirect $FUNCSIG$vi
(i32.const 0)
(i32.const 17)
)
- )
- (func $emterpretify_assertions_safeHeap
- (local $0 i32)
(call_indirect $FUNCSIG$vi
- (get_local $0)
+ (get_local $1)
(block (result i32)
(set_global $Int
(i32.const 1)
@@ -1169,8 +1166,6 @@
)
)
)
- )
- (func $call_emscripten_log
(call $emscripten_log)
(drop
(i32.trunc_s/f64
@@ -1180,31 +1175,6 @@
)
)
)
- (func $keepAlive
- (drop
- (call $sqrts
- (f64.const 3.14159)
- )
- )
- (drop
- (call $f2u
- (f64.const 100)
- )
- )
- (drop
- (call $f2s
- (f64.const 100)
- )
- )
- (drop
- (call $autoDrop
- (i32.const 52)
- )
- )
- (call $indirectInSequence)
- (call $emterpretify_assertions_safeHeap)
- (call $call_emscripten_log)
- )
(func $vi (param $0 i32)
(nop)
)
diff --git a/test/unit.fromasm.imprecise.no-opts b/test/unit.fromasm.imprecise.no-opts
index b66c69cf7..243b8b8fe 100644
--- a/test/unit.fromasm.imprecise.no-opts
+++ b/test/unit.fromasm.imprecise.no-opts
@@ -1994,6 +1994,11 @@
)
)
(drop
+ (call $sqrts
+ (f64.const 2.18281)
+ )
+ )
+ (drop
(call $f2u
(f64.const 100)
)
diff --git a/test/unit.fromasm.no-opts b/test/unit.fromasm.no-opts
index 074a44bfe..09d8361bd 100644
--- a/test/unit.fromasm.no-opts
+++ b/test/unit.fromasm.no-opts
@@ -2010,6 +2010,11 @@
)
)
(drop
+ (call $sqrts
+ (f64.const 2.18281)
+ )
+ )
+ (drop
(call $f2u
(f64.const 100)
)
diff --git a/test/wasm-only.asm.js b/test/wasm-only.asm.js
index 750ffaa6a..0013a30c3 100644
--- a/test/wasm-only.asm.js
+++ b/test/wasm-only.asm.js
@@ -441,17 +441,29 @@ function asm(global, env, buffer) {
function keepAlive() {
loads();
+ loads();
+ stores();
stores();
test();
+ test();
i64(imports());
+ i64(imports());
+ arg(i64(0));
arg(i64(0));
i64(call1(i64(0)));
+ i64(call1(i64(0)));
i64(call2(i64(0)));
+ i64(call2(i64(0)));
+ i64(returnCastConst());
i64(returnCastConst());
i64(ifValue64(i64(0), i64(0)));
+ i64(ifValue64(i64(0), i64(0)));
ifValue32(0, 0) | 0;
+ ifValue32(0, 0) | 0;
+ switch64(i64(0)) | 0;
switch64(i64(0)) | 0;
unreachable_leftovers(0, 0, 0);
+ unreachable_leftovers(0, 0, 0);
_memchr(0, 0, 0) | 0;
switch64TOOMUCH(i64(0)) | 0;
switch64_big_condition1(i64(0));
diff --git a/test/wasm-only.fromasm b/test/wasm-only.fromasm
index 8811d0cff..8f9825dda 100644
--- a/test/wasm-only.fromasm
+++ b/test/wasm-only.fromasm
@@ -241,18 +241,6 @@
)
)
)
- (func $i64u-div (param $0 i64) (param $1 i64) (result i64)
- (if (result i64)
- (i64.eqz
- (get_local $1)
- )
- (i64.const 0)
- (i64.div_u
- (get_local $0)
- (get_local $1)
- )
- )
- )
(func $i64s-div (param $0 i64) (param $1 i64) (result i64)
(if (result i64)
(i64.eqz
@@ -278,30 +266,6 @@
)
)
)
- (func $i64u-rem (param $0 i64) (param $1 i64) (result i64)
- (if (result i64)
- (i64.eqz
- (get_local $1)
- )
- (i64.const 0)
- (i64.rem_u
- (get_local $0)
- (get_local $1)
- )
- )
- )
- (func $i64s-rem (param $0 i64) (param $1 i64) (result i64)
- (if (result i64)
- (i64.eqz
- (get_local $1)
- )
- (i64.const 0)
- (i64.rem_s
- (get_local $0)
- (get_local $1)
- )
- )
- )
(func $f64-to-int64 (param $0 f64) (result i64)
(if (result i64)
(f64.ne
@@ -331,33 +295,66 @@
(func $test64
(local $0 i64)
(local $1 i64)
- (local $2 i32)
+ (local $2 i64)
(local $3 f32)
(local $4 f64)
- (drop
- (call $i64s-rem
- (call $i64u-rem
- (call $i64s-div
- (call $i64u-div
- (i64.mul
- (i64.sub
- (i64.add
- (tee_local $1
- (i64.const 128849018897)
- )
- (i64.const 100)
+ (set_local $2
+ (call $i64s-div
+ (block (result i64)
+ (set_local $2
+ (i64.mul
+ (i64.sub
+ (i64.add
+ (tee_local $0
+ (i64.const 128849018897)
)
- (get_local $1)
+ (i64.const 100)
)
- (get_local $1)
+ (get_local $0)
+ )
+ (get_local $0)
+ )
+ )
+ (if (result i64)
+ (i64.eqz
+ (tee_local $1
+ (get_local $0)
)
+ )
+ (i64.const 0)
+ (i64.div_u
+ (get_local $2)
(get_local $1)
)
- (get_local $1)
)
+ )
+ (get_local $0)
+ )
+ )
+ (set_local $1
+ (if (result i64)
+ (i64.eqz
+ (tee_local $1
+ (get_local $0)
+ )
+ )
+ (i64.const 0)
+ (i64.rem_u
+ (get_local $2)
(get_local $1)
)
- (get_local $1)
+ )
+ )
+ (drop
+ (if (result i64)
+ (i64.eqz
+ (get_local $0)
+ )
+ (i64.const 0)
+ (i64.rem_s
+ (get_local $1)
+ (get_local $0)
+ )
)
)
(drop
@@ -404,22 +401,18 @@
(i32.const 120)
(get_local $0)
)
- (set_local $2
- (i32.wrap/i64
- (get_local $0)
- )
- )
- (set_local $0
- (i64.extend_u/i32
- (get_local $2)
- )
- )
(drop
(call $f64-to-int64
(f64.promote/f32
(tee_local $3
(f32.convert_u/i64
- (get_local $0)
+ (tee_local $0
+ (i64.extend_u/i32
+ (i32.wrap/i64
+ (get_local $0)
+ )
+ )
+ )
)
)
)
@@ -903,14 +896,28 @@
)
(func $keepAlive
(call $loads)
+ (call $loads)
+ (call $stores)
(call $stores)
(call $test)
+ (call $test)
+ (drop
+ (call $imports)
+ )
(drop
(call $imports)
)
(call $arg
(i64.const 0)
)
+ (call $arg
+ (i64.const 0)
+ )
+ (drop
+ (call $call1
+ (i64.const 0)
+ )
+ )
(drop
(call $call1
(i64.const 0)
@@ -922,6 +929,14 @@
)
)
(drop
+ (call $call2
+ (i64.const 0)
+ )
+ )
+ (drop
+ (call $returnCastConst)
+ )
+ (drop
(call $returnCastConst)
)
(drop
@@ -931,12 +946,29 @@
)
)
(drop
+ (call $ifValue64
+ (i64.const 0)
+ (i64.const 0)
+ )
+ )
+ (drop
(call $ifValue32
(i32.const 0)
(i32.const 0)
)
)
(drop
+ (call $ifValue32
+ (i32.const 0)
+ (i32.const 0)
+ )
+ )
+ (drop
+ (call $switch64
+ (i64.const 0)
+ )
+ )
+ (drop
(call $switch64
(i64.const 0)
)
@@ -946,6 +978,11 @@
(i32.const 0)
(i32.const 0)
)
+ (call $unreachable_leftovers
+ (i32.const 0)
+ (i32.const 0)
+ (i32.const 0)
+ )
(drop
(call $_memchr
(i32.const 0)
diff --git a/test/wasm-only.fromasm.clamp b/test/wasm-only.fromasm.clamp
index 8811d0cff..8f9825dda 100644
--- a/test/wasm-only.fromasm.clamp
+++ b/test/wasm-only.fromasm.clamp
@@ -241,18 +241,6 @@
)
)
)
- (func $i64u-div (param $0 i64) (param $1 i64) (result i64)
- (if (result i64)
- (i64.eqz
- (get_local $1)
- )
- (i64.const 0)
- (i64.div_u
- (get_local $0)
- (get_local $1)
- )
- )
- )
(func $i64s-div (param $0 i64) (param $1 i64) (result i64)
(if (result i64)
(i64.eqz
@@ -278,30 +266,6 @@
)
)
)
- (func $i64u-rem (param $0 i64) (param $1 i64) (result i64)
- (if (result i64)
- (i64.eqz
- (get_local $1)
- )
- (i64.const 0)
- (i64.rem_u
- (get_local $0)
- (get_local $1)
- )
- )
- )
- (func $i64s-rem (param $0 i64) (param $1 i64) (result i64)
- (if (result i64)
- (i64.eqz
- (get_local $1)
- )
- (i64.const 0)
- (i64.rem_s
- (get_local $0)
- (get_local $1)
- )
- )
- )
(func $f64-to-int64 (param $0 f64) (result i64)
(if (result i64)
(f64.ne
@@ -331,33 +295,66 @@
(func $test64
(local $0 i64)
(local $1 i64)
- (local $2 i32)
+ (local $2 i64)
(local $3 f32)
(local $4 f64)
- (drop
- (call $i64s-rem
- (call $i64u-rem
- (call $i64s-div
- (call $i64u-div
- (i64.mul
- (i64.sub
- (i64.add
- (tee_local $1
- (i64.const 128849018897)
- )
- (i64.const 100)
+ (set_local $2
+ (call $i64s-div
+ (block (result i64)
+ (set_local $2
+ (i64.mul
+ (i64.sub
+ (i64.add
+ (tee_local $0
+ (i64.const 128849018897)
)
- (get_local $1)
+ (i64.const 100)
)
- (get_local $1)
+ (get_local $0)
+ )
+ (get_local $0)
+ )
+ )
+ (if (result i64)
+ (i64.eqz
+ (tee_local $1
+ (get_local $0)
)
+ )
+ (i64.const 0)
+ (i64.div_u
+ (get_local $2)
(get_local $1)
)
- (get_local $1)
)
+ )
+ (get_local $0)
+ )
+ )
+ (set_local $1
+ (if (result i64)
+ (i64.eqz
+ (tee_local $1
+ (get_local $0)
+ )
+ )
+ (i64.const 0)
+ (i64.rem_u
+ (get_local $2)
(get_local $1)
)
- (get_local $1)
+ )
+ )
+ (drop
+ (if (result i64)
+ (i64.eqz
+ (get_local $0)
+ )
+ (i64.const 0)
+ (i64.rem_s
+ (get_local $1)
+ (get_local $0)
+ )
)
)
(drop
@@ -404,22 +401,18 @@
(i32.const 120)
(get_local $0)
)
- (set_local $2
- (i32.wrap/i64
- (get_local $0)
- )
- )
- (set_local $0
- (i64.extend_u/i32
- (get_local $2)
- )
- )
(drop
(call $f64-to-int64
(f64.promote/f32
(tee_local $3
(f32.convert_u/i64
- (get_local $0)
+ (tee_local $0
+ (i64.extend_u/i32
+ (i32.wrap/i64
+ (get_local $0)
+ )
+ )
+ )
)
)
)
@@ -903,14 +896,28 @@
)
(func $keepAlive
(call $loads)
+ (call $loads)
+ (call $stores)
(call $stores)
(call $test)
+ (call $test)
+ (drop
+ (call $imports)
+ )
(drop
(call $imports)
)
(call $arg
(i64.const 0)
)
+ (call $arg
+ (i64.const 0)
+ )
+ (drop
+ (call $call1
+ (i64.const 0)
+ )
+ )
(drop
(call $call1
(i64.const 0)
@@ -922,6 +929,14 @@
)
)
(drop
+ (call $call2
+ (i64.const 0)
+ )
+ )
+ (drop
+ (call $returnCastConst)
+ )
+ (drop
(call $returnCastConst)
)
(drop
@@ -931,12 +946,29 @@
)
)
(drop
+ (call $ifValue64
+ (i64.const 0)
+ (i64.const 0)
+ )
+ )
+ (drop
(call $ifValue32
(i32.const 0)
(i32.const 0)
)
)
(drop
+ (call $ifValue32
+ (i32.const 0)
+ (i32.const 0)
+ )
+ )
+ (drop
+ (call $switch64
+ (i64.const 0)
+ )
+ )
+ (drop
(call $switch64
(i64.const 0)
)
@@ -946,6 +978,11 @@
(i32.const 0)
(i32.const 0)
)
+ (call $unreachable_leftovers
+ (i32.const 0)
+ (i32.const 0)
+ (i32.const 0)
+ )
(drop
(call $_memchr
(i32.const 0)
diff --git a/test/wasm-only.fromasm.clamp.no-opts b/test/wasm-only.fromasm.clamp.no-opts
index 143fc9892..c0cfa4676 100644
--- a/test/wasm-only.fromasm.clamp.no-opts
+++ b/test/wasm-only.fromasm.clamp.no-opts
@@ -1645,14 +1645,28 @@
)
(func $keepAlive
(call $loads)
+ (call $loads)
+ (call $stores)
(call $stores)
(call $test)
+ (call $test)
+ (drop
+ (call $imports)
+ )
(drop
(call $imports)
)
(call $arg
(i64.const 0)
)
+ (call $arg
+ (i64.const 0)
+ )
+ (drop
+ (call $call1
+ (i64.const 0)
+ )
+ )
(drop
(call $call1
(i64.const 0)
@@ -1664,6 +1678,14 @@
)
)
(drop
+ (call $call2
+ (i64.const 0)
+ )
+ )
+ (drop
+ (call $returnCastConst)
+ )
+ (drop
(call $returnCastConst)
)
(drop
@@ -1673,6 +1695,18 @@
)
)
(drop
+ (call $ifValue64
+ (i64.const 0)
+ (i64.const 0)
+ )
+ )
+ (drop
+ (call $ifValue32
+ (i32.const 0)
+ (i32.const 0)
+ )
+ )
+ (drop
(call $ifValue32
(i32.const 0)
(i32.const 0)
@@ -1683,6 +1717,16 @@
(i64.const 0)
)
)
+ (drop
+ (call $switch64
+ (i64.const 0)
+ )
+ )
+ (call $unreachable_leftovers
+ (i32.const 0)
+ (i32.const 0)
+ (i32.const 0)
+ )
(call $unreachable_leftovers
(i32.const 0)
(i32.const 0)
diff --git a/test/wasm-only.fromasm.imprecise b/test/wasm-only.fromasm.imprecise
index 2255bfc08..07f06b23f 100644
--- a/test/wasm-only.fromasm.imprecise
+++ b/test/wasm-only.fromasm.imprecise
@@ -629,14 +629,28 @@
)
(func $keepAlive
(call $loads)
+ (call $loads)
+ (call $stores)
(call $stores)
(call $test)
+ (call $test)
+ (drop
+ (call $imports)
+ )
(drop
(call $imports)
)
(call $arg
(i64.const 0)
)
+ (call $arg
+ (i64.const 0)
+ )
+ (drop
+ (call $call1
+ (i64.const 0)
+ )
+ )
(drop
(call $call1
(i64.const 0)
@@ -648,6 +662,14 @@
)
)
(drop
+ (call $call2
+ (i64.const 0)
+ )
+ )
+ (drop
+ (call $returnCastConst)
+ )
+ (drop
(call $returnCastConst)
)
(drop
@@ -657,6 +679,18 @@
)
)
(drop
+ (call $ifValue64
+ (i64.const 0)
+ (i64.const 0)
+ )
+ )
+ (drop
+ (call $ifValue32
+ (i32.const 0)
+ (i32.const 0)
+ )
+ )
+ (drop
(call $ifValue32
(i32.const 0)
(i32.const 0)
@@ -667,6 +701,16 @@
(i64.const 0)
)
)
+ (drop
+ (call $switch64
+ (i64.const 0)
+ )
+ )
+ (call $unreachable_leftovers
+ (i32.const 0)
+ (i32.const 0)
+ (i32.const 0)
+ )
(call $unreachable_leftovers
(i32.const 0)
(i32.const 0)
diff --git a/test/wasm-only.fromasm.imprecise.no-opts b/test/wasm-only.fromasm.imprecise.no-opts
index 0052a5c93..06935c945 100644
--- a/test/wasm-only.fromasm.imprecise.no-opts
+++ b/test/wasm-only.fromasm.imprecise.no-opts
@@ -1554,14 +1554,28 @@
)
(func $keepAlive
(call $loads)
+ (call $loads)
+ (call $stores)
(call $stores)
(call $test)
+ (call $test)
+ (drop
+ (call $imports)
+ )
(drop
(call $imports)
)
(call $arg
(i64.const 0)
)
+ (call $arg
+ (i64.const 0)
+ )
+ (drop
+ (call $call1
+ (i64.const 0)
+ )
+ )
(drop
(call $call1
(i64.const 0)
@@ -1573,6 +1587,14 @@
)
)
(drop
+ (call $call2
+ (i64.const 0)
+ )
+ )
+ (drop
+ (call $returnCastConst)
+ )
+ (drop
(call $returnCastConst)
)
(drop
@@ -1582,6 +1604,18 @@
)
)
(drop
+ (call $ifValue64
+ (i64.const 0)
+ (i64.const 0)
+ )
+ )
+ (drop
+ (call $ifValue32
+ (i32.const 0)
+ (i32.const 0)
+ )
+ )
+ (drop
(call $ifValue32
(i32.const 0)
(i32.const 0)
@@ -1592,6 +1626,16 @@
(i64.const 0)
)
)
+ (drop
+ (call $switch64
+ (i64.const 0)
+ )
+ )
+ (call $unreachable_leftovers
+ (i32.const 0)
+ (i32.const 0)
+ (i32.const 0)
+ )
(call $unreachable_leftovers
(i32.const 0)
(i32.const 0)
diff --git a/test/wasm-only.fromasm.no-opts b/test/wasm-only.fromasm.no-opts
index 143fc9892..c0cfa4676 100644
--- a/test/wasm-only.fromasm.no-opts
+++ b/test/wasm-only.fromasm.no-opts
@@ -1645,14 +1645,28 @@
)
(func $keepAlive
(call $loads)
+ (call $loads)
+ (call $stores)
(call $stores)
(call $test)
+ (call $test)
+ (drop
+ (call $imports)
+ )
(drop
(call $imports)
)
(call $arg
(i64.const 0)
)
+ (call $arg
+ (i64.const 0)
+ )
+ (drop
+ (call $call1
+ (i64.const 0)
+ )
+ )
(drop
(call $call1
(i64.const 0)
@@ -1664,6 +1678,14 @@
)
)
(drop
+ (call $call2
+ (i64.const 0)
+ )
+ )
+ (drop
+ (call $returnCastConst)
+ )
+ (drop
(call $returnCastConst)
)
(drop
@@ -1673,6 +1695,18 @@
)
)
(drop
+ (call $ifValue64
+ (i64.const 0)
+ (i64.const 0)
+ )
+ )
+ (drop
+ (call $ifValue32
+ (i32.const 0)
+ (i32.const 0)
+ )
+ )
+ (drop
(call $ifValue32
(i32.const 0)
(i32.const 0)
@@ -1683,6 +1717,16 @@
(i64.const 0)
)
)
+ (drop
+ (call $switch64
+ (i64.const 0)
+ )
+ )
+ (call $unreachable_leftovers
+ (i32.const 0)
+ (i32.const 0)
+ (i32.const 0)
+ )
(call $unreachable_leftovers
(i32.const 0)
(i32.const 0)