diff options
24 files changed, 3705 insertions, 3255 deletions
diff --git a/src/ir/equivalent_sets.h b/src/ir/equivalent_sets.h index d1a957bbd..dc3e348d2 100644 --- a/src/ir/equivalent_sets.h +++ b/src/ir/equivalent_sets.h @@ -25,8 +25,8 @@ namespace wasm { // A map of each index to all those it is equivalent to, and some helpers. // struct EquivalentSets { - // A set of indexes. - typedef std::unordered_set<Index> Set; + // A set of indexes. This is ordered for deterministic iteration. + typedef std::set<Index> Set; std::unordered_map<Index, std::shared_ptr<Set>> indexSets; diff --git a/src/passes/SimplifyLocals.cpp b/src/passes/SimplifyLocals.cpp index bf4eed24e..f3645c1f3 100644 --- a/src/passes/SimplifyLocals.cpp +++ b/src/passes/SimplifyLocals.cpp @@ -126,7 +126,7 @@ struct SimplifyLocals : public WalkerPass<LinearExecutionWalker<SimplifyLocals<a } else if (curr->is<Block>()) { return; // handled in visitBlock } else if (curr->is<If>()) { - assert(!curr->cast<If>()->ifFalse); // if-elses are handled by doNoteIfElse* methods + assert(!curr->cast<If>()->ifFalse); // if-elses are handled by doNoteIf* methods } else if (curr->is<Switch>()) { auto* sw = curr->cast<Switch>(); auto targets = BranchUtils::getUniqueTargets(sw); @@ -138,26 +138,34 @@ struct SimplifyLocals : public WalkerPass<LinearExecutionWalker<SimplifyLocals<a self->sinkables.clear(); } - static void doNoteIfElseCondition(SimplifyLocals<allowTee, allowStructure, allowNesting>* self, Expression** currp) { + static void doNoteIfCondition(SimplifyLocals<allowTee, allowStructure, allowNesting>* self, Expression** currp) { // we processed the condition of this if-else, and now control flow branches // into either the true or the false sides - assert((*currp)->cast<If>()->ifFalse); self->sinkables.clear(); } - static void doNoteIfElseTrue(SimplifyLocals<allowTee, allowStructure, allowNesting>* self, Expression** currp) { - // we processed the ifTrue side of this if-else, save it on the stack - assert((*currp)->cast<If>()->ifFalse); - self->ifStack.push_back(std::move(self->sinkables)); + static void doNoteIfTrue(SimplifyLocals<allowTee, allowStructure, allowNesting>* self, Expression** currp) { + auto* iff = (*currp)->dynCast<If>(); + if (iff->ifFalse) { + // We processed the ifTrue side of this if-else, save it on the stack. + assert((*currp)->cast<If>()->ifFalse); + self->ifStack.push_back(std::move(self->sinkables)); + } else { + // This is an if without an else. + if (allowStructure) { + self->optimizeIfReturn(iff, currp); + } + self->sinkables.clear(); + } } - static void doNoteIfElseFalse(SimplifyLocals<allowTee, allowStructure, allowNesting>* self, Expression** currp) { + static void doNoteIfFalse(SimplifyLocals<allowTee, allowStructure, allowNesting>* self, Expression** currp) { // we processed the ifFalse side of this if-else, we can now try to // mere with the ifTrue side and optimize a return value, if possible auto* iff = (*currp)->cast<If>(); assert(iff->ifFalse); if (allowStructure) { - self->optimizeIfReturn(iff, currp, self->ifStack.back()); + self->optimizeIfElseReturn(iff, currp, self->ifStack.back()); } self->ifStack.pop_back(); self->sinkables.clear(); @@ -444,7 +452,7 @@ struct SimplifyLocals : public WalkerPass<LinearExecutionWalker<SimplifyLocals<a } // optimize set_locals from both sides of an if into a return value - void optimizeIfReturn(If* iff, Expression** currp, Sinkables& ifTrue) { + void optimizeIfElseReturn(If* iff, Expression** currp, Sinkables& ifTrue) { assert(iff->ifFalse); // if this if already has a result, or is unreachable code, we have // nothing to do @@ -497,14 +505,14 @@ struct SimplifyLocals : public WalkerPass<LinearExecutionWalker<SimplifyLocals<a // need another cycle auto* ifTrueBlock = iff->ifTrue->dynCast<Block>(); if (iff->ifTrue->type != unreachable) { - if (!ifTrueBlock || ifTrueBlock->list.size() == 0 || !ifTrueBlock->list.back()->is<Nop>()) { + if (!ifTrueBlock || ifTrueBlock->name.is() || ifTrueBlock->list.size() == 0 || !ifTrueBlock->list.back()->is<Nop>()) { ifsToEnlarge.push_back(iff); return; } } auto* ifFalseBlock = iff->ifFalse->dynCast<Block>(); if (iff->ifFalse->type != unreachable) { - if (!ifFalseBlock || ifFalseBlock->list.size() == 0 || !ifFalseBlock->list.back()->is<Nop>()) { + if (!ifFalseBlock || ifFalseBlock->name.is() || ifFalseBlock->list.size() == 0 || !ifFalseBlock->list.back()->is<Nop>()) { ifsToEnlarge.push_back(iff); return; } @@ -532,20 +540,78 @@ struct SimplifyLocals : public WalkerPass<LinearExecutionWalker<SimplifyLocals<a anotherCycle = true; } + // Optimize set_locals from a one-sided iff, adding a get on the other: + // (if + // (..condition..) + // (block + // (set_local $x (..value..)) + // ) + // ) + // => + // (set_local $x + // (if (result ..) + // (..condition..) + // (block (result ..) + // (..value..) + // ) + // (get_local $x) + // ) + // ) + // This is a speculative optimization: we add a get here, as well as a branch + // in the if, so this is harmful for code size and for speed. However, later + // optimizations may sink the set and enable other useful things. If none of + // that happens, other passes can "undo" this by turning an if with a copy + // arm into a one-sided if. + void optimizeIfReturn(If* iff, Expression** currp) { + // If this if is unreachable code, we have nothing to do. + if (iff->type != none || iff->ifTrue->type != none) return; + // Anything sinkable is good for us. + if (sinkables.empty()) return; + Index goodIndex = sinkables.begin()->first; + // Ensure we have a place to write the return values for, if not, we + // need another cycle. + auto* ifTrueBlock = iff->ifTrue->dynCast<Block>(); + if (!ifTrueBlock || ifTrueBlock->name.is() || ifTrueBlock->list.size() == 0 || !ifTrueBlock->list.back()->is<Nop>()) { + ifsToEnlarge.push_back(iff); + return; + } + // Update the ifTrue side. + Builder builder(*this->getModule()); + auto** item = sinkables.at(goodIndex).item; + auto* set = (*item)->template cast<SetLocal>(); + ifTrueBlock->list[ifTrueBlock->list.size() - 1] = set->value; + *item = builder.makeNop(); + ifTrueBlock->finalize(); + assert(ifTrueBlock->type != none); + // Update the ifFalse side. + iff->ifFalse = builder.makeGetLocal(set->index, set->value->type); + iff->finalize(); // update type + // Update the get count. + getCounter.num[set->index]++; + assert(iff->type != none); + // Finally, reuse the set_local on the iff itself. + set->value = iff; + set->finalize(); + *currp = set; + anotherCycle = true; + } + // override scan to add a pre and a post check task to all nodes static void scan(SimplifyLocals<allowTee, allowStructure, allowNesting>* self, Expression** currp) { self->pushTask(visitPost, currp); auto* curr = *currp; - if (curr->is<If>() && curr->cast<If>()->ifFalse) { - // handle if-elses in a special manner, using the ifStack - self->pushTask(SimplifyLocals<allowTee, allowStructure, allowNesting>::doNoteIfElseFalse, currp); - self->pushTask(SimplifyLocals<allowTee, allowStructure, allowNesting>::scan, &curr->cast<If>()->ifFalse); - self->pushTask(SimplifyLocals<allowTee, allowStructure, allowNesting>::doNoteIfElseTrue, currp); - self->pushTask(SimplifyLocals<allowTee, allowStructure, allowNesting>::scan, &curr->cast<If>()->ifTrue); - self->pushTask(SimplifyLocals<allowTee, allowStructure, allowNesting>::doNoteIfElseCondition, currp); - self->pushTask(SimplifyLocals<allowTee, allowStructure, allowNesting>::scan, &curr->cast<If>()->condition); + if (auto* iff = curr->dynCast<If>()) { + // handle if in a special manner, using the ifStack for if-elses etc. + if (iff->ifFalse) { + self->pushTask(SimplifyLocals<allowTee, allowStructure, allowNesting>::doNoteIfFalse, currp); + self->pushTask(SimplifyLocals<allowTee, allowStructure, allowNesting>::scan, &iff->ifFalse); + } + self->pushTask(SimplifyLocals<allowTee, allowStructure, allowNesting>::doNoteIfTrue, currp); + self->pushTask(SimplifyLocals<allowTee, allowStructure, allowNesting>::scan, &iff->ifTrue); + self->pushTask(SimplifyLocals<allowTee, allowStructure, allowNesting>::doNoteIfCondition, currp); + self->pushTask(SimplifyLocals<allowTee, allowStructure, allowNesting>::scan, &iff->condition); } else { WalkerPass<LinearExecutionWalker<SimplifyLocals<allowTee, allowStructure, allowNesting>>>::scan(self, currp); } @@ -582,7 +648,7 @@ struct SimplifyLocals : public WalkerPass<LinearExecutionWalker<SimplifyLocals<a // opts; continue only if they do. In other words, do not end up // doing final opts again and again when no main opts are being // enabled. - if (runFinalOptimizations(func) && runMainOptimizations(func)) { + if (runLateOptimizations(func) && runMainOptimizations(func)) { anotherCycle = true; } } @@ -603,15 +669,17 @@ struct SimplifyLocals : public WalkerPass<LinearExecutionWalker<SimplifyLocals<a // enlarge ifs that were marked, for the next round if (ifsToEnlarge.size() > 0) { for (auto* iff : ifsToEnlarge) { - auto ifTrue = Builder(*this->getModule()).blockify(iff->ifTrue); + auto ifTrue = Builder(*this->getModule()).blockifyWithName(iff->ifTrue, Name()); iff->ifTrue = ifTrue; if (ifTrue->list.size() == 0 || !ifTrue->list.back()->template is<Nop>()) { ifTrue->list.push_back(this->getModule()->allocator.template alloc<Nop>()); } - auto ifFalse = Builder(*this->getModule()).blockify(iff->ifFalse); - iff->ifFalse = ifFalse; - if (ifFalse->list.size() == 0 || !ifFalse->list.back()->template is<Nop>()) { - ifFalse->list.push_back(this->getModule()->allocator.template alloc<Nop>()); + if (iff->ifFalse) { + auto ifFalse = Builder(*this->getModule()).blockifyWithName(iff->ifFalse, Name()); + iff->ifFalse = ifFalse; + if (ifFalse->list.size() == 0 || !ifFalse->list.back()->template is<Nop>()) { + ifFalse->list.push_back(this->getModule()->allocator.template alloc<Nop>()); + } } } ifsToEnlarge.clear(); @@ -641,7 +709,7 @@ struct SimplifyLocals : public WalkerPass<LinearExecutionWalker<SimplifyLocals<a return anotherCycle; } - bool runFinalOptimizations(Function* func) { + bool runLateOptimizations(Function* func) { // Finally, after optimizing a function we can do some additional // optimization. getCounter.analyze(func); diff --git a/test/debugInfo.fromasm b/test/debugInfo.fromasm index 45519f1ed..32ca0da5e 100644 --- a/test/debugInfo.fromasm +++ b/test/debugInfo.fromasm @@ -131,41 +131,36 @@ (set_local $1 (block $__rjto$0 (result i32) (block $__rjti$0 - (br $__rjto$0 - (if (result i32) - (i32.lt_s - (tee_local $1 - (i32.add - (get_local $0) - (i32.const 52) - ) + (if + (i32.lt_s + (tee_local $1 + (i32.add + (get_local $0) + (i32.const 52) ) - (i32.const 1369188723) ) - (block (result i32) - (br_if $__rjti$0 - (i32.eqz - (i32.sub - (get_local $1) - (i32.const -1108210269) - ) - ) + (i32.const 1369188723) + ) + (br_if $__rjti$0 + (i32.eqz + (i32.sub + (get_local $1) + (i32.const -1108210269) ) - (i32.const 0) ) - (block (result i32) - (br_if $__rjti$0 - (i32.eqz - (i32.sub - (get_local $1) - (i32.const 1369188723) - ) - ) + ) + (br_if $__rjti$0 + (i32.eqz + (i32.sub + (get_local $1) + (i32.const 1369188723) ) - (i32.const 0) ) ) ) + (br $__rjto$0 + (i32.const 0) + ) ) (call $switch_reach (get_local $0) diff --git a/test/debugInfo.fromasm.clamp b/test/debugInfo.fromasm.clamp index 45519f1ed..32ca0da5e 100644 --- a/test/debugInfo.fromasm.clamp +++ b/test/debugInfo.fromasm.clamp @@ -131,41 +131,36 @@ (set_local $1 (block $__rjto$0 (result i32) (block $__rjti$0 - (br $__rjto$0 - (if (result i32) - (i32.lt_s - (tee_local $1 - (i32.add - (get_local $0) - (i32.const 52) - ) + (if + (i32.lt_s + (tee_local $1 + (i32.add + (get_local $0) + (i32.const 52) ) - (i32.const 1369188723) ) - (block (result i32) - (br_if $__rjti$0 - (i32.eqz - (i32.sub - (get_local $1) - (i32.const -1108210269) - ) - ) + (i32.const 1369188723) + ) + (br_if $__rjti$0 + (i32.eqz + (i32.sub + (get_local $1) + (i32.const -1108210269) ) - (i32.const 0) ) - (block (result i32) - (br_if $__rjti$0 - (i32.eqz - (i32.sub - (get_local $1) - (i32.const 1369188723) - ) - ) + ) + (br_if $__rjti$0 + (i32.eqz + (i32.sub + (get_local $1) + (i32.const 1369188723) ) - (i32.const 0) ) ) ) + (br $__rjto$0 + (i32.const 0) + ) ) (call $switch_reach (get_local $0) diff --git a/test/debugInfo.fromasm.clamp.map b/test/debugInfo.fromasm.clamp.map index ab06a414e..1d9054e7e 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","(unknown)"],"names":[],"mappings":"sIC8ylTA,QC7vlTA,OAkDA,wBCnGA,OACA,OACA,cCAA,kBAKA,QAJA,OADA,0BAKA,wECsi1DA,KCrvyDA"}
\ 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","(unknown)"],"names":[],"mappings":"sIC8ylTA,QC7vlTA,OAkDA,wBCnGA,OACA,OACA,cCAA,kBAKA,QAJA,OADA,0BAKA,sECsi1DA,KCrvyDA"}
\ No newline at end of file diff --git a/test/debugInfo.fromasm.imprecise b/test/debugInfo.fromasm.imprecise index f8734889f..b4d624e89 100644 --- a/test/debugInfo.fromasm.imprecise +++ b/test/debugInfo.fromasm.imprecise @@ -118,41 +118,36 @@ (set_local $1 (block $__rjto$0 (result i32) (block $__rjti$0 - (br $__rjto$0 - (if (result i32) - (i32.lt_s - (tee_local $1 - (i32.add - (get_local $0) - (i32.const 52) - ) + (if + (i32.lt_s + (tee_local $1 + (i32.add + (get_local $0) + (i32.const 52) ) - (i32.const 1369188723) ) - (block (result i32) - (br_if $__rjti$0 - (i32.eqz - (i32.sub - (get_local $1) - (i32.const -1108210269) - ) - ) + (i32.const 1369188723) + ) + (br_if $__rjti$0 + (i32.eqz + (i32.sub + (get_local $1) + (i32.const -1108210269) ) - (i32.const 0) ) - (block (result i32) - (br_if $__rjti$0 - (i32.eqz - (i32.sub - (get_local $1) - (i32.const 1369188723) - ) - ) + ) + (br_if $__rjti$0 + (i32.eqz + (i32.sub + (get_local $1) + (i32.const 1369188723) ) - (i32.const 0) ) ) ) + (br $__rjto$0 + (i32.const 0) + ) ) (call $switch_reach (get_local $0) diff --git a/test/debugInfo.fromasm.imprecise.map b/test/debugInfo.fromasm.imprecise.map index 9e6ef8390..3d93580a9 100644 --- a/test/debugInfo.fromasm.imprecise.map +++ b/test/debugInfo.fromasm.imprecise.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","(unknown)"],"names":[],"mappings":"4FC8ylTA,QC7vlTA,OAkDA,QCnGA,OACA,OACA,aCAA,kBAKA,QAJA,OADA,0BAKA,wECsi1DA,KCrvyDA"}
\ 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","(unknown)"],"names":[],"mappings":"4FC8ylTA,QC7vlTA,OAkDA,QCnGA,OACA,OACA,aCAA,kBAKA,QAJA,OADA,0BAKA,sECsi1DA,KCrvyDA"}
\ No newline at end of file diff --git a/test/debugInfo.fromasm.map b/test/debugInfo.fromasm.map index ab06a414e..1d9054e7e 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","(unknown)"],"names":[],"mappings":"sIC8ylTA,QC7vlTA,OAkDA,wBCnGA,OACA,OACA,cCAA,kBAKA,QAJA,OADA,0BAKA,wECsi1DA,KCrvyDA"}
\ 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","(unknown)"],"names":[],"mappings":"sIC8ylTA,QC7vlTA,OAkDA,wBCnGA,OACA,OACA,cCAA,kBAKA,QAJA,OADA,0BAKA,sECsi1DA,KCrvyDA"}
\ No newline at end of file diff --git a/test/debugInfo.fromasm.read-written b/test/debugInfo.fromasm.read-written index d6d001f1e..0b4fd4f29 100644 --- a/test/debugInfo.fromasm.read-written +++ b/test/debugInfo.fromasm.read-written @@ -135,41 +135,36 @@ (set_local $1 (block $label$1 (result i32) (block $label$2 - (br $label$1 - (if (result i32) - (i32.lt_s - (tee_local $1 - (i32.add - (get_local $0) - (i32.const 52) - ) + (if + (i32.lt_s + (tee_local $1 + (i32.add + (get_local $0) + (i32.const 52) ) - (i32.const 1369188723) ) - (block (result i32) - (br_if $label$2 - (i32.eqz - (i32.sub - (get_local $1) - (i32.const -1108210269) - ) - ) + (i32.const 1369188723) + ) + (br_if $label$2 + (i32.eqz + (i32.sub + (get_local $1) + (i32.const -1108210269) ) - (i32.const 0) ) - (block (result i32) - (br_if $label$2 - (i32.eqz - (i32.sub - (get_local $1) - (i32.const 1369188723) - ) - ) + ) + (br_if $label$2 + (i32.eqz + (i32.sub + (get_local $1) + (i32.const 1369188723) ) - (i32.const 0) ) ) ) + (br $label$1 + (i32.const 0) + ) ) (call $switch_reach (get_local $0) diff --git a/test/emcc_O2_hello_world.fromasm b/test/emcc_O2_hello_world.fromasm index 02e8174a9..637486547 100644 --- a/test/emcc_O2_hello_world.fromasm +++ b/test/emcc_O2_hello_world.fromasm @@ -147,7 +147,7 @@ (block (set_local $5 (i32.load - (tee_local $17 + (tee_local $18 (i32.add (tee_local $0 (i32.load @@ -267,7 +267,7 @@ ) ) (return - (get_local $17) + (get_local $18) ) ) ) @@ -460,7 +460,7 @@ (get_local $22) (get_local $3) ) - (set_local $17 + (set_local $18 (i32.load (i32.const 184) ) @@ -483,7 +483,7 @@ (get_local $14) ) ) - (set_local $17 + (set_local $18 (get_local $6) ) ) @@ -523,7 +523,7 @@ (get_local $6) ) (if - (get_local $17) + (get_local $18) (block (set_local $3 (i32.load @@ -535,7 +535,7 @@ (i32.shl (tee_local $22 (i32.shr_u - (get_local $17) + (get_local $18) (i32.const 3) ) ) @@ -560,7 +560,7 @@ ) (if (i32.lt_u - (tee_local $17 + (tee_local $18 (i32.load (tee_local $22 (i32.add @@ -580,7 +580,7 @@ (get_local $22) ) (set_local $32 - (get_local $17) + (get_local $18) ) ) ) @@ -707,7 +707,7 @@ (i32.sub (i32.and (i32.load offset=4 - (tee_local $17 + (tee_local $18 (i32.load offset=480 (i32.shl (i32.add @@ -754,25 +754,25 @@ ) (set_local $3 (tee_local $8 - (get_local $17) + (get_local $18) ) ) (loop $while-in (block $while-out (set_local $11 (i32.lt_u - (tee_local $17 + (tee_local $18 (i32.sub (i32.and (i32.load offset=4 (tee_local $8 (if (result i32) - (tee_local $17 + (tee_local $18 (i32.load offset=16 (get_local $8) ) ) - (get_local $17) + (get_local $18) (if (result i32) (tee_local $11 (i32.load offset=20 @@ -803,7 +803,7 @@ ) (set_local $1 (select - (get_local $17) + (get_local $18) (get_local $1) (get_local $11) ) @@ -869,13 +869,13 @@ ) ) (block (result i32) - (set_local $17 + (set_local $18 (get_local $7) ) (get_local $0) ) (if (result i32) - (tee_local $17 + (tee_local $18 (i32.load (tee_local $11 (i32.add @@ -896,14 +896,14 @@ (i32.load (tee_local $0 (i32.add - (get_local $17) + (get_local $18) (i32.const 20) ) ) ) ) (block - (set_local $17 + (set_local $18 (get_local $7) ) (set_local $6 @@ -917,14 +917,14 @@ (i32.load (tee_local $0 (i32.add - (get_local $17) + (get_local $18) (i32.const 16) ) ) ) ) (block - (set_local $17 + (set_local $18 (get_local $7) ) (set_local $6 @@ -946,7 +946,7 @@ (i32.const 0) ) (set_local $24 - (get_local $17) + (get_local $18) ) ) ) @@ -1436,7 +1436,7 @@ (i32.and (i32.shr_u (i32.add - (tee_local $17 + (tee_local $18 (i32.shl (get_local $10) (get_local $7) @@ -1457,7 +1457,7 @@ ) (i32.shr_u (i32.shl - (get_local $17) + (get_local $18) (get_local $10) ) (i32.const 15) @@ -1487,7 +1487,7 @@ (set_local $10 (get_local $0) ) - (set_local $17 + (set_local $18 (i32.const 0) ) (set_local $3 @@ -1537,7 +1537,7 @@ (get_local $22) ) (block - (set_local $28 + (set_local $29 (get_local $0) ) (set_local $26 @@ -1562,7 +1562,7 @@ ) (set_local $22 (select - (get_local $17) + (get_local $18) (tee_local $0 (i32.load offset=20 (get_local $7) @@ -1615,7 +1615,7 @@ (get_local $22) ) (block - (set_local $17 + (set_local $18 (get_local $22) ) (set_local $3 @@ -1786,7 +1786,7 @@ ) ) (block - (set_local $28 + (set_local $29 (get_local $33) ) (set_local $26 @@ -1831,13 +1831,13 @@ (get_local $1) ) ) - (get_local $28) + (get_local $29) ) ) (set_local $8 (select (get_local $6) - (get_local $28) + (get_local $29) (get_local $3) ) ) @@ -1855,7 +1855,7 @@ ) ) (block - (set_local $28 + (set_local $29 (get_local $8) ) (set_local $26 @@ -1875,7 +1875,7 @@ ) ) (block - (set_local $28 + (set_local $29 (get_local $8) ) (set_local $30 @@ -1959,13 +1959,13 @@ ) ) (block (result i32) - (set_local $17 + (set_local $18 (get_local $0) ) (get_local $9) ) (if (result i32) - (tee_local $17 + (tee_local $18 (i32.load (tee_local $14 (i32.add @@ -1986,14 +1986,14 @@ (i32.load (tee_local $9 (i32.add - (get_local $17) + (get_local $18) (i32.const 20) ) ) ) ) (block - (set_local $17 + (set_local $18 (get_local $0) ) (set_local $7 @@ -2007,14 +2007,14 @@ (i32.load (tee_local $9 (i32.add - (get_local $17) + (get_local $18) (i32.const 16) ) ) ) ) (block - (set_local $17 + (set_local $18 (get_local $0) ) (set_local $7 @@ -2036,7 +2036,7 @@ (i32.const 0) ) (set_local $5 - (get_local $17) + (get_local $18) ) ) ) @@ -3063,456 +3063,458 @@ ) ) (if - (if (result i32) - (if (result i32) - (select - (i32.lt_u - (get_local $2) - (i32.const 2147483647) - ) - (i32.const 0) - (i32.eq - (tee_local $10 - (if (result i32) - (i32.and - (i32.load - (i32.const 620) - ) - (i32.const 4) - ) - (i32.const 190) - (block $label$break$L257 (result i32) - (if - (tee_local $7 + (block (result i32) + (if + (if (result i32) + (if (result i32) + (select + (i32.lt_u + (get_local $2) + (i32.const 2147483647) + ) + (i32.const 0) + (i32.eq + (tee_local $10 + (if (result i32) + (i32.and (i32.load - (i32.const 200) + (i32.const 620) ) + (i32.const 4) ) - (block $label$break$L259 - (set_local $16 - (i32.const 624) - ) - (loop $while-in34 - (block $while-out33 - (if - (if (result i32) - (i32.le_u - (tee_local $27 - (i32.load - (get_local $16) - ) - ) - (get_local $7) - ) - (i32.gt_u - (i32.add - (i32.load - (tee_local $5 - (i32.add + (i32.const 190) + (block $label$break$L257 (result i32) + (if + (tee_local $7 + (i32.load + (i32.const 200) + ) + ) + (block $label$break$L259 + (set_local $16 + (i32.const 624) + ) + (loop $while-in34 + (block $while-out33 + (if + (if (result i32) + (i32.le_u + (tee_local $27 + (i32.load (get_local $16) - (i32.const 4) ) ) + (get_local $7) + ) + (i32.gt_u + (i32.add + (i32.load + (tee_local $5 + (i32.add + (get_local $16) + (i32.const 4) + ) + ) + ) + (get_local $27) + ) + (get_local $7) ) - (get_local $27) + (i32.const 0) + ) + (block + (set_local $6 + (get_local $16) + ) + (set_local $8 + (get_local $5) + ) + (br $while-out33) ) - (get_local $7) - ) - (i32.const 0) - ) - (block - (set_local $6 - (get_local $16) - ) - (set_local $8 - (get_local $5) - ) - (br $while-out33) - ) - ) - (br_if $while-in34 - (tee_local $16 - (i32.load offset=8 - (get_local $16) ) - ) - ) - (set_local $10 - (i32.const 173) - ) - (br $label$break$L259) - ) - ) - (if - (i32.lt_u - (tee_local $16 - (i32.and - (get_local $23) - (i32.sub - (get_local $19) - (i32.load - (i32.const 188) + (br_if $while-in34 + (tee_local $16 + (i32.load offset=8 + (get_local $16) + ) ) ) - ) - ) - (i32.const 2147483647) - ) - (block - (set_local $5 - (call $_sbrk - (get_local $16) + (set_local $10 + (i32.const 173) + ) + (br $label$break$L259) ) ) (if - (i32.eq - (i32.add - (i32.load - (get_local $6) - ) - (i32.load - (get_local $8) + (i32.lt_u + (tee_local $16 + (i32.and + (get_local $23) + (i32.sub + (get_local $19) + (i32.load + (i32.const 188) + ) + ) ) ) - (get_local $5) + (i32.const 2147483647) ) - (if - (i32.ne - (get_local $5) - (i32.const -1) + (block + (set_local $5 + (call $_sbrk + (get_local $16) + ) ) - (block - (set_local $20 + (if + (i32.eq + (i32.add + (i32.load + (get_local $6) + ) + (i32.load + (get_local $8) + ) + ) (get_local $5) ) - (set_local $21 - (get_local $16) + (if + (i32.ne + (get_local $5) + (i32.const -1) + ) + (block + (set_local $20 + (get_local $5) + ) + (set_local $21 + (get_local $16) + ) + (br $label$break$L257 + (i32.const 193) + ) + ) ) - (br $label$break$L257 - (i32.const 193) + (block + (set_local $13 + (get_local $5) + ) + (set_local $17 + (get_local $16) + ) + (set_local $10 + (i32.const 183) + ) ) ) ) - (block - (set_local $13 - (get_local $5) - ) - (set_local $18 - (get_local $16) - ) - (set_local $10 - (i32.const 183) - ) - ) ) ) - ) - ) - (set_local $10 - (i32.const 173) - ) - ) - (if - (if (result i32) - (i32.eq - (get_local $10) - (i32.const 173) - ) - (i32.ne - (tee_local $7 - (call $_sbrk - (i32.const 0) - ) + (set_local $10 + (i32.const 173) ) - (i32.const -1) ) - (i32.const 0) - ) - (block $do-once35 - (set_local $0 + (if (if (result i32) - (i32.and - (tee_local $1 - (get_local $7) - ) - (tee_local $5 - (i32.add - (tee_local $16 - (i32.load - (i32.const 652) - ) - ) - (i32.const -1) - ) - ) + (i32.eq + (get_local $10) + (i32.const 173) ) - (i32.add - (i32.sub - (get_local $2) - (get_local $1) - ) - (i32.and - (i32.add - (get_local $1) - (get_local $5) - ) - (i32.sub + (i32.ne + (tee_local $7 + (call $_sbrk (i32.const 0) - (get_local $16) ) ) + (i32.const -1) ) - (get_local $2) - ) - ) - (set_local $1 - (i32.add - (tee_local $16 - (i32.load - (i32.const 608) - ) - ) - (get_local $0) - ) - ) - (if - (i32.and - (i32.lt_u - (get_local $0) - (i32.const 2147483647) - ) - (i32.gt_u - (get_local $0) - (get_local $9) - ) + (i32.const 0) ) - (block - (br_if $do-once35 - (select - (i32.or - (i32.le_u - (get_local $1) - (get_local $16) + (block $do-once35 + (set_local $0 + (if (result i32) + (i32.and + (tee_local $1 + (get_local $7) ) - (i32.gt_u - (get_local $1) - (tee_local $5 - (i32.load - (i32.const 616) + (tee_local $5 + (i32.add + (tee_local $16 + (i32.load + (i32.const 652) + ) ) + (i32.const -1) ) ) ) - (i32.const 0) - (get_local $5) - ) - ) - (set_local $18 - (if (result i32) - (i32.eq - (tee_local $5 - (call $_sbrk - (get_local $0) + (i32.add + (i32.sub + (get_local $2) + (get_local $1) + ) + (i32.and + (i32.add + (get_local $1) + (get_local $5) + ) + (i32.sub + (i32.const 0) + (get_local $16) ) ) - (get_local $7) ) - (block - (set_local $20 - (get_local $7) - ) - (set_local $21 - (get_local $0) - ) - (br $label$break$L257 - (i32.const 193) + (get_local $2) + ) + ) + (set_local $1 + (i32.add + (tee_local $16 + (i32.load + (i32.const 608) ) ) - (block (result i32) - (set_local $13 + (get_local $0) + ) + ) + (if + (i32.and + (i32.lt_u + (get_local $0) + (i32.const 2147483647) + ) + (i32.gt_u + (get_local $0) + (get_local $9) + ) + ) + (block + (br_if $do-once35 + (select + (i32.or + (i32.le_u + (get_local $1) + (get_local $16) + ) + (i32.gt_u + (get_local $1) + (tee_local $5 + (i32.load + (i32.const 616) + ) + ) + ) + ) + (i32.const 0) (get_local $5) ) - (set_local $10 - (i32.const 183) + ) + (set_local $17 + (if (result i32) + (i32.eq + (tee_local $5 + (call $_sbrk + (get_local $0) + ) + ) + (get_local $7) + ) + (block + (set_local $20 + (get_local $7) + ) + (set_local $21 + (get_local $0) + ) + (br $label$break$L257 + (i32.const 193) + ) + ) + (block (result i32) + (set_local $13 + (get_local $5) + ) + (set_local $10 + (i32.const 183) + ) + (get_local $0) + ) ) - (get_local $0) ) ) ) ) ) - ) - ) - (if - (i32.eq - (get_local $10) - (i32.const 183) - ) - (block $label$break$L279 - (set_local $5 - (i32.sub - (i32.const 0) - (get_local $18) + (if + (i32.eq + (get_local $10) + (i32.const 183) ) - ) - (set_local $4 - (if (result i32) - (if (result i32) - (i32.and - (i32.and - (i32.ne - (get_local $13) - (i32.const -1) + (block $label$break$L279 + (set_local $5 + (i32.sub + (i32.const 0) + (get_local $17) + ) + ) + (set_local $4 + (if (result i32) + (if (result i32) + (i32.and + (i32.and + (i32.ne + (get_local $13) + (i32.const -1) + ) + (i32.lt_u + (get_local $17) + (i32.const 2147483647) + ) + ) + (i32.gt_u + (get_local $15) + (get_local $17) + ) ) (i32.lt_u - (get_local $18) + (tee_local $1 + (i32.and + (i32.add + (tee_local $7 + (i32.load + (i32.const 656) + ) + ) + (i32.sub + (get_local $12) + (get_local $17) + ) + ) + (i32.sub + (i32.const 0) + (get_local $7) + ) + ) + ) (i32.const 2147483647) ) + (i32.const 0) ) - (i32.gt_u - (get_local $15) - (get_local $18) - ) - ) - (i32.lt_u - (tee_local $1 - (i32.and - (i32.add - (tee_local $7 - (i32.load - (i32.const 656) - ) - ) - (i32.sub - (get_local $12) - (get_local $18) - ) + (if (result i32) + (i32.eq + (call $_sbrk + (get_local $1) ) - (i32.sub - (i32.const 0) - (get_local $7) + (i32.const -1) + ) + (block + (drop + (call $_sbrk + (get_local $5) + ) ) + (br $label$break$L279) + ) + (i32.add + (get_local $1) + (get_local $17) ) ) - (i32.const 2147483647) + (get_local $17) ) - (i32.const 0) ) - (if (result i32) - (i32.eq - (call $_sbrk - (get_local $1) - ) + (if + (i32.ne + (get_local $13) (i32.const -1) ) (block - (drop - (call $_sbrk - (get_local $5) - ) + (set_local $20 + (get_local $13) + ) + (set_local $21 + (get_local $4) + ) + (br $label$break$L257 + (i32.const 193) ) - (br $label$break$L279) - ) - (i32.add - (get_local $1) - (get_local $18) ) ) - (get_local $18) ) ) - (if - (i32.ne - (get_local $13) - (i32.const -1) - ) - (block - (set_local $20 - (get_local $13) - ) - (set_local $21 - (get_local $4) - ) - (br $label$break$L257 - (i32.const 193) + (i32.store + (i32.const 620) + (i32.or + (i32.load + (i32.const 620) ) + (i32.const 4) ) ) + (i32.const 190) ) ) - (i32.store - (i32.const 620) - (i32.or - (i32.load - (i32.const 620) - ) - (i32.const 4) + ) + (i32.const 190) + ) + ) + (i32.and + (i32.and + (i32.ne + (tee_local $4 + (call $_sbrk + (get_local $2) + ) + ) + (i32.const -1) + ) + (i32.ne + (tee_local $2 + (call $_sbrk + (i32.const 0) ) ) - (i32.const 190) + (i32.const -1) ) ) + (i32.lt_u + (get_local $4) + (get_local $2) + ) ) - (i32.const 190) + (i32.const 0) ) - ) - (i32.and - (i32.and - (i32.ne - (tee_local $4 - (call $_sbrk - (get_local $2) - ) + (i32.gt_u + (tee_local $13 + (i32.sub + (get_local $2) + (get_local $4) ) - (i32.const -1) ) - (i32.ne - (tee_local $2 - (call $_sbrk - (i32.const 0) - ) - ) - (i32.const -1) + (i32.add + (get_local $9) + (i32.const 40) ) ) - (i32.lt_u - (get_local $4) - (get_local $2) - ) + (i32.const 0) ) - (i32.const 0) - ) - (i32.gt_u - (tee_local $13 - (i32.sub - (get_local $2) + (block + (set_local $20 (get_local $4) ) + (set_local $21 + (get_local $13) + ) + (set_local $10 + (i32.const 193) + ) ) - (i32.add - (get_local $9) - (i32.const 40) - ) - ) - (i32.const 0) - ) - (block - (set_local $20 - (get_local $4) ) - (set_local $21 - (get_local $13) - ) - (set_local $10 + (i32.eq + (get_local $10) (i32.const 193) ) ) - ) - (if - (i32.eq - (get_local $10) - (i32.const 193) - ) (block (i32.store (i32.const 608) @@ -3559,7 +3561,7 @@ ) (tee_local $12 (i32.load - (tee_local $18 + (tee_local $17 (i32.add (get_local $4) (i32.const 4) @@ -3575,7 +3577,7 @@ (get_local $2) ) (set_local $47 - (get_local $18) + (get_local $17) ) (set_local $48 (get_local $12) @@ -3661,7 +3663,7 @@ (get_local $13) ) ) - (set_local $18 + (set_local $17 (i32.add (i32.load (i32.const 188) @@ -3678,19 +3680,19 @@ ) (i32.store (i32.const 188) - (get_local $18) + (get_local $17) ) (i32.store offset=4 (get_local $4) (i32.or - (get_local $18) + (get_local $17) (i32.const 1) ) ) (i32.store offset=4 (i32.add (get_local $4) - (get_local $18) + (get_local $17) ) (i32.const 40) ) @@ -3707,7 +3709,7 @@ (if (result i32) (i32.lt_u (get_local $20) - (tee_local $18 + (tee_local $17 (i32.load (i32.const 192) ) @@ -3720,10 +3722,10 @@ ) (get_local $20) ) - (get_local $18) + (get_local $17) ) ) - (set_local $18 + (set_local $17 (i32.add (get_local $20) (get_local $21) @@ -3736,7 +3738,7 @@ (block $while-out42 (if (i32.eq - (get_local $18) + (get_local $17) (i32.load (get_local $4) ) @@ -3761,7 +3763,7 @@ ) ) ) - (set_local $29 + (set_local $28 (i32.const 624) ) ) @@ -3771,7 +3773,7 @@ (get_local $10) (i32.const 211) ) - (set_local $29 + (set_local $28 (if (result i32) (i32.and (i32.load offset=12 @@ -3831,7 +3833,7 @@ (i32.const 0) (tee_local $4 (i32.add - (get_local $18) + (get_local $17) (i32.const 8) ) ) @@ -3844,7 +3846,7 @@ (i32.const 7) ) ) - (get_local $18) + (get_local $17) ) ) (set_local $4 @@ -4937,7 +4939,7 @@ (i32.le_u (tee_local $4 (i32.load - (get_local $29) + (get_local $28) ) ) (get_local $13) @@ -4946,7 +4948,7 @@ (tee_local $15 (i32.add (i32.load offset=4 - (get_local $29) + (get_local $28) ) (get_local $4) ) @@ -4957,9 +4959,9 @@ ) (get_local $15) (block - (set_local $29 + (set_local $28 (i32.load offset=8 - (get_local $29) + (get_local $28) ) ) (br $while-in66) @@ -5004,7 +5006,7 @@ (tee_local $2 (i32.add (get_local $20) - (tee_local $18 + (tee_local $17 (select (i32.and (i32.sub @@ -5036,7 +5038,7 @@ (get_local $21) (i32.const -40) ) - (get_local $18) + (get_local $17) ) ) ) @@ -5178,7 +5180,7 @@ (i32.const 256) ) (block - (set_local $18 + (set_local $17 (i32.add (i32.shl (get_local $2) @@ -5207,7 +5209,7 @@ (i32.load (tee_local $2 (i32.add - (get_local $18) + (get_local $17) (i32.const 8) ) ) @@ -5237,12 +5239,12 @@ ) (set_local $44 (i32.add - (get_local $18) + (get_local $17) (i32.const 8) ) ) (set_local $36 - (get_local $18) + (get_local $17) ) ) ) @@ -5260,7 +5262,7 @@ ) (i32.store offset=12 (get_local $13) - (get_local $18) + (get_local $17) ) (br $do-once40) ) @@ -5270,7 +5272,7 @@ (i32.shl (tee_local $7 (if (result i32) - (tee_local $18 + (tee_local $17 (i32.shr_u (get_local $4) (i32.const 8) @@ -5283,18 +5285,18 @@ ) (i32.const 31) (block (result i32) - (set_local $18 + (set_local $17 (i32.and (i32.shr_u (i32.add (tee_local $0 (i32.shl - (get_local $18) + (get_local $17) (tee_local $8 (i32.and (i32.shr_u (i32.add - (get_local $18) + (get_local $17) (i32.const 1048320) ) (i32.const 16) @@ -5328,7 +5330,7 @@ (tee_local $1 (i32.shl (get_local $0) - (get_local $18) + (get_local $17) ) ) (i32.const 245760) @@ -5340,7 +5342,7 @@ ) (i32.or (get_local $8) - (get_local $18) + (get_local $17) ) ) ) @@ -7916,67 +7918,65 @@ (br $while-in) ) ) - (if - (i32.eq - (get_local $1) - (i32.const 6) - ) - (block - (i32.store offset=16 - (get_local $0) - (i32.add - (tee_local $4 - (i32.load - (get_local $8) - ) - ) - (i32.load offset=48 - (get_local $0) - ) - ) - ) - (i32.store - (get_local $7) - (tee_local $8 - (get_local $4) - ) - ) - (i32.store - (get_local $13) - (get_local $4) - ) - (set_local $15 - (get_local $2) - ) - ) - (if + (set_local $15 + (if (result i32) (i32.eq (get_local $1) - (i32.const 8) + (i32.const 6) ) - (block + (block (result i32) (i32.store offset=16 (get_local $0) - (i32.const 0) + (i32.add + (tee_local $4 + (i32.load + (get_local $8) + ) + ) + (i32.load offset=48 + (get_local $0) + ) + ) ) (i32.store (get_local $7) - (i32.const 0) + (tee_local $8 + (get_local $4) + ) ) (i32.store (get_local $13) - (i32.const 0) + (get_local $4) ) - (i32.store - (get_local $0) - (i32.or - (i32.load - (get_local $0) + (get_local $2) + ) + (if (result i32) + (i32.eq + (get_local $1) + (i32.const 8) + ) + (block (result i32) + (i32.store offset=16 + (get_local $0) + (i32.const 0) + ) + (i32.store + (get_local $7) + (i32.const 0) + ) + (i32.store + (get_local $13) + (i32.const 0) + ) + (i32.store + (get_local $0) + (i32.or + (i32.load + (get_local $0) + ) + (i32.const 32) ) - (i32.const 32) ) - ) - (set_local $15 (if (result i32) (i32.eq (get_local $17) @@ -7991,6 +7991,7 @@ ) ) ) + (get_local $15) ) ) ) @@ -8364,84 +8365,82 @@ ) ) ) - (if - (i32.eq - (get_local $2) - (i32.const 4) - ) - (block - (set_local $2 - (get_local $1) + (i32.sub + (if (result i32) + (i32.eq + (get_local $2) + (i32.const 4) ) - (set_local $0 - (loop $while-in1 (result i32) - (if (result i32) - (i32.and - (i32.add - (tee_local $1 - (i32.load - (get_local $2) + (block (result i32) + (set_local $2 + (get_local $1) + ) + (set_local $0 + (loop $while-in1 (result i32) + (if (result i32) + (i32.and + (i32.add + (tee_local $1 + (i32.load + (get_local $2) + ) ) + (i32.const -16843009) ) - (i32.const -16843009) - ) - (i32.xor - (i32.and - (get_local $1) + (i32.xor + (i32.and + (get_local $1) + (i32.const -2139062144) + ) (i32.const -2139062144) ) - (i32.const -2139062144) ) - ) - (get_local $2) - (block - (set_local $2 - (i32.add - (get_local $2) - (i32.const 4) + (get_local $2) + (block + (set_local $2 + (i32.add + (get_local $2) + (i32.const 4) + ) ) + (br $while-in1) ) - (br $while-in1) ) ) ) - ) - (if - (i32.and - (get_local $1) - (i32.const 255) - ) - (block - (set_local $1 - (get_local $0) + (if + (i32.and + (get_local $1) + (i32.const 255) ) - (loop $while-in3 - (if - (i32.load8_s - (tee_local $0 - (i32.add - (get_local $1) - (i32.const 1) + (block + (set_local $1 + (get_local $0) + ) + (loop $while-in3 + (if + (i32.load8_s + (tee_local $0 + (i32.add + (get_local $1) + (i32.const 1) + ) ) ) - ) - (block - (set_local $1 - (get_local $0) + (block + (set_local $1 + (get_local $0) + ) + (br $while-in3) ) - (br $while-in3) ) ) ) ) - ) - (set_local $5 (get_local $0) ) + (get_local $5) ) - ) - (i32.sub - (get_local $5) (get_local $3) ) ) @@ -8454,7 +8453,7 @@ (local $6 i32) (local $7 i32) (local $8 i32) - (set_local $3 + (set_local $4 (get_global $STACKTOP) ) (set_global $STACKTOP @@ -8464,8 +8463,8 @@ ) ) (i32.store8 - (tee_local $4 - (get_local $3) + (tee_local $5 + (get_local $4) ) (i32.const 10) ) @@ -8481,10 +8480,10 @@ ) ) (block - (set_local $5 + (set_local $6 (get_local $2) ) - (set_local $6 + (set_local $7 (i32.const 4) ) ) @@ -8492,16 +8491,16 @@ (call $___towrite (get_local $0) ) - (set_local $7 + (set_local $3 (i32.const -1) ) (block - (set_local $5 + (set_local $6 (i32.load (get_local $1) ) ) - (set_local $6 + (set_local $7 (i32.const 4) ) ) @@ -8509,10 +8508,10 @@ ) (if (i32.eq - (get_local $6) + (get_local $7) (i32.const 4) ) - (set_local $7 + (set_local $3 (block $do-once (result i32) (if (if (result i32) @@ -8527,7 +8526,7 @@ ) ) ) - (get_local $5) + (get_local $6) ) (i32.ne (tee_local $8 @@ -8560,7 +8559,7 @@ (i32.eq (call_indirect (type $FUNCSIG$iiii) (get_local $0) - (get_local $4) + (get_local $5) (i32.const 1) (i32.add (i32.and @@ -8575,7 +8574,7 @@ (i32.const 1) ) (i32.load8_u - (get_local $4) + (get_local $5) ) (i32.const -1) ) @@ -8583,9 +8582,9 @@ ) ) (set_global $STACKTOP - (get_local $3) + (get_local $4) ) - (get_local $7) + (get_local $3) ) (func $___fflush_unlocked (; 22 ;) (; has Stack IR ;) (param $0 i32) (result i32) (local $1 i32) @@ -9235,14 +9234,10 @@ ) (func $_fwrite (; 29 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) - (local $4 i32) - (set_local $4 - (i32.const 1) - ) (set_local $3 (get_local $1) ) - (if + (if (result i32) (block (result i32) (drop (i32.load offset=76 @@ -9260,18 +9255,16 @@ ) ) ) - (set_local $4 - (if (result i32) + (if (result i32) + (get_local $1) + (i32.div_u + (get_local $0) (get_local $1) - (i32.div_u - (get_local $0) - (get_local $1) - ) - (i32.const 0) ) + (i32.const 0) ) + (i32.const 1) ) - (get_local $4) ) (func $___stdout_write (; 30 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) diff --git a/test/emcc_O2_hello_world.fromasm.clamp b/test/emcc_O2_hello_world.fromasm.clamp index 02e8174a9..637486547 100644 --- a/test/emcc_O2_hello_world.fromasm.clamp +++ b/test/emcc_O2_hello_world.fromasm.clamp @@ -147,7 +147,7 @@ (block (set_local $5 (i32.load - (tee_local $17 + (tee_local $18 (i32.add (tee_local $0 (i32.load @@ -267,7 +267,7 @@ ) ) (return - (get_local $17) + (get_local $18) ) ) ) @@ -460,7 +460,7 @@ (get_local $22) (get_local $3) ) - (set_local $17 + (set_local $18 (i32.load (i32.const 184) ) @@ -483,7 +483,7 @@ (get_local $14) ) ) - (set_local $17 + (set_local $18 (get_local $6) ) ) @@ -523,7 +523,7 @@ (get_local $6) ) (if - (get_local $17) + (get_local $18) (block (set_local $3 (i32.load @@ -535,7 +535,7 @@ (i32.shl (tee_local $22 (i32.shr_u - (get_local $17) + (get_local $18) (i32.const 3) ) ) @@ -560,7 +560,7 @@ ) (if (i32.lt_u - (tee_local $17 + (tee_local $18 (i32.load (tee_local $22 (i32.add @@ -580,7 +580,7 @@ (get_local $22) ) (set_local $32 - (get_local $17) + (get_local $18) ) ) ) @@ -707,7 +707,7 @@ (i32.sub (i32.and (i32.load offset=4 - (tee_local $17 + (tee_local $18 (i32.load offset=480 (i32.shl (i32.add @@ -754,25 +754,25 @@ ) (set_local $3 (tee_local $8 - (get_local $17) + (get_local $18) ) ) (loop $while-in (block $while-out (set_local $11 (i32.lt_u - (tee_local $17 + (tee_local $18 (i32.sub (i32.and (i32.load offset=4 (tee_local $8 (if (result i32) - (tee_local $17 + (tee_local $18 (i32.load offset=16 (get_local $8) ) ) - (get_local $17) + (get_local $18) (if (result i32) (tee_local $11 (i32.load offset=20 @@ -803,7 +803,7 @@ ) (set_local $1 (select - (get_local $17) + (get_local $18) (get_local $1) (get_local $11) ) @@ -869,13 +869,13 @@ ) ) (block (result i32) - (set_local $17 + (set_local $18 (get_local $7) ) (get_local $0) ) (if (result i32) - (tee_local $17 + (tee_local $18 (i32.load (tee_local $11 (i32.add @@ -896,14 +896,14 @@ (i32.load (tee_local $0 (i32.add - (get_local $17) + (get_local $18) (i32.const 20) ) ) ) ) (block - (set_local $17 + (set_local $18 (get_local $7) ) (set_local $6 @@ -917,14 +917,14 @@ (i32.load (tee_local $0 (i32.add - (get_local $17) + (get_local $18) (i32.const 16) ) ) ) ) (block - (set_local $17 + (set_local $18 (get_local $7) ) (set_local $6 @@ -946,7 +946,7 @@ (i32.const 0) ) (set_local $24 - (get_local $17) + (get_local $18) ) ) ) @@ -1436,7 +1436,7 @@ (i32.and (i32.shr_u (i32.add - (tee_local $17 + (tee_local $18 (i32.shl (get_local $10) (get_local $7) @@ -1457,7 +1457,7 @@ ) (i32.shr_u (i32.shl - (get_local $17) + (get_local $18) (get_local $10) ) (i32.const 15) @@ -1487,7 +1487,7 @@ (set_local $10 (get_local $0) ) - (set_local $17 + (set_local $18 (i32.const 0) ) (set_local $3 @@ -1537,7 +1537,7 @@ (get_local $22) ) (block - (set_local $28 + (set_local $29 (get_local $0) ) (set_local $26 @@ -1562,7 +1562,7 @@ ) (set_local $22 (select - (get_local $17) + (get_local $18) (tee_local $0 (i32.load offset=20 (get_local $7) @@ -1615,7 +1615,7 @@ (get_local $22) ) (block - (set_local $17 + (set_local $18 (get_local $22) ) (set_local $3 @@ -1786,7 +1786,7 @@ ) ) (block - (set_local $28 + (set_local $29 (get_local $33) ) (set_local $26 @@ -1831,13 +1831,13 @@ (get_local $1) ) ) - (get_local $28) + (get_local $29) ) ) (set_local $8 (select (get_local $6) - (get_local $28) + (get_local $29) (get_local $3) ) ) @@ -1855,7 +1855,7 @@ ) ) (block - (set_local $28 + (set_local $29 (get_local $8) ) (set_local $26 @@ -1875,7 +1875,7 @@ ) ) (block - (set_local $28 + (set_local $29 (get_local $8) ) (set_local $30 @@ -1959,13 +1959,13 @@ ) ) (block (result i32) - (set_local $17 + (set_local $18 (get_local $0) ) (get_local $9) ) (if (result i32) - (tee_local $17 + (tee_local $18 (i32.load (tee_local $14 (i32.add @@ -1986,14 +1986,14 @@ (i32.load (tee_local $9 (i32.add - (get_local $17) + (get_local $18) (i32.const 20) ) ) ) ) (block - (set_local $17 + (set_local $18 (get_local $0) ) (set_local $7 @@ -2007,14 +2007,14 @@ (i32.load (tee_local $9 (i32.add - (get_local $17) + (get_local $18) (i32.const 16) ) ) ) ) (block - (set_local $17 + (set_local $18 (get_local $0) ) (set_local $7 @@ -2036,7 +2036,7 @@ (i32.const 0) ) (set_local $5 - (get_local $17) + (get_local $18) ) ) ) @@ -3063,456 +3063,458 @@ ) ) (if - (if (result i32) - (if (result i32) - (select - (i32.lt_u - (get_local $2) - (i32.const 2147483647) - ) - (i32.const 0) - (i32.eq - (tee_local $10 - (if (result i32) - (i32.and - (i32.load - (i32.const 620) - ) - (i32.const 4) - ) - (i32.const 190) - (block $label$break$L257 (result i32) - (if - (tee_local $7 + (block (result i32) + (if + (if (result i32) + (if (result i32) + (select + (i32.lt_u + (get_local $2) + (i32.const 2147483647) + ) + (i32.const 0) + (i32.eq + (tee_local $10 + (if (result i32) + (i32.and (i32.load - (i32.const 200) + (i32.const 620) ) + (i32.const 4) ) - (block $label$break$L259 - (set_local $16 - (i32.const 624) - ) - (loop $while-in34 - (block $while-out33 - (if - (if (result i32) - (i32.le_u - (tee_local $27 - (i32.load - (get_local $16) - ) - ) - (get_local $7) - ) - (i32.gt_u - (i32.add - (i32.load - (tee_local $5 - (i32.add + (i32.const 190) + (block $label$break$L257 (result i32) + (if + (tee_local $7 + (i32.load + (i32.const 200) + ) + ) + (block $label$break$L259 + (set_local $16 + (i32.const 624) + ) + (loop $while-in34 + (block $while-out33 + (if + (if (result i32) + (i32.le_u + (tee_local $27 + (i32.load (get_local $16) - (i32.const 4) ) ) + (get_local $7) + ) + (i32.gt_u + (i32.add + (i32.load + (tee_local $5 + (i32.add + (get_local $16) + (i32.const 4) + ) + ) + ) + (get_local $27) + ) + (get_local $7) ) - (get_local $27) + (i32.const 0) + ) + (block + (set_local $6 + (get_local $16) + ) + (set_local $8 + (get_local $5) + ) + (br $while-out33) ) - (get_local $7) - ) - (i32.const 0) - ) - (block - (set_local $6 - (get_local $16) - ) - (set_local $8 - (get_local $5) - ) - (br $while-out33) - ) - ) - (br_if $while-in34 - (tee_local $16 - (i32.load offset=8 - (get_local $16) ) - ) - ) - (set_local $10 - (i32.const 173) - ) - (br $label$break$L259) - ) - ) - (if - (i32.lt_u - (tee_local $16 - (i32.and - (get_local $23) - (i32.sub - (get_local $19) - (i32.load - (i32.const 188) + (br_if $while-in34 + (tee_local $16 + (i32.load offset=8 + (get_local $16) + ) ) ) - ) - ) - (i32.const 2147483647) - ) - (block - (set_local $5 - (call $_sbrk - (get_local $16) + (set_local $10 + (i32.const 173) + ) + (br $label$break$L259) ) ) (if - (i32.eq - (i32.add - (i32.load - (get_local $6) - ) - (i32.load - (get_local $8) + (i32.lt_u + (tee_local $16 + (i32.and + (get_local $23) + (i32.sub + (get_local $19) + (i32.load + (i32.const 188) + ) + ) ) ) - (get_local $5) + (i32.const 2147483647) ) - (if - (i32.ne - (get_local $5) - (i32.const -1) + (block + (set_local $5 + (call $_sbrk + (get_local $16) + ) ) - (block - (set_local $20 + (if + (i32.eq + (i32.add + (i32.load + (get_local $6) + ) + (i32.load + (get_local $8) + ) + ) (get_local $5) ) - (set_local $21 - (get_local $16) + (if + (i32.ne + (get_local $5) + (i32.const -1) + ) + (block + (set_local $20 + (get_local $5) + ) + (set_local $21 + (get_local $16) + ) + (br $label$break$L257 + (i32.const 193) + ) + ) ) - (br $label$break$L257 - (i32.const 193) + (block + (set_local $13 + (get_local $5) + ) + (set_local $17 + (get_local $16) + ) + (set_local $10 + (i32.const 183) + ) ) ) ) - (block - (set_local $13 - (get_local $5) - ) - (set_local $18 - (get_local $16) - ) - (set_local $10 - (i32.const 183) - ) - ) ) ) - ) - ) - (set_local $10 - (i32.const 173) - ) - ) - (if - (if (result i32) - (i32.eq - (get_local $10) - (i32.const 173) - ) - (i32.ne - (tee_local $7 - (call $_sbrk - (i32.const 0) - ) + (set_local $10 + (i32.const 173) ) - (i32.const -1) ) - (i32.const 0) - ) - (block $do-once35 - (set_local $0 + (if (if (result i32) - (i32.and - (tee_local $1 - (get_local $7) - ) - (tee_local $5 - (i32.add - (tee_local $16 - (i32.load - (i32.const 652) - ) - ) - (i32.const -1) - ) - ) + (i32.eq + (get_local $10) + (i32.const 173) ) - (i32.add - (i32.sub - (get_local $2) - (get_local $1) - ) - (i32.and - (i32.add - (get_local $1) - (get_local $5) - ) - (i32.sub + (i32.ne + (tee_local $7 + (call $_sbrk (i32.const 0) - (get_local $16) ) ) + (i32.const -1) ) - (get_local $2) - ) - ) - (set_local $1 - (i32.add - (tee_local $16 - (i32.load - (i32.const 608) - ) - ) - (get_local $0) - ) - ) - (if - (i32.and - (i32.lt_u - (get_local $0) - (i32.const 2147483647) - ) - (i32.gt_u - (get_local $0) - (get_local $9) - ) + (i32.const 0) ) - (block - (br_if $do-once35 - (select - (i32.or - (i32.le_u - (get_local $1) - (get_local $16) + (block $do-once35 + (set_local $0 + (if (result i32) + (i32.and + (tee_local $1 + (get_local $7) ) - (i32.gt_u - (get_local $1) - (tee_local $5 - (i32.load - (i32.const 616) + (tee_local $5 + (i32.add + (tee_local $16 + (i32.load + (i32.const 652) + ) ) + (i32.const -1) ) ) ) - (i32.const 0) - (get_local $5) - ) - ) - (set_local $18 - (if (result i32) - (i32.eq - (tee_local $5 - (call $_sbrk - (get_local $0) + (i32.add + (i32.sub + (get_local $2) + (get_local $1) + ) + (i32.and + (i32.add + (get_local $1) + (get_local $5) + ) + (i32.sub + (i32.const 0) + (get_local $16) ) ) - (get_local $7) ) - (block - (set_local $20 - (get_local $7) - ) - (set_local $21 - (get_local $0) - ) - (br $label$break$L257 - (i32.const 193) + (get_local $2) + ) + ) + (set_local $1 + (i32.add + (tee_local $16 + (i32.load + (i32.const 608) ) ) - (block (result i32) - (set_local $13 + (get_local $0) + ) + ) + (if + (i32.and + (i32.lt_u + (get_local $0) + (i32.const 2147483647) + ) + (i32.gt_u + (get_local $0) + (get_local $9) + ) + ) + (block + (br_if $do-once35 + (select + (i32.or + (i32.le_u + (get_local $1) + (get_local $16) + ) + (i32.gt_u + (get_local $1) + (tee_local $5 + (i32.load + (i32.const 616) + ) + ) + ) + ) + (i32.const 0) (get_local $5) ) - (set_local $10 - (i32.const 183) + ) + (set_local $17 + (if (result i32) + (i32.eq + (tee_local $5 + (call $_sbrk + (get_local $0) + ) + ) + (get_local $7) + ) + (block + (set_local $20 + (get_local $7) + ) + (set_local $21 + (get_local $0) + ) + (br $label$break$L257 + (i32.const 193) + ) + ) + (block (result i32) + (set_local $13 + (get_local $5) + ) + (set_local $10 + (i32.const 183) + ) + (get_local $0) + ) ) - (get_local $0) ) ) ) ) ) - ) - ) - (if - (i32.eq - (get_local $10) - (i32.const 183) - ) - (block $label$break$L279 - (set_local $5 - (i32.sub - (i32.const 0) - (get_local $18) + (if + (i32.eq + (get_local $10) + (i32.const 183) ) - ) - (set_local $4 - (if (result i32) - (if (result i32) - (i32.and - (i32.and - (i32.ne - (get_local $13) - (i32.const -1) + (block $label$break$L279 + (set_local $5 + (i32.sub + (i32.const 0) + (get_local $17) + ) + ) + (set_local $4 + (if (result i32) + (if (result i32) + (i32.and + (i32.and + (i32.ne + (get_local $13) + (i32.const -1) + ) + (i32.lt_u + (get_local $17) + (i32.const 2147483647) + ) + ) + (i32.gt_u + (get_local $15) + (get_local $17) + ) ) (i32.lt_u - (get_local $18) + (tee_local $1 + (i32.and + (i32.add + (tee_local $7 + (i32.load + (i32.const 656) + ) + ) + (i32.sub + (get_local $12) + (get_local $17) + ) + ) + (i32.sub + (i32.const 0) + (get_local $7) + ) + ) + ) (i32.const 2147483647) ) + (i32.const 0) ) - (i32.gt_u - (get_local $15) - (get_local $18) - ) - ) - (i32.lt_u - (tee_local $1 - (i32.and - (i32.add - (tee_local $7 - (i32.load - (i32.const 656) - ) - ) - (i32.sub - (get_local $12) - (get_local $18) - ) + (if (result i32) + (i32.eq + (call $_sbrk + (get_local $1) ) - (i32.sub - (i32.const 0) - (get_local $7) + (i32.const -1) + ) + (block + (drop + (call $_sbrk + (get_local $5) + ) ) + (br $label$break$L279) + ) + (i32.add + (get_local $1) + (get_local $17) ) ) - (i32.const 2147483647) + (get_local $17) ) - (i32.const 0) ) - (if (result i32) - (i32.eq - (call $_sbrk - (get_local $1) - ) + (if + (i32.ne + (get_local $13) (i32.const -1) ) (block - (drop - (call $_sbrk - (get_local $5) - ) + (set_local $20 + (get_local $13) + ) + (set_local $21 + (get_local $4) + ) + (br $label$break$L257 + (i32.const 193) ) - (br $label$break$L279) - ) - (i32.add - (get_local $1) - (get_local $18) ) ) - (get_local $18) ) ) - (if - (i32.ne - (get_local $13) - (i32.const -1) - ) - (block - (set_local $20 - (get_local $13) - ) - (set_local $21 - (get_local $4) - ) - (br $label$break$L257 - (i32.const 193) + (i32.store + (i32.const 620) + (i32.or + (i32.load + (i32.const 620) ) + (i32.const 4) ) ) + (i32.const 190) ) ) - (i32.store - (i32.const 620) - (i32.or - (i32.load - (i32.const 620) - ) - (i32.const 4) + ) + (i32.const 190) + ) + ) + (i32.and + (i32.and + (i32.ne + (tee_local $4 + (call $_sbrk + (get_local $2) + ) + ) + (i32.const -1) + ) + (i32.ne + (tee_local $2 + (call $_sbrk + (i32.const 0) ) ) - (i32.const 190) + (i32.const -1) ) ) + (i32.lt_u + (get_local $4) + (get_local $2) + ) ) - (i32.const 190) + (i32.const 0) ) - ) - (i32.and - (i32.and - (i32.ne - (tee_local $4 - (call $_sbrk - (get_local $2) - ) + (i32.gt_u + (tee_local $13 + (i32.sub + (get_local $2) + (get_local $4) ) - (i32.const -1) ) - (i32.ne - (tee_local $2 - (call $_sbrk - (i32.const 0) - ) - ) - (i32.const -1) + (i32.add + (get_local $9) + (i32.const 40) ) ) - (i32.lt_u - (get_local $4) - (get_local $2) - ) + (i32.const 0) ) - (i32.const 0) - ) - (i32.gt_u - (tee_local $13 - (i32.sub - (get_local $2) + (block + (set_local $20 (get_local $4) ) + (set_local $21 + (get_local $13) + ) + (set_local $10 + (i32.const 193) + ) ) - (i32.add - (get_local $9) - (i32.const 40) - ) - ) - (i32.const 0) - ) - (block - (set_local $20 - (get_local $4) ) - (set_local $21 - (get_local $13) - ) - (set_local $10 + (i32.eq + (get_local $10) (i32.const 193) ) ) - ) - (if - (i32.eq - (get_local $10) - (i32.const 193) - ) (block (i32.store (i32.const 608) @@ -3559,7 +3561,7 @@ ) (tee_local $12 (i32.load - (tee_local $18 + (tee_local $17 (i32.add (get_local $4) (i32.const 4) @@ -3575,7 +3577,7 @@ (get_local $2) ) (set_local $47 - (get_local $18) + (get_local $17) ) (set_local $48 (get_local $12) @@ -3661,7 +3663,7 @@ (get_local $13) ) ) - (set_local $18 + (set_local $17 (i32.add (i32.load (i32.const 188) @@ -3678,19 +3680,19 @@ ) (i32.store (i32.const 188) - (get_local $18) + (get_local $17) ) (i32.store offset=4 (get_local $4) (i32.or - (get_local $18) + (get_local $17) (i32.const 1) ) ) (i32.store offset=4 (i32.add (get_local $4) - (get_local $18) + (get_local $17) ) (i32.const 40) ) @@ -3707,7 +3709,7 @@ (if (result i32) (i32.lt_u (get_local $20) - (tee_local $18 + (tee_local $17 (i32.load (i32.const 192) ) @@ -3720,10 +3722,10 @@ ) (get_local $20) ) - (get_local $18) + (get_local $17) ) ) - (set_local $18 + (set_local $17 (i32.add (get_local $20) (get_local $21) @@ -3736,7 +3738,7 @@ (block $while-out42 (if (i32.eq - (get_local $18) + (get_local $17) (i32.load (get_local $4) ) @@ -3761,7 +3763,7 @@ ) ) ) - (set_local $29 + (set_local $28 (i32.const 624) ) ) @@ -3771,7 +3773,7 @@ (get_local $10) (i32.const 211) ) - (set_local $29 + (set_local $28 (if (result i32) (i32.and (i32.load offset=12 @@ -3831,7 +3833,7 @@ (i32.const 0) (tee_local $4 (i32.add - (get_local $18) + (get_local $17) (i32.const 8) ) ) @@ -3844,7 +3846,7 @@ (i32.const 7) ) ) - (get_local $18) + (get_local $17) ) ) (set_local $4 @@ -4937,7 +4939,7 @@ (i32.le_u (tee_local $4 (i32.load - (get_local $29) + (get_local $28) ) ) (get_local $13) @@ -4946,7 +4948,7 @@ (tee_local $15 (i32.add (i32.load offset=4 - (get_local $29) + (get_local $28) ) (get_local $4) ) @@ -4957,9 +4959,9 @@ ) (get_local $15) (block - (set_local $29 + (set_local $28 (i32.load offset=8 - (get_local $29) + (get_local $28) ) ) (br $while-in66) @@ -5004,7 +5006,7 @@ (tee_local $2 (i32.add (get_local $20) - (tee_local $18 + (tee_local $17 (select (i32.and (i32.sub @@ -5036,7 +5038,7 @@ (get_local $21) (i32.const -40) ) - (get_local $18) + (get_local $17) ) ) ) @@ -5178,7 +5180,7 @@ (i32.const 256) ) (block - (set_local $18 + (set_local $17 (i32.add (i32.shl (get_local $2) @@ -5207,7 +5209,7 @@ (i32.load (tee_local $2 (i32.add - (get_local $18) + (get_local $17) (i32.const 8) ) ) @@ -5237,12 +5239,12 @@ ) (set_local $44 (i32.add - (get_local $18) + (get_local $17) (i32.const 8) ) ) (set_local $36 - (get_local $18) + (get_local $17) ) ) ) @@ -5260,7 +5262,7 @@ ) (i32.store offset=12 (get_local $13) - (get_local $18) + (get_local $17) ) (br $do-once40) ) @@ -5270,7 +5272,7 @@ (i32.shl (tee_local $7 (if (result i32) - (tee_local $18 + (tee_local $17 (i32.shr_u (get_local $4) (i32.const 8) @@ -5283,18 +5285,18 @@ ) (i32.const 31) (block (result i32) - (set_local $18 + (set_local $17 (i32.and (i32.shr_u (i32.add (tee_local $0 (i32.shl - (get_local $18) + (get_local $17) (tee_local $8 (i32.and (i32.shr_u (i32.add - (get_local $18) + (get_local $17) (i32.const 1048320) ) (i32.const 16) @@ -5328,7 +5330,7 @@ (tee_local $1 (i32.shl (get_local $0) - (get_local $18) + (get_local $17) ) ) (i32.const 245760) @@ -5340,7 +5342,7 @@ ) (i32.or (get_local $8) - (get_local $18) + (get_local $17) ) ) ) @@ -7916,67 +7918,65 @@ (br $while-in) ) ) - (if - (i32.eq - (get_local $1) - (i32.const 6) - ) - (block - (i32.store offset=16 - (get_local $0) - (i32.add - (tee_local $4 - (i32.load - (get_local $8) - ) - ) - (i32.load offset=48 - (get_local $0) - ) - ) - ) - (i32.store - (get_local $7) - (tee_local $8 - (get_local $4) - ) - ) - (i32.store - (get_local $13) - (get_local $4) - ) - (set_local $15 - (get_local $2) - ) - ) - (if + (set_local $15 + (if (result i32) (i32.eq (get_local $1) - (i32.const 8) + (i32.const 6) ) - (block + (block (result i32) (i32.store offset=16 (get_local $0) - (i32.const 0) + (i32.add + (tee_local $4 + (i32.load + (get_local $8) + ) + ) + (i32.load offset=48 + (get_local $0) + ) + ) ) (i32.store (get_local $7) - (i32.const 0) + (tee_local $8 + (get_local $4) + ) ) (i32.store (get_local $13) - (i32.const 0) + (get_local $4) ) - (i32.store - (get_local $0) - (i32.or - (i32.load - (get_local $0) + (get_local $2) + ) + (if (result i32) + (i32.eq + (get_local $1) + (i32.const 8) + ) + (block (result i32) + (i32.store offset=16 + (get_local $0) + (i32.const 0) + ) + (i32.store + (get_local $7) + (i32.const 0) + ) + (i32.store + (get_local $13) + (i32.const 0) + ) + (i32.store + (get_local $0) + (i32.or + (i32.load + (get_local $0) + ) + (i32.const 32) ) - (i32.const 32) ) - ) - (set_local $15 (if (result i32) (i32.eq (get_local $17) @@ -7991,6 +7991,7 @@ ) ) ) + (get_local $15) ) ) ) @@ -8364,84 +8365,82 @@ ) ) ) - (if - (i32.eq - (get_local $2) - (i32.const 4) - ) - (block - (set_local $2 - (get_local $1) + (i32.sub + (if (result i32) + (i32.eq + (get_local $2) + (i32.const 4) ) - (set_local $0 - (loop $while-in1 (result i32) - (if (result i32) - (i32.and - (i32.add - (tee_local $1 - (i32.load - (get_local $2) + (block (result i32) + (set_local $2 + (get_local $1) + ) + (set_local $0 + (loop $while-in1 (result i32) + (if (result i32) + (i32.and + (i32.add + (tee_local $1 + (i32.load + (get_local $2) + ) ) + (i32.const -16843009) ) - (i32.const -16843009) - ) - (i32.xor - (i32.and - (get_local $1) + (i32.xor + (i32.and + (get_local $1) + (i32.const -2139062144) + ) (i32.const -2139062144) ) - (i32.const -2139062144) ) - ) - (get_local $2) - (block - (set_local $2 - (i32.add - (get_local $2) - (i32.const 4) + (get_local $2) + (block + (set_local $2 + (i32.add + (get_local $2) + (i32.const 4) + ) ) + (br $while-in1) ) - (br $while-in1) ) ) ) - ) - (if - (i32.and - (get_local $1) - (i32.const 255) - ) - (block - (set_local $1 - (get_local $0) + (if + (i32.and + (get_local $1) + (i32.const 255) ) - (loop $while-in3 - (if - (i32.load8_s - (tee_local $0 - (i32.add - (get_local $1) - (i32.const 1) + (block + (set_local $1 + (get_local $0) + ) + (loop $while-in3 + (if + (i32.load8_s + (tee_local $0 + (i32.add + (get_local $1) + (i32.const 1) + ) ) ) - ) - (block - (set_local $1 - (get_local $0) + (block + (set_local $1 + (get_local $0) + ) + (br $while-in3) ) - (br $while-in3) ) ) ) ) - ) - (set_local $5 (get_local $0) ) + (get_local $5) ) - ) - (i32.sub - (get_local $5) (get_local $3) ) ) @@ -8454,7 +8453,7 @@ (local $6 i32) (local $7 i32) (local $8 i32) - (set_local $3 + (set_local $4 (get_global $STACKTOP) ) (set_global $STACKTOP @@ -8464,8 +8463,8 @@ ) ) (i32.store8 - (tee_local $4 - (get_local $3) + (tee_local $5 + (get_local $4) ) (i32.const 10) ) @@ -8481,10 +8480,10 @@ ) ) (block - (set_local $5 + (set_local $6 (get_local $2) ) - (set_local $6 + (set_local $7 (i32.const 4) ) ) @@ -8492,16 +8491,16 @@ (call $___towrite (get_local $0) ) - (set_local $7 + (set_local $3 (i32.const -1) ) (block - (set_local $5 + (set_local $6 (i32.load (get_local $1) ) ) - (set_local $6 + (set_local $7 (i32.const 4) ) ) @@ -8509,10 +8508,10 @@ ) (if (i32.eq - (get_local $6) + (get_local $7) (i32.const 4) ) - (set_local $7 + (set_local $3 (block $do-once (result i32) (if (if (result i32) @@ -8527,7 +8526,7 @@ ) ) ) - (get_local $5) + (get_local $6) ) (i32.ne (tee_local $8 @@ -8560,7 +8559,7 @@ (i32.eq (call_indirect (type $FUNCSIG$iiii) (get_local $0) - (get_local $4) + (get_local $5) (i32.const 1) (i32.add (i32.and @@ -8575,7 +8574,7 @@ (i32.const 1) ) (i32.load8_u - (get_local $4) + (get_local $5) ) (i32.const -1) ) @@ -8583,9 +8582,9 @@ ) ) (set_global $STACKTOP - (get_local $3) + (get_local $4) ) - (get_local $7) + (get_local $3) ) (func $___fflush_unlocked (; 22 ;) (; has Stack IR ;) (param $0 i32) (result i32) (local $1 i32) @@ -9235,14 +9234,10 @@ ) (func $_fwrite (; 29 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) - (local $4 i32) - (set_local $4 - (i32.const 1) - ) (set_local $3 (get_local $1) ) - (if + (if (result i32) (block (result i32) (drop (i32.load offset=76 @@ -9260,18 +9255,16 @@ ) ) ) - (set_local $4 - (if (result i32) + (if (result i32) + (get_local $1) + (i32.div_u + (get_local $0) (get_local $1) - (i32.div_u - (get_local $0) - (get_local $1) - ) - (i32.const 0) ) + (i32.const 0) ) + (i32.const 1) ) - (get_local $4) ) (func $___stdout_write (; 30 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) diff --git a/test/emcc_O2_hello_world.fromasm.imprecise b/test/emcc_O2_hello_world.fromasm.imprecise index f098efba5..8df23c84e 100644 --- a/test/emcc_O2_hello_world.fromasm.imprecise +++ b/test/emcc_O2_hello_world.fromasm.imprecise @@ -146,7 +146,7 @@ (block (set_local $5 (i32.load - (tee_local $17 + (tee_local $18 (i32.add (tee_local $0 (i32.load @@ -266,7 +266,7 @@ ) ) (return - (get_local $17) + (get_local $18) ) ) ) @@ -459,7 +459,7 @@ (get_local $22) (get_local $3) ) - (set_local $17 + (set_local $18 (i32.load (i32.const 184) ) @@ -482,7 +482,7 @@ (get_local $14) ) ) - (set_local $17 + (set_local $18 (get_local $6) ) ) @@ -522,7 +522,7 @@ (get_local $6) ) (if - (get_local $17) + (get_local $18) (block (set_local $3 (i32.load @@ -534,7 +534,7 @@ (i32.shl (tee_local $22 (i32.shr_u - (get_local $17) + (get_local $18) (i32.const 3) ) ) @@ -559,7 +559,7 @@ ) (if (i32.lt_u - (tee_local $17 + (tee_local $18 (i32.load (tee_local $22 (i32.add @@ -579,7 +579,7 @@ (get_local $22) ) (set_local $32 - (get_local $17) + (get_local $18) ) ) ) @@ -706,7 +706,7 @@ (i32.sub (i32.and (i32.load offset=4 - (tee_local $17 + (tee_local $18 (i32.load offset=480 (i32.shl (i32.add @@ -753,25 +753,25 @@ ) (set_local $3 (tee_local $8 - (get_local $17) + (get_local $18) ) ) (loop $while-in (block $while-out (set_local $11 (i32.lt_u - (tee_local $17 + (tee_local $18 (i32.sub (i32.and (i32.load offset=4 (tee_local $8 (if (result i32) - (tee_local $17 + (tee_local $18 (i32.load offset=16 (get_local $8) ) ) - (get_local $17) + (get_local $18) (if (result i32) (tee_local $11 (i32.load offset=20 @@ -802,7 +802,7 @@ ) (set_local $1 (select - (get_local $17) + (get_local $18) (get_local $1) (get_local $11) ) @@ -868,13 +868,13 @@ ) ) (block (result i32) - (set_local $17 + (set_local $18 (get_local $7) ) (get_local $0) ) (if (result i32) - (tee_local $17 + (tee_local $18 (i32.load (tee_local $11 (i32.add @@ -895,14 +895,14 @@ (i32.load (tee_local $0 (i32.add - (get_local $17) + (get_local $18) (i32.const 20) ) ) ) ) (block - (set_local $17 + (set_local $18 (get_local $7) ) (set_local $6 @@ -916,14 +916,14 @@ (i32.load (tee_local $0 (i32.add - (get_local $17) + (get_local $18) (i32.const 16) ) ) ) ) (block - (set_local $17 + (set_local $18 (get_local $7) ) (set_local $6 @@ -945,7 +945,7 @@ (i32.const 0) ) (set_local $24 - (get_local $17) + (get_local $18) ) ) ) @@ -1435,7 +1435,7 @@ (i32.and (i32.shr_u (i32.add - (tee_local $17 + (tee_local $18 (i32.shl (get_local $10) (get_local $7) @@ -1456,7 +1456,7 @@ ) (i32.shr_u (i32.shl - (get_local $17) + (get_local $18) (get_local $10) ) (i32.const 15) @@ -1486,7 +1486,7 @@ (set_local $10 (get_local $0) ) - (set_local $17 + (set_local $18 (i32.const 0) ) (set_local $3 @@ -1536,7 +1536,7 @@ (get_local $22) ) (block - (set_local $28 + (set_local $29 (get_local $0) ) (set_local $26 @@ -1561,7 +1561,7 @@ ) (set_local $22 (select - (get_local $17) + (get_local $18) (tee_local $0 (i32.load offset=20 (get_local $7) @@ -1614,7 +1614,7 @@ (get_local $22) ) (block - (set_local $17 + (set_local $18 (get_local $22) ) (set_local $3 @@ -1785,7 +1785,7 @@ ) ) (block - (set_local $28 + (set_local $29 (get_local $33) ) (set_local $26 @@ -1830,13 +1830,13 @@ (get_local $1) ) ) - (get_local $28) + (get_local $29) ) ) (set_local $8 (select (get_local $6) - (get_local $28) + (get_local $29) (get_local $3) ) ) @@ -1854,7 +1854,7 @@ ) ) (block - (set_local $28 + (set_local $29 (get_local $8) ) (set_local $26 @@ -1874,7 +1874,7 @@ ) ) (block - (set_local $28 + (set_local $29 (get_local $8) ) (set_local $30 @@ -1958,13 +1958,13 @@ ) ) (block (result i32) - (set_local $17 + (set_local $18 (get_local $0) ) (get_local $9) ) (if (result i32) - (tee_local $17 + (tee_local $18 (i32.load (tee_local $14 (i32.add @@ -1985,14 +1985,14 @@ (i32.load (tee_local $9 (i32.add - (get_local $17) + (get_local $18) (i32.const 20) ) ) ) ) (block - (set_local $17 + (set_local $18 (get_local $0) ) (set_local $7 @@ -2006,14 +2006,14 @@ (i32.load (tee_local $9 (i32.add - (get_local $17) + (get_local $18) (i32.const 16) ) ) ) ) (block - (set_local $17 + (set_local $18 (get_local $0) ) (set_local $7 @@ -2035,7 +2035,7 @@ (i32.const 0) ) (set_local $5 - (get_local $17) + (get_local $18) ) ) ) @@ -3062,456 +3062,458 @@ ) ) (if - (if (result i32) - (if (result i32) - (select - (i32.lt_u - (get_local $2) - (i32.const 2147483647) - ) - (i32.const 0) - (i32.eq - (tee_local $10 - (if (result i32) - (i32.and - (i32.load - (i32.const 620) - ) - (i32.const 4) - ) - (i32.const 190) - (block $label$break$L257 (result i32) - (if - (tee_local $7 + (block (result i32) + (if + (if (result i32) + (if (result i32) + (select + (i32.lt_u + (get_local $2) + (i32.const 2147483647) + ) + (i32.const 0) + (i32.eq + (tee_local $10 + (if (result i32) + (i32.and (i32.load - (i32.const 200) + (i32.const 620) ) + (i32.const 4) ) - (block $label$break$L259 - (set_local $16 - (i32.const 624) - ) - (loop $while-in34 - (block $while-out33 - (if - (if (result i32) - (i32.le_u - (tee_local $27 - (i32.load - (get_local $16) - ) - ) - (get_local $7) - ) - (i32.gt_u - (i32.add - (i32.load - (tee_local $5 - (i32.add + (i32.const 190) + (block $label$break$L257 (result i32) + (if + (tee_local $7 + (i32.load + (i32.const 200) + ) + ) + (block $label$break$L259 + (set_local $16 + (i32.const 624) + ) + (loop $while-in34 + (block $while-out33 + (if + (if (result i32) + (i32.le_u + (tee_local $27 + (i32.load (get_local $16) - (i32.const 4) ) ) + (get_local $7) ) - (get_local $27) + (i32.gt_u + (i32.add + (i32.load + (tee_local $5 + (i32.add + (get_local $16) + (i32.const 4) + ) + ) + ) + (get_local $27) + ) + (get_local $7) + ) + (i32.const 0) + ) + (block + (set_local $6 + (get_local $16) + ) + (set_local $8 + (get_local $5) + ) + (br $while-out33) ) - (get_local $7) - ) - (i32.const 0) - ) - (block - (set_local $6 - (get_local $16) - ) - (set_local $8 - (get_local $5) - ) - (br $while-out33) - ) - ) - (br_if $while-in34 - (tee_local $16 - (i32.load offset=8 - (get_local $16) ) - ) - ) - (set_local $10 - (i32.const 173) - ) - (br $label$break$L259) - ) - ) - (if - (i32.lt_u - (tee_local $16 - (i32.and - (get_local $23) - (i32.sub - (get_local $19) - (i32.load - (i32.const 188) + (br_if $while-in34 + (tee_local $16 + (i32.load offset=8 + (get_local $16) + ) ) ) - ) - ) - (i32.const 2147483647) - ) - (block - (set_local $5 - (call $_sbrk - (get_local $16) + (set_local $10 + (i32.const 173) + ) + (br $label$break$L259) ) ) (if - (i32.eq - (i32.add - (i32.load - (get_local $6) - ) - (i32.load - (get_local $8) + (i32.lt_u + (tee_local $16 + (i32.and + (get_local $23) + (i32.sub + (get_local $19) + (i32.load + (i32.const 188) + ) + ) ) ) - (get_local $5) + (i32.const 2147483647) ) - (if - (i32.ne - (get_local $5) - (i32.const -1) + (block + (set_local $5 + (call $_sbrk + (get_local $16) + ) ) - (block - (set_local $20 + (if + (i32.eq + (i32.add + (i32.load + (get_local $6) + ) + (i32.load + (get_local $8) + ) + ) (get_local $5) ) - (set_local $21 - (get_local $16) + (if + (i32.ne + (get_local $5) + (i32.const -1) + ) + (block + (set_local $20 + (get_local $5) + ) + (set_local $21 + (get_local $16) + ) + (br $label$break$L257 + (i32.const 193) + ) + ) ) - (br $label$break$L257 - (i32.const 193) + (block + (set_local $13 + (get_local $5) + ) + (set_local $17 + (get_local $16) + ) + (set_local $10 + (i32.const 183) + ) ) ) ) - (block - (set_local $13 - (get_local $5) - ) - (set_local $18 - (get_local $16) - ) - (set_local $10 - (i32.const 183) - ) - ) ) ) - ) - ) - (set_local $10 - (i32.const 173) - ) - ) - (if - (if (result i32) - (i32.eq - (get_local $10) - (i32.const 173) - ) - (i32.ne - (tee_local $7 - (call $_sbrk - (i32.const 0) - ) + (set_local $10 + (i32.const 173) ) - (i32.const -1) ) - (i32.const 0) - ) - (block $do-once35 - (set_local $0 + (if (if (result i32) - (i32.and - (tee_local $1 - (get_local $7) - ) - (tee_local $5 - (i32.add - (tee_local $16 - (i32.load - (i32.const 652) - ) - ) - (i32.const -1) - ) - ) + (i32.eq + (get_local $10) + (i32.const 173) ) - (i32.add - (i32.sub - (get_local $2) - (get_local $1) - ) - (i32.and - (i32.add - (get_local $1) - (get_local $5) - ) - (i32.sub + (i32.ne + (tee_local $7 + (call $_sbrk (i32.const 0) - (get_local $16) ) ) + (i32.const -1) ) - (get_local $2) - ) - ) - (set_local $1 - (i32.add - (tee_local $16 - (i32.load - (i32.const 608) - ) - ) - (get_local $0) - ) - ) - (if - (i32.and - (i32.lt_u - (get_local $0) - (i32.const 2147483647) - ) - (i32.gt_u - (get_local $0) - (get_local $9) - ) + (i32.const 0) ) - (block - (br_if $do-once35 - (select - (i32.or - (i32.le_u - (get_local $1) - (get_local $16) + (block $do-once35 + (set_local $0 + (if (result i32) + (i32.and + (tee_local $1 + (get_local $7) ) - (i32.gt_u - (get_local $1) - (tee_local $5 - (i32.load - (i32.const 616) + (tee_local $5 + (i32.add + (tee_local $16 + (i32.load + (i32.const 652) + ) ) + (i32.const -1) ) ) ) - (i32.const 0) - (get_local $5) - ) - ) - (set_local $18 - (if (result i32) - (i32.eq - (tee_local $5 - (call $_sbrk - (get_local $0) + (i32.add + (i32.sub + (get_local $2) + (get_local $1) + ) + (i32.and + (i32.add + (get_local $1) + (get_local $5) + ) + (i32.sub + (i32.const 0) + (get_local $16) ) ) - (get_local $7) ) - (block - (set_local $20 - (get_local $7) - ) - (set_local $21 - (get_local $0) - ) - (br $label$break$L257 - (i32.const 193) + (get_local $2) + ) + ) + (set_local $1 + (i32.add + (tee_local $16 + (i32.load + (i32.const 608) ) ) - (block (result i32) - (set_local $13 + (get_local $0) + ) + ) + (if + (i32.and + (i32.lt_u + (get_local $0) + (i32.const 2147483647) + ) + (i32.gt_u + (get_local $0) + (get_local $9) + ) + ) + (block + (br_if $do-once35 + (select + (i32.or + (i32.le_u + (get_local $1) + (get_local $16) + ) + (i32.gt_u + (get_local $1) + (tee_local $5 + (i32.load + (i32.const 616) + ) + ) + ) + ) + (i32.const 0) (get_local $5) ) - (set_local $10 - (i32.const 183) + ) + (set_local $17 + (if (result i32) + (i32.eq + (tee_local $5 + (call $_sbrk + (get_local $0) + ) + ) + (get_local $7) + ) + (block + (set_local $20 + (get_local $7) + ) + (set_local $21 + (get_local $0) + ) + (br $label$break$L257 + (i32.const 193) + ) + ) + (block (result i32) + (set_local $13 + (get_local $5) + ) + (set_local $10 + (i32.const 183) + ) + (get_local $0) + ) ) - (get_local $0) ) ) ) ) ) - ) - ) - (if - (i32.eq - (get_local $10) - (i32.const 183) - ) - (block $label$break$L279 - (set_local $5 - (i32.sub - (i32.const 0) - (get_local $18) + (if + (i32.eq + (get_local $10) + (i32.const 183) ) - ) - (set_local $4 - (if (result i32) - (if (result i32) - (i32.and - (i32.and - (i32.ne - (get_local $13) - (i32.const -1) + (block $label$break$L279 + (set_local $5 + (i32.sub + (i32.const 0) + (get_local $17) + ) + ) + (set_local $4 + (if (result i32) + (if (result i32) + (i32.and + (i32.and + (i32.ne + (get_local $13) + (i32.const -1) + ) + (i32.lt_u + (get_local $17) + (i32.const 2147483647) + ) + ) + (i32.gt_u + (get_local $15) + (get_local $17) + ) ) (i32.lt_u - (get_local $18) + (tee_local $1 + (i32.and + (i32.add + (tee_local $7 + (i32.load + (i32.const 656) + ) + ) + (i32.sub + (get_local $12) + (get_local $17) + ) + ) + (i32.sub + (i32.const 0) + (get_local $7) + ) + ) + ) (i32.const 2147483647) ) + (i32.const 0) ) - (i32.gt_u - (get_local $15) - (get_local $18) - ) - ) - (i32.lt_u - (tee_local $1 - (i32.and - (i32.add - (tee_local $7 - (i32.load - (i32.const 656) - ) - ) - (i32.sub - (get_local $12) - (get_local $18) - ) + (if (result i32) + (i32.eq + (call $_sbrk + (get_local $1) ) - (i32.sub - (i32.const 0) - (get_local $7) + (i32.const -1) + ) + (block + (drop + (call $_sbrk + (get_local $5) + ) ) + (br $label$break$L279) + ) + (i32.add + (get_local $1) + (get_local $17) ) ) - (i32.const 2147483647) + (get_local $17) ) - (i32.const 0) ) - (if (result i32) - (i32.eq - (call $_sbrk - (get_local $1) - ) + (if + (i32.ne + (get_local $13) (i32.const -1) ) (block - (drop - (call $_sbrk - (get_local $5) - ) + (set_local $20 + (get_local $13) + ) + (set_local $21 + (get_local $4) + ) + (br $label$break$L257 + (i32.const 193) ) - (br $label$break$L279) - ) - (i32.add - (get_local $1) - (get_local $18) ) ) - (get_local $18) ) ) - (if - (i32.ne - (get_local $13) - (i32.const -1) - ) - (block - (set_local $20 - (get_local $13) - ) - (set_local $21 - (get_local $4) - ) - (br $label$break$L257 - (i32.const 193) + (i32.store + (i32.const 620) + (i32.or + (i32.load + (i32.const 620) ) + (i32.const 4) ) ) + (i32.const 190) ) ) - (i32.store - (i32.const 620) - (i32.or - (i32.load - (i32.const 620) - ) - (i32.const 4) + ) + (i32.const 190) + ) + ) + (i32.and + (i32.and + (i32.ne + (tee_local $4 + (call $_sbrk + (get_local $2) ) ) - (i32.const 190) + (i32.const -1) + ) + (i32.ne + (tee_local $2 + (call $_sbrk + (i32.const 0) + ) + ) + (i32.const -1) ) ) + (i32.lt_u + (get_local $4) + (get_local $2) + ) ) - (i32.const 190) + (i32.const 0) ) - ) - (i32.and - (i32.and - (i32.ne - (tee_local $4 - (call $_sbrk - (get_local $2) - ) + (i32.gt_u + (tee_local $13 + (i32.sub + (get_local $2) + (get_local $4) ) - (i32.const -1) ) - (i32.ne - (tee_local $2 - (call $_sbrk - (i32.const 0) - ) - ) - (i32.const -1) + (i32.add + (get_local $9) + (i32.const 40) ) ) - (i32.lt_u - (get_local $4) - (get_local $2) - ) + (i32.const 0) ) - (i32.const 0) - ) - (i32.gt_u - (tee_local $13 - (i32.sub - (get_local $2) + (block + (set_local $20 (get_local $4) ) + (set_local $21 + (get_local $13) + ) + (set_local $10 + (i32.const 193) + ) ) - (i32.add - (get_local $9) - (i32.const 40) - ) - ) - (i32.const 0) - ) - (block - (set_local $20 - (get_local $4) ) - (set_local $21 - (get_local $13) - ) - (set_local $10 + (i32.eq + (get_local $10) (i32.const 193) ) ) - ) - (if - (i32.eq - (get_local $10) - (i32.const 193) - ) (block (i32.store (i32.const 608) @@ -3558,7 +3560,7 @@ ) (tee_local $12 (i32.load - (tee_local $18 + (tee_local $17 (i32.add (get_local $4) (i32.const 4) @@ -3574,7 +3576,7 @@ (get_local $2) ) (set_local $47 - (get_local $18) + (get_local $17) ) (set_local $48 (get_local $12) @@ -3660,7 +3662,7 @@ (get_local $13) ) ) - (set_local $18 + (set_local $17 (i32.add (i32.load (i32.const 188) @@ -3677,19 +3679,19 @@ ) (i32.store (i32.const 188) - (get_local $18) + (get_local $17) ) (i32.store offset=4 (get_local $4) (i32.or - (get_local $18) + (get_local $17) (i32.const 1) ) ) (i32.store offset=4 (i32.add (get_local $4) - (get_local $18) + (get_local $17) ) (i32.const 40) ) @@ -3706,7 +3708,7 @@ (if (result i32) (i32.lt_u (get_local $20) - (tee_local $18 + (tee_local $17 (i32.load (i32.const 192) ) @@ -3719,10 +3721,10 @@ ) (get_local $20) ) - (get_local $18) + (get_local $17) ) ) - (set_local $18 + (set_local $17 (i32.add (get_local $20) (get_local $21) @@ -3735,7 +3737,7 @@ (block $while-out42 (if (i32.eq - (get_local $18) + (get_local $17) (i32.load (get_local $4) ) @@ -3760,7 +3762,7 @@ ) ) ) - (set_local $29 + (set_local $28 (i32.const 624) ) ) @@ -3770,7 +3772,7 @@ (get_local $10) (i32.const 211) ) - (set_local $29 + (set_local $28 (if (result i32) (i32.and (i32.load offset=12 @@ -3830,7 +3832,7 @@ (i32.const 0) (tee_local $4 (i32.add - (get_local $18) + (get_local $17) (i32.const 8) ) ) @@ -3843,7 +3845,7 @@ (i32.const 7) ) ) - (get_local $18) + (get_local $17) ) ) (set_local $4 @@ -4936,7 +4938,7 @@ (i32.le_u (tee_local $4 (i32.load - (get_local $29) + (get_local $28) ) ) (get_local $13) @@ -4945,7 +4947,7 @@ (tee_local $15 (i32.add (i32.load offset=4 - (get_local $29) + (get_local $28) ) (get_local $4) ) @@ -4956,9 +4958,9 @@ ) (get_local $15) (block - (set_local $29 + (set_local $28 (i32.load offset=8 - (get_local $29) + (get_local $28) ) ) (br $while-in66) @@ -5003,7 +5005,7 @@ (tee_local $2 (i32.add (get_local $20) - (tee_local $18 + (tee_local $17 (select (i32.and (i32.sub @@ -5035,7 +5037,7 @@ (get_local $21) (i32.const -40) ) - (get_local $18) + (get_local $17) ) ) ) @@ -5177,7 +5179,7 @@ (i32.const 256) ) (block - (set_local $18 + (set_local $17 (i32.add (i32.shl (get_local $2) @@ -5206,7 +5208,7 @@ (i32.load (tee_local $2 (i32.add - (get_local $18) + (get_local $17) (i32.const 8) ) ) @@ -5236,12 +5238,12 @@ ) (set_local $44 (i32.add - (get_local $18) + (get_local $17) (i32.const 8) ) ) (set_local $36 - (get_local $18) + (get_local $17) ) ) ) @@ -5259,7 +5261,7 @@ ) (i32.store offset=12 (get_local $13) - (get_local $18) + (get_local $17) ) (br $do-once40) ) @@ -5269,7 +5271,7 @@ (i32.shl (tee_local $7 (if (result i32) - (tee_local $18 + (tee_local $17 (i32.shr_u (get_local $4) (i32.const 8) @@ -5282,18 +5284,18 @@ ) (i32.const 31) (block (result i32) - (set_local $18 + (set_local $17 (i32.and (i32.shr_u (i32.add (tee_local $0 (i32.shl - (get_local $18) + (get_local $17) (tee_local $8 (i32.and (i32.shr_u (i32.add - (get_local $18) + (get_local $17) (i32.const 1048320) ) (i32.const 16) @@ -5327,7 +5329,7 @@ (tee_local $1 (i32.shl (get_local $0) - (get_local $18) + (get_local $17) ) ) (i32.const 245760) @@ -5339,7 +5341,7 @@ ) (i32.or (get_local $8) - (get_local $18) + (get_local $17) ) ) ) @@ -7803,10 +7805,10 @@ (i32.const 0) ) (block - (set_local $16 + (set_local $15 (get_local $5) ) - (set_local $17 + (set_local $16 (get_local $3) ) (set_local $1 @@ -7915,12 +7917,15 @@ (br $while-in) ) ) - (if + (set_global $STACKTOP + (get_local $12) + ) + (if (result i32) (i32.eq (get_local $1) (i32.const 6) ) - (block + (block (result i32) (i32.store offset=16 (get_local $0) (i32.add @@ -7944,16 +7949,14 @@ (get_local $13) (get_local $4) ) - (set_local $15 - (get_local $2) - ) + (get_local $2) ) - (if + (if (result i32) (i32.eq (get_local $1) (i32.const 8) ) - (block + (block (result i32) (i32.store offset=16 (get_local $0) (i32.const 0) @@ -7975,28 +7978,23 @@ (i32.const 32) ) ) - (set_local $15 - (select - (i32.const 0) - (i32.sub - (get_local $2) - (i32.load offset=4 - (get_local $16) - ) - ) - (i32.eq - (get_local $17) - (i32.const 2) + (select + (i32.const 0) + (i32.sub + (get_local $2) + (i32.load offset=4 + (get_local $15) ) ) + (i32.eq + (get_local $16) + (i32.const 2) + ) ) ) + (get_local $17) ) ) - (set_global $STACKTOP - (get_local $12) - ) - (get_local $15) ) (func $___fwritex (; 18 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) @@ -8358,84 +8356,82 @@ ) ) ) - (if - (i32.eq - (get_local $2) - (i32.const 4) - ) - (block - (set_local $2 - (get_local $1) + (i32.sub + (if (result i32) + (i32.eq + (get_local $2) + (i32.const 4) ) - (set_local $0 - (loop $while-in1 (result i32) - (if (result i32) - (i32.and - (i32.add - (tee_local $1 - (i32.load - (get_local $2) + (block (result i32) + (set_local $2 + (get_local $1) + ) + (set_local $0 + (loop $while-in1 (result i32) + (if (result i32) + (i32.and + (i32.add + (tee_local $1 + (i32.load + (get_local $2) + ) ) + (i32.const -16843009) ) - (i32.const -16843009) - ) - (i32.xor - (i32.and - (get_local $1) + (i32.xor + (i32.and + (get_local $1) + (i32.const -2139062144) + ) (i32.const -2139062144) ) - (i32.const -2139062144) ) - ) - (get_local $2) - (block - (set_local $2 - (i32.add - (get_local $2) - (i32.const 4) + (get_local $2) + (block + (set_local $2 + (i32.add + (get_local $2) + (i32.const 4) + ) ) + (br $while-in1) ) - (br $while-in1) ) ) ) - ) - (if - (i32.and - (get_local $1) - (i32.const 255) - ) - (block - (set_local $1 - (get_local $0) + (if + (i32.and + (get_local $1) + (i32.const 255) ) - (loop $while-in3 - (if - (i32.load8_s - (tee_local $0 - (i32.add - (get_local $1) - (i32.const 1) + (block + (set_local $1 + (get_local $0) + ) + (loop $while-in3 + (if + (i32.load8_s + (tee_local $0 + (i32.add + (get_local $1) + (i32.const 1) + ) ) ) - ) - (block - (set_local $1 - (get_local $0) + (block + (set_local $1 + (get_local $0) + ) + (br $while-in3) ) - (br $while-in3) ) ) ) ) - ) - (set_local $5 (get_local $0) ) + (get_local $5) ) - ) - (i32.sub - (get_local $5) (get_local $3) ) ) @@ -8448,7 +8444,7 @@ (local $6 i32) (local $7 i32) (local $8 i32) - (set_local $3 + (set_local $4 (get_global $STACKTOP) ) (set_global $STACKTOP @@ -8458,8 +8454,8 @@ ) ) (i32.store8 - (tee_local $4 - (get_local $3) + (tee_local $5 + (get_local $4) ) (i32.const 10) ) @@ -8475,10 +8471,10 @@ ) ) (block - (set_local $5 + (set_local $6 (get_local $2) ) - (set_local $6 + (set_local $7 (i32.const 4) ) ) @@ -8486,16 +8482,16 @@ (call $___towrite (get_local $0) ) - (set_local $7 + (set_local $3 (i32.const -1) ) (block - (set_local $5 + (set_local $6 (i32.load (get_local $1) ) ) - (set_local $6 + (set_local $7 (i32.const 4) ) ) @@ -8503,10 +8499,10 @@ ) (if (i32.eq - (get_local $6) + (get_local $7) (i32.const 4) ) - (set_local $7 + (set_local $3 (block $do-once (result i32) (if (if (result i32) @@ -8521,7 +8517,7 @@ ) ) ) - (get_local $5) + (get_local $6) ) (i32.ne (tee_local $8 @@ -8554,7 +8550,7 @@ (i32.eq (call_indirect (type $FUNCSIG$iiii) (get_local $0) - (get_local $4) + (get_local $5) (i32.const 1) (i32.add (i32.and @@ -8569,7 +8565,7 @@ (i32.const 1) ) (i32.load8_u - (get_local $4) + (get_local $5) ) (i32.const -1) ) @@ -8577,9 +8573,9 @@ ) ) (set_global $STACKTOP - (get_local $3) + (get_local $4) ) - (get_local $7) + (get_local $3) ) (func $___fflush_unlocked (; 22 ;) (; has Stack IR ;) (param $0 i32) (result i32) (local $1 i32) @@ -8996,6 +8992,9 @@ (local $0 i32) (local $1 i32) (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) (drop (i32.load offset=76 (tee_local $0 @@ -9007,72 +9006,86 @@ ) (i32.shr_s (i32.shl - (tee_local $0 - (if (result i32) - (i32.lt_s - (i32.add - (call $_fwrite - (i32.const 672) - (call $_strlen - (i32.const 672) - ) - (get_local $0) - ) - (i32.const -1) - ) - (i32.const 0) - ) - (i32.const 1) - (block $do-once (result i32) - (if - (if (result i32) - (i32.ne - (i32.load8_s offset=75 - (get_local $0) - ) - (i32.const 10) - ) - (i32.lt_u - (tee_local $1 - (i32.load + (if (result i32) + (i32.lt_s + (i32.add + (select + (i32.div_u + (tee_local $4 + (call $___fwritex + (i32.const 672) + (tee_local $3 (tee_local $2 - (i32.add - (get_local $0) - (i32.const 20) + (call $_strlen + (i32.const 672) ) ) ) - ) - (i32.load offset=16 (get_local $0) ) ) - (i32.const 0) + (get_local $2) ) - (block - (i32.store - (get_local $2) - (i32.add - (get_local $1) - (i32.const 1) - ) + (i32.const 1) + (i32.ne + (get_local $3) + (get_local $4) + ) + ) + (i32.const -1) + ) + (i32.const 0) + ) + (i32.const 1) + (block $do-once (result i32) + (if + (if (result i32) + (i32.ne + (i32.load8_s offset=75 + (get_local $0) ) - (i32.store8 - (get_local $1) - (i32.const 10) + (i32.const 10) + ) + (i32.lt_u + (tee_local $1 + (i32.load + (tee_local $5 + (i32.add + (get_local $0) + (i32.const 20) + ) + ) + ) ) - (br $do-once - (i32.const 0) + (i32.load offset=16 + (get_local $0) ) ) + (i32.const 0) ) - (i32.lt_s - (call $___overflow - (get_local $0) + (block + (i32.store + (get_local $5) + (i32.add + (get_local $1) + (i32.const 1) + ) + ) + (i32.store8 + (get_local $1) + (i32.const 10) + ) + (br $do-once + (i32.const 0) ) - (i32.const 0) ) ) + (i32.lt_s + (call $___overflow + (get_local $0) + ) + (i32.const 0) + ) ) ) (i32.const 31) @@ -9227,36 +9240,7 @@ ) ) ) - (func $_fwrite (; 29 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - (local $3 i32) - (local $4 i32) - (set_local $4 - (i32.const 1) - ) - (set_local $3 - (get_local $1) - ) - (if - (i32.ne - (get_local $3) - (tee_local $0 - (call $___fwritex - (get_local $0) - (get_local $3) - (get_local $2) - ) - ) - ) - (set_local $4 - (i32.div_u - (get_local $0) - (get_local $1) - ) - ) - ) - (get_local $4) - ) - (func $___stdout_write (; 30 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $___stdout_write (; 29 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (set_local $4 @@ -9325,7 +9309,7 @@ ) (get_local $3) ) - (func $___stdio_close (; 31 ;) (; has Stack IR ;) (param $0 i32) (result i32) + (func $___stdio_close (; 30 ;) (; has Stack IR ;) (param $0 i32) (result i32) (local $1 i32) (set_local $1 (get_global $STACKTOP) @@ -9355,7 +9339,7 @@ ) (get_local $0) ) - (func $___syscall_ret (; 32 ;) (; has Stack IR ;) (param $0 i32) (result i32) + (func $___syscall_ret (; 31 ;) (; has Stack IR ;) (param $0 i32) (result i32) (if (result i32) (i32.gt_u (get_local $0) @@ -9374,7 +9358,7 @@ (get_local $0) ) ) - (func $dynCall_iiii (; 33 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $dynCall_iiii (; 32 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) (call_indirect (type $FUNCSIG$iiii) (get_local $1) (get_local $2) @@ -9388,7 +9372,7 @@ ) ) ) - (func $stackAlloc (; 34 ;) (; has Stack IR ;) (param $0 i32) (result i32) + (func $stackAlloc (; 33 ;) (; has Stack IR ;) (param $0 i32) (result i32) (local $1 i32) (set_local $1 (get_global $STACKTOP) @@ -9410,7 +9394,7 @@ ) (get_local $1) ) - (func $___errno_location (; 35 ;) (; has Stack IR ;) (result i32) + (func $___errno_location (; 34 ;) (; has Stack IR ;) (result i32) (if (result i32) (i32.load (i32.const 8) @@ -9421,7 +9405,7 @@ (i32.const 60) ) ) - (func $setThrew (; 36 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) + (func $setThrew (; 35 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (if (i32.eqz (get_global $__THREW__) @@ -9436,7 +9420,7 @@ ) ) ) - (func $dynCall_ii (; 37 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32) + (func $dynCall_ii (; 36 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32) (call_indirect (type $FUNCSIG$ii) (get_local $1) (i32.and @@ -9445,10 +9429,10 @@ ) ) ) - (func $_cleanup_418 (; 38 ;) (; has Stack IR ;) (param $0 i32) + (func $_cleanup_418 (; 37 ;) (; has Stack IR ;) (param $0 i32) (nop) ) - (func $establishStackSpace (; 39 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) + (func $establishStackSpace (; 38 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (set_global $STACKTOP (get_local $0) ) @@ -9456,7 +9440,7 @@ (get_local $1) ) ) - (func $dynCall_vi (; 40 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) + (func $dynCall_vi (; 39 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (call_indirect (type $FUNCSIG$vi) (get_local $1) (i32.add @@ -9468,41 +9452,41 @@ ) ) ) - (func $b1 (; 41 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $b1 (; 40 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (call $abort (i32.const 1) ) (i32.const 0) ) - (func $stackRestore (; 42 ;) (; has Stack IR ;) (param $0 i32) + (func $stackRestore (; 41 ;) (; has Stack IR ;) (param $0 i32) (set_global $STACKTOP (get_local $0) ) ) - (func $setTempRet0 (; 43 ;) (; has Stack IR ;) (param $0 i32) + (func $setTempRet0 (; 42 ;) (; has Stack IR ;) (param $0 i32) (set_global $tempRet0 (get_local $0) ) ) - (func $b0 (; 44 ;) (; has Stack IR ;) (param $0 i32) (result i32) + (func $b0 (; 43 ;) (; has Stack IR ;) (param $0 i32) (result i32) (call $abort (i32.const 0) ) (i32.const 0) ) - (func $getTempRet0 (; 45 ;) (; has Stack IR ;) (result i32) + (func $getTempRet0 (; 44 ;) (; has Stack IR ;) (result i32) (get_global $tempRet0) ) - (func $_main (; 46 ;) (; has Stack IR ;) (result i32) + (func $_main (; 45 ;) (; has Stack IR ;) (result i32) (drop (call $_puts) ) (i32.const 0) ) - (func $stackSave (; 47 ;) (; has Stack IR ;) (result i32) + (func $stackSave (; 46 ;) (; has Stack IR ;) (result i32) (get_global $STACKTOP) ) - (func $b2 (; 48 ;) (; has Stack IR ;) (param $0 i32) + (func $b2 (; 47 ;) (; has Stack IR ;) (param $0 i32) (call $abort (i32.const 2) ) diff --git a/test/emcc_hello_world.fromasm b/test/emcc_hello_world.fromasm index 6552ae32c..e7fbb92a8 100644 --- a/test/emcc_hello_world.fromasm +++ b/test/emcc_hello_world.fromasm @@ -2151,8 +2151,8 @@ (local $19 i32) (local $20 i32) (local $21 i32) - (local $22 i32) - (local $23 f64) + (local $22 f64) + (local $23 i32) (local $24 i32) (local $25 i32) (local $26 i32) @@ -2270,7 +2270,7 @@ (get_local $32) ) (tee_local $36 - (tee_local $22 + (tee_local $23 (i32.add (get_local $14) (i32.const 588) @@ -2305,14 +2305,14 @@ (set_local $42 (tee_local $29 (i32.add - (get_local $22) + (get_local $23) (i32.const 9) ) ) ) (set_local $33 (i32.add - (get_local $22) + (get_local $23) (i32.const 8) ) ) @@ -3934,7 +3934,7 @@ (if (tee_local $5 (f64.ne - (tee_local $23 + (tee_local $22 (f64.mul (call $_frexp (get_local $16) @@ -3998,7 +3998,7 @@ (i32.const 11) ) ) - (get_local $23) + (get_local $22) (block (result f64) (set_local $16 (f64.const 8) @@ -4031,7 +4031,7 @@ (get_local $16) (f64.sub (f64.neg - (get_local $23) + (get_local $22) ) (get_local $16) ) @@ -4039,7 +4039,7 @@ ) (f64.sub (f64.add - (get_local $23) + (get_local $22) (get_local $16) ) (get_local $16) @@ -4048,6 +4048,12 @@ ) ) ) + (set_local $12 + (i32.or + (get_local $26) + (i32.const 2) + ) + ) (if (i32.eq (tee_local $5 @@ -4094,12 +4100,6 @@ ) ) ) - (set_local $12 - (i32.or - (get_local $26) - (i32.const 2) - ) - ) (i32.store8 (i32.add (get_local $5) @@ -4143,7 +4143,7 @@ ) ) (set_local $5 - (get_local $22) + (get_local $23) ) (loop $while-in56 (i32.store8 @@ -4306,7 +4306,7 @@ ) (drop (call $___fwritex - (get_local $22) + (get_local $23) (get_local $5) (get_local $0) ) @@ -4385,7 +4385,7 @@ ) ) (f64.mul - (get_local $23) + (get_local $22) (f64.const 268435456) ) ) @@ -4395,7 +4395,7 @@ (get_local $20) ) ) - (get_local $23) + (get_local $22) ) ) ) @@ -5050,7 +5050,7 @@ ) ) ) - (set_local $23 + (set_local $22 (select (f64.const 9007199254740994) (f64.const 9007199254740992) @@ -5070,14 +5070,14 @@ (i32.const 45) ) (block - (set_local $23 + (set_local $16 (f64.neg - (get_local $23) + (get_local $16) ) ) - (set_local $16 + (set_local $22 (f64.neg - (get_local $16) + (get_local $22) ) ) ) @@ -5095,10 +5095,10 @@ (br_if $do-once81 (f64.eq (f64.add - (get_local $23) + (get_local $22) (get_local $16) ) - (get_local $23) + (get_local $22) ) ) (i32.store @@ -5729,7 +5729,7 @@ (br_if $do-once103 (i32.le_u (get_local $7) - (get_local $22) + (get_local $23) ) ) (loop $while-in106 @@ -5745,7 +5745,7 @@ (br_if $while-in106 (i32.gt_u (get_local $7) - (get_local $22) + (get_local $23) ) ) ) @@ -5833,7 +5833,7 @@ (get_local $29) ) ) - (get_local $22) + (get_local $23) ) (loop $while-in112 (i32.store8 @@ -5848,7 +5848,7 @@ (br_if $while-in112 (i32.gt_u (get_local $6) - (get_local $22) + (get_local $23) ) ) ) @@ -5933,87 +5933,141 @@ (get_local $24) ) ) - (if - (i32.gt_s - (get_local $5) - (i32.const -1) - ) - (block - (set_local $18 - (i32.eqz - (get_local $21) + (call $_pad + (get_local $0) + (i32.const 48) + (block (result i32) + (if + (i32.gt_s + (get_local $5) + (i32.const -1) ) - ) - (set_local $6 - (get_local $12) - ) - (set_local $7 - (get_local $5) - ) - (loop $while-in114 - (if - (i32.eq - (tee_local $5 - (call $_fmt_u - (i32.load - (get_local $6) - ) - (i32.const 0) - (get_local $29) - ) + (block + (set_local $18 + (i32.eqz + (get_local $21) ) - (get_local $29) ) - (block - (i32.store8 - (get_local $33) - (i32.const 48) - ) - (set_local $5 - (get_local $33) - ) + (set_local $6 + (get_local $12) ) - ) - (block $do-once115 - (if - (i32.eq - (get_local $6) - (get_local $12) - ) - (block - (if - (i32.eqz - (i32.and + (set_local $7 + (get_local $5) + ) + (loop $while-in114 + (if + (i32.eq + (tee_local $5 + (call $_fmt_u (i32.load - (get_local $0) + (get_local $6) ) - (i32.const 32) - ) - ) - (drop - (call $___fwritex - (get_local $5) - (i32.const 1) - (get_local $0) + (i32.const 0) + (get_local $29) ) ) + (get_local $29) ) - (set_local $5 - (i32.add - (get_local $5) - (i32.const 1) + (block + (i32.store8 + (get_local $33) + (i32.const 48) + ) + (set_local $5 + (get_local $33) ) ) - (br_if $do-once115 - (i32.and - (i32.lt_s - (get_local $7) - (i32.const 1) + ) + (block $do-once115 + (if + (i32.eq + (get_local $6) + (get_local $12) + ) + (block + (if + (i32.eqz + (i32.and + (i32.load + (get_local $0) + ) + (i32.const 32) + ) + ) + (drop + (call $___fwritex + (get_local $5) + (i32.const 1) + (get_local $0) + ) + ) + ) + (set_local $5 + (i32.add + (get_local $5) + (i32.const 1) + ) + ) + (br_if $do-once115 + (i32.and + (i32.lt_s + (get_local $7) + (i32.const 1) + ) + (get_local $18) + ) + ) + (br_if $do-once115 + (i32.and + (i32.load + (get_local $0) + ) + (i32.const 32) + ) + ) + (drop + (call $___fwritex + (i32.const 4143) + (i32.const 1) + (get_local $0) + ) + ) + ) + (block + (br_if $do-once115 + (i32.le_u + (get_local $5) + (get_local $23) + ) + ) + (loop $while-in118 + (i32.store8 + (tee_local $5 + (i32.add + (get_local $5) + (i32.const -1) + ) + ) + (i32.const 48) + ) + (br_if $while-in118 + (i32.gt_u + (get_local $5) + (get_local $23) + ) + ) ) - (get_local $18) ) ) - (br_if $do-once115 + ) + (set_local $8 + (i32.sub + (get_local $42) + (get_local $5) + ) + ) + (if + (i32.eqz (i32.and (i32.load (get_local $0) @@ -6023,104 +6077,52 @@ ) (drop (call $___fwritex - (i32.const 4143) - (i32.const 1) + (get_local $5) + (select + (get_local $8) + (get_local $7) + (i32.gt_s + (get_local $7) + (get_local $8) + ) + ) (get_local $0) ) ) ) - (block - (br_if $do-once115 - (i32.le_u - (get_local $5) - (get_local $22) - ) - ) - (loop $while-in118 - (i32.store8 - (tee_local $5 + (br_if $while-in114 + (i32.and + (i32.lt_u + (tee_local $6 (i32.add - (get_local $5) - (i32.const -1) + (get_local $6) + (i32.const 4) ) ) - (i32.const 48) - ) - (br_if $while-in118 - (i32.gt_u - (get_local $5) - (get_local $22) - ) + (get_local $9) ) - ) - ) - ) - ) - (set_local $8 - (i32.sub - (get_local $42) - (get_local $5) - ) - ) - (if - (i32.eqz - (i32.and - (i32.load - (get_local $0) - ) - (i32.const 32) - ) - ) - (drop - (call $___fwritex - (get_local $5) - (select - (get_local $8) - (get_local $7) (i32.gt_s - (get_local $7) - (get_local $8) + (tee_local $7 + (i32.sub + (get_local $7) + (get_local $8) + ) + ) + (i32.const -1) ) ) - (get_local $0) ) ) - ) - (br_if $while-in114 - (i32.and - (i32.lt_u - (tee_local $6 - (i32.add - (get_local $6) - (i32.const 4) - ) - ) - (get_local $9) - ) - (i32.gt_s - (tee_local $7 - (i32.sub - (get_local $7) - (get_local $8) - ) - ) - (i32.const -1) - ) + (set_local $5 + (get_local $7) ) ) ) - (set_local $5 - (get_local $7) + (i32.add + (get_local $5) + (i32.const 18) ) ) - ) - (call $_pad - (get_local $0) - (i32.const 48) - (i32.add - (get_local $5) - (i32.const 18) - ) (i32.const 18) (i32.const 0) ) @@ -6187,32 +6189,6 @@ ) (get_local $8) ) - (if - (i32.eqz - (i32.and - (tee_local $5 - (i32.load - (get_local $0) - ) - ) - (i32.const 32) - ) - ) - (block - (drop - (call $___fwritex - (get_local $30) - (get_local $9) - (get_local $0) - ) - ) - (set_local $5 - (i32.load - (get_local $0) - ) - ) - ) - ) (set_local $6 (select (select @@ -6237,10 +6213,38 @@ ) ) (if - (i32.eqz - (i32.and - (get_local $5) - (i32.const 32) + (block (result i32) + (if + (i32.eqz + (i32.and + (tee_local $5 + (i32.load + (get_local $0) + ) + ) + (i32.const 32) + ) + ) + (block + (drop + (call $___fwritex + (get_local $30) + (get_local $9) + (get_local $0) + ) + ) + (set_local $5 + (i32.load + (get_local $0) + ) + ) + ) + ) + (i32.eqz + (i32.and + (get_local $5) + (i32.const 32) + ) ) ) (drop diff --git a/test/emcc_hello_world.fromasm.clamp b/test/emcc_hello_world.fromasm.clamp index 57d86747f..a6d85be58 100644 --- a/test/emcc_hello_world.fromasm.clamp +++ b/test/emcc_hello_world.fromasm.clamp @@ -2201,8 +2201,8 @@ (local $19 i32) (local $20 i32) (local $21 i32) - (local $22 i32) - (local $23 f64) + (local $22 f64) + (local $23 i32) (local $24 i32) (local $25 i32) (local $26 i32) @@ -2320,7 +2320,7 @@ (get_local $32) ) (tee_local $36 - (tee_local $22 + (tee_local $23 (i32.add (get_local $14) (i32.const 588) @@ -2355,14 +2355,14 @@ (set_local $42 (tee_local $29 (i32.add - (get_local $22) + (get_local $23) (i32.const 9) ) ) ) (set_local $33 (i32.add - (get_local $22) + (get_local $23) (i32.const 8) ) ) @@ -3984,7 +3984,7 @@ (if (tee_local $5 (f64.ne - (tee_local $23 + (tee_local $22 (f64.mul (call $_frexp (get_local $16) @@ -4048,7 +4048,7 @@ (i32.const 11) ) ) - (get_local $23) + (get_local $22) (block (result f64) (set_local $16 (f64.const 8) @@ -4081,7 +4081,7 @@ (get_local $16) (f64.sub (f64.neg - (get_local $23) + (get_local $22) ) (get_local $16) ) @@ -4089,7 +4089,7 @@ ) (f64.sub (f64.add - (get_local $23) + (get_local $22) (get_local $16) ) (get_local $16) @@ -4098,6 +4098,12 @@ ) ) ) + (set_local $12 + (i32.or + (get_local $26) + (i32.const 2) + ) + ) (if (i32.eq (tee_local $5 @@ -4144,12 +4150,6 @@ ) ) ) - (set_local $12 - (i32.or - (get_local $26) - (i32.const 2) - ) - ) (i32.store8 (i32.add (get_local $5) @@ -4193,7 +4193,7 @@ ) ) (set_local $5 - (get_local $22) + (get_local $23) ) (loop $while-in56 (i32.store8 @@ -4356,7 +4356,7 @@ ) (drop (call $___fwritex - (get_local $22) + (get_local $23) (get_local $5) (get_local $0) ) @@ -4435,7 +4435,7 @@ ) ) (f64.mul - (get_local $23) + (get_local $22) (f64.const 268435456) ) ) @@ -4445,7 +4445,7 @@ (get_local $20) ) ) - (get_local $23) + (get_local $22) ) ) ) @@ -5100,7 +5100,7 @@ ) ) ) - (set_local $23 + (set_local $22 (select (f64.const 9007199254740994) (f64.const 9007199254740992) @@ -5120,14 +5120,14 @@ (i32.const 45) ) (block - (set_local $23 + (set_local $16 (f64.neg - (get_local $23) + (get_local $16) ) ) - (set_local $16 + (set_local $22 (f64.neg - (get_local $16) + (get_local $22) ) ) ) @@ -5145,10 +5145,10 @@ (br_if $do-once81 (f64.eq (f64.add - (get_local $23) + (get_local $22) (get_local $16) ) - (get_local $23) + (get_local $22) ) ) (i32.store @@ -5779,7 +5779,7 @@ (br_if $do-once103 (i32.le_u (get_local $7) - (get_local $22) + (get_local $23) ) ) (loop $while-in106 @@ -5795,7 +5795,7 @@ (br_if $while-in106 (i32.gt_u (get_local $7) - (get_local $22) + (get_local $23) ) ) ) @@ -5883,7 +5883,7 @@ (get_local $29) ) ) - (get_local $22) + (get_local $23) ) (loop $while-in112 (i32.store8 @@ -5898,7 +5898,7 @@ (br_if $while-in112 (i32.gt_u (get_local $6) - (get_local $22) + (get_local $23) ) ) ) @@ -5983,87 +5983,141 @@ (get_local $24) ) ) - (if - (i32.gt_s - (get_local $5) - (i32.const -1) - ) - (block - (set_local $18 - (i32.eqz - (get_local $21) + (call $_pad + (get_local $0) + (i32.const 48) + (block (result i32) + (if + (i32.gt_s + (get_local $5) + (i32.const -1) ) - ) - (set_local $6 - (get_local $12) - ) - (set_local $7 - (get_local $5) - ) - (loop $while-in114 - (if - (i32.eq - (tee_local $5 - (call $_fmt_u - (i32.load - (get_local $6) - ) - (i32.const 0) - (get_local $29) - ) + (block + (set_local $18 + (i32.eqz + (get_local $21) ) - (get_local $29) ) - (block - (i32.store8 - (get_local $33) - (i32.const 48) - ) - (set_local $5 - (get_local $33) - ) + (set_local $6 + (get_local $12) ) - ) - (block $do-once115 - (if - (i32.eq - (get_local $6) - (get_local $12) - ) - (block - (if - (i32.eqz - (i32.and + (set_local $7 + (get_local $5) + ) + (loop $while-in114 + (if + (i32.eq + (tee_local $5 + (call $_fmt_u (i32.load - (get_local $0) + (get_local $6) ) - (i32.const 32) - ) - ) - (drop - (call $___fwritex - (get_local $5) - (i32.const 1) - (get_local $0) + (i32.const 0) + (get_local $29) ) ) + (get_local $29) ) - (set_local $5 - (i32.add - (get_local $5) - (i32.const 1) + (block + (i32.store8 + (get_local $33) + (i32.const 48) + ) + (set_local $5 + (get_local $33) ) ) - (br_if $do-once115 - (i32.and - (i32.lt_s - (get_local $7) - (i32.const 1) + ) + (block $do-once115 + (if + (i32.eq + (get_local $6) + (get_local $12) + ) + (block + (if + (i32.eqz + (i32.and + (i32.load + (get_local $0) + ) + (i32.const 32) + ) + ) + (drop + (call $___fwritex + (get_local $5) + (i32.const 1) + (get_local $0) + ) + ) + ) + (set_local $5 + (i32.add + (get_local $5) + (i32.const 1) + ) + ) + (br_if $do-once115 + (i32.and + (i32.lt_s + (get_local $7) + (i32.const 1) + ) + (get_local $18) + ) + ) + (br_if $do-once115 + (i32.and + (i32.load + (get_local $0) + ) + (i32.const 32) + ) + ) + (drop + (call $___fwritex + (i32.const 4143) + (i32.const 1) + (get_local $0) + ) + ) + ) + (block + (br_if $do-once115 + (i32.le_u + (get_local $5) + (get_local $23) + ) + ) + (loop $while-in118 + (i32.store8 + (tee_local $5 + (i32.add + (get_local $5) + (i32.const -1) + ) + ) + (i32.const 48) + ) + (br_if $while-in118 + (i32.gt_u + (get_local $5) + (get_local $23) + ) + ) ) - (get_local $18) ) ) - (br_if $do-once115 + ) + (set_local $8 + (i32.sub + (get_local $42) + (get_local $5) + ) + ) + (if + (i32.eqz (i32.and (i32.load (get_local $0) @@ -6073,104 +6127,52 @@ ) (drop (call $___fwritex - (i32.const 4143) - (i32.const 1) + (get_local $5) + (select + (get_local $8) + (get_local $7) + (i32.gt_s + (get_local $7) + (get_local $8) + ) + ) (get_local $0) ) ) ) - (block - (br_if $do-once115 - (i32.le_u - (get_local $5) - (get_local $22) - ) - ) - (loop $while-in118 - (i32.store8 - (tee_local $5 + (br_if $while-in114 + (i32.and + (i32.lt_u + (tee_local $6 (i32.add - (get_local $5) - (i32.const -1) + (get_local $6) + (i32.const 4) ) ) - (i32.const 48) - ) - (br_if $while-in118 - (i32.gt_u - (get_local $5) - (get_local $22) - ) + (get_local $9) ) - ) - ) - ) - ) - (set_local $8 - (i32.sub - (get_local $42) - (get_local $5) - ) - ) - (if - (i32.eqz - (i32.and - (i32.load - (get_local $0) - ) - (i32.const 32) - ) - ) - (drop - (call $___fwritex - (get_local $5) - (select - (get_local $8) - (get_local $7) (i32.gt_s - (get_local $7) - (get_local $8) + (tee_local $7 + (i32.sub + (get_local $7) + (get_local $8) + ) + ) + (i32.const -1) ) ) - (get_local $0) ) ) - ) - (br_if $while-in114 - (i32.and - (i32.lt_u - (tee_local $6 - (i32.add - (get_local $6) - (i32.const 4) - ) - ) - (get_local $9) - ) - (i32.gt_s - (tee_local $7 - (i32.sub - (get_local $7) - (get_local $8) - ) - ) - (i32.const -1) - ) + (set_local $5 + (get_local $7) ) ) ) - (set_local $5 - (get_local $7) + (i32.add + (get_local $5) + (i32.const 18) ) ) - ) - (call $_pad - (get_local $0) - (i32.const 48) - (i32.add - (get_local $5) - (i32.const 18) - ) (i32.const 18) (i32.const 0) ) @@ -6237,32 +6239,6 @@ ) (get_local $8) ) - (if - (i32.eqz - (i32.and - (tee_local $5 - (i32.load - (get_local $0) - ) - ) - (i32.const 32) - ) - ) - (block - (drop - (call $___fwritex - (get_local $30) - (get_local $9) - (get_local $0) - ) - ) - (set_local $5 - (i32.load - (get_local $0) - ) - ) - ) - ) (set_local $6 (select (select @@ -6287,10 +6263,38 @@ ) ) (if - (i32.eqz - (i32.and - (get_local $5) - (i32.const 32) + (block (result i32) + (if + (i32.eqz + (i32.and + (tee_local $5 + (i32.load + (get_local $0) + ) + ) + (i32.const 32) + ) + ) + (block + (drop + (call $___fwritex + (get_local $30) + (get_local $9) + (get_local $0) + ) + ) + (set_local $5 + (i32.load + (get_local $0) + ) + ) + ) + ) + (i32.eqz + (i32.and + (get_local $5) + (i32.const 32) + ) ) ) (drop diff --git a/test/emcc_hello_world.fromasm.imprecise b/test/emcc_hello_world.fromasm.imprecise index 69bcbdba9..ec57aa743 100644 --- a/test/emcc_hello_world.fromasm.imprecise +++ b/test/emcc_hello_world.fromasm.imprecise @@ -2090,8 +2090,8 @@ (local $19 i32) (local $20 i32) (local $21 i32) - (local $22 i32) - (local $23 f64) + (local $22 f64) + (local $23 i32) (local $24 i32) (local $25 i32) (local $26 i32) @@ -2208,7 +2208,7 @@ (get_local $32) ) (tee_local $36 - (tee_local $22 + (tee_local $23 (i32.add (get_local $14) (i32.const 588) @@ -2243,14 +2243,14 @@ (set_local $42 (tee_local $29 (i32.add - (get_local $22) + (get_local $23) (i32.const 9) ) ) ) (set_local $33 (i32.add - (get_local $22) + (get_local $23) (i32.const 8) ) ) @@ -3854,7 +3854,7 @@ (if (tee_local $5 (f64.ne - (tee_local $23 + (tee_local $22 (f64.mul (call $_frexp (get_local $16) @@ -3918,7 +3918,7 @@ (i32.const 11) ) ) - (get_local $23) + (get_local $22) (block (result f64) (set_local $16 (f64.const 8) @@ -3945,7 +3945,7 @@ (get_local $16) (f64.sub (f64.neg - (get_local $23) + (get_local $22) ) (get_local $16) ) @@ -3953,7 +3953,7 @@ ) (f64.sub (f64.add - (get_local $23) + (get_local $22) (get_local $16) ) (get_local $16) @@ -3968,6 +3968,12 @@ ) ) ) + (set_local $12 + (i32.or + (get_local $26) + (i32.const 2) + ) + ) (if (i32.eq (tee_local $5 @@ -4014,12 +4020,6 @@ ) ) ) - (set_local $12 - (i32.or - (get_local $26) - (i32.const 2) - ) - ) (i32.store8 (i32.add (get_local $5) @@ -4063,7 +4063,7 @@ ) ) (set_local $5 - (get_local $22) + (get_local $23) ) (loop $while-in56 (i32.store8 @@ -4226,7 +4226,7 @@ ) (drop (call $___fwritex - (get_local $22) + (get_local $23) (get_local $5) (get_local $0) ) @@ -4305,7 +4305,7 @@ ) ) (f64.mul - (get_local $23) + (get_local $22) (f64.const 268435456) ) ) @@ -4315,7 +4315,7 @@ (get_local $20) ) ) - (get_local $23) + (get_local $22) ) ) ) @@ -4961,7 +4961,7 @@ ) ) ) - (set_local $23 + (set_local $22 (select (f64.const 9007199254740994) (f64.const 9007199254740992) @@ -4984,14 +4984,14 @@ (i32.const 45) ) (block - (set_local $23 + (set_local $16 (f64.neg - (get_local $23) + (get_local $16) ) ) - (set_local $16 + (set_local $22 (f64.neg - (get_local $16) + (get_local $22) ) ) ) @@ -5009,10 +5009,10 @@ (br_if $do-once81 (f64.eq (f64.add - (get_local $23) + (get_local $22) (get_local $16) ) - (get_local $23) + (get_local $22) ) ) (i32.store @@ -5643,7 +5643,7 @@ (br_if $do-once103 (i32.le_u (get_local $7) - (get_local $22) + (get_local $23) ) ) (loop $while-in106 @@ -5659,7 +5659,7 @@ (br_if $while-in106 (i32.gt_u (get_local $7) - (get_local $22) + (get_local $23) ) ) ) @@ -5747,7 +5747,7 @@ (get_local $29) ) ) - (get_local $22) + (get_local $23) ) (loop $while-in112 (i32.store8 @@ -5762,7 +5762,7 @@ (br_if $while-in112 (i32.gt_u (get_local $6) - (get_local $22) + (get_local $23) ) ) ) @@ -5847,194 +5847,196 @@ (get_local $24) ) ) - (if - (i32.gt_s - (get_local $5) - (i32.const -1) - ) - (block - (set_local $18 - (i32.eqz - (get_local $21) + (call $_pad + (get_local $0) + (i32.const 48) + (block (result i32) + (if + (i32.gt_s + (get_local $5) + (i32.const -1) ) - ) - (set_local $6 - (get_local $12) - ) - (set_local $7 - (get_local $5) - ) - (loop $while-in114 - (if - (i32.eq - (tee_local $5 - (call $_fmt_u - (i32.load - (get_local $6) - ) - (i32.const 0) - (get_local $29) - ) + (block + (set_local $18 + (i32.eqz + (get_local $21) ) - (get_local $29) ) - (block - (i32.store8 - (get_local $33) - (i32.const 48) - ) - (set_local $5 - (get_local $33) - ) + (set_local $6 + (get_local $12) ) - ) - (block $do-once115 - (if - (i32.eq - (get_local $6) - (get_local $12) - ) - (block - (if - (i32.eqz - (i32.and + (set_local $7 + (get_local $5) + ) + (loop $while-in114 + (if + (i32.eq + (tee_local $5 + (call $_fmt_u (i32.load - (get_local $0) + (get_local $6) ) - (i32.const 32) - ) - ) - (drop - (call $___fwritex - (get_local $5) - (i32.const 1) - (get_local $0) + (i32.const 0) + (get_local $29) ) ) + (get_local $29) ) - (set_local $5 - (i32.add - (get_local $5) - (i32.const 1) + (block + (i32.store8 + (get_local $33) + (i32.const 48) + ) + (set_local $5 + (get_local $33) ) ) - (br_if $do-once115 - (i32.or - (i32.and - (i32.load - (get_local $0) + ) + (block $do-once115 + (if + (i32.eq + (get_local $6) + (get_local $12) + ) + (block + (if + (i32.eqz + (i32.and + (i32.load + (get_local $0) + ) + (i32.const 32) + ) + ) + (drop + (call $___fwritex + (get_local $5) + (i32.const 1) + (get_local $0) + ) ) - (i32.const 32) ) - (i32.and - (i32.lt_s - (get_local $7) + (set_local $5 + (i32.add + (get_local $5) (i32.const 1) ) - (get_local $18) + ) + (br_if $do-once115 + (i32.or + (i32.and + (i32.load + (get_local $0) + ) + (i32.const 32) + ) + (i32.and + (i32.lt_s + (get_local $7) + (i32.const 1) + ) + (get_local $18) + ) + ) + ) + (drop + (call $___fwritex + (i32.const 4143) + (i32.const 1) + (get_local $0) + ) ) ) - ) - (drop - (call $___fwritex - (i32.const 4143) - (i32.const 1) - (get_local $0) - ) - ) - ) - (block - (br_if $do-once115 - (i32.le_u - (get_local $5) - (get_local $22) - ) - ) - (loop $while-in118 - (i32.store8 - (tee_local $5 - (i32.add + (block + (br_if $do-once115 + (i32.le_u (get_local $5) - (i32.const -1) + (get_local $23) ) ) - (i32.const 48) - ) - (br_if $while-in118 - (i32.gt_u - (get_local $5) - (get_local $22) + (loop $while-in118 + (i32.store8 + (tee_local $5 + (i32.add + (get_local $5) + (i32.const -1) + ) + ) + (i32.const 48) + ) + (br_if $while-in118 + (i32.gt_u + (get_local $5) + (get_local $23) + ) + ) ) ) ) ) - ) - ) - (set_local $8 - (i32.sub - (get_local $42) - (get_local $5) - ) - ) - (if - (i32.eqz - (i32.and - (i32.load - (get_local $0) + (set_local $8 + (i32.sub + (get_local $42) + (get_local $5) ) - (i32.const 32) ) - ) - (drop - (call $___fwritex - (get_local $5) - (select - (get_local $8) - (get_local $7) - (i32.gt_s - (get_local $7) - (get_local $8) + (if + (i32.eqz + (i32.and + (i32.load + (get_local $0) + ) + (i32.const 32) ) ) - (get_local $0) - ) - ) - ) - (br_if $while-in114 - (i32.and - (i32.lt_u - (tee_local $6 - (i32.add - (get_local $6) - (i32.const 4) + (drop + (call $___fwritex + (get_local $5) + (select + (get_local $8) + (get_local $7) + (i32.gt_s + (get_local $7) + (get_local $8) + ) + ) + (get_local $0) ) ) - (get_local $9) ) - (i32.gt_s - (tee_local $7 - (i32.sub - (get_local $7) - (get_local $8) + (br_if $while-in114 + (i32.and + (i32.lt_u + (tee_local $6 + (i32.add + (get_local $6) + (i32.const 4) + ) + ) + (get_local $9) + ) + (i32.gt_s + (tee_local $7 + (i32.sub + (get_local $7) + (get_local $8) + ) + ) + (i32.const -1) ) ) - (i32.const -1) ) ) + (set_local $5 + (get_local $7) + ) ) ) - (set_local $5 - (get_local $7) + (i32.add + (get_local $5) + (i32.const 18) ) ) - ) - (call $_pad - (get_local $0) - (i32.const 48) - (i32.add - (get_local $5) - (i32.const 18) - ) (i32.const 18) (i32.const 0) ) @@ -6101,32 +6103,6 @@ ) (get_local $8) ) - (if - (i32.eqz - (i32.and - (tee_local $5 - (i32.load - (get_local $0) - ) - ) - (i32.const 32) - ) - ) - (block - (drop - (call $___fwritex - (get_local $30) - (get_local $9) - (get_local $0) - ) - ) - (set_local $5 - (i32.load - (get_local $0) - ) - ) - ) - ) (set_local $6 (select (select @@ -6151,10 +6127,38 @@ ) ) (if - (i32.eqz - (i32.and - (get_local $5) - (i32.const 32) + (block (result i32) + (if + (i32.eqz + (i32.and + (tee_local $5 + (i32.load + (get_local $0) + ) + ) + (i32.const 32) + ) + ) + (block + (drop + (call $___fwritex + (get_local $30) + (get_local $9) + (get_local $0) + ) + ) + (set_local $5 + (i32.load + (get_local $0) + ) + ) + ) + ) + (i32.eqz + (i32.and + (get_local $5) + (i32.const 32) + ) ) ) (drop diff --git a/test/memorygrowth.fromasm b/test/memorygrowth.fromasm index 46e4beb04..3dac1de09 100644 --- a/test/memorygrowth.fromasm +++ b/test/memorygrowth.fromasm @@ -1573,7 +1573,7 @@ (get_local $2) ) (block - (set_local $29 + (set_local $30 (get_local $13) ) (set_local $28 @@ -1825,7 +1825,7 @@ ) ) (block - (set_local $29 + (set_local $30 (get_local $36) ) (set_local $28 @@ -1870,13 +1870,13 @@ (get_local $0) ) ) - (get_local $29) + (get_local $30) ) ) (set_local $6 (select (get_local $9) - (get_local $29) + (get_local $30) (get_local $3) ) ) @@ -1894,7 +1894,7 @@ ) ) (block - (set_local $29 + (set_local $30 (get_local $6) ) (set_local $28 @@ -1914,7 +1914,7 @@ ) ) (block - (set_local $29 + (set_local $30 (get_local $6) ) (set_local $32 @@ -3518,15 +3518,15 @@ ) ) (block - (set_local $20 - (get_local $4) - ) (set_local $26 (get_local $12) ) (set_local $8 (i32.const 191) ) + (set_local $20 + (get_local $4) + ) ) ) ) @@ -3783,7 +3783,7 @@ ) ) ) - (set_local $30 + (set_local $29 (i32.const 1656) ) ) @@ -3793,7 +3793,7 @@ (get_local $8) (i32.const 209) ) - (set_local $30 + (set_local $29 (if (result i32) (i32.and (i32.load offset=12 @@ -4951,7 +4951,7 @@ (i32.le_u (tee_local $1 (i32.load - (get_local $30) + (get_local $29) ) ) (get_local $12) @@ -4961,7 +4961,7 @@ (tee_local $16 (i32.add (i32.load offset=4 - (get_local $30) + (get_local $29) ) (get_local $1) ) @@ -4976,9 +4976,9 @@ ) ) ) - (set_local $30 + (set_local $29 (i32.load offset=8 - (get_local $30) + (get_local $29) ) ) (br $while-in66) @@ -7965,67 +7965,65 @@ (br $while-in) ) ) - (if - (i32.eq - (get_local $1) - (i32.const 6) - ) - (block - (i32.store offset=16 - (get_local $0) - (i32.add - (tee_local $4 - (i32.load - (get_local $8) - ) - ) - (i32.load offset=48 - (get_local $0) - ) - ) - ) - (i32.store - (get_local $7) - (tee_local $8 - (get_local $4) - ) - ) - (i32.store - (get_local $13) - (get_local $4) - ) - (set_local $15 - (get_local $2) - ) - ) - (if + (set_local $15 + (if (result i32) (i32.eq (get_local $1) - (i32.const 8) + (i32.const 6) ) - (block + (block (result i32) (i32.store offset=16 (get_local $0) - (i32.const 0) + (i32.add + (tee_local $4 + (i32.load + (get_local $8) + ) + ) + (i32.load offset=48 + (get_local $0) + ) + ) ) (i32.store (get_local $7) - (i32.const 0) + (tee_local $8 + (get_local $4) + ) ) (i32.store (get_local $13) - (i32.const 0) + (get_local $4) ) - (i32.store - (get_local $0) - (i32.or - (i32.load - (get_local $0) + (get_local $2) + ) + (if (result i32) + (i32.eq + (get_local $1) + (i32.const 8) + ) + (block (result i32) + (i32.store offset=16 + (get_local $0) + (i32.const 0) + ) + (i32.store + (get_local $7) + (i32.const 0) + ) + (i32.store + (get_local $13) + (i32.const 0) + ) + (i32.store + (get_local $0) + (i32.or + (i32.load + (get_local $0) + ) + (i32.const 32) ) - (i32.const 32) ) - ) - (set_local $15 (if (result i32) (i32.eq (get_local $17) @@ -8040,6 +8038,7 @@ ) ) ) + (get_local $15) ) ) ) @@ -8311,91 +8310,89 @@ ) ) ) - (if - (i32.eq - (get_local $2) - (i32.const 4) - ) - (block - (set_local $2 - (get_local $1) + (i32.sub + (if (result i32) + (i32.eq + (get_local $2) + (i32.const 4) ) - (set_local $0 - (loop $while-in1 (result i32) - (if (result i32) - (i32.and - (i32.add - (tee_local $1 - (i32.load - (get_local $2) + (block (result i32) + (set_local $2 + (get_local $1) + ) + (set_local $0 + (loop $while-in1 (result i32) + (if (result i32) + (i32.and + (i32.add + (tee_local $1 + (i32.load + (get_local $2) + ) ) + (i32.const -16843009) ) - (i32.const -16843009) - ) - (i32.xor - (i32.and - (get_local $1) + (i32.xor + (i32.and + (get_local $1) + (i32.const -2139062144) + ) (i32.const -2139062144) ) - (i32.const -2139062144) ) - ) - (get_local $2) - (block - (set_local $2 - (i32.add - (get_local $2) - (i32.const 4) + (get_local $2) + (block + (set_local $2 + (i32.add + (get_local $2) + (i32.const 4) + ) ) + (br $while-in1) ) - (br $while-in1) ) ) ) - ) - (if - (i32.and - (get_local $1) - (i32.const 255) - ) - (block - (set_local $1 - (get_local $0) + (if + (i32.and + (get_local $1) + (i32.const 255) ) - (loop $while-in3 - (if - (i32.load8_s - (tee_local $0 - (i32.add - (get_local $1) - (i32.const 1) + (block + (set_local $1 + (get_local $0) + ) + (loop $while-in3 + (if + (i32.load8_s + (tee_local $0 + (i32.add + (get_local $1) + (i32.const 1) + ) ) ) - ) - (block - (set_local $1 - (get_local $0) + (block + (set_local $1 + (get_local $0) + ) + (br $while-in3) ) - (br $while-in3) ) ) ) ) - ) - (set_local $5 (get_local $0) ) + (get_local $5) ) - ) - (i32.sub - (get_local $5) (get_local $3) ) ) (func $_a (; 18 ;) (; has Stack IR ;) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) - (tee_local $1 + (tee_local $2 (if (result i32) (get_local $0) (block $do-once (result i32) @@ -8434,22 +8431,22 @@ (i32.const 1188) ) (if - (tee_local $2 + (tee_local $1 (i32.load (i32.const 1184) ) ) (block - (set_local $1 - (get_local $2) - ) (set_local $2 + (get_local $1) + ) + (set_local $1 (get_local $0) ) (loop $while-in (drop (i32.load offset=76 - (get_local $1) + (get_local $2) ) ) (set_local $0 @@ -8458,38 +8455,38 @@ (if (i32.gt_u (i32.load offset=20 - (get_local $1) + (get_local $2) ) (i32.load offset=28 - (get_local $1) + (get_local $2) ) ) - (set_local $2 + (set_local $1 (i32.or (call $$a - (get_local $1) + (get_local $2) ) - (get_local $2) + (get_local $1) ) ) ) (br_if $while-in - (tee_local $1 + (tee_local $2 (i32.load offset=56 - (get_local $1) + (get_local $2) ) ) ) ) ) - (set_local $2 + (set_local $1 (get_local $0) ) ) (call $xa (i32.const 1188) ) - (get_local $2) + (get_local $1) ) ) ) @@ -9222,14 +9219,10 @@ ) (func $bb (; 26 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) - (local $4 i32) - (set_local $4 - (i32.const 1) - ) (set_local $3 (get_local $1) ) - (if + (if (result i32) (block (result i32) (drop (i32.load offset=76 @@ -9247,18 +9240,16 @@ ) ) ) - (set_local $4 - (if (result i32) + (if (result i32) + (get_local $1) + (i32.div_u + (get_local $0) (get_local $1) - (i32.div_u - (get_local $0) - (get_local $1) - ) - (i32.const 0) ) + (i32.const 0) ) + (i32.const 1) ) - (get_local $4) ) (func $Ua (; 27 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) diff --git a/test/memorygrowth.fromasm.clamp b/test/memorygrowth.fromasm.clamp index 46e4beb04..3dac1de09 100644 --- a/test/memorygrowth.fromasm.clamp +++ b/test/memorygrowth.fromasm.clamp @@ -1573,7 +1573,7 @@ (get_local $2) ) (block - (set_local $29 + (set_local $30 (get_local $13) ) (set_local $28 @@ -1825,7 +1825,7 @@ ) ) (block - (set_local $29 + (set_local $30 (get_local $36) ) (set_local $28 @@ -1870,13 +1870,13 @@ (get_local $0) ) ) - (get_local $29) + (get_local $30) ) ) (set_local $6 (select (get_local $9) - (get_local $29) + (get_local $30) (get_local $3) ) ) @@ -1894,7 +1894,7 @@ ) ) (block - (set_local $29 + (set_local $30 (get_local $6) ) (set_local $28 @@ -1914,7 +1914,7 @@ ) ) (block - (set_local $29 + (set_local $30 (get_local $6) ) (set_local $32 @@ -3518,15 +3518,15 @@ ) ) (block - (set_local $20 - (get_local $4) - ) (set_local $26 (get_local $12) ) (set_local $8 (i32.const 191) ) + (set_local $20 + (get_local $4) + ) ) ) ) @@ -3783,7 +3783,7 @@ ) ) ) - (set_local $30 + (set_local $29 (i32.const 1656) ) ) @@ -3793,7 +3793,7 @@ (get_local $8) (i32.const 209) ) - (set_local $30 + (set_local $29 (if (result i32) (i32.and (i32.load offset=12 @@ -4951,7 +4951,7 @@ (i32.le_u (tee_local $1 (i32.load - (get_local $30) + (get_local $29) ) ) (get_local $12) @@ -4961,7 +4961,7 @@ (tee_local $16 (i32.add (i32.load offset=4 - (get_local $30) + (get_local $29) ) (get_local $1) ) @@ -4976,9 +4976,9 @@ ) ) ) - (set_local $30 + (set_local $29 (i32.load offset=8 - (get_local $30) + (get_local $29) ) ) (br $while-in66) @@ -7965,67 +7965,65 @@ (br $while-in) ) ) - (if - (i32.eq - (get_local $1) - (i32.const 6) - ) - (block - (i32.store offset=16 - (get_local $0) - (i32.add - (tee_local $4 - (i32.load - (get_local $8) - ) - ) - (i32.load offset=48 - (get_local $0) - ) - ) - ) - (i32.store - (get_local $7) - (tee_local $8 - (get_local $4) - ) - ) - (i32.store - (get_local $13) - (get_local $4) - ) - (set_local $15 - (get_local $2) - ) - ) - (if + (set_local $15 + (if (result i32) (i32.eq (get_local $1) - (i32.const 8) + (i32.const 6) ) - (block + (block (result i32) (i32.store offset=16 (get_local $0) - (i32.const 0) + (i32.add + (tee_local $4 + (i32.load + (get_local $8) + ) + ) + (i32.load offset=48 + (get_local $0) + ) + ) ) (i32.store (get_local $7) - (i32.const 0) + (tee_local $8 + (get_local $4) + ) ) (i32.store (get_local $13) - (i32.const 0) + (get_local $4) ) - (i32.store - (get_local $0) - (i32.or - (i32.load - (get_local $0) + (get_local $2) + ) + (if (result i32) + (i32.eq + (get_local $1) + (i32.const 8) + ) + (block (result i32) + (i32.store offset=16 + (get_local $0) + (i32.const 0) + ) + (i32.store + (get_local $7) + (i32.const 0) + ) + (i32.store + (get_local $13) + (i32.const 0) + ) + (i32.store + (get_local $0) + (i32.or + (i32.load + (get_local $0) + ) + (i32.const 32) ) - (i32.const 32) ) - ) - (set_local $15 (if (result i32) (i32.eq (get_local $17) @@ -8040,6 +8038,7 @@ ) ) ) + (get_local $15) ) ) ) @@ -8311,91 +8310,89 @@ ) ) ) - (if - (i32.eq - (get_local $2) - (i32.const 4) - ) - (block - (set_local $2 - (get_local $1) + (i32.sub + (if (result i32) + (i32.eq + (get_local $2) + (i32.const 4) ) - (set_local $0 - (loop $while-in1 (result i32) - (if (result i32) - (i32.and - (i32.add - (tee_local $1 - (i32.load - (get_local $2) + (block (result i32) + (set_local $2 + (get_local $1) + ) + (set_local $0 + (loop $while-in1 (result i32) + (if (result i32) + (i32.and + (i32.add + (tee_local $1 + (i32.load + (get_local $2) + ) ) + (i32.const -16843009) ) - (i32.const -16843009) - ) - (i32.xor - (i32.and - (get_local $1) + (i32.xor + (i32.and + (get_local $1) + (i32.const -2139062144) + ) (i32.const -2139062144) ) - (i32.const -2139062144) ) - ) - (get_local $2) - (block - (set_local $2 - (i32.add - (get_local $2) - (i32.const 4) + (get_local $2) + (block + (set_local $2 + (i32.add + (get_local $2) + (i32.const 4) + ) ) + (br $while-in1) ) - (br $while-in1) ) ) ) - ) - (if - (i32.and - (get_local $1) - (i32.const 255) - ) - (block - (set_local $1 - (get_local $0) + (if + (i32.and + (get_local $1) + (i32.const 255) ) - (loop $while-in3 - (if - (i32.load8_s - (tee_local $0 - (i32.add - (get_local $1) - (i32.const 1) + (block + (set_local $1 + (get_local $0) + ) + (loop $while-in3 + (if + (i32.load8_s + (tee_local $0 + (i32.add + (get_local $1) + (i32.const 1) + ) ) ) - ) - (block - (set_local $1 - (get_local $0) + (block + (set_local $1 + (get_local $0) + ) + (br $while-in3) ) - (br $while-in3) ) ) ) ) - ) - (set_local $5 (get_local $0) ) + (get_local $5) ) - ) - (i32.sub - (get_local $5) (get_local $3) ) ) (func $_a (; 18 ;) (; has Stack IR ;) (param $0 i32) (result i32) (local $1 i32) (local $2 i32) - (tee_local $1 + (tee_local $2 (if (result i32) (get_local $0) (block $do-once (result i32) @@ -8434,22 +8431,22 @@ (i32.const 1188) ) (if - (tee_local $2 + (tee_local $1 (i32.load (i32.const 1184) ) ) (block - (set_local $1 - (get_local $2) - ) (set_local $2 + (get_local $1) + ) + (set_local $1 (get_local $0) ) (loop $while-in (drop (i32.load offset=76 - (get_local $1) + (get_local $2) ) ) (set_local $0 @@ -8458,38 +8455,38 @@ (if (i32.gt_u (i32.load offset=20 - (get_local $1) + (get_local $2) ) (i32.load offset=28 - (get_local $1) + (get_local $2) ) ) - (set_local $2 + (set_local $1 (i32.or (call $$a - (get_local $1) + (get_local $2) ) - (get_local $2) + (get_local $1) ) ) ) (br_if $while-in - (tee_local $1 + (tee_local $2 (i32.load offset=56 - (get_local $1) + (get_local $2) ) ) ) ) ) - (set_local $2 + (set_local $1 (get_local $0) ) ) (call $xa (i32.const 1188) ) - (get_local $2) + (get_local $1) ) ) ) @@ -9222,14 +9219,10 @@ ) (func $bb (; 26 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) - (local $4 i32) - (set_local $4 - (i32.const 1) - ) (set_local $3 (get_local $1) ) - (if + (if (result i32) (block (result i32) (drop (i32.load offset=76 @@ -9247,18 +9240,16 @@ ) ) ) - (set_local $4 - (if (result i32) + (if (result i32) + (get_local $1) + (i32.div_u + (get_local $0) (get_local $1) - (i32.div_u - (get_local $0) - (get_local $1) - ) - (i32.const 0) ) + (i32.const 0) ) + (i32.const 1) ) - (get_local $4) ) (func $Ua (; 27 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) diff --git a/test/memorygrowth.fromasm.imprecise b/test/memorygrowth.fromasm.imprecise index 72f7b31e4..0044bab54 100644 --- a/test/memorygrowth.fromasm.imprecise +++ b/test/memorygrowth.fromasm.imprecise @@ -1571,7 +1571,7 @@ (get_local $2) ) (block - (set_local $29 + (set_local $30 (get_local $13) ) (set_local $28 @@ -1823,7 +1823,7 @@ ) ) (block - (set_local $29 + (set_local $30 (get_local $36) ) (set_local $28 @@ -1868,13 +1868,13 @@ (get_local $0) ) ) - (get_local $29) + (get_local $30) ) ) (set_local $6 (select (get_local $9) - (get_local $29) + (get_local $30) (get_local $3) ) ) @@ -1892,7 +1892,7 @@ ) ) (block - (set_local $29 + (set_local $30 (get_local $6) ) (set_local $28 @@ -1912,7 +1912,7 @@ ) ) (block - (set_local $29 + (set_local $30 (get_local $6) ) (set_local $32 @@ -3516,15 +3516,15 @@ ) ) (block - (set_local $20 - (get_local $4) - ) (set_local $26 (get_local $12) ) (set_local $8 (i32.const 191) ) + (set_local $20 + (get_local $4) + ) ) ) ) @@ -3781,7 +3781,7 @@ ) ) ) - (set_local $30 + (set_local $29 (i32.const 1656) ) ) @@ -3791,7 +3791,7 @@ (get_local $8) (i32.const 209) ) - (set_local $30 + (set_local $29 (if (result i32) (i32.and (i32.load offset=12 @@ -4949,7 +4949,7 @@ (i32.le_u (tee_local $1 (i32.load - (get_local $30) + (get_local $29) ) ) (get_local $12) @@ -4959,7 +4959,7 @@ (tee_local $16 (i32.add (i32.load offset=4 - (get_local $30) + (get_local $29) ) (get_local $1) ) @@ -4974,9 +4974,9 @@ ) ) ) - (set_local $30 + (set_local $29 (i32.load offset=8 - (get_local $30) + (get_local $29) ) ) (br $while-in66) @@ -7851,10 +7851,10 @@ (i32.const 0) ) (block - (set_local $16 + (set_local $15 (get_local $5) ) - (set_local $17 + (set_local $16 (get_local $3) ) (set_local $1 @@ -7963,12 +7963,15 @@ (br $while-in) ) ) - (if + (set_global $r + (get_local $12) + ) + (if (result i32) (i32.eq (get_local $1) (i32.const 6) ) - (block + (block (result i32) (i32.store offset=16 (get_local $0) (i32.add @@ -7992,16 +7995,14 @@ (get_local $13) (get_local $4) ) - (set_local $15 - (get_local $2) - ) + (get_local $2) ) - (if + (if (result i32) (i32.eq (get_local $1) (i32.const 8) ) - (block + (block (result i32) (i32.store offset=16 (get_local $0) (i32.const 0) @@ -8023,28 +8024,23 @@ (i32.const 32) ) ) - (set_local $15 - (select - (i32.const 0) - (i32.sub - (get_local $2) - (i32.load offset=4 - (get_local $16) - ) - ) - (i32.eq - (get_local $17) - (i32.const 2) + (select + (i32.const 0) + (i32.sub + (get_local $2) + (i32.load offset=4 + (get_local $15) ) ) + (i32.eq + (get_local $16) + (i32.const 2) + ) ) ) + (get_local $17) ) ) - (set_global $r - (get_local $12) - ) - (get_local $15) ) (func $Wa (; 16 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) @@ -8309,84 +8305,82 @@ ) ) ) - (if - (i32.eq - (get_local $2) - (i32.const 4) - ) - (block - (set_local $2 - (get_local $1) + (i32.sub + (if (result i32) + (i32.eq + (get_local $2) + (i32.const 4) ) - (set_local $0 - (loop $while-in1 (result i32) - (if (result i32) - (i32.and - (i32.add - (tee_local $1 - (i32.load - (get_local $2) + (block (result i32) + (set_local $2 + (get_local $1) + ) + (set_local $0 + (loop $while-in1 (result i32) + (if (result i32) + (i32.and + (i32.add + (tee_local $1 + (i32.load + (get_local $2) + ) ) + (i32.const -16843009) ) - (i32.const -16843009) - ) - (i32.xor - (i32.and - (get_local $1) + (i32.xor + (i32.and + (get_local $1) + (i32.const -2139062144) + ) (i32.const -2139062144) ) - (i32.const -2139062144) ) - ) - (get_local $2) - (block - (set_local $2 - (i32.add - (get_local $2) - (i32.const 4) + (get_local $2) + (block + (set_local $2 + (i32.add + (get_local $2) + (i32.const 4) + ) ) + (br $while-in1) ) - (br $while-in1) ) ) ) - ) - (if - (i32.and - (get_local $1) - (i32.const 255) - ) - (block - (set_local $1 - (get_local $0) + (if + (i32.and + (get_local $1) + (i32.const 255) ) - (loop $while-in3 - (if - (i32.load8_s - (tee_local $0 - (i32.add - (get_local $1) - (i32.const 1) + (block + (set_local $1 + (get_local $0) + ) + (loop $while-in3 + (if + (i32.load8_s + (tee_local $0 + (i32.add + (get_local $1) + (i32.const 1) + ) ) ) - ) - (block - (set_local $1 - (get_local $0) + (block + (set_local $1 + (get_local $0) + ) + (br $while-in3) ) - (br $while-in3) ) ) ) ) - ) - (set_local $5 (get_local $0) ) + (get_local $5) ) - ) - (i32.sub - (get_local $5) (get_local $3) ) ) @@ -9052,6 +9046,7 @@ (local $0 i32) (local $1 i32) (local $2 i32) + (local $3 i32) (drop (i32.load offset=76 (tee_local $0 @@ -9063,70 +9058,84 @@ ) (i32.shr_s (i32.shl - (tee_local $1 - (if (result i32) - (i32.lt_s - (i32.add - (call $bb - (i32.const 1144) - (call $Za - (i32.const 1144) + (if (result i32) + (i32.lt_s + (i32.add + (select + (i32.div_u + (tee_local $3 + (call $Wa + (i32.const 1144) + (tee_local $2 + (tee_local $1 + (call $Za + (i32.const 1144) + ) + ) + ) + (get_local $0) + ) ) - (get_local $0) + (get_local $1) + ) + (i32.const 1) + (i32.ne + (get_local $2) + (get_local $3) ) - (i32.const -1) ) - (i32.const 0) + (i32.const -1) ) - (i32.const 1) - (block $do-once (result i32) - (if - (i32.ne - (i32.load8_s offset=75 - (get_local $0) - ) - (i32.const 10) + (i32.const 0) + ) + (i32.const 1) + (block $do-once (result i32) + (if + (i32.ne + (i32.load8_s offset=75 + (get_local $0) ) - (if - (i32.lt_u - (tee_local $1 - (i32.load - (tee_local $2 - (i32.add - (get_local $0) - (i32.const 20) - ) + (i32.const 10) + ) + (if + (i32.lt_u + (tee_local $1 + (i32.load + (tee_local $2 + (i32.add + (get_local $0) + (i32.const 20) ) ) ) - (i32.load offset=16 - (get_local $0) - ) ) - (block - (i32.store - (get_local $2) - (i32.add - (get_local $1) - (i32.const 1) - ) - ) - (i32.store8 + (i32.load offset=16 + (get_local $0) + ) + ) + (block + (i32.store + (get_local $2) + (i32.add (get_local $1) - (i32.const 10) - ) - (br $do-once - (i32.const 0) + (i32.const 1) ) ) + (i32.store8 + (get_local $1) + (i32.const 10) + ) + (br $do-once + (i32.const 0) + ) ) ) - (i32.lt_s - (call $ab - (get_local $0) - ) - (i32.const 0) + ) + (i32.lt_s + (call $ab + (get_local $0) ) + (i32.const 0) ) ) ) @@ -9213,36 +9222,7 @@ ) ) ) - (func $bb (; 26 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) - (local $3 i32) - (local $4 i32) - (set_local $4 - (i32.const 1) - ) - (set_local $3 - (get_local $1) - ) - (if - (i32.ne - (get_local $3) - (tee_local $0 - (call $Wa - (get_local $0) - (get_local $3) - (get_local $2) - ) - ) - ) - (set_local $4 - (i32.div_u - (get_local $0) - (get_local $1) - ) - ) - ) - (get_local $4) - ) - (func $Ua (; 27 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $Ua (; 26 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (set_local $4 @@ -9311,7 +9291,7 @@ ) (get_local $0) ) - (func $Va (; 28 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $Va (; 27 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (local $3 i32) (local $4 i32) (set_local $4 @@ -9381,7 +9361,7 @@ ) (get_local $3) ) - (func $Oa (; 29 ;) (; has Stack IR ;) (param $0 i32) (result i32) + (func $Oa (; 28 ;) (; has Stack IR ;) (param $0 i32) (result i32) (local $1 i32) (set_local $1 (get_global $r) @@ -9411,7 +9391,7 @@ ) (get_local $0) ) - (func $Pa (; 30 ;) (; has Stack IR ;) (param $0 i32) (result i32) + (func $Pa (; 29 ;) (; has Stack IR ;) (param $0 i32) (result i32) (if (result i32) (i32.gt_u (get_local $0) @@ -9430,7 +9410,7 @@ (get_local $0) ) ) - (func $Qa (; 31 ;) (; has Stack IR ;) (result i32) + (func $Qa (; 30 ;) (; has Stack IR ;) (result i32) (select (i32.load (i32.const 64) @@ -9441,7 +9421,7 @@ ) ) ) - (func $lb (; 32 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) + (func $lb (; 31 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (param $3 i32) (result i32) (call_indirect (type $FUNCSIG$iiii) (get_local $1) (get_local $2) @@ -9455,7 +9435,7 @@ ) ) ) - (func $Ea (; 33 ;) (; has Stack IR ;) (param $0 i32) (result i32) + (func $Ea (; 32 ;) (; has Stack IR ;) (param $0 i32) (result i32) (local $1 i32) (set_local $1 (get_global $r) @@ -9477,13 +9457,13 @@ ) (get_local $1) ) - (func $ob (; 34 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) + (func $ob (; 33 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (param $2 i32) (result i32) (call $ja (i32.const 1) ) (i32.const 0) ) - (func $Ia (; 35 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) + (func $Ia (; 34 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (if (i32.eqz (get_global $v) @@ -9498,7 +9478,7 @@ ) ) ) - (func $kb (; 36 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32) + (func $kb (; 35 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32) (call_indirect (type $FUNCSIG$ii) (get_local $1) (i32.and @@ -9507,10 +9487,10 @@ ) ) ) - (func $Sa (; 37 ;) (; has Stack IR ;) (param $0 i32) + (func $Sa (; 36 ;) (; has Stack IR ;) (param $0 i32) (nop) ) - (func $mb (; 38 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) + (func $mb (; 37 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (call_indirect (type $FUNCSIG$vi) (get_local $1) (i32.add @@ -9522,7 +9502,7 @@ ) ) ) - (func $Ha (; 39 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) + (func $Ha (; 38 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (set_global $r (get_local $0) ) @@ -9530,40 +9510,40 @@ (get_local $1) ) ) - (func $nb (; 40 ;) (; has Stack IR ;) (param $0 i32) (result i32) + (func $nb (; 39 ;) (; has Stack IR ;) (param $0 i32) (result i32) (call $ja (i32.const 0) ) (i32.const 0) ) - (func $Na (; 41 ;) (; has Stack IR ;) (result i32) + (func $Na (; 40 ;) (; has Stack IR ;) (result i32) (drop (call $db) ) (i32.const 0) ) - (func $pb (; 42 ;) (; has Stack IR ;) (param $0 i32) + (func $pb (; 41 ;) (; has Stack IR ;) (param $0 i32) (call $ja (i32.const 2) ) ) - (func $La (; 43 ;) (; has Stack IR ;) (param $0 i32) + (func $La (; 42 ;) (; has Stack IR ;) (param $0 i32) (set_global $K (get_local $0) ) ) - (func $Ga (; 44 ;) (; has Stack IR ;) (param $0 i32) + (func $Ga (; 43 ;) (; has Stack IR ;) (param $0 i32) (set_global $r (get_local $0) ) ) - (func $Ma (; 45 ;) (; has Stack IR ;) (result i32) + (func $Ma (; 44 ;) (; has Stack IR ;) (result i32) (get_global $K) ) - (func $Fa (; 46 ;) (; has Stack IR ;) (result i32) + (func $Fa (; 45 ;) (; has Stack IR ;) (result i32) (get_global $r) ) - (func $ib (; 47 ;) (; has Stack IR ;) (result i32) + (func $ib (; 46 ;) (; has Stack IR ;) (result i32) (i32.const 0) ) ) diff --git a/test/passes/inlining-optimizing_optimize-level=3.txt b/test/passes/inlining-optimizing_optimize-level=3.txt index 0a2d39db3..35d1219fe 100644 --- a/test/passes/inlining-optimizing_optimize-level=3.txt +++ b/test/passes/inlining-optimizing_optimize-level=3.txt @@ -2322,16 +2322,16 @@ (block $label$break$L1 (if (i32.gt_s - (get_local $17) + (get_local $16) (i32.const -1) ) - (set_local $17 + (set_local $16 (if (result i32) (i32.gt_s (get_local $10) (i32.sub (i32.const 2147483647) - (get_local $17) + (get_local $16) ) ) (block (result i32) @@ -2343,7 +2343,7 @@ ) (i32.add (get_local $10) - (get_local $17) + (get_local $16) ) ) ) @@ -2709,7 +2709,7 @@ (set_local $8 (i32.const 1) ) - (set_local $16 + (set_local $17 (i32.load (get_local $6) ) @@ -2724,7 +2724,7 @@ (if (get_local $8) (block - (set_local $17 + (set_local $16 (i32.const -1) ) (br $label$break$L1) @@ -2741,7 +2741,7 @@ (set_local $10 (get_local $6) ) - (set_local $16 + (set_local $17 (i32.const 0) ) (br $do-once5 @@ -2749,7 +2749,7 @@ ) ) ) - (set_local $16 + (set_local $17 (i32.load (tee_local $10 (i32.and @@ -2780,14 +2780,14 @@ (set_local $12 (if (result i32) (i32.lt_s - (get_local $16) + (get_local $17) (i32.const 0) ) (block (result i32) - (set_local $16 + (set_local $17 (i32.sub (i32.const 0) - (get_local $16) + (get_local $17) ) ) (i32.or @@ -2864,7 +2864,7 @@ (i32.const 0) ) (block - (set_local $17 + (set_local $16 (i32.const -1) ) (br $label$break$L1) @@ -2873,7 +2873,7 @@ (set_local $12 (get_local $1) ) - (set_local $16 + (set_local $17 (get_local $6) ) (get_local $8) @@ -2884,7 +2884,7 @@ (set_local $12 (get_local $1) ) - (set_local $16 + (set_local $17 (i32.const 0) ) (get_local $8) @@ -3056,7 +3056,7 @@ (if (get_local $1) (block - (set_local $17 + (set_local $16 (i32.const -1) ) (br $label$break$L1) @@ -3123,7 +3123,7 @@ (i32.const 57) ) (block - (set_local $17 + (set_local $16 (i32.const -1) ) (br $label$break$L1) @@ -3183,7 +3183,7 @@ ) ) (block - (set_local $17 + (set_local $16 (i32.const -1) ) (br $label$break$L1) @@ -3208,7 +3208,7 @@ (if (get_local $8) (block - (set_local $17 + (set_local $16 (i32.const -1) ) (br $label$break$L1) @@ -3260,7 +3260,7 @@ (get_local $28) ) (block - (set_local $17 + (set_local $16 (i32.const 0) ) (br $label$break$L1) @@ -3384,7 +3384,7 @@ (i32.load (get_local $14) ) - (get_local $17) + (get_local $16) ) (set_local $5 (get_local $10) @@ -3398,7 +3398,7 @@ (i32.load (get_local $14) ) - (get_local $17) + (get_local $16) ) (set_local $5 (get_local $10) @@ -3414,14 +3414,14 @@ (get_local $14) ) ) - (get_local $17) + (get_local $16) ) (i32.store offset=4 (get_local $5) (i32.shr_s (i32.shl (i32.lt_s - (get_local $17) + (get_local $16) (i32.const 0) ) (i32.const 31) @@ -3441,7 +3441,7 @@ (i32.load (get_local $14) ) - (get_local $17) + (get_local $16) ) (set_local $5 (get_local $10) @@ -3455,7 +3455,7 @@ (i32.load (get_local $14) ) - (get_local $17) + (get_local $16) ) (set_local $5 (get_local $10) @@ -3469,7 +3469,7 @@ (i32.load (get_local $14) ) - (get_local $17) + (get_local $16) ) (set_local $5 (get_local $10) @@ -3485,14 +3485,14 @@ (get_local $14) ) ) - (get_local $17) + (get_local $16) ) (i32.store offset=4 (get_local $5) (i32.shr_s (i32.shl (i32.lt_s - (get_local $17) + (get_local $16) (i32.const 0) ) (i32.const 31) @@ -3832,7 +3832,7 @@ (call $_pad (get_local $0) (i32.const 32) - (get_local $16) + (get_local $17) (i32.const 0) (get_local $12) ) @@ -4047,6 +4047,12 @@ ) ) ) + (set_local $11 + (i32.or + (get_local $27) + (i32.const 2) + ) + ) (if (i32.eq (tee_local $5 @@ -4093,12 +4099,6 @@ ) ) ) - (set_local $11 - (i32.or - (get_local $27) - (i32.const 2) - ) - ) (i32.store8 (i32.add (get_local $5) @@ -4243,7 +4243,7 @@ (call $_pad (get_local $0) (i32.const 32) - (get_local $16) + (get_local $17) (tee_local $7 (i32.add (tee_local $6 @@ -4302,7 +4302,7 @@ (call $_pad (get_local $0) (i32.const 48) - (get_local $16) + (get_local $17) (get_local $7) (i32.xor (get_local $12) @@ -4370,7 +4370,7 @@ (call $_pad (get_local $0) (i32.const 32) - (get_local $16) + (get_local $17) (get_local $7) (i32.xor (get_local $12) @@ -4379,11 +4379,11 @@ ) (br $do-once49 (select - (get_local $16) + (get_local $17) (get_local $7) (i32.lt_s (get_local $7) - (get_local $16) + (get_local $17) ) ) ) @@ -5356,7 +5356,7 @@ (call $_pad (get_local $0) (i32.const 32) - (get_local $16) + (get_local $17) (tee_local $13 (i32.add (i32.add @@ -5748,7 +5748,7 @@ (call $_pad (get_local $0) (i32.const 48) - (get_local $16) + (get_local $17) (get_local $13) (i32.xor (get_local $12) @@ -6223,7 +6223,7 @@ (call $_pad (get_local $0) (i32.const 32) - (get_local $16) + (get_local $17) (get_local $13) (i32.xor (get_local $12) @@ -6231,11 +6231,11 @@ ) ) (select - (get_local $16) + (get_local $17) (get_local $13) (i32.lt_s (get_local $13) - (get_local $16) + (get_local $17) ) ) ) @@ -6243,7 +6243,7 @@ (call $_pad (get_local $0) (i32.const 32) - (get_local $16) + (get_local $17) (tee_local $7 (i32.add (tee_local $9 @@ -6263,32 +6263,6 @@ ) (get_local $8) ) - (if - (i32.eqz - (i32.and - (tee_local $5 - (i32.load - (get_local $0) - ) - ) - (i32.const 32) - ) - ) - (block - (drop - (call $___fwritex - (get_local $30) - (get_local $9) - (get_local $0) - ) - ) - (set_local $5 - (i32.load - (get_local $0) - ) - ) - ) - ) (set_local $6 (select (select @@ -6313,10 +6287,38 @@ ) ) (if - (i32.eqz - (i32.and - (get_local $5) - (i32.const 32) + (block (result i32) + (if + (i32.eqz + (i32.and + (tee_local $5 + (i32.load + (get_local $0) + ) + ) + (i32.const 32) + ) + ) + (block + (drop + (call $___fwritex + (get_local $30) + (get_local $9) + (get_local $0) + ) + ) + (set_local $5 + (i32.load + (get_local $0) + ) + ) + ) + ) + (i32.eqz + (i32.and + (get_local $5) + (i32.const 32) + ) ) ) (drop @@ -6330,7 +6332,7 @@ (call $_pad (get_local $0) (i32.const 32) - (get_local $16) + (get_local $17) (get_local $7) (i32.xor (get_local $12) @@ -6338,11 +6340,11 @@ ) ) (select - (get_local $16) + (get_local $17) (get_local $7) (i32.lt_s (get_local $7) - (get_local $16) + (get_local $17) ) ) ) @@ -6614,7 +6616,7 @@ (i32.const 0) ) (block - (set_local $17 + (set_local $16 (i32.const -1) ) (br $label$break$L1) @@ -6623,7 +6625,7 @@ (call $_pad (get_local $0) (i32.const 32) - (get_local $16) + (get_local $17) (get_local $5) (get_local $12) ) @@ -6718,7 +6720,7 @@ (call $_pad (get_local $0) (i32.const 32) - (get_local $16) + (get_local $17) (get_local $7) (i32.xor (get_local $12) @@ -6730,10 +6732,10 @@ ) (set_local $10 (select - (get_local $16) + (get_local $17) (get_local $7) (i32.gt_s - (get_local $16) + (get_local $17) (get_local $7) ) ) @@ -6821,9 +6823,9 @@ (get_local $8) ) ) - (get_local $16) + (get_local $17) (i32.lt_s - (get_local $16) + (get_local $17) (get_local $5) ) ) @@ -6949,7 +6951,7 @@ (i32.const 10) ) ) - (set_local $17 + (set_local $16 (i32.const 1) ) (br $label$break$L343) @@ -6973,7 +6975,7 @@ ) ) (block - (set_local $17 + (set_local $16 (i32.const -1) ) (br $label$break$L343) @@ -6990,16 +6992,16 @@ (i32.const 10) ) ) - (set_local $17 + (set_local $16 (i32.const 1) ) ) - (set_local $17 + (set_local $16 (i32.const 1) ) ) ) - (set_local $17 + (set_local $16 (i32.const 0) ) ) @@ -7008,7 +7010,7 @@ (set_global $STACKTOP (get_local $34) ) - (get_local $17) + (get_local $16) ) (func $_pop_arg_336 (; 45 ;) (type $10) (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i32) diff --git a/test/passes/simplify-locals.txt b/test/passes/simplify-locals.txt index 2e380049f..ae1355032 100644 --- a/test/passes/simplify-locals.txt +++ b/test/passes/simplify-locals.txt @@ -7,16 +7,20 @@ (type $5 (func (param i32) (result i32))) (type $6 (func (param i32 i32 i32 i32 i32 i32))) (type $FUNCSIG$iii (func (param i32 i32) (result i32))) - (type $8 (func (param i32 i32))) - (type $9 (func (param i32 i32 i32) (result i32))) - (type $10 (func (param i64))) + (type $FUNCSIG$vf (func (param f32))) + (type $9 (func (param i32 i32))) + (type $10 (func (param i32 i32 i32) (result i32))) + (type $11 (func (param i64))) + (type $12 (func (param i32 f64 f64 f32 i32) (result f64))) (import "env" "waka" (func $waka)) (import "env" "waka_int" (func $waka_int (result i32))) (import "env" "i64sub" (func $_i64Subtract (param i32 i32 i32 i32) (result i32))) (import "env" "moddi" (func $___udivmoddi4 (param i32 i32 i32 i32 i32) (result i32))) (import "env" "lp" (func $lp (param i32 i32) (result i32))) + (import "fuzzing-support" "log-f32" (func $fimport$0 (param f32))) (memory $0 256 256) - (func $contrast (; 5 ;) (type $FUNCSIG$v) + (global $global$0 (mut i32) (i32.const 10)) + (func $contrast (; 6 ;) (type $FUNCSIG$v) (local $x i32) (local $y i32) (local $z i32) @@ -78,7 +82,7 @@ ) ) ) - (func $b0-yes (; 6 ;) (type $4) (param $i1 i32) + (func $b0-yes (; 7 ;) (type $4) (param $i1 i32) (local $x i32) (local $y i32) (local $a i32) @@ -400,7 +404,7 @@ ) ) ) - (func $Ia (; 7 ;) (type $5) (param $a i32) (result i32) + (func $Ia (; 8 ;) (type $5) (param $a i32) (result i32) (local $b i32) (block $switch$0 (block $switch-default$6 @@ -411,7 +415,7 @@ (i32.const 60) ) ) - (func $memories (; 8 ;) (type $6) (param $i2 i32) (param $i3 i32) (param $bi2 i32) (param $bi3 i32) (param $ci3 i32) (param $di3 i32) + (func $memories (; 9 ;) (type $6) (param $i2 i32) (param $i3 i32) (param $bi2 i32) (param $bi3 i32) (param $ci3 i32) (param $di3 i32) (local $set_with_no_get i32) (nop) (i32.store8 @@ -443,7 +447,7 @@ (i32.const 456) ) ) - (func $___remdi3 (; 9 ;) (type $FUNCSIG$iiiii) (param $$a$0 i32) (param $$a$1 i32) (param $$b$0 i32) (param $$b$1 i32) (result i32) + (func $___remdi3 (; 10 ;) (type $FUNCSIG$iiiii) (param $$a$0 i32) (param $$a$1 i32) (param $$b$0 i32) (param $$b$1 i32) (result i32) (local $$1$1 i32) (local $$1$0 i32) (local $$rem i32) @@ -636,7 +640,7 @@ ) ) ) - (func $block-returns (; 10 ;) (type $FUNCSIG$v) + (func $block-returns (; 11 ;) (type $FUNCSIG$v) (local $x i32) (set_local $x (block $out (result i32) @@ -685,12 +689,16 @@ (tee_local $x (if (result i32) (i32.const 1) - (block $block3 (result i32) - (nop) + (block (result i32) + (block $block3 + (nop) + ) (i32.const 14) ) - (block $block5 (result i32) - (nop) + (block (result i32) + (block $block5 + (nop) + ) (i32.const 25) ) ) @@ -706,7 +714,7 @@ ) ) ) - (func $multiple (; 11 ;) (type $6) (param $s i32) (param $r i32) (param $f i32) (param $p i32) (param $t i32) (param $m i32) + (func $multiple (; 12 ;) (type $6) (param $s i32) (param $r i32) (param $f i32) (param $p i32) (param $t i32) (param $m i32) (nop) (set_local $r (i32.add @@ -733,7 +741,7 @@ (get_local $t) ) ) - (func $switch-def (; 12 ;) (type $5) (param $i3 i32) (result i32) + (func $switch-def (; 13 ;) (type $5) (param $i3 i32) (result i32) (local $i1 i32) (set_local $i1 (i32.const 10) @@ -752,7 +760,7 @@ (get_local $i1) ) ) - (func $no-out-of-label (; 13 ;) (type $8) (param $x i32) (param $y i32) + (func $no-out-of-label (; 14 ;) (type $9) (param $x i32) (param $y i32) (nop) (set_local $x (loop $moar (result i32) @@ -778,7 +786,7 @@ (get_local $y) ) ) - (func $freetype-cd (; 14 ;) (type $5) (param $a i32) (result i32) + (func $freetype-cd (; 15 ;) (type $5) (param $a i32) (result i32) (local $e i32) (nop) (tee_local $a @@ -805,7 +813,7 @@ ) ) ) - (func $drop-if-value (; 15 ;) (type $9) (param $x i32) (param $y i32) (param $z i32) (result i32) + (func $drop-if-value (; 16 ;) (type $10) (param $x i32) (param $y i32) (param $z i32) (result i32) (local $temp i32) (drop (if (result i32) @@ -833,7 +841,7 @@ (i32.const 0) ) ) - (func $drop-br_if (; 16 ;) (type $9) (param $label i32) (param $$cond2 i32) (param $$$0151 i32) (result i32) + (func $drop-br_if (; 17 ;) (type $10) (param $label i32) (param $$cond2 i32) (param $$$0151 i32) (result i32) (nop) (tee_local $label (block $label$break$L4 (result i32) @@ -865,7 +873,7 @@ ) ) ) - (func $drop-tee-unreachable (; 17 ;) (type $FUNCSIG$v) + (func $drop-tee-unreachable (; 18 ;) (type $FUNCSIG$v) (local $x i32) (tee_local $x (unreachable) @@ -874,7 +882,7 @@ (get_local $x) ) ) - (func $if-return-but-unreachable (; 18 ;) (type $10) (param $var$0 i64) + (func $if-return-but-unreachable (; 19 ;) (type $11) (param $var$0 i64) (if (unreachable) (drop @@ -885,6 +893,231 @@ ) ) ) + (func $if-one-side (; 20 ;) (type $FUNCSIG$i) (result i32) + (local $x i32) + (nop) + (tee_local $x + (if (result i32) + (i32.const 1) + (block (result i32) + (nop) + (i32.const 2) + ) + (get_local $x) + ) + ) + ) + (func $if-one-side-undo (; 21 ;) (type $FUNCSIG$i) (result i32) + (local $x i32) + (local $y i32) + (set_local $y + (i32.const 0) + ) + (set_local $x + (if (result i32) + (i32.const 1) + (block (result i32) + (nop) + (i32.const 2) + ) + (get_local $x) + ) + ) + (get_local $y) + ) + (func $if-one-side-multi (; 22 ;) (type $5) (param $0 i32) (result i32) + (nop) + (tee_local $0 + (if (result i32) + (i32.lt_s + (get_local $0) + (i32.const -1073741824) + ) + (block (result i32) + (nop) + (i32.const -1073741824) + ) + (block (result i32) + (nop) + (if (result i32) + (i32.gt_s + (get_local $0) + (i32.const 1073741823) + ) + (block (result i32) + (nop) + (i32.const 1073741823) + ) + (get_local $0) + ) + ) + ) + ) + ) + (func $if-one-side-undo-but-its-a-tee (; 23 ;) (type $5) (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $x i32) + (local $y i32) + (local $z i32) + (set_local $x + (if (result i32) + (i32.const -1) + (i32.const -2) + (get_local $x) + ) + ) + (drop + (call $if-one-side-undo-but-its-a-tee + (tee_local $x + (if (result i32) + (i32.const -3) + (i32.const -4) + (get_local $x) + ) + ) + ) + ) + (nop) + (drop + (i32.eqz + (tee_local $y + (if (result i32) + (i32.const -5) + (i32.const -6) + (get_local $y) + ) + ) + ) + ) + (nop) + (drop + (i32.add + (tee_local $z + (if (result i32) + (i32.const -7) + (i32.const -8) + (get_local $z) + ) + ) + (get_local $z) + ) + ) + (if + (block $label$1 (result i32) + (nop) + (nop) + (tee_local $4 + (if (result i32) + (tee_local $4 + (if (result i32) + (i32.const 1) + (block (result i32) + (nop) + (i32.const 2) + ) + (get_local $4) + ) + ) + (block (result i32) + (nop) + (i32.const 0) + ) + (get_local $4) + ) + ) + ) + (unreachable) + ) + (i32.const 0) + ) + (func $splittable-ifs-multicycle (; 24 ;) (type $5) (param $20 i32) (result i32) + (nop) + (tee_local $20 + (if (result i32) + (i32.const 1) + (if (result i32) + (i32.const 2) + (if (result i32) + (i32.const 3) + (i32.const 4) + (get_local $20) + ) + (get_local $20) + ) + (get_local $20) + ) + ) + ) + (func $update-getCounter (; 25 ;) (type $12) (param $0 i32) (param $1 f64) (param $2 f64) (param $3 f32) (param $4 i32) (result f64) + (set_global $global$0 + (i32.sub + (get_global $global$0) + (i32.const 1) + ) + ) + (set_global $global$0 + (i32.sub + (get_global $global$0) + (i32.const 1) + ) + ) + (loop $label$1 (result f64) + (set_global $global$0 + (i32.sub + (get_global $global$0) + (i32.const 1) + ) + ) + (set_global $global$0 + (i32.sub + (get_global $global$0) + (i32.const 1) + ) + ) + (call $fimport$0 + (tee_local $3 + (if (result f32) + (i32.eqz + (get_local $0) + ) + (f32.const 4623408228068004207103214e13) + (get_local $3) + ) + ) + ) + (set_global $global$0 + (i32.sub + (get_global $global$0) + (i32.const 1) + ) + ) + (if (result f64) + (get_global $global$0) + (block $block + (set_global $global$0 + (i32.sub + (get_global $global$0) + (i32.const 1) + ) + ) + (set_local $0 + (i32.const -65) + ) + (set_global $global$0 + (i32.sub + (get_global $global$0) + (i32.const 1) + ) + ) + (br $label$1) + ) + (f64.const -70) + ) + ) + ) ) (module (type $FUNCSIG$v (func)) @@ -1118,20 +1351,24 @@ (drop (if (result i32) (i32.const 1) - (block $block - (drop - (i32.const 2) - ) - (drop - (i32.const 3) + (block + (block $block + (drop + (i32.const 2) + ) + (drop + (i32.const 3) + ) + (br $out) ) - (br $out) (nop) ) - (block $block2 (result i32) - (nop) - (drop - (i32.const 5) + (block (result i32) + (block $block2 + (nop) + (drop + (i32.const 5) + ) ) (i32.const 4) ) @@ -1140,21 +1377,25 @@ (drop (if (result i32) (i32.const 6) - (block $block4 (result i32) - (nop) - (drop - (i32.const 8) + (block (result i32) + (block $block4 + (nop) + (drop + (i32.const 8) + ) ) (i32.const 7) ) - (block $block5 - (drop - (i32.const 9) - ) - (drop - (i32.const 10) + (block + (block $block5 + (drop + (i32.const 9) + ) + (drop + (i32.const 10) + ) + (br $out) ) - (br $out) (nop) ) ) @@ -1241,38 +1482,46 @@ (func $pick (; 16 ;) (type $FUNCSIG$v) (local $x i32) (local $y i32) - (drop + (set_local $x (get_local $y) ) - (if - (i32.const 1) - (drop + (drop + (if (result i32) (i32.const 1) + (block (result i32) + (nop) + (i32.const 1) + ) + (get_local $x) ) ) (drop (get_local $y) ) - (drop + (set_local $x (get_local $y) ) ) (func $pick-2 (; 17 ;) (type $FUNCSIG$v) (local $x i32) (local $y i32) - (drop + (set_local $y (get_local $x) ) - (if - (i32.const 1) - (drop + (drop + (if (result i32) (i32.const 1) + (block (result i32) + (nop) + (i32.const 1) + ) + (get_local $y) ) ) (drop (get_local $x) ) - (drop + (set_local $y (get_local $x) ) ) @@ -1284,29 +1533,39 @@ (nop) (nop) (set_local $z - (get_local $x) + (tee_local $y + (get_local $x) + ) ) (drop (get_local $x) ) - (if - (i32.const 1) - (drop + (set_local $y + (if (result i32) (i32.const 1) + (block (result i32) + (nop) + (i32.const 1) + ) + (get_local $y) ) ) (set_local $x (get_local $z) ) - (if - (i32.const 1) - (drop + (drop + (if (result i32) (i32.const 1) + (block (result i32) + (nop) + (i32.const 1) + ) + (get_local $y) ) ) (nop) (nop) - (drop + (set_local $y (get_local $x) ) (nop) @@ -1315,15 +1574,19 @@ (i32.const 2) ) ) - (if - (i32.const 1) - (drop + (drop + (if (result i32) (i32.const 1) + (block (result i32) + (nop) + (i32.const 1) + ) + (get_local $y) ) ) (nop) (nop) - (drop + (set_local $y (get_local $x) ) (set_local $z @@ -1379,9 +1642,11 @@ (nop) (i32.const 2) ) - (block $block (result i32) - (nop) - (nop) + (block (result i32) + (block $block + (nop) + (nop) + ) (get_local $x) ) ) diff --git a/test/passes/simplify-locals.wast b/test/passes/simplify-locals.wast index 60531717c..5396e6a5b 100644 --- a/test/passes/simplify-locals.wast +++ b/test/passes/simplify-locals.wast @@ -12,6 +12,8 @@ (import $_i64Subtract "env" "i64sub" (param i32 i32 i32 i32) (result i32)) (import $___udivmoddi4 "env" "moddi" (param i32 i32 i32 i32 i32) (result i32)) (import $lp "env" "lp" (param i32 i32) (result i32)) + (import "fuzzing-support" "log-f32" (func $fimport$0 (param f32))) + (global $global$0 (mut i32) (i32.const 10)) (func $contrast ;; check for tee and structure sinking (local $x i32) (local $y i32) @@ -882,6 +884,207 @@ ) ) ) + (func $if-one-side (result i32) + (local $x i32) + (if + (i32.const 1) + (set_local $x + (i32.const 2) + ) + ) + (get_local $x) + ) + (func $if-one-side-undo (result i32) + (local $x i32) + (local $y i32) + (set_local $y + (i32.const 0) + ) + (if + (i32.const 1) + (set_local $x + (i32.const 2) + ) + ) + (get_local $y) + ) + (func $if-one-side-multi (param $0 i32) (result i32) + (if + (i32.lt_s + (get_local $0) + (i32.const -1073741824) + ) + (set_local $0 + (i32.const -1073741824) + ) + (if + (i32.gt_s + (get_local $0) + (i32.const 1073741823) + ) + (set_local $0 + (i32.const 1073741823) + ) + ) + ) + (get_local $0) + ) + (func $if-one-side-undo-but-its-a-tee (param $0 i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $x i32) + (local $y i32) + (local $z i32) + ;; break these splittable ifs up + (set_local $x + (if (result i32) + (i32.const -1) + (i32.const -2) + (get_local $x) + ) + ) + ;; oops, this one is a tee + (drop + (call $if-one-side-undo-but-its-a-tee + (tee_local $x + (if (result i32) + (i32.const -3) + (i32.const -4) + (get_local $x) + ) + ) + ) + ) + ;; sinkable + (set_local $y + (if (result i32) + (i32.const -5) + (i32.const -6) + (get_local $y) + ) + ) + (drop (i32.eqz (get_local $y))) + ;; tee-able at best + (set_local $z + (if (result i32) + (i32.const -7) + (i32.const -8) + (get_local $z) + ) + ) + (drop + (i32.add + (get_local $z) + (get_local $z) + ) + ) + (if + (block $label$1 (result i32) + (if + (i32.const 1) + (set_local $4 + (i32.const 2) + ) + ) + (if + (get_local $4) + (set_local $4 + (i32.const 0) + ) + ) + (get_local $4) + ) + (unreachable) + ) + (i32.const 0) + ) + (func $splittable-ifs-multicycle (param $20 i32) (result i32) + (set_local $20 + (if (result i32) + (i32.const 1) + (if (result i32) + (i32.const 2) + (if (result i32) + (i32.const 3) + (i32.const 4) + (get_local $20) + ) + (get_local $20) + ) + (get_local $20) + ) + ) + (get_local $20) + ) + (func $update-getCounter (param $0 i32) (param $1 f64) (param $2 f64) (param $3 f32) (param $4 i32) (result f64) + (set_global $global$0 + (i32.sub + (get_global $global$0) + (i32.const 1) + ) + ) + (set_global $global$0 + (i32.sub + (get_global $global$0) + (i32.const 1) + ) + ) + (loop $label$1 (result f64) + (set_global $global$0 + (i32.sub + (get_global $global$0) + (i32.const 1) + ) + ) + (set_global $global$0 + (i32.sub + (get_global $global$0) + (i32.const 1) + ) + ) + (call $fimport$0 + (tee_local $3 + (if (result f32) + (i32.eqz + (get_local $0) + ) + (f32.const 4623408228068004207103214e13) + (get_local $3) + ) + ) + ) + (set_global $global$0 + (i32.sub + (get_global $global$0) + (i32.const 1) + ) + ) + (if (result f64) + (get_global $global$0) + (block + (set_global $global$0 + (i32.sub + (get_global $global$0) + (i32.const 1) + ) + ) + (set_local $0 + (i32.const -65) + ) + (set_global $global$0 + (i32.sub + (get_global $global$0) + (i32.const 1) + ) + ) + (br $label$1) + ) + (f64.const -70) + ) + ) + ) ) (module (memory (shared 256 256)) diff --git a/test/unit.fromasm b/test/unit.fromasm index cd9874cea..57277cdd3 100644 --- a/test/unit.fromasm +++ b/test/unit.fromasm @@ -234,20 +234,20 @@ ) (func $smallCompare (; 19 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32) (if - (i32.lt_s - (get_local $0) - (get_local $1) - ) - (set_local $0 - (i32.add - (get_local $0) - (i32.const 1) - ) - ) - ) - (if (i32.lt_u - (get_local $0) + (tee_local $0 + (select + (i32.add + (get_local $0) + (i32.const 1) + ) + (get_local $0) + (i32.lt_s + (get_local $0) + (get_local $1) + ) + ) + ) (get_local $1) ) (set_local $0 @@ -427,24 +427,20 @@ (func $zeroInit (; 26 ;) (; has Stack IR ;) (param $0 i32) (local $1 i32) (if - (call $lb - (i32.const 0) - ) - (if - (call $lb - (i32.const 1) - ) - (set_local $1 + (i32.eq + (if (result i32) + (call $lb + (i32.const 0) + ) + (if (result i32) + (call $lb + (i32.const 1) + ) + (i32.const 3) + (get_local $1) + ) (i32.const 3) ) - ) - (set_local $1 - (i32.const 3) - ) - ) - (if - (i32.eq - (get_local $1) (i32.const 3) ) (drop @@ -1000,16 +996,16 @@ ) (if (i32.eq - (get_local $0) - (i32.const 300) - ) - (set_local $1 - (i32.const 2) - ) - ) - (if - (i32.eq - (get_local $1) + (tee_local $1 + (select + (i32.const 2) + (get_local $1) + (i32.eq + (get_local $0) + (i32.const 300) + ) + ) + ) (i32.const 2) ) (call $relooperJumpThreading_irreducible diff --git a/test/unit.fromasm.clamp b/test/unit.fromasm.clamp index 1a11052a2..9947d9315 100644 --- a/test/unit.fromasm.clamp +++ b/test/unit.fromasm.clamp @@ -284,20 +284,20 @@ ) (func $smallCompare (; 20 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32) (if - (i32.lt_s - (get_local $0) - (get_local $1) - ) - (set_local $0 - (i32.add - (get_local $0) - (i32.const 1) - ) - ) - ) - (if (i32.lt_u - (get_local $0) + (tee_local $0 + (select + (i32.add + (get_local $0) + (i32.const 1) + ) + (get_local $0) + (i32.lt_s + (get_local $0) + (get_local $1) + ) + ) + ) (get_local $1) ) (set_local $0 @@ -477,24 +477,20 @@ (func $zeroInit (; 27 ;) (; has Stack IR ;) (param $0 i32) (local $1 i32) (if - (call $lb - (i32.const 0) - ) - (if - (call $lb - (i32.const 1) - ) - (set_local $1 + (i32.eq + (if (result i32) + (call $lb + (i32.const 0) + ) + (if (result i32) + (call $lb + (i32.const 1) + ) + (i32.const 3) + (get_local $1) + ) (i32.const 3) ) - ) - (set_local $1 - (i32.const 3) - ) - ) - (if - (i32.eq - (get_local $1) (i32.const 3) ) (drop @@ -1050,16 +1046,16 @@ ) (if (i32.eq - (get_local $0) - (i32.const 300) - ) - (set_local $1 - (i32.const 2) - ) - ) - (if - (i32.eq - (get_local $1) + (tee_local $1 + (select + (i32.const 2) + (get_local $1) + (i32.eq + (get_local $0) + (i32.const 300) + ) + ) + ) (i32.const 2) ) (call $relooperJumpThreading_irreducible diff --git a/test/unit.fromasm.imprecise b/test/unit.fromasm.imprecise index b5da4cfe4..a56482591 100644 --- a/test/unit.fromasm.imprecise +++ b/test/unit.fromasm.imprecise @@ -233,20 +233,20 @@ ) (func $smallCompare (; 18 ;) (; has Stack IR ;) (param $0 i32) (param $1 i32) (result i32) (if - (i32.lt_s - (get_local $0) - (get_local $1) - ) - (set_local $0 - (i32.add - (get_local $0) - (i32.const 1) - ) - ) - ) - (if (i32.lt_u - (get_local $0) + (tee_local $0 + (select + (i32.add + (get_local $0) + (i32.const 1) + ) + (get_local $0) + (i32.lt_s + (get_local $0) + (get_local $1) + ) + ) + ) (get_local $1) ) (set_local $0 @@ -426,24 +426,20 @@ (func $zeroInit (; 25 ;) (; has Stack IR ;) (param $0 i32) (local $1 i32) (if - (call $lb - (i32.const 0) - ) - (if - (call $lb - (i32.const 1) - ) - (set_local $1 + (i32.eq + (if (result i32) + (call $lb + (i32.const 0) + ) + (if (result i32) + (call $lb + (i32.const 1) + ) + (i32.const 3) + (get_local $1) + ) (i32.const 3) ) - ) - (set_local $1 - (i32.const 3) - ) - ) - (if - (i32.eq - (get_local $1) (i32.const 3) ) (drop @@ -999,16 +995,16 @@ ) (if (i32.eq - (get_local $0) - (i32.const 300) - ) - (set_local $1 - (i32.const 2) - ) - ) - (if - (i32.eq - (get_local $1) + (tee_local $1 + (select + (i32.const 2) + (get_local $1) + (i32.eq + (get_local $0) + (i32.const 300) + ) + ) + ) (i32.const 2) ) (call $relooperJumpThreading_irreducible |