From 759bafb906ba3addc5ab470ca41455ef452f30ab Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Sat, 23 Apr 2016 18:10:05 -0700 Subject: vacuum dead code after unconditional brs --- src/passes/Vacuum.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/passes/Vacuum.cpp b/src/passes/Vacuum.cpp index 863d78f14..ed868f2f9 100644 --- a/src/passes/Vacuum.cpp +++ b/src/passes/Vacuum.cpp @@ -32,14 +32,25 @@ struct Vacuum : public WalkerPass>> { int skip = 0; auto& list = curr->list; size_t size = list.size(); + bool needResize = false; for (size_t z = 0; z < size; z++) { if (list[z]->is()) { skip++; - } else if (skip > 0) { - list[z - skip] = list[z]; + needResize = true; + } else { + if (skip > 0) { + list[z - skip] = list[z]; + } + // if this is an unconditional br, the rest is dead code + Break* br = list[z - skip]->dynCast(); + if (br && !br->condition) { + list.resize(z - skip + 1); + needResize = false; + break; + } } } - if (skip > 0) { + if (needResize) { list.resize(size - skip); } if (!curr->name.is()) { -- cgit v1.2.3 From c2dfbb512297e0d008de6ffad4a97799e68b3ed1 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Sat, 23 Apr 2016 18:12:44 -0700 Subject: vacuum dead code after br_table --- src/passes/Vacuum.cpp | 3 ++- test/passes/vacuum.txt | 5 +++++ test/passes/vacuum.wast | 6 ++++++ 3 files changed, 13 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/passes/Vacuum.cpp b/src/passes/Vacuum.cpp index ed868f2f9..12565f603 100644 --- a/src/passes/Vacuum.cpp +++ b/src/passes/Vacuum.cpp @@ -43,7 +43,8 @@ struct Vacuum : public WalkerPass>> { } // if this is an unconditional br, the rest is dead code Break* br = list[z - skip]->dynCast(); - if (br && !br->condition) { + Switch* sw = list[z - skip]->dynCast(); + if ((br && !br->condition) || sw) { list.resize(z - skip + 1); needResize = false; break; diff --git a/test/passes/vacuum.txt b/test/passes/vacuum.txt index a6c7f22f0..103dbc6bc 100644 --- a/test/passes/vacuum.txt +++ b/test/passes/vacuum.txt @@ -11,5 +11,10 @@ (block $waka2 (br $waka2) ) + (block $waka3 + (br_table $waka3 $waka3 $waka3 + (i32.const 57) + ) + ) ) ) diff --git a/test/passes/vacuum.wast b/test/passes/vacuum.wast index dda86804e..a0c638eb8 100644 --- a/test/passes/vacuum.wast +++ b/test/passes/vacuum.wast @@ -17,6 +17,12 @@ (br $waka2) (i32.const 56) ) + (block $waka3 + (br_table $waka3 $waka3 $waka3 + (i32.const 57) + ) + (i32.const 58) + ) ) ) -- cgit v1.2.3 From 9f1849ef99db9fa8a8a44daec348b7f2bb562453 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Sat, 23 Apr 2016 20:00:39 -0700 Subject: handle general control flow in RemoveUnusedBrs --- src/passes/RemoveUnusedBrs.cpp | 148 ++-- test/emcc_O2_hello_world.fromasm | 946 ++++++++++----------- test/emcc_O2_hello_world.fromasm.imprecise | 946 ++++++++++----------- test/emcc_hello_world.fromasm | 1217 +++++++++++++--------------- test/emcc_hello_world.fromasm.imprecise | 1217 +++++++++++++--------------- test/memorygrowth.fromasm | 851 +++++++++---------- test/memorygrowth.fromasm.imprecise | 851 +++++++++---------- test/passes/remove-unused-brs.txt | 93 ++- test/passes/remove-unused-brs.wast | 73 ++ test/unit.fromasm | 1 - test/unit.fromasm.imprecise | 1 - 11 files changed, 3086 insertions(+), 3258 deletions(-) (limited to 'src') diff --git a/src/passes/RemoveUnusedBrs.cpp b/src/passes/RemoveUnusedBrs.cpp index cfd9ea7ce..255d86b9c 100644 --- a/src/passes/RemoveUnusedBrs.cpp +++ b/src/passes/RemoveUnusedBrs.cpp @@ -15,89 +15,119 @@ */ // -// Removes branches that go to where they go anyhow +// Removes branches for which we go to where they go anyhow // #include #include +#include namespace wasm { struct RemoveUnusedBrs : public WalkerPass>> { bool isFunctionParallel() { return true; } - // preparation: try to unify branches, as the fewer there are, the higher a chance we can remove them - // specifically for if-else, turn an if-else with branches to the same target at the end of each - // child, and with a value, to a branch to that target containing the if-else + typedef std::vector Flows; + + // list of breaks that are currently flowing. if they reach their target without + // interference, they can be removed (or their value forwarded TODO) + Flows flows; + + // a stack for if-else contents, we merge their outputs + std::vector ifStack; + + static void visitAny(RemoveUnusedBrs* self, Expression** currp) { + auto* curr = *currp; + auto& flows = self->flows; + + if (curr->is()) { + flows.clear(); + auto* br = curr->cast(); + if (!br->condition && !br->value) { // TODO: optimize in those cases? + // a break, let's see where it flows to + flows.push_back(br); + } + } else if (curr->is()) { + flows.clear(); + } else if (curr->is()) { + auto* iff = curr->cast(); + if (iff->ifFalse) { + assert(self->ifStack.size() > 0); + for (auto* flow : self->ifStack.back()) { + flows.push_back(flow); + } + self->ifStack.pop_back(); + } + } else if (curr->is()) { + // any breaks flowing to here are unnecessary, as we get here anyhow + auto name = curr->cast()->name; + if (name.is()) { + size_t size = flows.size(); + size_t skip = 0; + for (size_t i = 0; i < size; i++) { + if (flows[i]->name == name) { + ExpressionManipulator::nop(flows[i]); + skip++; + } else if (skip > 0) { + flows[i - skip] = flows[i]; + } + } + if (skip > 0) { + flows.resize(size - skip); + } + } + } else if (curr->is()) { + // TODO we might optimize branches out of here + flows.clear(); + } else { + // anything else stops the flow + flows.clear(); + } + } + + static void clear(RemoveUnusedBrs* self, Expression** currp) { + self->flows.clear(); + } + + static void saveIfTrue(RemoveUnusedBrs* self, Expression** currp) { + self->ifStack.push_back(std::move(self->flows)); + } + void visitIf(If* curr) { if (!curr->ifFalse) { - // try to reduce an if (condition) br => br_if (condition) , which might open up other optimization opportunities + // if without an else. try to reduce if (condition) br => br_if (condition) Break* br = curr->ifTrue->dynCast(); if (br && !br->condition) { // TODO: if there is a condition, join them br->condition = curr->condition; replaceCurrent(br); } - return; - } - if (isConcreteWasmType(curr->type)) return; // already has a returned value - // an if_else that indirectly returns a value by breaking to the same target can potentially remove both breaks, and break outside once - auto getLast = [](Expression *side) -> Expression* { - Block* b = side->dynCast(); - if (!b) return nullptr; - if (b->list.size() == 0) return nullptr; - return b->list.back(); - }; - auto process = [&](Expression *side, bool doIt) { - Expression* last = getLast(side); - if (!last) return Name(); - Block* b = side->cast(); - Break* br = last->dynCast(); - if (!br) return Name(); - if (br->condition) return Name(); - if (!br->value) return Name(); - if (doIt) { - b->list[b->list.size()-1] = br->value; - } - return br->name; - }; - // do both, or none - if (process(curr->ifTrue, false).is() && process(curr->ifTrue, false) == process(curr->ifFalse, false)) { - auto br = getLast(curr->ifTrue)->cast(); // we are about to discard this, so why not reuse it! - process(curr->ifTrue, true); - process(curr->ifFalse, true); - curr->type = br->value->type; // if_else now returns a value - br->value = curr; - // no need to change anything else in the br - target is correct already - replaceCurrent(br); } } - // main portion - void visitBlock(Block *curr) { - if (curr->name.isNull()) return; - if (curr->list.size() == 0) return; - // preparation - remove all code after an unconditional break, since it can't execute, and it might confuse us (we look at the last) - for (size_t i = 0; i < curr->list.size()-1; i++) { - Break* br = curr->list[i]->dynCast(); - if (br && !br->condition) { - curr->list.resize(i+1); - break; - } - } - Expression* last = curr->list.back(); - if (Break* br = last->dynCast()) { - if (br->condition) return; - if (br->name == curr->name) { - if (!br->value) { - curr->list.pop_back(); - } else { - curr->list[curr->list.size()-1] = br->value; // can replace with the value - } + // override scan to add a pre and a post check task to all nodes + static void scan(RemoveUnusedBrs* self, Expression** currp) { + self->pushTask(visitAny, currp); + + auto* iff = (*currp)->dynCast(); + + if (iff) { + self->pushTask(doVisitIf, currp); + if (iff->ifFalse) { + // we need to join up if-else control flow, and clear after the condition + self->pushTask(scan, &iff->ifFalse); + self->pushTask(saveIfTrue, currp); // safe the ifTrue flow, we'll join it later } + self->pushTask(scan, &iff->ifTrue); + self->pushTask(clear, currp); // clear all flow after the condition + self->pushTask(scan, &iff->condition); + } else { + WalkerPass>>::scan(self, currp); } } + + // TODO: multiple rounds? }; -static RegisterPass registerPass("remove-unused-brs", "removes breaks from locations that are never branched to"); +static RegisterPass registerPass("remove-unused-brs", "removes breaks from locations that are not needed"); } // namespace wasm diff --git a/test/emcc_O2_hello_world.fromasm b/test/emcc_O2_hello_world.fromasm index de6dfd4b8..ce017ac82 100644 --- a/test/emcc_O2_hello_world.fromasm +++ b/test/emcc_O2_hello_world.fromasm @@ -217,59 +217,56 @@ ) ) ) - (block $do-once$2 - (if - (i32.ne - (get_local $i7) - (get_local $i11) - ) - (block - (if - (i32.lt_u - (get_local $i11) - (i32.load - (i32.const 192) - ) + (if + (i32.ne + (get_local $i7) + (get_local $i11) + ) + (block + (if + (i32.lt_u + (get_local $i11) + (i32.load + (i32.const 192) ) - (call_import $_abort) ) - (if - (i32.eq - (i32.load - (set_local $i12 - (i32.add - (get_local $i11) - (i32.const 12) - ) + (call_import $_abort) + ) + (if + (i32.eq + (i32.load + (set_local $i12 + (i32.add + (get_local $i11) + (i32.const 12) ) ) - (get_local $i9) ) - (block - (i32.store - (get_local $i12) - (get_local $i7) - ) - (i32.store - (get_local $i8) - (get_local $i11) - ) - (br $do-once$2) + (get_local $i9) + ) + (block + (i32.store + (get_local $i12) + (get_local $i7) + ) + (i32.store + (get_local $i8) + (get_local $i11) ) - (call_import $_abort) ) + (call_import $_abort) ) - (i32.store - (i32.const 176) - (i32.and - (get_local $i4) - (i32.xor - (i32.shl - (i32.const 1) - (get_local $i6) - ) - (i32.const -1) + ) + (i32.store + (i32.const 176) + (i32.and + (get_local $i4) + (i32.xor + (i32.shl + (i32.const 1) + (get_local $i6) ) + (i32.const -1) ) ) ) @@ -462,70 +459,67 @@ ) ) ) - (block $do-once$4 - (if - (i32.ne - (get_local $i15) - (get_local $i7) - ) - (block - (if - (i32.lt_u - (get_local $i7) - (i32.load - (i32.const 192) - ) + (if + (i32.ne + (get_local $i15) + (get_local $i7) + ) + (block + (if + (i32.lt_u + (get_local $i7) + (i32.load + (i32.const 192) ) - (call_import $_abort) ) - (if - (i32.eq - (i32.load - (set_local $i11 - (i32.add - (get_local $i7) - (i32.const 12) - ) + (call_import $_abort) + ) + (if + (i32.eq + (i32.load + (set_local $i11 + (i32.add + (get_local $i7) + (i32.const 12) ) ) - (get_local $i14) ) - (block - (i32.store - (get_local $i11) - (get_local $i15) - ) - (i32.store - (get_local $i16) - (get_local $i7) - ) - (set_local $i18 - (i32.load - (i32.const 184) - ) + (get_local $i14) + ) + (block + (i32.store + (get_local $i11) + (get_local $i15) + ) + (i32.store + (get_local $i16) + (get_local $i7) + ) + (set_local $i18 + (i32.load + (i32.const 184) ) - (br $do-once$4) ) - (call_import $_abort) ) + (call_import $_abort) ) - (block - (i32.store - (i32.const 176) - (i32.and - (get_local $i4) - (i32.xor - (i32.shl - (i32.const 1) - (get_local $i17) - ) - (i32.const -1) + ) + (block + (i32.store + (i32.const 176) + (i32.and + (get_local $i4) + (i32.xor + (i32.shl + (i32.const 1) + (get_local $i17) ) + (i32.const -1) ) ) - (set_local $i18 - (get_local $i8) - ) + ) + (set_local $i18 + (get_local $i8) ) ) ) @@ -1015,7 +1009,6 @@ (set_local $i24 (get_local $i27) ) - (br $do-once$8) ) ) ) @@ -1069,7 +1062,6 @@ (set_local $i24 (get_local $i12) ) - (br $do-once$8) ) (call_import $_abort) ) @@ -1181,29 +1173,26 @@ (get_local $i24) (get_local $i5) ) - (block $do-once$14 + (if + (set_local $i7 + (i32.load offset=16 + (get_local $i22) + ) + ) (if - (set_local $i7 - (i32.load offset=16 - (get_local $i22) - ) + (i32.lt_u + (get_local $i7) + (get_local $i12) ) - (if - (i32.lt_u + (call_import $_abort) + (block + (i32.store offset=16 + (get_local $i24) (get_local $i7) - (get_local $i12) ) - (call_import $_abort) - (block - (i32.store offset=16 - (get_local $i24) - (get_local $i7) - ) - (i32.store offset=24 - (get_local $i7) - (get_local $i24) - ) - (br $do-once$14) + (i32.store offset=24 + (get_local $i7) + (get_local $i24) ) ) ) @@ -1231,7 +1220,6 @@ (get_local $i7) (get_local $i24) ) - (br $do-once$12) ) ) ) @@ -2194,7 +2182,6 @@ (set_local $i45 (get_local $i48) ) - (br $do-once$21) ) ) ) @@ -2248,7 +2235,6 @@ (set_local $i45 (get_local $i7) ) - (br $do-once$21) ) (call_import $_abort) ) @@ -2360,29 +2346,26 @@ (get_local $i45) (get_local $i3) ) - (block $do-once$27 + (if + (set_local $i15 + (i32.load offset=16 + (get_local $i44) + ) + ) (if - (set_local $i15 - (i32.load offset=16 - (get_local $i44) - ) + (i32.lt_u + (get_local $i15) + (get_local $i7) ) - (if - (i32.lt_u + (call_import $_abort) + (block + (i32.store offset=16 + (get_local $i45) (get_local $i15) - (get_local $i7) ) - (call_import $_abort) - (block - (i32.store offset=16 - (get_local $i45) - (get_local $i15) - ) - (i32.store offset=24 - (get_local $i15) - (get_local $i45) - ) - (br $do-once$27) + (i32.store offset=24 + (get_local $i15) + (get_local $i45) ) ) ) @@ -2410,7 +2393,6 @@ (get_local $i15) (get_local $i45) ) - (br $do-once$25) ) ) ) @@ -2838,7 +2820,6 @@ (get_local $i8) (get_local $i8) ) - (br $do-once$29) ) ) (if @@ -2891,7 +2872,6 @@ (get_local $i8) (i32.const 0) ) - (br $do-once$29) ) (call_import $_abort) ) @@ -3112,64 +3092,61 @@ ) ) ) - (block $do-once$33 - (if - (i32.eqz - (i32.load - (i32.const 648) - ) + (if + (i32.eqz + (i32.load + (i32.const 648) ) - (if - (i32.and - (i32.add - (set_local $i53 - (call_import $_sysconf - (i32.const 30) - ) + ) + (if + (i32.and + (i32.add + (set_local $i53 + (call_import $_sysconf + (i32.const 30) ) - (i32.const -1) ) + (i32.const -1) + ) + (get_local $i53) + ) + (call_import $_abort) + (block + (i32.store + (i32.const 656) (get_local $i53) ) - (call_import $_abort) - (block - (i32.store - (i32.const 656) - (get_local $i53) - ) - (i32.store - (i32.const 652) - (get_local $i53) - ) - (i32.store - (i32.const 660) - (i32.const -1) - ) - (i32.store - (i32.const 664) - (i32.const -1) - ) - (i32.store - (i32.const 668) - (i32.const 0) - ) - (i32.store - (i32.const 620) - (i32.const 0) - ) - (i32.store - (i32.const 648) - (i32.xor - (i32.and - (call_import $_time - (i32.const 0) - ) - (i32.const -16) + (i32.store + (i32.const 652) + (get_local $i53) + ) + (i32.store + (i32.const 660) + (i32.const -1) + ) + (i32.store + (i32.const 664) + (i32.const -1) + ) + (i32.store + (i32.const 668) + (i32.const 0) + ) + (i32.store + (i32.const 620) + (i32.const 0) + ) + (i32.store + (i32.const 648) + (i32.xor + (i32.and + (call_import $_time + (i32.const 0) ) - (i32.const 1431655768) + (i32.const -16) ) + (i32.const 1431655768) ) - (br $do-once$33) ) ) ) @@ -3545,76 +3522,71 @@ (get_local $i61) ) ) - (block $do-once$42 + (if (if - (if + (i32.and + (i32.gt_u + (get_local $i53) + (get_local $i61) + ) (i32.and - (i32.gt_u - (get_local $i53) + (i32.lt_u (get_local $i61) + (i32.const 2147483647) ) - (i32.and - (i32.lt_u - (get_local $i61) - (i32.const 2147483647) - ) - (i32.ne - (get_local $i60) - (i32.const -1) - ) + (i32.ne + (get_local $i60) + (i32.const -1) ) ) - (i32.lt_u - (set_local $i5 - (i32.and - (i32.add - (i32.sub - (get_local $i44) - (get_local $i61) - ) - (set_local $i52 - (i32.load - (i32.const 656) - ) - ) - ) + ) + (i32.lt_u + (set_local $i5 + (i32.and + (i32.add (i32.sub - (i32.const 0) - (get_local $i52) + (get_local $i44) + (get_local $i61) ) + (set_local $i52 + (i32.load + (i32.const 656) + ) + ) + ) + (i32.sub + (i32.const 0) + (get_local $i52) ) ) - (i32.const 2147483647) ) - (i32.const 0) + (i32.const 2147483647) ) - (if - (i32.eq - (call_import $_sbrk - (get_local $i5) - ) - (i32.const -1) - ) - (block - (call_import $_sbrk - (get_local $i45) - ) - (br $label$break$L279) + (i32.const 0) + ) + (if + (i32.eq + (call_import $_sbrk + (get_local $i5) ) - (block - (set_local $i63 - (i32.add - (get_local $i5) - (get_local $i61) - ) - ) - (br $do-once$42) + (i32.const -1) + ) + (block + (call_import $_sbrk + (get_local $i45) ) + (br $label$break$L279) ) (set_local $i63 - (get_local $i61) + (i32.add + (get_local $i5) + (get_local $i61) + ) ) ) + (set_local $i63 + (get_local $i61) + ) ) (if (i32.ne @@ -4306,7 +4278,6 @@ (set_local $i72 (get_local $i75) ) - (br $do-once$53) ) ) ) @@ -4360,7 +4331,6 @@ (set_local $i72 (get_local $i55) ) - (br $do-once$53) ) (call_import $_abort) ) @@ -4471,34 +4441,31 @@ (get_local $i72) (get_local $i54) ) - (block $do-once$59 - (if - (set_local $i45 - (i32.load - (set_local $i5 - (i32.add - (get_local $i43) - (i32.const 16) - ) + (if + (set_local $i45 + (i32.load + (set_local $i5 + (i32.add + (get_local $i43) + (i32.const 16) ) ) ) - (if - (i32.lt_u + ) + (if + (i32.lt_u + (get_local $i45) + (get_local $i55) + ) + (call_import $_abort) + (block + (i32.store offset=16 + (get_local $i72) (get_local $i45) - (get_local $i55) ) - (call_import $_abort) - (block - (i32.store offset=16 - (get_local $i72) - (get_local $i45) - ) - (i32.store offset=24 - (get_local $i45) - (get_local $i72) - ) - (br $do-once$59) + (i32.store offset=24 + (get_local $i45) + (get_local $i72) ) ) ) @@ -4529,7 +4496,6 @@ (get_local $i45) (get_local $i72) ) - (br $label$break$L331) ) ) ) @@ -5113,7 +5079,6 @@ (get_local $i63) (get_local $i63) ) - (br $do-once$50) ) ) (if @@ -5166,7 +5131,6 @@ (get_local $i63) (i32.const 0) ) - (br $do-once$50) ) (call_import $_abort) ) @@ -5857,7 +5821,6 @@ (get_local $i60) (get_local $i60) ) - (br $do-once$44) ) ) (if @@ -5910,7 +5873,6 @@ (get_local $i60) (i32.const 0) ) - (br $do-once$44) ) (call_import $_abort) ) @@ -6598,7 +6560,6 @@ (set_local $i18 (get_local $i21) ) - (br $do-once$2) ) ) ) @@ -6652,7 +6613,6 @@ (set_local $i18 (get_local $i10) ) - (br $do-once$2) ) (call_import $_abort) ) @@ -6778,34 +6738,31 @@ (get_local $i18) (get_local $i7) ) - (block $do-once$6 - (if - (set_local $i14 - (i32.load - (set_local $i11 - (i32.add - (get_local $i8) - (i32.const 16) - ) + (if + (set_local $i14 + (i32.load + (set_local $i11 + (i32.add + (get_local $i8) + (i32.const 16) ) ) ) - (if - (i32.lt_u + ) + (if + (i32.lt_u + (get_local $i14) + (get_local $i10) + ) + (call_import $_abort) + (block + (i32.store offset=16 + (get_local $i18) (get_local $i14) - (get_local $i10) ) - (call_import $_abort) - (block - (i32.store offset=16 - (get_local $i18) - (get_local $i14) - ) - (i32.store offset=24 - (get_local $i14) - (get_local $i18) - ) - (br $do-once$6) + (i32.store offset=24 + (get_local $i14) + (get_local $i18) ) ) ) @@ -6839,7 +6796,6 @@ (set_local $i13 (get_local $i9) ) - (br $do-once$0) ) ) (block @@ -7164,7 +7120,6 @@ (set_local $i23 (get_local $i26) ) - (br $do-once$10) ) ) ) @@ -7220,7 +7175,6 @@ (set_local $i23 (get_local $i22) ) - (br $do-once$10) ) (call_import $_abort) ) @@ -7331,34 +7285,31 @@ (get_local $i23) (get_local $i21) ) - (block $do-once$14 - (if - (set_local $i8 - (i32.load - (set_local $i9 - (i32.add - (get_local $i6) - (i32.const 16) - ) + (if + (set_local $i8 + (i32.load + (set_local $i9 + (i32.add + (get_local $i6) + (i32.const 16) ) ) ) - (if - (i32.lt_u + ) + (if + (i32.lt_u + (get_local $i8) + (get_local $i22) + ) + (call_import $_abort) + (block + (i32.store offset=16 + (get_local $i23) (get_local $i8) - (get_local $i22) ) - (call_import $_abort) - (block - (i32.store offset=16 - (get_local $i23) - (get_local $i8) - ) - (i32.store offset=24 - (get_local $i8) - (get_local $i23) - ) - (br $do-once$14) + (i32.store offset=24 + (get_local $i8) + (get_local $i23) ) ) ) @@ -7386,7 +7337,6 @@ (get_local $i8) (get_local $i23) ) - (br $do-once$8) ) ) ) @@ -7773,228 +7723,224 @@ (get_local $i12) (i32.const 0) ) - (block $do-once$16 - (if - (i32.and - (set_local $i30 - (i32.load - (i32.const 180) - ) + (if + (i32.and + (set_local $i30 + (i32.load + (i32.const 180) ) - (set_local $i18 - (i32.shl - (i32.const 1) - (get_local $i32) - ) + ) + (set_local $i18 + (i32.shl + (i32.const 1) + (get_local $i32) ) ) - (block - (set_local $i31 - (i32.shl - (get_local $i29) - (if - (i32.eq + ) + (block + (set_local $i31 + (i32.shl + (get_local $i29) + (if + (i32.eq + (get_local $i32) + (i32.const 31) + ) + (i32.const 0) + (i32.sub + (i32.const 25) + (i32.shr_u (get_local $i32) - (i32.const 31) - ) - (i32.const 0) - (i32.sub - (i32.const 25) - (i32.shr_u - (get_local $i32) - (i32.const 1) - ) + (i32.const 1) ) ) ) ) - (set_local $i2 - (i32.load - (get_local $i5) - ) + ) + (set_local $i2 + (i32.load + (get_local $i5) ) - (loop $while-out$18 $while-in$19 - (if - (i32.eq - (i32.and - (i32.load offset=4 - (get_local $i2) - ) - (i32.const -8) - ) - (get_local $i29) - ) - (block - (set_local $i33 + ) + (loop $while-out$18 $while-in$19 + (if + (i32.eq + (i32.and + (i32.load offset=4 (get_local $i2) ) - (set_local $i34 - (i32.const 130) - ) - (br $while-out$18) + (i32.const -8) ) + (get_local $i29) ) - (if - (set_local $i13 - (i32.load - (set_local $i28 + (block + (set_local $i33 + (get_local $i2) + ) + (set_local $i34 + (i32.const 130) + ) + (br $while-out$18) + ) + ) + (if + (set_local $i13 + (i32.load + (set_local $i28 + (i32.add (i32.add - (i32.add - (get_local $i2) - (i32.const 16) - ) - (i32.shl - (i32.shr_u - (get_local $i31) - (i32.const 31) - ) - (i32.const 2) + (get_local $i2) + (i32.const 16) + ) + (i32.shl + (i32.shr_u + (get_local $i31) + (i32.const 31) ) + (i32.const 2) ) ) ) ) - (block - (set_local $i31 - (i32.shl - (get_local $i31) - (i32.const 1) - ) - ) - (set_local $i2 - (get_local $i13) + ) + (block + (set_local $i31 + (i32.shl + (get_local $i31) + (i32.const 1) ) ) - (block - (set_local $i35 - (get_local $i28) - ) - (set_local $i36 - (get_local $i2) - ) - (set_local $i34 - (i32.const 127) - ) - (br $while-out$18) + (set_local $i2 + (get_local $i13) + ) + ) + (block + (set_local $i35 + (get_local $i28) + ) + (set_local $i36 + (get_local $i2) + ) + (set_local $i34 + (i32.const 127) + ) + (br $while-out$18) + ) + ) + (br $while-in$19) + ) + (if + (i32.eq + (get_local $i34) + (i32.const 127) + ) + (if + (i32.lt_u + (get_local $i35) + (i32.load + (i32.const 192) + ) + ) + (call_import $_abort) + (block + (i32.store + (get_local $i35) + (get_local $i12) + ) + (i32.store offset=24 + (get_local $i12) + (get_local $i36) + ) + (i32.store offset=12 + (get_local $i12) + (get_local $i12) + ) + (i32.store offset=8 + (get_local $i12) + (get_local $i12) ) ) - (br $while-in$19) ) (if (i32.eq (get_local $i34) - (i32.const 127) + (i32.const 130) ) (if - (i32.lt_u - (get_local $i35) - (i32.load - (i32.const 192) + (i32.and + (i32.ge_u + (set_local $i31 + (i32.load + (set_local $i2 + (i32.add + (get_local $i33) + (i32.const 8) + ) + ) + ) + ) + (set_local $i9 + (i32.load + (i32.const 192) + ) + ) + ) + (i32.ge_u + (get_local $i33) + (get_local $i9) ) ) - (call_import $_abort) (block + (i32.store offset=12 + (get_local $i31) + (get_local $i12) + ) (i32.store - (get_local $i35) + (get_local $i2) (get_local $i12) ) - (i32.store offset=24 + (i32.store offset=8 (get_local $i12) - (get_local $i36) + (get_local $i31) ) (i32.store offset=12 (get_local $i12) - (get_local $i12) + (get_local $i33) ) - (i32.store offset=8 - (get_local $i12) + (i32.store offset=24 (get_local $i12) + (i32.const 0) ) - (br $do-once$16) - ) - ) - (if - (i32.eq - (get_local $i34) - (i32.const 130) - ) - (if - (i32.and - (i32.ge_u - (set_local $i31 - (i32.load - (set_local $i2 - (i32.add - (get_local $i33) - (i32.const 8) - ) - ) - ) - ) - (set_local $i9 - (i32.load - (i32.const 192) - ) - ) - ) - (i32.ge_u - (get_local $i33) - (get_local $i9) - ) - ) - (block - (i32.store offset=12 - (get_local $i31) - (get_local $i12) - ) - (i32.store - (get_local $i2) - (get_local $i12) - ) - (i32.store offset=8 - (get_local $i12) - (get_local $i31) - ) - (i32.store offset=12 - (get_local $i12) - (get_local $i33) - ) - (i32.store offset=24 - (get_local $i12) - (i32.const 0) - ) - (br $do-once$16) - ) - (call_import $_abort) ) + (call_import $_abort) ) ) ) - (block - (i32.store - (i32.const 180) - (i32.or - (get_local $i30) - (get_local $i18) - ) - ) - (i32.store - (get_local $i5) - (get_local $i12) - ) - (i32.store offset=24 - (get_local $i12) - (get_local $i5) - ) - (i32.store offset=12 - (get_local $i12) - (get_local $i12) - ) - (i32.store offset=8 - (get_local $i12) - (get_local $i12) + ) + (block + (i32.store + (i32.const 180) + (i32.or + (get_local $i30) + (get_local $i18) ) ) + (i32.store + (get_local $i5) + (get_local $i12) + ) + (i32.store offset=24 + (get_local $i12) + (get_local $i5) + ) + (i32.store offset=12 + (get_local $i12) + (get_local $i12) + ) + (i32.store offset=8 + (get_local $i12) + (get_local $i12) + ) ) ) (i32.store diff --git a/test/emcc_O2_hello_world.fromasm.imprecise b/test/emcc_O2_hello_world.fromasm.imprecise index de6dfd4b8..ce017ac82 100644 --- a/test/emcc_O2_hello_world.fromasm.imprecise +++ b/test/emcc_O2_hello_world.fromasm.imprecise @@ -217,59 +217,56 @@ ) ) ) - (block $do-once$2 - (if - (i32.ne - (get_local $i7) - (get_local $i11) - ) - (block - (if - (i32.lt_u - (get_local $i11) - (i32.load - (i32.const 192) - ) + (if + (i32.ne + (get_local $i7) + (get_local $i11) + ) + (block + (if + (i32.lt_u + (get_local $i11) + (i32.load + (i32.const 192) ) - (call_import $_abort) ) - (if - (i32.eq - (i32.load - (set_local $i12 - (i32.add - (get_local $i11) - (i32.const 12) - ) + (call_import $_abort) + ) + (if + (i32.eq + (i32.load + (set_local $i12 + (i32.add + (get_local $i11) + (i32.const 12) ) ) - (get_local $i9) ) - (block - (i32.store - (get_local $i12) - (get_local $i7) - ) - (i32.store - (get_local $i8) - (get_local $i11) - ) - (br $do-once$2) + (get_local $i9) + ) + (block + (i32.store + (get_local $i12) + (get_local $i7) + ) + (i32.store + (get_local $i8) + (get_local $i11) ) - (call_import $_abort) ) + (call_import $_abort) ) - (i32.store - (i32.const 176) - (i32.and - (get_local $i4) - (i32.xor - (i32.shl - (i32.const 1) - (get_local $i6) - ) - (i32.const -1) + ) + (i32.store + (i32.const 176) + (i32.and + (get_local $i4) + (i32.xor + (i32.shl + (i32.const 1) + (get_local $i6) ) + (i32.const -1) ) ) ) @@ -462,70 +459,67 @@ ) ) ) - (block $do-once$4 - (if - (i32.ne - (get_local $i15) - (get_local $i7) - ) - (block - (if - (i32.lt_u - (get_local $i7) - (i32.load - (i32.const 192) - ) + (if + (i32.ne + (get_local $i15) + (get_local $i7) + ) + (block + (if + (i32.lt_u + (get_local $i7) + (i32.load + (i32.const 192) ) - (call_import $_abort) ) - (if - (i32.eq - (i32.load - (set_local $i11 - (i32.add - (get_local $i7) - (i32.const 12) - ) + (call_import $_abort) + ) + (if + (i32.eq + (i32.load + (set_local $i11 + (i32.add + (get_local $i7) + (i32.const 12) ) ) - (get_local $i14) ) - (block - (i32.store - (get_local $i11) - (get_local $i15) - ) - (i32.store - (get_local $i16) - (get_local $i7) - ) - (set_local $i18 - (i32.load - (i32.const 184) - ) + (get_local $i14) + ) + (block + (i32.store + (get_local $i11) + (get_local $i15) + ) + (i32.store + (get_local $i16) + (get_local $i7) + ) + (set_local $i18 + (i32.load + (i32.const 184) ) - (br $do-once$4) ) - (call_import $_abort) ) + (call_import $_abort) ) - (block - (i32.store - (i32.const 176) - (i32.and - (get_local $i4) - (i32.xor - (i32.shl - (i32.const 1) - (get_local $i17) - ) - (i32.const -1) + ) + (block + (i32.store + (i32.const 176) + (i32.and + (get_local $i4) + (i32.xor + (i32.shl + (i32.const 1) + (get_local $i17) ) + (i32.const -1) ) ) - (set_local $i18 - (get_local $i8) - ) + ) + (set_local $i18 + (get_local $i8) ) ) ) @@ -1015,7 +1009,6 @@ (set_local $i24 (get_local $i27) ) - (br $do-once$8) ) ) ) @@ -1069,7 +1062,6 @@ (set_local $i24 (get_local $i12) ) - (br $do-once$8) ) (call_import $_abort) ) @@ -1181,29 +1173,26 @@ (get_local $i24) (get_local $i5) ) - (block $do-once$14 + (if + (set_local $i7 + (i32.load offset=16 + (get_local $i22) + ) + ) (if - (set_local $i7 - (i32.load offset=16 - (get_local $i22) - ) + (i32.lt_u + (get_local $i7) + (get_local $i12) ) - (if - (i32.lt_u + (call_import $_abort) + (block + (i32.store offset=16 + (get_local $i24) (get_local $i7) - (get_local $i12) ) - (call_import $_abort) - (block - (i32.store offset=16 - (get_local $i24) - (get_local $i7) - ) - (i32.store offset=24 - (get_local $i7) - (get_local $i24) - ) - (br $do-once$14) + (i32.store offset=24 + (get_local $i7) + (get_local $i24) ) ) ) @@ -1231,7 +1220,6 @@ (get_local $i7) (get_local $i24) ) - (br $do-once$12) ) ) ) @@ -2194,7 +2182,6 @@ (set_local $i45 (get_local $i48) ) - (br $do-once$21) ) ) ) @@ -2248,7 +2235,6 @@ (set_local $i45 (get_local $i7) ) - (br $do-once$21) ) (call_import $_abort) ) @@ -2360,29 +2346,26 @@ (get_local $i45) (get_local $i3) ) - (block $do-once$27 + (if + (set_local $i15 + (i32.load offset=16 + (get_local $i44) + ) + ) (if - (set_local $i15 - (i32.load offset=16 - (get_local $i44) - ) + (i32.lt_u + (get_local $i15) + (get_local $i7) ) - (if - (i32.lt_u + (call_import $_abort) + (block + (i32.store offset=16 + (get_local $i45) (get_local $i15) - (get_local $i7) ) - (call_import $_abort) - (block - (i32.store offset=16 - (get_local $i45) - (get_local $i15) - ) - (i32.store offset=24 - (get_local $i15) - (get_local $i45) - ) - (br $do-once$27) + (i32.store offset=24 + (get_local $i15) + (get_local $i45) ) ) ) @@ -2410,7 +2393,6 @@ (get_local $i15) (get_local $i45) ) - (br $do-once$25) ) ) ) @@ -2838,7 +2820,6 @@ (get_local $i8) (get_local $i8) ) - (br $do-once$29) ) ) (if @@ -2891,7 +2872,6 @@ (get_local $i8) (i32.const 0) ) - (br $do-once$29) ) (call_import $_abort) ) @@ -3112,64 +3092,61 @@ ) ) ) - (block $do-once$33 - (if - (i32.eqz - (i32.load - (i32.const 648) - ) + (if + (i32.eqz + (i32.load + (i32.const 648) ) - (if - (i32.and - (i32.add - (set_local $i53 - (call_import $_sysconf - (i32.const 30) - ) + ) + (if + (i32.and + (i32.add + (set_local $i53 + (call_import $_sysconf + (i32.const 30) ) - (i32.const -1) ) + (i32.const -1) + ) + (get_local $i53) + ) + (call_import $_abort) + (block + (i32.store + (i32.const 656) (get_local $i53) ) - (call_import $_abort) - (block - (i32.store - (i32.const 656) - (get_local $i53) - ) - (i32.store - (i32.const 652) - (get_local $i53) - ) - (i32.store - (i32.const 660) - (i32.const -1) - ) - (i32.store - (i32.const 664) - (i32.const -1) - ) - (i32.store - (i32.const 668) - (i32.const 0) - ) - (i32.store - (i32.const 620) - (i32.const 0) - ) - (i32.store - (i32.const 648) - (i32.xor - (i32.and - (call_import $_time - (i32.const 0) - ) - (i32.const -16) + (i32.store + (i32.const 652) + (get_local $i53) + ) + (i32.store + (i32.const 660) + (i32.const -1) + ) + (i32.store + (i32.const 664) + (i32.const -1) + ) + (i32.store + (i32.const 668) + (i32.const 0) + ) + (i32.store + (i32.const 620) + (i32.const 0) + ) + (i32.store + (i32.const 648) + (i32.xor + (i32.and + (call_import $_time + (i32.const 0) ) - (i32.const 1431655768) + (i32.const -16) ) + (i32.const 1431655768) ) - (br $do-once$33) ) ) ) @@ -3545,76 +3522,71 @@ (get_local $i61) ) ) - (block $do-once$42 + (if (if - (if + (i32.and + (i32.gt_u + (get_local $i53) + (get_local $i61) + ) (i32.and - (i32.gt_u - (get_local $i53) + (i32.lt_u (get_local $i61) + (i32.const 2147483647) ) - (i32.and - (i32.lt_u - (get_local $i61) - (i32.const 2147483647) - ) - (i32.ne - (get_local $i60) - (i32.const -1) - ) + (i32.ne + (get_local $i60) + (i32.const -1) ) ) - (i32.lt_u - (set_local $i5 - (i32.and - (i32.add - (i32.sub - (get_local $i44) - (get_local $i61) - ) - (set_local $i52 - (i32.load - (i32.const 656) - ) - ) - ) + ) + (i32.lt_u + (set_local $i5 + (i32.and + (i32.add (i32.sub - (i32.const 0) - (get_local $i52) + (get_local $i44) + (get_local $i61) ) + (set_local $i52 + (i32.load + (i32.const 656) + ) + ) + ) + (i32.sub + (i32.const 0) + (get_local $i52) ) ) - (i32.const 2147483647) ) - (i32.const 0) + (i32.const 2147483647) ) - (if - (i32.eq - (call_import $_sbrk - (get_local $i5) - ) - (i32.const -1) - ) - (block - (call_import $_sbrk - (get_local $i45) - ) - (br $label$break$L279) + (i32.const 0) + ) + (if + (i32.eq + (call_import $_sbrk + (get_local $i5) ) - (block - (set_local $i63 - (i32.add - (get_local $i5) - (get_local $i61) - ) - ) - (br $do-once$42) + (i32.const -1) + ) + (block + (call_import $_sbrk + (get_local $i45) ) + (br $label$break$L279) ) (set_local $i63 - (get_local $i61) + (i32.add + (get_local $i5) + (get_local $i61) + ) ) ) + (set_local $i63 + (get_local $i61) + ) ) (if (i32.ne @@ -4306,7 +4278,6 @@ (set_local $i72 (get_local $i75) ) - (br $do-once$53) ) ) ) @@ -4360,7 +4331,6 @@ (set_local $i72 (get_local $i55) ) - (br $do-once$53) ) (call_import $_abort) ) @@ -4471,34 +4441,31 @@ (get_local $i72) (get_local $i54) ) - (block $do-once$59 - (if - (set_local $i45 - (i32.load - (set_local $i5 - (i32.add - (get_local $i43) - (i32.const 16) - ) + (if + (set_local $i45 + (i32.load + (set_local $i5 + (i32.add + (get_local $i43) + (i32.const 16) ) ) ) - (if - (i32.lt_u + ) + (if + (i32.lt_u + (get_local $i45) + (get_local $i55) + ) + (call_import $_abort) + (block + (i32.store offset=16 + (get_local $i72) (get_local $i45) - (get_local $i55) ) - (call_import $_abort) - (block - (i32.store offset=16 - (get_local $i72) - (get_local $i45) - ) - (i32.store offset=24 - (get_local $i45) - (get_local $i72) - ) - (br $do-once$59) + (i32.store offset=24 + (get_local $i45) + (get_local $i72) ) ) ) @@ -4529,7 +4496,6 @@ (get_local $i45) (get_local $i72) ) - (br $label$break$L331) ) ) ) @@ -5113,7 +5079,6 @@ (get_local $i63) (get_local $i63) ) - (br $do-once$50) ) ) (if @@ -5166,7 +5131,6 @@ (get_local $i63) (i32.const 0) ) - (br $do-once$50) ) (call_import $_abort) ) @@ -5857,7 +5821,6 @@ (get_local $i60) (get_local $i60) ) - (br $do-once$44) ) ) (if @@ -5910,7 +5873,6 @@ (get_local $i60) (i32.const 0) ) - (br $do-once$44) ) (call_import $_abort) ) @@ -6598,7 +6560,6 @@ (set_local $i18 (get_local $i21) ) - (br $do-once$2) ) ) ) @@ -6652,7 +6613,6 @@ (set_local $i18 (get_local $i10) ) - (br $do-once$2) ) (call_import $_abort) ) @@ -6778,34 +6738,31 @@ (get_local $i18) (get_local $i7) ) - (block $do-once$6 - (if - (set_local $i14 - (i32.load - (set_local $i11 - (i32.add - (get_local $i8) - (i32.const 16) - ) + (if + (set_local $i14 + (i32.load + (set_local $i11 + (i32.add + (get_local $i8) + (i32.const 16) ) ) ) - (if - (i32.lt_u + ) + (if + (i32.lt_u + (get_local $i14) + (get_local $i10) + ) + (call_import $_abort) + (block + (i32.store offset=16 + (get_local $i18) (get_local $i14) - (get_local $i10) ) - (call_import $_abort) - (block - (i32.store offset=16 - (get_local $i18) - (get_local $i14) - ) - (i32.store offset=24 - (get_local $i14) - (get_local $i18) - ) - (br $do-once$6) + (i32.store offset=24 + (get_local $i14) + (get_local $i18) ) ) ) @@ -6839,7 +6796,6 @@ (set_local $i13 (get_local $i9) ) - (br $do-once$0) ) ) (block @@ -7164,7 +7120,6 @@ (set_local $i23 (get_local $i26) ) - (br $do-once$10) ) ) ) @@ -7220,7 +7175,6 @@ (set_local $i23 (get_local $i22) ) - (br $do-once$10) ) (call_import $_abort) ) @@ -7331,34 +7285,31 @@ (get_local $i23) (get_local $i21) ) - (block $do-once$14 - (if - (set_local $i8 - (i32.load - (set_local $i9 - (i32.add - (get_local $i6) - (i32.const 16) - ) + (if + (set_local $i8 + (i32.load + (set_local $i9 + (i32.add + (get_local $i6) + (i32.const 16) ) ) ) - (if - (i32.lt_u + ) + (if + (i32.lt_u + (get_local $i8) + (get_local $i22) + ) + (call_import $_abort) + (block + (i32.store offset=16 + (get_local $i23) (get_local $i8) - (get_local $i22) ) - (call_import $_abort) - (block - (i32.store offset=16 - (get_local $i23) - (get_local $i8) - ) - (i32.store offset=24 - (get_local $i8) - (get_local $i23) - ) - (br $do-once$14) + (i32.store offset=24 + (get_local $i8) + (get_local $i23) ) ) ) @@ -7386,7 +7337,6 @@ (get_local $i8) (get_local $i23) ) - (br $do-once$8) ) ) ) @@ -7773,228 +7723,224 @@ (get_local $i12) (i32.const 0) ) - (block $do-once$16 - (if - (i32.and - (set_local $i30 - (i32.load - (i32.const 180) - ) + (if + (i32.and + (set_local $i30 + (i32.load + (i32.const 180) ) - (set_local $i18 - (i32.shl - (i32.const 1) - (get_local $i32) - ) + ) + (set_local $i18 + (i32.shl + (i32.const 1) + (get_local $i32) ) ) - (block - (set_local $i31 - (i32.shl - (get_local $i29) - (if - (i32.eq + ) + (block + (set_local $i31 + (i32.shl + (get_local $i29) + (if + (i32.eq + (get_local $i32) + (i32.const 31) + ) + (i32.const 0) + (i32.sub + (i32.const 25) + (i32.shr_u (get_local $i32) - (i32.const 31) - ) - (i32.const 0) - (i32.sub - (i32.const 25) - (i32.shr_u - (get_local $i32) - (i32.const 1) - ) + (i32.const 1) ) ) ) ) - (set_local $i2 - (i32.load - (get_local $i5) - ) + ) + (set_local $i2 + (i32.load + (get_local $i5) ) - (loop $while-out$18 $while-in$19 - (if - (i32.eq - (i32.and - (i32.load offset=4 - (get_local $i2) - ) - (i32.const -8) - ) - (get_local $i29) - ) - (block - (set_local $i33 + ) + (loop $while-out$18 $while-in$19 + (if + (i32.eq + (i32.and + (i32.load offset=4 (get_local $i2) ) - (set_local $i34 - (i32.const 130) - ) - (br $while-out$18) + (i32.const -8) ) + (get_local $i29) ) - (if - (set_local $i13 - (i32.load - (set_local $i28 + (block + (set_local $i33 + (get_local $i2) + ) + (set_local $i34 + (i32.const 130) + ) + (br $while-out$18) + ) + ) + (if + (set_local $i13 + (i32.load + (set_local $i28 + (i32.add (i32.add - (i32.add - (get_local $i2) - (i32.const 16) - ) - (i32.shl - (i32.shr_u - (get_local $i31) - (i32.const 31) - ) - (i32.const 2) + (get_local $i2) + (i32.const 16) + ) + (i32.shl + (i32.shr_u + (get_local $i31) + (i32.const 31) ) + (i32.const 2) ) ) ) ) - (block - (set_local $i31 - (i32.shl - (get_local $i31) - (i32.const 1) - ) - ) - (set_local $i2 - (get_local $i13) + ) + (block + (set_local $i31 + (i32.shl + (get_local $i31) + (i32.const 1) ) ) - (block - (set_local $i35 - (get_local $i28) - ) - (set_local $i36 - (get_local $i2) - ) - (set_local $i34 - (i32.const 127) - ) - (br $while-out$18) + (set_local $i2 + (get_local $i13) + ) + ) + (block + (set_local $i35 + (get_local $i28) + ) + (set_local $i36 + (get_local $i2) + ) + (set_local $i34 + (i32.const 127) + ) + (br $while-out$18) + ) + ) + (br $while-in$19) + ) + (if + (i32.eq + (get_local $i34) + (i32.const 127) + ) + (if + (i32.lt_u + (get_local $i35) + (i32.load + (i32.const 192) + ) + ) + (call_import $_abort) + (block + (i32.store + (get_local $i35) + (get_local $i12) + ) + (i32.store offset=24 + (get_local $i12) + (get_local $i36) + ) + (i32.store offset=12 + (get_local $i12) + (get_local $i12) + ) + (i32.store offset=8 + (get_local $i12) + (get_local $i12) ) ) - (br $while-in$19) ) (if (i32.eq (get_local $i34) - (i32.const 127) + (i32.const 130) ) (if - (i32.lt_u - (get_local $i35) - (i32.load - (i32.const 192) + (i32.and + (i32.ge_u + (set_local $i31 + (i32.load + (set_local $i2 + (i32.add + (get_local $i33) + (i32.const 8) + ) + ) + ) + ) + (set_local $i9 + (i32.load + (i32.const 192) + ) + ) + ) + (i32.ge_u + (get_local $i33) + (get_local $i9) ) ) - (call_import $_abort) (block + (i32.store offset=12 + (get_local $i31) + (get_local $i12) + ) (i32.store - (get_local $i35) + (get_local $i2) (get_local $i12) ) - (i32.store offset=24 + (i32.store offset=8 (get_local $i12) - (get_local $i36) + (get_local $i31) ) (i32.store offset=12 (get_local $i12) - (get_local $i12) + (get_local $i33) ) - (i32.store offset=8 - (get_local $i12) + (i32.store offset=24 (get_local $i12) + (i32.const 0) ) - (br $do-once$16) - ) - ) - (if - (i32.eq - (get_local $i34) - (i32.const 130) - ) - (if - (i32.and - (i32.ge_u - (set_local $i31 - (i32.load - (set_local $i2 - (i32.add - (get_local $i33) - (i32.const 8) - ) - ) - ) - ) - (set_local $i9 - (i32.load - (i32.const 192) - ) - ) - ) - (i32.ge_u - (get_local $i33) - (get_local $i9) - ) - ) - (block - (i32.store offset=12 - (get_local $i31) - (get_local $i12) - ) - (i32.store - (get_local $i2) - (get_local $i12) - ) - (i32.store offset=8 - (get_local $i12) - (get_local $i31) - ) - (i32.store offset=12 - (get_local $i12) - (get_local $i33) - ) - (i32.store offset=24 - (get_local $i12) - (i32.const 0) - ) - (br $do-once$16) - ) - (call_import $_abort) ) + (call_import $_abort) ) ) ) - (block - (i32.store - (i32.const 180) - (i32.or - (get_local $i30) - (get_local $i18) - ) - ) - (i32.store - (get_local $i5) - (get_local $i12) - ) - (i32.store offset=24 - (get_local $i12) - (get_local $i5) - ) - (i32.store offset=12 - (get_local $i12) - (get_local $i12) - ) - (i32.store offset=8 - (get_local $i12) - (get_local $i12) + ) + (block + (i32.store + (i32.const 180) + (i32.or + (get_local $i30) + (get_local $i18) ) ) + (i32.store + (get_local $i5) + (get_local $i12) + ) + (i32.store offset=24 + (get_local $i12) + (get_local $i5) + ) + (i32.store offset=12 + (get_local $i12) + (get_local $i12) + ) + (i32.store offset=8 + (get_local $i12) + (get_local $i12) + ) ) ) (i32.store diff --git a/test/emcc_hello_world.fromasm b/test/emcc_hello_world.fromasm index 387da4310..603d2c0bf 100644 --- a/test/emcc_hello_world.fromasm +++ b/test/emcc_hello_world.fromasm @@ -2526,7 +2526,6 @@ (set_local $$retval$0 (i32.const 4) ) - (br $do-once$0) ) (block (i32.store @@ -2536,7 +2535,6 @@ (set_local $$retval$0 (i32.const -1) ) - (br $do-once$0) ) ) ) @@ -3859,44 +3857,38 @@ (i32.const 0) ) (loop $label$break$L1 $label$continue$L1 - (block $do-once$0 + (if + (i32.gt_s + (get_local $$cnt$0) + (i32.const -1) + ) (if (i32.gt_s - (get_local $$cnt$0) - (i32.const -1) - ) - (if - (i32.gt_s - (get_local $$l$0) - (i32.sub - (i32.const 2147483647) - (get_local $$cnt$0) - ) + (get_local $$l$0) + (i32.sub + (i32.const 2147483647) + (get_local $$cnt$0) ) - (block - (i32.store - (call $___errno_location) - (i32.const 75) - ) - (set_local $$cnt$1 - (i32.const -1) - ) - (br $do-once$0) + ) + (block + (i32.store + (call $___errno_location) + (i32.const 75) ) - (block - (set_local $$cnt$1 - (i32.add - (get_local $$l$0) - (get_local $$cnt$0) - ) - ) - (br $do-once$0) + (set_local $$cnt$1 + (i32.const -1) ) ) (set_local $$cnt$1 - (get_local $$cnt$0) + (i32.add + (get_local $$l$0) + (get_local $$cnt$0) + ) ) ) + (set_local $$cnt$1 + (get_local $$cnt$0) + ) ) (if (i32.eq @@ -6242,107 +6234,99 @@ (i32.const 2) ) ) - (block $do-once$58 - (if - (i32.or - (i32.gt_u - (get_local $$p$0) - (i32.const 11) - ) - (i32.eq - (set_local $$sub74$i - (i32.sub - (i32.const 12) - (get_local $$p$0) - ) + (if + (i32.or + (i32.gt_u + (get_local $$p$0) + (i32.const 11) + ) + (i32.eq + (set_local $$sub74$i + (i32.sub + (i32.const 12) + (get_local $$p$0) ) - (i32.const 0) ) + (i32.const 0) ) - (set_local $$y$addr$1$i - (get_local $$mul$i$240) + ) + (set_local $$y$addr$1$i + (get_local $$mul$i$240) + ) + (block + (set_local $$re$1482$i + (get_local $$sub74$i) ) - (block - (set_local $$re$1482$i - (get_local $$sub74$i) - ) - (set_local $$round$0481$i - (f64.const 8) + (set_local $$round$0481$i + (f64.const 8) + ) + (loop $while-out$60 $while-in$61 + (set_local $$mul80$i + (f64.mul + (get_local $$round$0481$i) + (f64.const 16) + ) ) - (loop $while-out$60 $while-in$61 - (set_local $$mul80$i - (f64.mul - (get_local $$round$0481$i) - (f64.const 16) + (if + (i32.eq + (set_local $$dec78$i + (i32.add + (get_local $$re$1482$i) + (i32.const -1) + ) ) + (i32.const 0) ) - (if - (i32.eq - (set_local $$dec78$i - (i32.add - (get_local $$re$1482$i) - (i32.const -1) - ) - ) - (i32.const 0) + (block + (set_local $$mul80$i$lcssa + (get_local $$mul80$i) ) - (block - (set_local $$mul80$i$lcssa - (get_local $$mul80$i) - ) - (br $while-out$60) + (br $while-out$60) + ) + (block + (set_local $$re$1482$i + (get_local $$dec78$i) ) - (block - (set_local $$re$1482$i - (get_local $$dec78$i) - ) - (set_local $$round$0481$i - (get_local $$mul80$i) - ) + (set_local $$round$0481$i + (get_local $$mul80$i) ) ) - (br $while-in$61) ) - (if - (i32.eq - (i32.shr_s - (i32.shl - (i32.load8_s - (get_local $$prefix$0$add$ptr65$i) - ) - (i32.const 24) + (br $while-in$61) + ) + (if + (i32.eq + (i32.shr_s + (i32.shl + (i32.load8_s + (get_local $$prefix$0$add$ptr65$i) ) (i32.const 24) ) - (i32.const 45) - ) - (block - (set_local $$y$addr$1$i - (f64.neg - (f64.add - (get_local $$mul80$i$lcssa) - (f64.sub - (f64.neg - (get_local $$mul$i$240) - ) - (get_local $$mul80$i$lcssa) - ) - ) - ) - ) - (br $do-once$58) + (i32.const 24) ) - (block - (set_local $$y$addr$1$i + (i32.const 45) + ) + (set_local $$y$addr$1$i + (f64.neg + (f64.add + (get_local $$mul80$i$lcssa) (f64.sub - (f64.add + (f64.neg (get_local $$mul$i$240) - (get_local $$mul80$i$lcssa) ) (get_local $$mul80$i$lcssa) ) ) - (br $do-once$58) + ) + ) + (set_local $$y$addr$1$i + (f64.sub + (f64.add + (get_local $$mul$i$240) + (get_local $$mul80$i$lcssa) + ) + (get_local $$mul80$i$lcssa) ) ) ) @@ -8282,7 +8266,6 @@ (set_local $$t$addr$1$i (get_local $$t$addr$0$i) ) - (br $do-once$98) ) (block (set_local $$$sub562$i @@ -8322,7 +8305,6 @@ (set_local $$t$addr$1$i (get_local $$t$addr$0$i) ) - (br $do-once$98) ) ) ) @@ -10928,7 +10910,6 @@ ) (br $label$break$L1) ) - (br $label$break$L1) ) ) ) @@ -11925,60 +11906,57 @@ ) ) ) - (block $do-once$2 - (if - (i32.eq - (get_local $$arrayidx) - (get_local $$3) - ) - (i32.store - (i32.const 176) - (i32.and - (get_local $$0) - (i32.xor - (i32.shl - (i32.const 1) - (get_local $$add8) - ) - (i32.const -1) + (if + (i32.eq + (get_local $$arrayidx) + (get_local $$3) + ) + (i32.store + (i32.const 176) + (i32.and + (get_local $$0) + (i32.xor + (i32.shl + (i32.const 1) + (get_local $$add8) ) + (i32.const -1) ) ) - (block - (if - (i32.lt_u - (get_local $$3) - (i32.load - (i32.const 192) - ) + ) + (block + (if + (i32.lt_u + (get_local $$3) + (i32.load + (i32.const 192) ) - (call_import $_abort) ) - (if - (i32.eq - (i32.load - (set_local $$bk - (i32.add - (get_local $$3) - (i32.const 12) - ) + (call_import $_abort) + ) + (if + (i32.eq + (i32.load + (set_local $$bk + (i32.add + (get_local $$3) + (i32.const 12) ) ) - (get_local $$2) ) - (block - (i32.store - (get_local $$bk) - (get_local $$arrayidx) - ) - (i32.store - (get_local $$1) - (get_local $$3) - ) - (br $do-once$2) + (get_local $$2) + ) + (block + (i32.store + (get_local $$bk) + (get_local $$arrayidx) + ) + (i32.store + (get_local $$1) + (get_local $$3) ) - (call_import $_abort) ) + (call_import $_abort) ) ) ) @@ -12184,70 +12162,67 @@ ) ) ) - (block $do-once$4 - (if - (i32.eq - (get_local $$arrayidx66) - (get_local $$10) - ) - (block - (i32.store - (i32.const 176) - (i32.and - (get_local $$0) - (i32.xor - (i32.shl - (i32.const 1) - (get_local $$add64) - ) - (i32.const -1) + (if + (i32.eq + (get_local $$arrayidx66) + (get_local $$10) + ) + (block + (i32.store + (i32.const 176) + (i32.and + (get_local $$0) + (i32.xor + (i32.shl + (i32.const 1) + (get_local $$add64) ) + (i32.const -1) ) ) - (set_local $$13 - (get_local $$7) - ) ) - (block - (if - (i32.lt_u - (get_local $$10) - (i32.load - (i32.const 192) - ) + (set_local $$13 + (get_local $$7) + ) + ) + (block + (if + (i32.lt_u + (get_local $$10) + (i32.load + (i32.const 192) ) - (call_import $_abort) ) - (if - (i32.eq - (i32.load - (set_local $$bk78 - (i32.add - (get_local $$10) - (i32.const 12) - ) + (call_import $_abort) + ) + (if + (i32.eq + (i32.load + (set_local $$bk78 + (i32.add + (get_local $$10) + (i32.const 12) ) ) - (get_local $$9) ) - (block - (i32.store - (get_local $$bk78) - (get_local $$arrayidx66) - ) - (i32.store - (get_local $$8) - (get_local $$10) - ) - (set_local $$13 - (i32.load - (i32.const 184) - ) + (get_local $$9) + ) + (block + (i32.store + (get_local $$bk78) + (get_local $$arrayidx66) + ) + (i32.store + (get_local $$8) + (get_local $$10) + ) + (set_local $$13 + (i32.load + (i32.const 184) ) - (br $do-once$4) ) - (call_import $_abort) ) + (call_import $_abort) ) ) ) @@ -12779,7 +12754,6 @@ (set_local $$R$3$i (get_local $$R$1$i$lcssa) ) - (br $do-once$8) ) ) ) @@ -12835,7 +12809,6 @@ (set_local $$R$3$i (get_local $$27) ) - (br $do-once$8) ) (call_import $_abort) ) @@ -12954,34 +12927,31 @@ (get_local $$R$3$i) (get_local $$26) ) - (block $do-once$14 - (if - (i32.eqz - (i32.eq - (set_local $$41 - (i32.load offset=16 - (get_local $$v$0$i$lcssa) - ) + (if + (i32.eqz + (i32.eq + (set_local $$41 + (i32.load offset=16 + (get_local $$v$0$i$lcssa) ) - (i32.const 0) ) + (i32.const 0) ) - (if - (i32.lt_u + ) + (if + (i32.lt_u + (get_local $$41) + (get_local $$40) + ) + (call_import $_abort) + (block + (i32.store offset=16 + (get_local $$R$3$i) (get_local $$41) - (get_local $$40) ) - (call_import $_abort) - (block - (i32.store offset=16 - (get_local $$R$3$i) - (get_local $$41) - ) - (i32.store offset=24 - (get_local $$41) - (get_local $$R$3$i) - ) - (br $do-once$14) + (i32.store offset=24 + (get_local $$41) + (get_local $$R$3$i) ) ) ) @@ -13014,7 +12984,6 @@ (get_local $$42) (get_local $$R$3$i) ) - (br $do-once$12) ) ) ) @@ -14052,7 +14021,6 @@ (set_local $$R$3$i$171 (get_local $$R$1$i$168$lcssa) ) - (br $do-once$21) ) ) ) @@ -14108,7 +14076,6 @@ (set_local $$R$3$i$171 (get_local $$64) ) - (br $do-once$21) ) (call_import $_abort) ) @@ -14227,34 +14194,31 @@ (get_local $$R$3$i$171) (get_local $$63) ) - (block $do-once$27 - (if - (i32.eqz - (i32.eq - (set_local $$78 - (i32.load offset=16 - (get_local $$v$4$lcssa$i) - ) + (if + (i32.eqz + (i32.eq + (set_local $$78 + (i32.load offset=16 + (get_local $$v$4$lcssa$i) ) - (i32.const 0) ) + (i32.const 0) ) - (if - (i32.lt_u + ) + (if + (i32.lt_u + (get_local $$78) + (get_local $$77) + ) + (call_import $_abort) + (block + (i32.store offset=16 + (get_local $$R$3$i$171) (get_local $$78) - (get_local $$77) ) - (call_import $_abort) - (block - (i32.store offset=16 - (get_local $$R$3$i$171) - (get_local $$78) - ) - (i32.store offset=24 - (get_local $$78) - (get_local $$R$3$i$171) - ) - (br $do-once$27) + (i32.store offset=24 + (get_local $$78) + (get_local $$R$3$i$171) ) ) ) @@ -14287,7 +14251,6 @@ (get_local $$79) (get_local $$R$3$i$171) ) - (br $do-once$25) ) ) ) @@ -14776,7 +14739,6 @@ (get_local $$add$ptr$i$161) (get_local $$add$ptr$i$161) ) - (br $do-once$29) ) ) (if @@ -14829,7 +14791,6 @@ (get_local $$add$ptr$i$161) (i32.const 0) ) - (br $do-once$29) ) (call_import $_abort) ) @@ -15019,70 +14980,67 @@ ) ) ) - (block $do-once$33 + (if + (i32.eq + (i32.load + (i32.const 648) + ) + (i32.const 0) + ) (if (i32.eq - (i32.load - (i32.const 648) - ) - (i32.const 0) - ) - (if - (i32.eq - (i32.and - (i32.add - (set_local $$call$i$i - (call_import $_sysconf - (i32.const 30) - ) + (i32.and + (i32.add + (set_local $$call$i$i + (call_import $_sysconf + (i32.const 30) ) - (i32.const -1) ) - (get_local $$call$i$i) + (i32.const -1) ) + (get_local $$call$i$i) + ) + (i32.const 0) + ) + (block + (i32.store + (i32.const 656) + (get_local $$call$i$i) + ) + (i32.store + (i32.const 652) + (get_local $$call$i$i) + ) + (i32.store + (i32.const 660) + (i32.const -1) + ) + (i32.store + (i32.const 664) + (i32.const -1) + ) + (i32.store + (i32.const 668) (i32.const 0) ) - (block - (i32.store - (i32.const 656) - (get_local $$call$i$i) - ) - (i32.store - (i32.const 652) - (get_local $$call$i$i) - ) - (i32.store - (i32.const 660) - (i32.const -1) - ) - (i32.store - (i32.const 664) - (i32.const -1) - ) - (i32.store - (i32.const 668) - (i32.const 0) - ) - (i32.store - (i32.const 620) - (i32.const 0) - ) - (i32.store - (i32.const 648) - (i32.xor - (i32.and - (call_import $_time - (i32.const 0) - ) - (i32.const -16) + (i32.store + (i32.const 620) + (i32.const 0) + ) + (i32.store + (i32.const 648) + (i32.xor + (i32.and + (call_import $_time + (i32.const 0) ) - (i32.const 1431655768) + (i32.const -16) ) + (i32.const 1431655768) ) - (br $do-once$33) ) - (call_import $_abort) ) + (call_import $_abort) ) ) (set_local $$add$i$180 @@ -15474,78 +15432,73 @@ (get_local $$ssize$2$ph$i) ) ) - (block $do-once$42 - (if + (if + (i32.and + (i32.gt_u + (get_local $$add$i$180) + (get_local $$ssize$2$ph$i) + ) (i32.and - (i32.gt_u - (get_local $$add$i$180) + (i32.lt_u (get_local $$ssize$2$ph$i) + (i32.const 2147483647) ) - (i32.and - (i32.lt_u - (get_local $$ssize$2$ph$i) - (i32.const 2147483647) - ) - (i32.ne - (get_local $$br$2$ph$i) - (i32.const -1) - ) + (i32.ne + (get_local $$br$2$ph$i) + (i32.const -1) ) ) - (if - (i32.lt_u - (set_local $$and104$i - (i32.and - (i32.add - (i32.sub - (get_local $$sub$i$181) - (get_local $$ssize$2$ph$i) - ) - (set_local $$115 - (i32.load - (i32.const 656) - ) - ) - ) + ) + (if + (i32.lt_u + (set_local $$and104$i + (i32.and + (i32.add (i32.sub - (i32.const 0) - (get_local $$115) + (get_local $$sub$i$181) + (get_local $$ssize$2$ph$i) + ) + (set_local $$115 + (i32.load + (i32.const 656) + ) ) ) - ) - (i32.const 2147483647) - ) - (if - (i32.eq - (call_import $_sbrk - (get_local $$and104$i) + (i32.sub + (i32.const 0) + (get_local $$115) ) - (i32.const -1) ) - (block - (call_import $_sbrk - (get_local $$sub112$i) - ) - (br $label$break$L279) + ) + (i32.const 2147483647) + ) + (if + (i32.eq + (call_import $_sbrk + (get_local $$and104$i) ) - (block - (set_local $$ssize$5$i - (i32.add - (get_local $$and104$i) - (get_local $$ssize$2$ph$i) - ) - ) - (br $do-once$42) + (i32.const -1) + ) + (block + (call_import $_sbrk + (get_local $$sub112$i) ) + (br $label$break$L279) ) (set_local $$ssize$5$i - (get_local $$ssize$2$ph$i) + (i32.add + (get_local $$and104$i) + (get_local $$ssize$2$ph$i) + ) ) ) (set_local $$ssize$5$i (get_local $$ssize$2$ph$i) ) ) + (set_local $$ssize$5$i + (get_local $$ssize$2$ph$i) + ) ) (if (i32.eqz @@ -16603,7 +16556,6 @@ (set_local $$R$3$i$i (get_local $$R$1$i$i$lcssa) ) - (br $do-once$59) ) ) ) @@ -16659,7 +16611,6 @@ (set_local $$R$3$i$i (get_local $$155) ) - (br $do-once$59) ) (call_import $_abort) ) @@ -16777,39 +16728,36 @@ (get_local $$R$3$i$i) (get_local $$154) ) - (block $do-once$65 - (if - (i32.eqz - (i32.eq - (set_local $$169 - (i32.load - (set_local $$child166$i$i - (i32.add - (get_local $$add$ptr16$i$i) - (i32.const 16) - ) + (if + (i32.eqz + (i32.eq + (set_local $$169 + (i32.load + (set_local $$child166$i$i + (i32.add + (get_local $$add$ptr16$i$i) + (i32.const 16) ) ) ) - (i32.const 0) ) + (i32.const 0) ) - (if - (i32.lt_u + ) + (if + (i32.lt_u + (get_local $$169) + (get_local $$168) + ) + (call_import $_abort) + (block + (i32.store offset=16 + (get_local $$R$3$i$i) (get_local $$169) - (get_local $$168) ) - (call_import $_abort) - (block - (i32.store offset=16 - (get_local $$R$3$i$i) - (get_local $$169) - ) - (i32.store offset=24 - (get_local $$169) - (get_local $$R$3$i$i) - ) - (br $do-once$65) + (i32.store offset=24 + (get_local $$169) + (get_local $$R$3$i$i) ) ) ) @@ -16841,7 +16789,6 @@ (get_local $$170) (get_local $$R$3$i$i) ) - (br $label$break$L331) ) ) ) @@ -17332,7 +17279,6 @@ (get_local $$add$ptr17$i$i) (get_local $$add$ptr17$i$i) ) - (br $do-once$52) ) ) (if @@ -17385,7 +17331,6 @@ (get_local $$add$ptr17$i$i) (i32.const 0) ) - (br $do-once$52) ) (call_import $_abort) ) @@ -18110,7 +18055,6 @@ (get_local $$119) (get_local $$119) ) - (br $do-once$44) ) ) (if @@ -18163,7 +18107,6 @@ (get_local $$119) (i32.const 0) ) - (br $do-once$44) ) (call_import $_abort) ) @@ -18812,7 +18755,6 @@ (set_local $$R$3 (get_local $$R$1$lcssa) ) - (br $do-once$2) ) ) ) @@ -18868,7 +18810,6 @@ (set_local $$R$3 (get_local $$10) ) - (br $do-once$2) ) (call_import $_abort) ) @@ -19007,39 +18948,36 @@ (get_local $$R$3) (get_local $$9) ) - (block $do-once$6 - (if - (i32.eqz - (i32.eq - (set_local $$24 - (i32.load - (set_local $$child171 - (i32.add - (get_local $$add$ptr16) - (i32.const 16) - ) + (if + (i32.eqz + (i32.eq + (set_local $$24 + (i32.load + (set_local $$child171 + (i32.add + (get_local $$add$ptr16) + (i32.const 16) ) ) ) - (i32.const 0) ) + (i32.const 0) ) - (if - (i32.lt_u + ) + (if + (i32.lt_u + (get_local $$24) + (get_local $$23) + ) + (call_import $_abort) + (block + (i32.store offset=16 + (get_local $$R$3) (get_local $$24) - (get_local $$23) ) - (call_import $_abort) - (block - (i32.store offset=16 - (get_local $$R$3) - (get_local $$24) - ) - (i32.store offset=24 - (get_local $$24) - (get_local $$R$3) - ) - (br $do-once$6) + (i32.store offset=24 + (get_local $$24) + (get_local $$R$3) ) ) ) @@ -19084,7 +19022,6 @@ (set_local $$psize$1 (get_local $$add17) ) - (br $do-once$0) ) ) ) @@ -19521,7 +19458,6 @@ (set_local $$R332$3 (get_local $$R332$1$lcssa) ) - (br $do-once$10) ) ) ) @@ -19579,7 +19515,6 @@ (set_local $$R332$3 (get_local $$42) ) - (br $do-once$10) ) (call_import $_abort) ) @@ -19697,39 +19632,36 @@ (get_local $$R332$3) (get_local $$41) ) - (block $do-once$14 - (if - (i32.eqz - (i32.eq - (set_local $$58 - (i32.load - (set_local $$child443 - (i32.add - (get_local $$add$ptr6) - (i32.const 16) - ) + (if + (i32.eqz + (i32.eq + (set_local $$58 + (i32.load + (set_local $$child443 + (i32.add + (get_local $$add$ptr6) + (i32.const 16) ) ) ) - (i32.const 0) ) + (i32.const 0) ) - (if - (i32.lt_u + ) + (if + (i32.lt_u + (get_local $$58) + (get_local $$57) + ) + (call_import $_abort) + (block + (i32.store offset=16 + (get_local $$R332$3) (get_local $$58) - (get_local $$57) ) - (call_import $_abort) - (block - (i32.store offset=16 - (get_local $$R332$3) - (get_local $$58) - ) - (i32.store offset=24 - (get_local $$58) - (get_local $$R332$3) - ) - (br $do-once$14) + (i32.store offset=24 + (get_local $$58) + (get_local $$R332$3) ) ) ) @@ -19762,7 +19694,6 @@ (get_local $$59) (get_local $$R332$3) ) - (br $do-once$8) ) ) ) @@ -20066,243 +19997,239 @@ (get_local $$p$1) (i32.const 0) ) - (block $do-once$16 - (if - (i32.eq - (i32.and - (set_local $$66 - (i32.load - (i32.const 180) - ) - ) - (set_local $$shl573 - (i32.shl - (i32.const 1) - (get_local $$I534$0) - ) + (if + (i32.eq + (i32.and + (set_local $$66 + (i32.load + (i32.const 180) ) ) - (i32.const 0) - ) - (block - (i32.store - (i32.const 180) - (i32.or - (get_local $$66) - (get_local $$shl573) + (set_local $$shl573 + (i32.shl + (i32.const 1) + (get_local $$I534$0) ) ) - (i32.store - (get_local $$arrayidx567) - (get_local $$p$1) + ) + (i32.const 0) + ) + (block + (i32.store + (i32.const 180) + (i32.or + (get_local $$66) + (get_local $$shl573) ) - (i32.store offset=24 - (get_local $$p$1) + ) + (i32.store + (get_local $$arrayidx567) + (get_local $$p$1) + ) + (i32.store offset=24 + (get_local $$p$1) + (get_local $$arrayidx567) + ) + (i32.store offset=12 + (get_local $$p$1) + (get_local $$p$1) + ) + (i32.store offset=8 + (get_local $$p$1) + (get_local $$p$1) + ) + ) + (block + (set_local $$67 + (i32.load (get_local $$arrayidx567) ) - (i32.store offset=12 - (get_local $$p$1) - (get_local $$p$1) - ) - (i32.store offset=8 - (get_local $$p$1) - (get_local $$p$1) + ) + (set_local $$sub589 + (i32.sub + (i32.const 25) + (i32.shr_u + (get_local $$I534$0) + (i32.const 1) + ) ) ) - (block - (set_local $$67 - (i32.load - (get_local $$arrayidx567) + (set_local $$cond + (if + (i32.eq + (get_local $$I534$0) + (i32.const 31) ) + (i32.const 0) + (get_local $$sub589) ) - (set_local $$sub589 - (i32.sub - (i32.const 25) - (i32.shr_u - (get_local $$I534$0) - (i32.const 1) + ) + (set_local $$K583$0 + (i32.shl + (get_local $$psize$2) + (get_local $$cond) + ) + ) + (set_local $$T$0 + (get_local $$67) + ) + (loop $while-out$18 $while-in$19 + (if + (i32.eq + (i32.and + (i32.load offset=4 + (get_local $$T$0) + ) + (i32.const -8) ) + (get_local $$psize$2) ) - ) - (set_local $$cond - (if - (i32.eq - (get_local $$I534$0) - (i32.const 31) + (block + (set_local $$T$0$lcssa + (get_local $$T$0) ) - (i32.const 0) - (get_local $$sub589) + (set_local $label + (i32.const 130) + ) + (br $while-out$18) ) ) - (set_local $$K583$0 + (set_local $$shl600 (i32.shl - (get_local $$psize$2) - (get_local $$cond) + (get_local $$K583$0) + (i32.const 1) ) ) - (set_local $$T$0 - (get_local $$67) - ) - (loop $while-out$18 $while-in$19 - (if - (i32.eq - (i32.and - (i32.load offset=4 - (get_local $$T$0) + (if + (i32.eq + (set_local $$69 + (i32.load + (set_local $$arrayidx599 + (i32.add + (i32.add + (get_local $$T$0) + (i32.const 16) + ) + (i32.shl + (i32.shr_u + (get_local $$K583$0) + (i32.const 31) + ) + (i32.const 2) + ) + ) ) - (i32.const -8) ) - (get_local $$psize$2) ) - (block - (set_local $$T$0$lcssa - (get_local $$T$0) - ) - (set_local $label - (i32.const 130) - ) - (br $while-out$18) + (i32.const 0) + ) + (block + (set_local $$T$0$lcssa319 + (get_local $$T$0) + ) + (set_local $$arrayidx599$lcssa + (get_local $$arrayidx599) + ) + (set_local $label + (i32.const 127) ) + (br $while-out$18) ) - (set_local $$shl600 - (i32.shl - (get_local $$K583$0) - (i32.const 1) + (block + (set_local $$K583$0 + (get_local $$shl600) + ) + (set_local $$T$0 + (get_local $$69) ) ) - (if - (i32.eq - (set_local $$69 - (i32.load - (set_local $$arrayidx599 - (i32.add - (i32.add - (get_local $$T$0) - (i32.const 16) - ) - (i32.shl - (i32.shr_u - (get_local $$K583$0) - (i32.const 31) - ) - (i32.const 2) - ) - ) - ) - ) - ) - (i32.const 0) + ) + (br $while-in$19) + ) + (if + (i32.eq + (get_local $label) + (i32.const 127) + ) + (if + (i32.lt_u + (get_local $$arrayidx599$lcssa) + (i32.load + (i32.const 192) ) - (block - (set_local $$T$0$lcssa319 - (get_local $$T$0) - ) - (set_local $$arrayidx599$lcssa - (get_local $$arrayidx599) - ) - (set_local $label - (i32.const 127) - ) - (br $while-out$18) + ) + (call_import $_abort) + (block + (i32.store + (get_local $$arrayidx599$lcssa) + (get_local $$p$1) ) - (block - (set_local $$K583$0 - (get_local $$shl600) - ) - (set_local $$T$0 - (get_local $$69) - ) + (i32.store offset=24 + (get_local $$p$1) + (get_local $$T$0$lcssa319) + ) + (i32.store offset=12 + (get_local $$p$1) + (get_local $$p$1) + ) + (i32.store offset=8 + (get_local $$p$1) + (get_local $$p$1) ) ) - (br $while-in$19) ) (if (i32.eq (get_local $label) - (i32.const 127) + (i32.const 130) ) (if - (i32.lt_u - (get_local $$arrayidx599$lcssa) - (i32.load - (i32.const 192) + (i32.and + (i32.ge_u + (set_local $$71 + (i32.load + (set_local $$fd620 + (i32.add + (get_local $$T$0$lcssa) + (i32.const 8) + ) + ) + ) + ) + (set_local $$72 + (i32.load + (i32.const 192) + ) + ) + ) + (i32.ge_u + (get_local $$T$0$lcssa) + (get_local $$72) ) ) - (call_import $_abort) (block + (i32.store offset=12 + (get_local $$71) + (get_local $$p$1) + ) (i32.store - (get_local $$arrayidx599$lcssa) + (get_local $$fd620) (get_local $$p$1) ) - (i32.store offset=24 + (i32.store offset=8 (get_local $$p$1) - (get_local $$T$0$lcssa319) + (get_local $$71) ) (i32.store offset=12 (get_local $$p$1) - (get_local $$p$1) + (get_local $$T$0$lcssa) ) - (i32.store offset=8 - (get_local $$p$1) + (i32.store offset=24 (get_local $$p$1) + (i32.const 0) ) - (br $do-once$16) - ) - ) - (if - (i32.eq - (get_local $label) - (i32.const 130) - ) - (if - (i32.and - (i32.ge_u - (set_local $$71 - (i32.load - (set_local $$fd620 - (i32.add - (get_local $$T$0$lcssa) - (i32.const 8) - ) - ) - ) - ) - (set_local $$72 - (i32.load - (i32.const 192) - ) - ) - ) - (i32.ge_u - (get_local $$T$0$lcssa) - (get_local $$72) - ) - ) - (block - (i32.store offset=12 - (get_local $$71) - (get_local $$p$1) - ) - (i32.store - (get_local $$fd620) - (get_local $$p$1) - ) - (i32.store offset=8 - (get_local $$p$1) - (get_local $$71) - ) - (i32.store offset=12 - (get_local $$p$1) - (get_local $$T$0$lcssa) - ) - (i32.store offset=24 - (get_local $$p$1) - (i32.const 0) - ) - (br $do-once$16) - ) - (call_import $_abort) ) + (call_import $_abort) ) ) ) diff --git a/test/emcc_hello_world.fromasm.imprecise b/test/emcc_hello_world.fromasm.imprecise index 6fcffbf53..b8890f5ed 100644 --- a/test/emcc_hello_world.fromasm.imprecise +++ b/test/emcc_hello_world.fromasm.imprecise @@ -2524,7 +2524,6 @@ (set_local $$retval$0 (i32.const 4) ) - (br $do-once$0) ) (block (i32.store @@ -2534,7 +2533,6 @@ (set_local $$retval$0 (i32.const -1) ) - (br $do-once$0) ) ) ) @@ -3857,44 +3855,38 @@ (i32.const 0) ) (loop $label$break$L1 $label$continue$L1 - (block $do-once$0 + (if + (i32.gt_s + (get_local $$cnt$0) + (i32.const -1) + ) (if (i32.gt_s - (get_local $$cnt$0) - (i32.const -1) - ) - (if - (i32.gt_s - (get_local $$l$0) - (i32.sub - (i32.const 2147483647) - (get_local $$cnt$0) - ) + (get_local $$l$0) + (i32.sub + (i32.const 2147483647) + (get_local $$cnt$0) ) - (block - (i32.store - (call $___errno_location) - (i32.const 75) - ) - (set_local $$cnt$1 - (i32.const -1) - ) - (br $do-once$0) + ) + (block + (i32.store + (call $___errno_location) + (i32.const 75) ) - (block - (set_local $$cnt$1 - (i32.add - (get_local $$l$0) - (get_local $$cnt$0) - ) - ) - (br $do-once$0) + (set_local $$cnt$1 + (i32.const -1) ) ) (set_local $$cnt$1 - (get_local $$cnt$0) + (i32.add + (get_local $$l$0) + (get_local $$cnt$0) + ) ) ) + (set_local $$cnt$1 + (get_local $$cnt$0) + ) ) (if (i32.eq @@ -6240,107 +6232,99 @@ (i32.const 2) ) ) - (block $do-once$58 - (if - (i32.or - (i32.gt_u - (get_local $$p$0) - (i32.const 11) - ) - (i32.eq - (set_local $$sub74$i - (i32.sub - (i32.const 12) - (get_local $$p$0) - ) + (if + (i32.or + (i32.gt_u + (get_local $$p$0) + (i32.const 11) + ) + (i32.eq + (set_local $$sub74$i + (i32.sub + (i32.const 12) + (get_local $$p$0) ) - (i32.const 0) ) + (i32.const 0) ) - (set_local $$y$addr$1$i - (get_local $$mul$i$240) + ) + (set_local $$y$addr$1$i + (get_local $$mul$i$240) + ) + (block + (set_local $$re$1482$i + (get_local $$sub74$i) ) - (block - (set_local $$re$1482$i - (get_local $$sub74$i) - ) - (set_local $$round$0481$i - (f64.const 8) + (set_local $$round$0481$i + (f64.const 8) + ) + (loop $while-out$60 $while-in$61 + (set_local $$mul80$i + (f64.mul + (get_local $$round$0481$i) + (f64.const 16) + ) ) - (loop $while-out$60 $while-in$61 - (set_local $$mul80$i - (f64.mul - (get_local $$round$0481$i) - (f64.const 16) + (if + (i32.eq + (set_local $$dec78$i + (i32.add + (get_local $$re$1482$i) + (i32.const -1) + ) ) + (i32.const 0) ) - (if - (i32.eq - (set_local $$dec78$i - (i32.add - (get_local $$re$1482$i) - (i32.const -1) - ) - ) - (i32.const 0) + (block + (set_local $$mul80$i$lcssa + (get_local $$mul80$i) ) - (block - (set_local $$mul80$i$lcssa - (get_local $$mul80$i) - ) - (br $while-out$60) + (br $while-out$60) + ) + (block + (set_local $$re$1482$i + (get_local $$dec78$i) ) - (block - (set_local $$re$1482$i - (get_local $$dec78$i) - ) - (set_local $$round$0481$i - (get_local $$mul80$i) - ) + (set_local $$round$0481$i + (get_local $$mul80$i) ) ) - (br $while-in$61) ) - (if - (i32.eq - (i32.shr_s - (i32.shl - (i32.load8_s - (get_local $$prefix$0$add$ptr65$i) - ) - (i32.const 24) + (br $while-in$61) + ) + (if + (i32.eq + (i32.shr_s + (i32.shl + (i32.load8_s + (get_local $$prefix$0$add$ptr65$i) ) (i32.const 24) ) - (i32.const 45) - ) - (block - (set_local $$y$addr$1$i - (f64.neg - (f64.add - (get_local $$mul80$i$lcssa) - (f64.sub - (f64.neg - (get_local $$mul$i$240) - ) - (get_local $$mul80$i$lcssa) - ) - ) - ) - ) - (br $do-once$58) + (i32.const 24) ) - (block - (set_local $$y$addr$1$i + (i32.const 45) + ) + (set_local $$y$addr$1$i + (f64.neg + (f64.add + (get_local $$mul80$i$lcssa) (f64.sub - (f64.add + (f64.neg (get_local $$mul$i$240) - (get_local $$mul80$i$lcssa) ) (get_local $$mul80$i$lcssa) ) ) - (br $do-once$58) + ) + ) + (set_local $$y$addr$1$i + (f64.sub + (f64.add + (get_local $$mul$i$240) + (get_local $$mul80$i$lcssa) + ) + (get_local $$mul80$i$lcssa) ) ) ) @@ -8280,7 +8264,6 @@ (set_local $$t$addr$1$i (get_local $$t$addr$0$i) ) - (br $do-once$98) ) (block (set_local $$$sub562$i @@ -8320,7 +8303,6 @@ (set_local $$t$addr$1$i (get_local $$t$addr$0$i) ) - (br $do-once$98) ) ) ) @@ -10926,7 +10908,6 @@ ) (br $label$break$L1) ) - (br $label$break$L1) ) ) ) @@ -11923,60 +11904,57 @@ ) ) ) - (block $do-once$2 - (if - (i32.eq - (get_local $$arrayidx) - (get_local $$3) - ) - (i32.store - (i32.const 176) - (i32.and - (get_local $$0) - (i32.xor - (i32.shl - (i32.const 1) - (get_local $$add8) - ) - (i32.const -1) + (if + (i32.eq + (get_local $$arrayidx) + (get_local $$3) + ) + (i32.store + (i32.const 176) + (i32.and + (get_local $$0) + (i32.xor + (i32.shl + (i32.const 1) + (get_local $$add8) ) + (i32.const -1) ) ) - (block - (if - (i32.lt_u - (get_local $$3) - (i32.load - (i32.const 192) - ) + ) + (block + (if + (i32.lt_u + (get_local $$3) + (i32.load + (i32.const 192) ) - (call_import $_abort) ) - (if - (i32.eq - (i32.load - (set_local $$bk - (i32.add - (get_local $$3) - (i32.const 12) - ) + (call_import $_abort) + ) + (if + (i32.eq + (i32.load + (set_local $$bk + (i32.add + (get_local $$3) + (i32.const 12) ) ) - (get_local $$2) ) - (block - (i32.store - (get_local $$bk) - (get_local $$arrayidx) - ) - (i32.store - (get_local $$1) - (get_local $$3) - ) - (br $do-once$2) + (get_local $$2) + ) + (block + (i32.store + (get_local $$bk) + (get_local $$arrayidx) + ) + (i32.store + (get_local $$1) + (get_local $$3) ) - (call_import $_abort) ) + (call_import $_abort) ) ) ) @@ -12182,70 +12160,67 @@ ) ) ) - (block $do-once$4 - (if - (i32.eq - (get_local $$arrayidx66) - (get_local $$10) - ) - (block - (i32.store - (i32.const 176) - (i32.and - (get_local $$0) - (i32.xor - (i32.shl - (i32.const 1) - (get_local $$add64) - ) - (i32.const -1) + (if + (i32.eq + (get_local $$arrayidx66) + (get_local $$10) + ) + (block + (i32.store + (i32.const 176) + (i32.and + (get_local $$0) + (i32.xor + (i32.shl + (i32.const 1) + (get_local $$add64) ) + (i32.const -1) ) ) - (set_local $$13 - (get_local $$7) - ) ) - (block - (if - (i32.lt_u - (get_local $$10) - (i32.load - (i32.const 192) - ) + (set_local $$13 + (get_local $$7) + ) + ) + (block + (if + (i32.lt_u + (get_local $$10) + (i32.load + (i32.const 192) ) - (call_import $_abort) ) - (if - (i32.eq - (i32.load - (set_local $$bk78 - (i32.add - (get_local $$10) - (i32.const 12) - ) + (call_import $_abort) + ) + (if + (i32.eq + (i32.load + (set_local $$bk78 + (i32.add + (get_local $$10) + (i32.const 12) ) ) - (get_local $$9) ) - (block - (i32.store - (get_local $$bk78) - (get_local $$arrayidx66) - ) - (i32.store - (get_local $$8) - (get_local $$10) - ) - (set_local $$13 - (i32.load - (i32.const 184) - ) + (get_local $$9) + ) + (block + (i32.store + (get_local $$bk78) + (get_local $$arrayidx66) + ) + (i32.store + (get_local $$8) + (get_local $$10) + ) + (set_local $$13 + (i32.load + (i32.const 184) ) - (br $do-once$4) ) - (call_import $_abort) ) + (call_import $_abort) ) ) ) @@ -12777,7 +12752,6 @@ (set_local $$R$3$i (get_local $$R$1$i$lcssa) ) - (br $do-once$8) ) ) ) @@ -12833,7 +12807,6 @@ (set_local $$R$3$i (get_local $$27) ) - (br $do-once$8) ) (call_import $_abort) ) @@ -12952,34 +12925,31 @@ (get_local $$R$3$i) (get_local $$26) ) - (block $do-once$14 - (if - (i32.eqz - (i32.eq - (set_local $$41 - (i32.load offset=16 - (get_local $$v$0$i$lcssa) - ) + (if + (i32.eqz + (i32.eq + (set_local $$41 + (i32.load offset=16 + (get_local $$v$0$i$lcssa) ) - (i32.const 0) ) + (i32.const 0) ) - (if - (i32.lt_u + ) + (if + (i32.lt_u + (get_local $$41) + (get_local $$40) + ) + (call_import $_abort) + (block + (i32.store offset=16 + (get_local $$R$3$i) (get_local $$41) - (get_local $$40) ) - (call_import $_abort) - (block - (i32.store offset=16 - (get_local $$R$3$i) - (get_local $$41) - ) - (i32.store offset=24 - (get_local $$41) - (get_local $$R$3$i) - ) - (br $do-once$14) + (i32.store offset=24 + (get_local $$41) + (get_local $$R$3$i) ) ) ) @@ -13012,7 +12982,6 @@ (get_local $$42) (get_local $$R$3$i) ) - (br $do-once$12) ) ) ) @@ -14050,7 +14019,6 @@ (set_local $$R$3$i$171 (get_local $$R$1$i$168$lcssa) ) - (br $do-once$21) ) ) ) @@ -14106,7 +14074,6 @@ (set_local $$R$3$i$171 (get_local $$64) ) - (br $do-once$21) ) (call_import $_abort) ) @@ -14225,34 +14192,31 @@ (get_local $$R$3$i$171) (get_local $$63) ) - (block $do-once$27 - (if - (i32.eqz - (i32.eq - (set_local $$78 - (i32.load offset=16 - (get_local $$v$4$lcssa$i) - ) + (if + (i32.eqz + (i32.eq + (set_local $$78 + (i32.load offset=16 + (get_local $$v$4$lcssa$i) ) - (i32.const 0) ) + (i32.const 0) ) - (if - (i32.lt_u + ) + (if + (i32.lt_u + (get_local $$78) + (get_local $$77) + ) + (call_import $_abort) + (block + (i32.store offset=16 + (get_local $$R$3$i$171) (get_local $$78) - (get_local $$77) ) - (call_import $_abort) - (block - (i32.store offset=16 - (get_local $$R$3$i$171) - (get_local $$78) - ) - (i32.store offset=24 - (get_local $$78) - (get_local $$R$3$i$171) - ) - (br $do-once$27) + (i32.store offset=24 + (get_local $$78) + (get_local $$R$3$i$171) ) ) ) @@ -14285,7 +14249,6 @@ (get_local $$79) (get_local $$R$3$i$171) ) - (br $do-once$25) ) ) ) @@ -14774,7 +14737,6 @@ (get_local $$add$ptr$i$161) (get_local $$add$ptr$i$161) ) - (br $do-once$29) ) ) (if @@ -14827,7 +14789,6 @@ (get_local $$add$ptr$i$161) (i32.const 0) ) - (br $do-once$29) ) (call_import $_abort) ) @@ -15017,70 +14978,67 @@ ) ) ) - (block $do-once$33 + (if + (i32.eq + (i32.load + (i32.const 648) + ) + (i32.const 0) + ) (if (i32.eq - (i32.load - (i32.const 648) - ) - (i32.const 0) - ) - (if - (i32.eq - (i32.and - (i32.add - (set_local $$call$i$i - (call_import $_sysconf - (i32.const 30) - ) + (i32.and + (i32.add + (set_local $$call$i$i + (call_import $_sysconf + (i32.const 30) ) - (i32.const -1) ) - (get_local $$call$i$i) + (i32.const -1) ) + (get_local $$call$i$i) + ) + (i32.const 0) + ) + (block + (i32.store + (i32.const 656) + (get_local $$call$i$i) + ) + (i32.store + (i32.const 652) + (get_local $$call$i$i) + ) + (i32.store + (i32.const 660) + (i32.const -1) + ) + (i32.store + (i32.const 664) + (i32.const -1) + ) + (i32.store + (i32.const 668) (i32.const 0) ) - (block - (i32.store - (i32.const 656) - (get_local $$call$i$i) - ) - (i32.store - (i32.const 652) - (get_local $$call$i$i) - ) - (i32.store - (i32.const 660) - (i32.const -1) - ) - (i32.store - (i32.const 664) - (i32.const -1) - ) - (i32.store - (i32.const 668) - (i32.const 0) - ) - (i32.store - (i32.const 620) - (i32.const 0) - ) - (i32.store - (i32.const 648) - (i32.xor - (i32.and - (call_import $_time - (i32.const 0) - ) - (i32.const -16) + (i32.store + (i32.const 620) + (i32.const 0) + ) + (i32.store + (i32.const 648) + (i32.xor + (i32.and + (call_import $_time + (i32.const 0) ) - (i32.const 1431655768) + (i32.const -16) ) + (i32.const 1431655768) ) - (br $do-once$33) ) - (call_import $_abort) ) + (call_import $_abort) ) ) (set_local $$add$i$180 @@ -15472,78 +15430,73 @@ (get_local $$ssize$2$ph$i) ) ) - (block $do-once$42 - (if + (if + (i32.and + (i32.gt_u + (get_local $$add$i$180) + (get_local $$ssize$2$ph$i) + ) (i32.and - (i32.gt_u - (get_local $$add$i$180) + (i32.lt_u (get_local $$ssize$2$ph$i) + (i32.const 2147483647) ) - (i32.and - (i32.lt_u - (get_local $$ssize$2$ph$i) - (i32.const 2147483647) - ) - (i32.ne - (get_local $$br$2$ph$i) - (i32.const -1) - ) + (i32.ne + (get_local $$br$2$ph$i) + (i32.const -1) ) ) - (if - (i32.lt_u - (set_local $$and104$i - (i32.and - (i32.add - (i32.sub - (get_local $$sub$i$181) - (get_local $$ssize$2$ph$i) - ) - (set_local $$115 - (i32.load - (i32.const 656) - ) - ) - ) + ) + (if + (i32.lt_u + (set_local $$and104$i + (i32.and + (i32.add (i32.sub - (i32.const 0) - (get_local $$115) + (get_local $$sub$i$181) + (get_local $$ssize$2$ph$i) + ) + (set_local $$115 + (i32.load + (i32.const 656) + ) ) ) - ) - (i32.const 2147483647) - ) - (if - (i32.eq - (call_import $_sbrk - (get_local $$and104$i) + (i32.sub + (i32.const 0) + (get_local $$115) ) - (i32.const -1) ) - (block - (call_import $_sbrk - (get_local $$sub112$i) - ) - (br $label$break$L279) + ) + (i32.const 2147483647) + ) + (if + (i32.eq + (call_import $_sbrk + (get_local $$and104$i) ) - (block - (set_local $$ssize$5$i - (i32.add - (get_local $$and104$i) - (get_local $$ssize$2$ph$i) - ) - ) - (br $do-once$42) + (i32.const -1) + ) + (block + (call_import $_sbrk + (get_local $$sub112$i) ) + (br $label$break$L279) ) (set_local $$ssize$5$i - (get_local $$ssize$2$ph$i) + (i32.add + (get_local $$and104$i) + (get_local $$ssize$2$ph$i) + ) ) ) (set_local $$ssize$5$i (get_local $$ssize$2$ph$i) ) ) + (set_local $$ssize$5$i + (get_local $$ssize$2$ph$i) + ) ) (if (i32.eqz @@ -16601,7 +16554,6 @@ (set_local $$R$3$i$i (get_local $$R$1$i$i$lcssa) ) - (br $do-once$59) ) ) ) @@ -16657,7 +16609,6 @@ (set_local $$R$3$i$i (get_local $$155) ) - (br $do-once$59) ) (call_import $_abort) ) @@ -16775,39 +16726,36 @@ (get_local $$R$3$i$i) (get_local $$154) ) - (block $do-once$65 - (if - (i32.eqz - (i32.eq - (set_local $$169 - (i32.load - (set_local $$child166$i$i - (i32.add - (get_local $$add$ptr16$i$i) - (i32.const 16) - ) + (if + (i32.eqz + (i32.eq + (set_local $$169 + (i32.load + (set_local $$child166$i$i + (i32.add + (get_local $$add$ptr16$i$i) + (i32.const 16) ) ) ) - (i32.const 0) ) + (i32.const 0) ) - (if - (i32.lt_u + ) + (if + (i32.lt_u + (get_local $$169) + (get_local $$168) + ) + (call_import $_abort) + (block + (i32.store offset=16 + (get_local $$R$3$i$i) (get_local $$169) - (get_local $$168) ) - (call_import $_abort) - (block - (i32.store offset=16 - (get_local $$R$3$i$i) - (get_local $$169) - ) - (i32.store offset=24 - (get_local $$169) - (get_local $$R$3$i$i) - ) - (br $do-once$65) + (i32.store offset=24 + (get_local $$169) + (get_local $$R$3$i$i) ) ) ) @@ -16839,7 +16787,6 @@ (get_local $$170) (get_local $$R$3$i$i) ) - (br $label$break$L331) ) ) ) @@ -17330,7 +17277,6 @@ (get_local $$add$ptr17$i$i) (get_local $$add$ptr17$i$i) ) - (br $do-once$52) ) ) (if @@ -17383,7 +17329,6 @@ (get_local $$add$ptr17$i$i) (i32.const 0) ) - (br $do-once$52) ) (call_import $_abort) ) @@ -18108,7 +18053,6 @@ (get_local $$119) (get_local $$119) ) - (br $do-once$44) ) ) (if @@ -18161,7 +18105,6 @@ (get_local $$119) (i32.const 0) ) - (br $do-once$44) ) (call_import $_abort) ) @@ -18810,7 +18753,6 @@ (set_local $$R$3 (get_local $$R$1$lcssa) ) - (br $do-once$2) ) ) ) @@ -18866,7 +18808,6 @@ (set_local $$R$3 (get_local $$10) ) - (br $do-once$2) ) (call_import $_abort) ) @@ -19005,39 +18946,36 @@ (get_local $$R$3) (get_local $$9) ) - (block $do-once$6 - (if - (i32.eqz - (i32.eq - (set_local $$24 - (i32.load - (set_local $$child171 - (i32.add - (get_local $$add$ptr16) - (i32.const 16) - ) + (if + (i32.eqz + (i32.eq + (set_local $$24 + (i32.load + (set_local $$child171 + (i32.add + (get_local $$add$ptr16) + (i32.const 16) ) ) ) - (i32.const 0) ) + (i32.const 0) ) - (if - (i32.lt_u + ) + (if + (i32.lt_u + (get_local $$24) + (get_local $$23) + ) + (call_import $_abort) + (block + (i32.store offset=16 + (get_local $$R$3) (get_local $$24) - (get_local $$23) ) - (call_import $_abort) - (block - (i32.store offset=16 - (get_local $$R$3) - (get_local $$24) - ) - (i32.store offset=24 - (get_local $$24) - (get_local $$R$3) - ) - (br $do-once$6) + (i32.store offset=24 + (get_local $$24) + (get_local $$R$3) ) ) ) @@ -19082,7 +19020,6 @@ (set_local $$psize$1 (get_local $$add17) ) - (br $do-once$0) ) ) ) @@ -19519,7 +19456,6 @@ (set_local $$R332$3 (get_local $$R332$1$lcssa) ) - (br $do-once$10) ) ) ) @@ -19577,7 +19513,6 @@ (set_local $$R332$3 (get_local $$42) ) - (br $do-once$10) ) (call_import $_abort) ) @@ -19695,39 +19630,36 @@ (get_local $$R332$3) (get_local $$41) ) - (block $do-once$14 - (if - (i32.eqz - (i32.eq - (set_local $$58 - (i32.load - (set_local $$child443 - (i32.add - (get_local $$add$ptr6) - (i32.const 16) - ) + (if + (i32.eqz + (i32.eq + (set_local $$58 + (i32.load + (set_local $$child443 + (i32.add + (get_local $$add$ptr6) + (i32.const 16) ) ) ) - (i32.const 0) ) + (i32.const 0) ) - (if - (i32.lt_u + ) + (if + (i32.lt_u + (get_local $$58) + (get_local $$57) + ) + (call_import $_abort) + (block + (i32.store offset=16 + (get_local $$R332$3) (get_local $$58) - (get_local $$57) ) - (call_import $_abort) - (block - (i32.store offset=16 - (get_local $$R332$3) - (get_local $$58) - ) - (i32.store offset=24 - (get_local $$58) - (get_local $$R332$3) - ) - (br $do-once$14) + (i32.store offset=24 + (get_local $$58) + (get_local $$R332$3) ) ) ) @@ -19760,7 +19692,6 @@ (get_local $$59) (get_local $$R332$3) ) - (br $do-once$8) ) ) ) @@ -20064,243 +19995,239 @@ (get_local $$p$1) (i32.const 0) ) - (block $do-once$16 - (if - (i32.eq - (i32.and - (set_local $$66 - (i32.load - (i32.const 180) - ) - ) - (set_local $$shl573 - (i32.shl - (i32.const 1) - (get_local $$I534$0) - ) + (if + (i32.eq + (i32.and + (set_local $$66 + (i32.load + (i32.const 180) ) ) - (i32.const 0) - ) - (block - (i32.store - (i32.const 180) - (i32.or - (get_local $$66) - (get_local $$shl573) + (set_local $$shl573 + (i32.shl + (i32.const 1) + (get_local $$I534$0) ) ) - (i32.store - (get_local $$arrayidx567) - (get_local $$p$1) + ) + (i32.const 0) + ) + (block + (i32.store + (i32.const 180) + (i32.or + (get_local $$66) + (get_local $$shl573) ) - (i32.store offset=24 - (get_local $$p$1) + ) + (i32.store + (get_local $$arrayidx567) + (get_local $$p$1) + ) + (i32.store offset=24 + (get_local $$p$1) + (get_local $$arrayidx567) + ) + (i32.store offset=12 + (get_local $$p$1) + (get_local $$p$1) + ) + (i32.store offset=8 + (get_local $$p$1) + (get_local $$p$1) + ) + ) + (block + (set_local $$67 + (i32.load (get_local $$arrayidx567) ) - (i32.store offset=12 - (get_local $$p$1) - (get_local $$p$1) - ) - (i32.store offset=8 - (get_local $$p$1) - (get_local $$p$1) + ) + (set_local $$sub589 + (i32.sub + (i32.const 25) + (i32.shr_u + (get_local $$I534$0) + (i32.const 1) + ) ) ) - (block - (set_local $$67 - (i32.load - (get_local $$arrayidx567) + (set_local $$cond + (if + (i32.eq + (get_local $$I534$0) + (i32.const 31) ) + (i32.const 0) + (get_local $$sub589) ) - (set_local $$sub589 - (i32.sub - (i32.const 25) - (i32.shr_u - (get_local $$I534$0) - (i32.const 1) + ) + (set_local $$K583$0 + (i32.shl + (get_local $$psize$2) + (get_local $$cond) + ) + ) + (set_local $$T$0 + (get_local $$67) + ) + (loop $while-out$18 $while-in$19 + (if + (i32.eq + (i32.and + (i32.load offset=4 + (get_local $$T$0) + ) + (i32.const -8) ) + (get_local $$psize$2) ) - ) - (set_local $$cond - (if - (i32.eq - (get_local $$I534$0) - (i32.const 31) + (block + (set_local $$T$0$lcssa + (get_local $$T$0) ) - (i32.const 0) - (get_local $$sub589) + (set_local $label + (i32.const 130) + ) + (br $while-out$18) ) ) - (set_local $$K583$0 + (set_local $$shl600 (i32.shl - (get_local $$psize$2) - (get_local $$cond) + (get_local $$K583$0) + (i32.const 1) ) ) - (set_local $$T$0 - (get_local $$67) - ) - (loop $while-out$18 $while-in$19 - (if - (i32.eq - (i32.and - (i32.load offset=4 - (get_local $$T$0) + (if + (i32.eq + (set_local $$69 + (i32.load + (set_local $$arrayidx599 + (i32.add + (i32.add + (get_local $$T$0) + (i32.const 16) + ) + (i32.shl + (i32.shr_u + (get_local $$K583$0) + (i32.const 31) + ) + (i32.const 2) + ) + ) ) - (i32.const -8) ) - (get_local $$psize$2) ) - (block - (set_local $$T$0$lcssa - (get_local $$T$0) - ) - (set_local $label - (i32.const 130) - ) - (br $while-out$18) + (i32.const 0) + ) + (block + (set_local $$T$0$lcssa319 + (get_local $$T$0) + ) + (set_local $$arrayidx599$lcssa + (get_local $$arrayidx599) + ) + (set_local $label + (i32.const 127) ) + (br $while-out$18) ) - (set_local $$shl600 - (i32.shl - (get_local $$K583$0) - (i32.const 1) + (block + (set_local $$K583$0 + (get_local $$shl600) + ) + (set_local $$T$0 + (get_local $$69) ) ) - (if - (i32.eq - (set_local $$69 - (i32.load - (set_local $$arrayidx599 - (i32.add - (i32.add - (get_local $$T$0) - (i32.const 16) - ) - (i32.shl - (i32.shr_u - (get_local $$K583$0) - (i32.const 31) - ) - (i32.const 2) - ) - ) - ) - ) - ) - (i32.const 0) + ) + (br $while-in$19) + ) + (if + (i32.eq + (get_local $label) + (i32.const 127) + ) + (if + (i32.lt_u + (get_local $$arrayidx599$lcssa) + (i32.load + (i32.const 192) ) - (block - (set_local $$T$0$lcssa319 - (get_local $$T$0) - ) - (set_local $$arrayidx599$lcssa - (get_local $$arrayidx599) - ) - (set_local $label - (i32.const 127) - ) - (br $while-out$18) + ) + (call_import $_abort) + (block + (i32.store + (get_local $$arrayidx599$lcssa) + (get_local $$p$1) ) - (block - (set_local $$K583$0 - (get_local $$shl600) - ) - (set_local $$T$0 - (get_local $$69) - ) + (i32.store offset=24 + (get_local $$p$1) + (get_local $$T$0$lcssa319) + ) + (i32.store offset=12 + (get_local $$p$1) + (get_local $$p$1) + ) + (i32.store offset=8 + (get_local $$p$1) + (get_local $$p$1) ) ) - (br $while-in$19) ) (if (i32.eq (get_local $label) - (i32.const 127) + (i32.const 130) ) (if - (i32.lt_u - (get_local $$arrayidx599$lcssa) - (i32.load - (i32.const 192) + (i32.and + (i32.ge_u + (set_local $$71 + (i32.load + (set_local $$fd620 + (i32.add + (get_local $$T$0$lcssa) + (i32.const 8) + ) + ) + ) + ) + (set_local $$72 + (i32.load + (i32.const 192) + ) + ) + ) + (i32.ge_u + (get_local $$T$0$lcssa) + (get_local $$72) ) ) - (call_import $_abort) (block + (i32.store offset=12 + (get_local $$71) + (get_local $$p$1) + ) (i32.store - (get_local $$arrayidx599$lcssa) + (get_local $$fd620) (get_local $$p$1) ) - (i32.store offset=24 + (i32.store offset=8 (get_local $$p$1) - (get_local $$T$0$lcssa319) + (get_local $$71) ) (i32.store offset=12 (get_local $$p$1) - (get_local $$p$1) + (get_local $$T$0$lcssa) ) - (i32.store offset=8 - (get_local $$p$1) + (i32.store offset=24 (get_local $$p$1) + (i32.const 0) ) - (br $do-once$16) - ) - ) - (if - (i32.eq - (get_local $label) - (i32.const 130) - ) - (if - (i32.and - (i32.ge_u - (set_local $$71 - (i32.load - (set_local $$fd620 - (i32.add - (get_local $$T$0$lcssa) - (i32.const 8) - ) - ) - ) - ) - (set_local $$72 - (i32.load - (i32.const 192) - ) - ) - ) - (i32.ge_u - (get_local $$T$0$lcssa) - (get_local $$72) - ) - ) - (block - (i32.store offset=12 - (get_local $$71) - (get_local $$p$1) - ) - (i32.store - (get_local $$fd620) - (get_local $$p$1) - ) - (i32.store offset=8 - (get_local $$p$1) - (get_local $$71) - ) - (i32.store offset=12 - (get_local $$p$1) - (get_local $$T$0$lcssa) - ) - (i32.store offset=24 - (get_local $$p$1) - (i32.const 0) - ) - (br $do-once$16) - ) - (call_import $_abort) ) + (call_import $_abort) ) ) ) diff --git a/test/memorygrowth.fromasm b/test/memorygrowth.fromasm index dac188a60..e2bb3354e 100644 --- a/test/memorygrowth.fromasm +++ b/test/memorygrowth.fromasm @@ -234,60 +234,57 @@ ) ) ) - (block $do-once$2 - (if - (i32.eq - (get_local $i) - (get_local $n) - ) - (i32.store - (i32.const 1208) - (i32.and - (get_local $f) - (i32.xor - (i32.shl - (i32.const 1) - (get_local $h) - ) - (i32.const -1) + (if + (i32.eq + (get_local $i) + (get_local $n) + ) + (i32.store + (i32.const 1208) + (i32.and + (get_local $f) + (i32.xor + (i32.shl + (i32.const 1) + (get_local $h) ) + (i32.const -1) ) ) - (block - (if - (i32.lt_u - (get_local $n) - (i32.load - (i32.const 1224) - ) + ) + (block + (if + (i32.lt_u + (get_local $n) + (i32.load + (i32.const 1224) ) - (call_import $qa) ) - (if - (i32.eq - (i32.load - (set_local $o - (i32.add - (get_local $n) - (i32.const 12) - ) + (call_import $qa) + ) + (if + (i32.eq + (i32.load + (set_local $o + (i32.add + (get_local $n) + (i32.const 12) ) ) - (get_local $l) ) - (block - (i32.store - (get_local $o) - (get_local $i) - ) - (i32.store - (get_local $j) - (get_local $n) - ) - (br $do-once$2) + (get_local $l) + ) + (block + (i32.store + (get_local $o) + (get_local $i) + ) + (i32.store + (get_local $j) + (get_local $n) ) - (call_import $qa) ) + (call_import $qa) ) ) ) @@ -483,70 +480,67 @@ ) ) ) - (block $do-once$4 - (if - (i32.eq - (get_local $s) - (get_local $i) - ) - (block - (i32.store - (i32.const 1208) - (i32.and - (get_local $f) - (i32.xor - (i32.shl - (i32.const 1) - (get_local $u) - ) - (i32.const -1) + (if + (i32.eq + (get_local $s) + (get_local $i) + ) + (block + (i32.store + (i32.const 1208) + (i32.and + (get_local $f) + (i32.xor + (i32.shl + (i32.const 1) + (get_local $u) ) + (i32.const -1) ) ) - (set_local $v - (get_local $j) - ) ) - (block - (if - (i32.lt_u - (get_local $i) - (i32.load - (i32.const 1224) - ) + (set_local $v + (get_local $j) + ) + ) + (block + (if + (i32.lt_u + (get_local $i) + (i32.load + (i32.const 1224) ) - (call_import $qa) ) - (if - (i32.eq - (i32.load - (set_local $n - (i32.add - (get_local $i) - (i32.const 12) - ) + (call_import $qa) + ) + (if + (i32.eq + (i32.load + (set_local $n + (i32.add + (get_local $i) + (i32.const 12) ) ) - (get_local $q) ) - (block - (i32.store - (get_local $n) - (get_local $s) - ) - (i32.store - (get_local $t) - (get_local $i) - ) - (set_local $v - (i32.load - (i32.const 1216) - ) + (get_local $q) + ) + (block + (i32.store + (get_local $n) + (get_local $s) + ) + (i32.store + (get_local $t) + (get_local $i) + ) + (set_local $v + (i32.load + (i32.const 1216) ) - (br $do-once$4) ) - (call_import $qa) ) + (call_import $qa) ) ) ) @@ -1043,7 +1037,6 @@ (set_local $C (get_local $F) ) - (br $do-once$8) ) ) ) @@ -1097,7 +1090,6 @@ (set_local $C (get_local $o) ) - (br $do-once$8) ) (call_import $qa) ) @@ -1209,29 +1201,26 @@ (get_local $C) (get_local $e) ) - (block $do-once$14 + (if + (set_local $s + (i32.load offset=16 + (get_local $A) + ) + ) (if - (set_local $s - (i32.load offset=16 - (get_local $A) - ) + (i32.lt_u + (get_local $s) + (get_local $o) ) - (if - (i32.lt_u + (call_import $qa) + (block + (i32.store offset=16 + (get_local $C) (get_local $s) - (get_local $o) ) - (call_import $qa) - (block - (i32.store offset=16 - (get_local $C) - (get_local $s) - ) - (i32.store offset=24 - (get_local $s) - (get_local $C) - ) - (br $do-once$14) + (i32.store offset=24 + (get_local $s) + (get_local $C) ) ) ) @@ -1259,7 +1248,6 @@ (get_local $s) (get_local $C) ) - (br $do-once$12) ) ) ) @@ -2230,7 +2218,6 @@ (set_local $W (get_local $Z) ) - (br $do-once$21) ) ) ) @@ -2284,7 +2271,6 @@ (set_local $W (get_local $s) ) - (br $do-once$21) ) (call_import $qa) ) @@ -2396,29 +2382,26 @@ (get_local $W) (get_local $g) ) - (block $do-once$27 + (if + (set_local $q + (i32.load offset=16 + (get_local $V) + ) + ) (if - (set_local $q - (i32.load offset=16 - (get_local $V) - ) + (i32.lt_u + (get_local $q) + (get_local $s) ) - (if - (i32.lt_u + (call_import $qa) + (block + (i32.store offset=16 + (get_local $W) (get_local $q) - (get_local $s) ) - (call_import $qa) - (block - (i32.store offset=16 - (get_local $W) - (get_local $q) - ) - (i32.store offset=24 - (get_local $q) - (get_local $W) - ) - (br $do-once$27) + (i32.store offset=24 + (get_local $q) + (get_local $W) ) ) ) @@ -2446,7 +2429,6 @@ (get_local $q) (get_local $W) ) - (br $do-once$25) ) ) ) @@ -2905,7 +2887,6 @@ (get_local $i) (get_local $i) ) - (br $do-once$29) ) ) (if @@ -2958,7 +2939,6 @@ (get_local $i) (i32.const 0) ) - (br $do-once$29) ) (call_import $qa) ) @@ -3583,78 +3563,73 @@ (get_local $ka) ) ) - (block $do-once$40 - (if + (if + (i32.and + (i32.gt_u + (get_local $ea) + (get_local $ka) + ) (i32.and - (i32.gt_u - (get_local $ea) + (i32.lt_u (get_local $ka) + (i32.const 2147483647) ) - (i32.and - (i32.lt_u - (get_local $ka) - (i32.const 2147483647) - ) - (i32.ne - (get_local $ja) - (i32.const -1) - ) + (i32.ne + (get_local $ja) + (i32.const -1) ) ) - (if - (i32.lt_u - (set_local $e - (i32.and - (i32.add - (i32.sub - (get_local $ca) - (get_local $ka) - ) - (set_local $U - (i32.load - (i32.const 1688) - ) - ) - ) + ) + (if + (i32.lt_u + (set_local $e + (i32.and + (i32.add (i32.sub - (i32.const 0) - (get_local $U) + (get_local $ca) + (get_local $ka) + ) + (set_local $U + (i32.load + (i32.const 1688) + ) ) ) - ) - (i32.const 2147483647) - ) - (if - (i32.eq - (call_import $ta - (get_local $e) - ) - (i32.const -1) - ) - (block - (call_import $ta - (get_local $$) + (i32.sub + (i32.const 0) + (get_local $U) ) - (br $label$break$d) ) - (block - (set_local $ma - (i32.add - (get_local $e) - (get_local $ka) - ) - ) - (br $do-once$40) + ) + (i32.const 2147483647) + ) + (if + (i32.eq + (call_import $ta + (get_local $e) ) + (i32.const -1) + ) + (block + (call_import $ta + (get_local $$) + ) + (br $label$break$d) ) (set_local $ma - (get_local $ka) + (i32.add + (get_local $e) + (get_local $ka) + ) ) ) (set_local $ma (get_local $ka) ) ) + (set_local $ma + (get_local $ka) + ) ) (if (i32.ne @@ -4487,7 +4462,6 @@ (set_local $ya (get_local $Ba) ) - (br $do-once$57) ) ) ) @@ -4541,7 +4515,6 @@ (set_local $ya (get_local $e) ) - (br $do-once$57) ) (call_import $qa) ) @@ -4652,34 +4625,31 @@ (get_local $ya) (get_local $$) ) - (block $do-once$63 - (if - (set_local $V - (i32.load - (set_local $da - (i32.add - (get_local $ma) - (i32.const 16) - ) + (if + (set_local $V + (i32.load + (set_local $da + (i32.add + (get_local $ma) + (i32.const 16) ) ) ) - (if - (i32.lt_u + ) + (if + (i32.lt_u + (get_local $V) + (get_local $e) + ) + (call_import $qa) + (block + (i32.store offset=16 + (get_local $ya) (get_local $V) - (get_local $e) ) - (call_import $qa) - (block - (i32.store offset=16 - (get_local $ya) - (get_local $V) - ) - (i32.store offset=24 - (get_local $V) - (get_local $ya) - ) - (br $do-once$63) + (i32.store offset=24 + (get_local $V) + (get_local $ya) ) ) ) @@ -4710,7 +4680,6 @@ (get_local $V) (get_local $ya) ) - (br $label$break$e) ) ) ) @@ -5171,7 +5140,6 @@ (get_local $ka) (get_local $ka) ) - (br $do-once$50) ) ) (if @@ -5224,7 +5192,6 @@ (get_local $ka) (i32.const 0) ) - (br $do-once$50) ) (call_import $qa) ) @@ -5894,7 +5861,6 @@ (get_local $ja) (get_local $ja) ) - (br $do-once$42) ) ) (if @@ -5947,7 +5913,6 @@ (get_local $ja) (i32.const 0) ) - (br $do-once$42) ) (call_import $qa) ) @@ -6645,7 +6610,6 @@ (set_local $s (get_local $v) ) - (br $do-once$2) ) ) ) @@ -6699,7 +6663,6 @@ (set_local $s (get_local $j) ) - (br $do-once$2) ) (call_import $qa) ) @@ -6825,34 +6788,31 @@ (get_local $s) (get_local $g) ) - (block $do-once$6 - (if - (set_local $o - (i32.load - (set_local $l - (i32.add - (get_local $h) - (i32.const 16) - ) + (if + (set_local $o + (i32.load + (set_local $l + (i32.add + (get_local $h) + (i32.const 16) ) ) ) - (if - (i32.lt_u + ) + (if + (i32.lt_u + (get_local $o) + (get_local $j) + ) + (call_import $qa) + (block + (i32.store offset=16 + (get_local $s) (get_local $o) - (get_local $j) ) - (call_import $qa) - (block - (i32.store offset=16 - (get_local $s) - (get_local $o) - ) - (i32.store offset=24 - (get_local $o) - (get_local $s) - ) - (br $do-once$6) + (i32.store offset=24 + (get_local $o) + (get_local $s) ) ) ) @@ -6886,7 +6846,6 @@ (set_local $n (get_local $i) ) - (br $do-once$0) ) ) (block @@ -7331,7 +7290,6 @@ (set_local $y (get_local $B) ) - (br $do-once$10) ) ) ) @@ -7387,7 +7345,6 @@ (set_local $y (get_local $w) ) - (br $do-once$10) ) (call_import $qa) ) @@ -7498,34 +7455,31 @@ (get_local $y) (get_local $v) ) - (block $do-once$14 - (if - (set_local $h - (i32.load - (set_local $i - (i32.add - (get_local $f) - (i32.const 16) - ) + (if + (set_local $h + (i32.load + (set_local $i + (i32.add + (get_local $f) + (i32.const 16) ) ) ) - (if - (i32.lt_u + ) + (if + (i32.lt_u + (get_local $h) + (get_local $w) + ) + (call_import $qa) + (block + (i32.store offset=16 + (get_local $y) (get_local $h) - (get_local $w) ) - (call_import $qa) - (block - (i32.store offset=16 - (get_local $y) - (get_local $h) - ) - (i32.store offset=24 - (get_local $h) - (get_local $y) - ) - (br $do-once$14) + (i32.store offset=24 + (get_local $h) + (get_local $y) ) ) ) @@ -7553,7 +7507,6 @@ (get_local $h) (get_local $y) ) - (br $do-once$8) ) ) ) @@ -7820,228 +7773,224 @@ (get_local $m) (i32.const 0) ) - (block $do-once$16 - (if - (i32.and - (set_local $E - (i32.load - (i32.const 1212) - ) + (if + (i32.and + (set_local $E + (i32.load + (i32.const 1212) ) - (set_local $e - (i32.shl - (i32.const 1) - (get_local $G) - ) + ) + (set_local $e + (i32.shl + (i32.const 1) + (get_local $G) ) ) - (block - (set_local $F - (i32.shl - (get_local $D) - (if - (i32.eq + ) + (block + (set_local $F + (i32.shl + (get_local $D) + (if + (i32.eq + (get_local $G) + (i32.const 31) + ) + (i32.const 0) + (i32.sub + (i32.const 25) + (i32.shr_u (get_local $G) - (i32.const 31) - ) - (i32.const 0) - (i32.sub - (i32.const 25) - (i32.shr_u - (get_local $G) - (i32.const 1) - ) + (i32.const 1) ) ) ) ) - (set_local $b - (i32.load - (get_local $s) - ) + ) + (set_local $b + (i32.load + (get_local $s) ) - (loop $while-out$18 $while-in$19 - (if - (i32.eq - (i32.and - (i32.load offset=4 - (get_local $b) - ) - (i32.const -8) - ) - (get_local $D) - ) - (block - (set_local $H + ) + (loop $while-out$18 $while-in$19 + (if + (i32.eq + (i32.and + (i32.load offset=4 (get_local $b) ) - (set_local $I - (i32.const 130) - ) - (br $while-out$18) + (i32.const -8) ) + (get_local $D) ) - (if - (set_local $y - (i32.load - (set_local $n + (block + (set_local $H + (get_local $b) + ) + (set_local $I + (i32.const 130) + ) + (br $while-out$18) + ) + ) + (if + (set_local $y + (i32.load + (set_local $n + (i32.add (i32.add - (i32.add - (get_local $b) - (i32.const 16) - ) - (i32.shl - (i32.shr_u - (get_local $F) - (i32.const 31) - ) - (i32.const 2) + (get_local $b) + (i32.const 16) + ) + (i32.shl + (i32.shr_u + (get_local $F) + (i32.const 31) ) + (i32.const 2) ) ) ) ) - (block - (set_local $F - (i32.shl - (get_local $F) - (i32.const 1) - ) - ) - (set_local $b - (get_local $y) + ) + (block + (set_local $F + (i32.shl + (get_local $F) + (i32.const 1) ) ) - (block - (set_local $J - (get_local $n) - ) - (set_local $K - (get_local $b) - ) - (set_local $I - (i32.const 127) - ) - (br $while-out$18) + (set_local $b + (get_local $y) + ) + ) + (block + (set_local $J + (get_local $n) + ) + (set_local $K + (get_local $b) + ) + (set_local $I + (i32.const 127) + ) + (br $while-out$18) + ) + ) + (br $while-in$19) + ) + (if + (i32.eq + (get_local $I) + (i32.const 127) + ) + (if + (i32.lt_u + (get_local $J) + (i32.load + (i32.const 1224) + ) + ) + (call_import $qa) + (block + (i32.store + (get_local $J) + (get_local $m) + ) + (i32.store offset=24 + (get_local $m) + (get_local $K) + ) + (i32.store offset=12 + (get_local $m) + (get_local $m) + ) + (i32.store offset=8 + (get_local $m) + (get_local $m) ) ) - (br $while-in$19) ) (if (i32.eq (get_local $I) - (i32.const 127) + (i32.const 130) ) (if - (i32.lt_u - (get_local $J) - (i32.load - (i32.const 1224) + (i32.and + (i32.ge_u + (set_local $F + (i32.load + (set_local $b + (i32.add + (get_local $H) + (i32.const 8) + ) + ) + ) + ) + (set_local $i + (i32.load + (i32.const 1224) + ) + ) + ) + (i32.ge_u + (get_local $H) + (get_local $i) ) ) - (call_import $qa) (block + (i32.store offset=12 + (get_local $F) + (get_local $m) + ) (i32.store - (get_local $J) + (get_local $b) (get_local $m) ) - (i32.store offset=24 + (i32.store offset=8 (get_local $m) - (get_local $K) + (get_local $F) ) (i32.store offset=12 (get_local $m) - (get_local $m) + (get_local $H) ) - (i32.store offset=8 - (get_local $m) + (i32.store offset=24 (get_local $m) + (i32.const 0) ) - (br $do-once$16) - ) - ) - (if - (i32.eq - (get_local $I) - (i32.const 130) - ) - (if - (i32.and - (i32.ge_u - (set_local $F - (i32.load - (set_local $b - (i32.add - (get_local $H) - (i32.const 8) - ) - ) - ) - ) - (set_local $i - (i32.load - (i32.const 1224) - ) - ) - ) - (i32.ge_u - (get_local $H) - (get_local $i) - ) - ) - (block - (i32.store offset=12 - (get_local $F) - (get_local $m) - ) - (i32.store - (get_local $b) - (get_local $m) - ) - (i32.store offset=8 - (get_local $m) - (get_local $F) - ) - (i32.store offset=12 - (get_local $m) - (get_local $H) - ) - (i32.store offset=24 - (get_local $m) - (i32.const 0) - ) - (br $do-once$16) - ) - (call_import $qa) ) + (call_import $qa) ) ) ) - (block - (i32.store - (i32.const 1212) - (i32.or - (get_local $E) - (get_local $e) - ) - ) - (i32.store - (get_local $s) - (get_local $m) - ) - (i32.store offset=24 - (get_local $m) - (get_local $s) - ) - (i32.store offset=12 - (get_local $m) - (get_local $m) - ) - (i32.store offset=8 - (get_local $m) - (get_local $m) + ) + (block + (i32.store + (i32.const 1212) + (i32.or + (get_local $E) + (get_local $e) ) ) + (i32.store + (get_local $s) + (get_local $m) + ) + (i32.store offset=24 + (get_local $m) + (get_local $s) + ) + (i32.store offset=12 + (get_local $m) + (get_local $m) + ) + (i32.store offset=8 + (get_local $m) + (get_local $m) + ) ) ) (i32.store diff --git a/test/memorygrowth.fromasm.imprecise b/test/memorygrowth.fromasm.imprecise index dac188a60..e2bb3354e 100644 --- a/test/memorygrowth.fromasm.imprecise +++ b/test/memorygrowth.fromasm.imprecise @@ -234,60 +234,57 @@ ) ) ) - (block $do-once$2 - (if - (i32.eq - (get_local $i) - (get_local $n) - ) - (i32.store - (i32.const 1208) - (i32.and - (get_local $f) - (i32.xor - (i32.shl - (i32.const 1) - (get_local $h) - ) - (i32.const -1) + (if + (i32.eq + (get_local $i) + (get_local $n) + ) + (i32.store + (i32.const 1208) + (i32.and + (get_local $f) + (i32.xor + (i32.shl + (i32.const 1) + (get_local $h) ) + (i32.const -1) ) ) - (block - (if - (i32.lt_u - (get_local $n) - (i32.load - (i32.const 1224) - ) + ) + (block + (if + (i32.lt_u + (get_local $n) + (i32.load + (i32.const 1224) ) - (call_import $qa) ) - (if - (i32.eq - (i32.load - (set_local $o - (i32.add - (get_local $n) - (i32.const 12) - ) + (call_import $qa) + ) + (if + (i32.eq + (i32.load + (set_local $o + (i32.add + (get_local $n) + (i32.const 12) ) ) - (get_local $l) ) - (block - (i32.store - (get_local $o) - (get_local $i) - ) - (i32.store - (get_local $j) - (get_local $n) - ) - (br $do-once$2) + (get_local $l) + ) + (block + (i32.store + (get_local $o) + (get_local $i) + ) + (i32.store + (get_local $j) + (get_local $n) ) - (call_import $qa) ) + (call_import $qa) ) ) ) @@ -483,70 +480,67 @@ ) ) ) - (block $do-once$4 - (if - (i32.eq - (get_local $s) - (get_local $i) - ) - (block - (i32.store - (i32.const 1208) - (i32.and - (get_local $f) - (i32.xor - (i32.shl - (i32.const 1) - (get_local $u) - ) - (i32.const -1) + (if + (i32.eq + (get_local $s) + (get_local $i) + ) + (block + (i32.store + (i32.const 1208) + (i32.and + (get_local $f) + (i32.xor + (i32.shl + (i32.const 1) + (get_local $u) ) + (i32.const -1) ) ) - (set_local $v - (get_local $j) - ) ) - (block - (if - (i32.lt_u - (get_local $i) - (i32.load - (i32.const 1224) - ) + (set_local $v + (get_local $j) + ) + ) + (block + (if + (i32.lt_u + (get_local $i) + (i32.load + (i32.const 1224) ) - (call_import $qa) ) - (if - (i32.eq - (i32.load - (set_local $n - (i32.add - (get_local $i) - (i32.const 12) - ) + (call_import $qa) + ) + (if + (i32.eq + (i32.load + (set_local $n + (i32.add + (get_local $i) + (i32.const 12) ) ) - (get_local $q) ) - (block - (i32.store - (get_local $n) - (get_local $s) - ) - (i32.store - (get_local $t) - (get_local $i) - ) - (set_local $v - (i32.load - (i32.const 1216) - ) + (get_local $q) + ) + (block + (i32.store + (get_local $n) + (get_local $s) + ) + (i32.store + (get_local $t) + (get_local $i) + ) + (set_local $v + (i32.load + (i32.const 1216) ) - (br $do-once$4) ) - (call_import $qa) ) + (call_import $qa) ) ) ) @@ -1043,7 +1037,6 @@ (set_local $C (get_local $F) ) - (br $do-once$8) ) ) ) @@ -1097,7 +1090,6 @@ (set_local $C (get_local $o) ) - (br $do-once$8) ) (call_import $qa) ) @@ -1209,29 +1201,26 @@ (get_local $C) (get_local $e) ) - (block $do-once$14 + (if + (set_local $s + (i32.load offset=16 + (get_local $A) + ) + ) (if - (set_local $s - (i32.load offset=16 - (get_local $A) - ) + (i32.lt_u + (get_local $s) + (get_local $o) ) - (if - (i32.lt_u + (call_import $qa) + (block + (i32.store offset=16 + (get_local $C) (get_local $s) - (get_local $o) ) - (call_import $qa) - (block - (i32.store offset=16 - (get_local $C) - (get_local $s) - ) - (i32.store offset=24 - (get_local $s) - (get_local $C) - ) - (br $do-once$14) + (i32.store offset=24 + (get_local $s) + (get_local $C) ) ) ) @@ -1259,7 +1248,6 @@ (get_local $s) (get_local $C) ) - (br $do-once$12) ) ) ) @@ -2230,7 +2218,6 @@ (set_local $W (get_local $Z) ) - (br $do-once$21) ) ) ) @@ -2284,7 +2271,6 @@ (set_local $W (get_local $s) ) - (br $do-once$21) ) (call_import $qa) ) @@ -2396,29 +2382,26 @@ (get_local $W) (get_local $g) ) - (block $do-once$27 + (if + (set_local $q + (i32.load offset=16 + (get_local $V) + ) + ) (if - (set_local $q - (i32.load offset=16 - (get_local $V) - ) + (i32.lt_u + (get_local $q) + (get_local $s) ) - (if - (i32.lt_u + (call_import $qa) + (block + (i32.store offset=16 + (get_local $W) (get_local $q) - (get_local $s) ) - (call_import $qa) - (block - (i32.store offset=16 - (get_local $W) - (get_local $q) - ) - (i32.store offset=24 - (get_local $q) - (get_local $W) - ) - (br $do-once$27) + (i32.store offset=24 + (get_local $q) + (get_local $W) ) ) ) @@ -2446,7 +2429,6 @@ (get_local $q) (get_local $W) ) - (br $do-once$25) ) ) ) @@ -2905,7 +2887,6 @@ (get_local $i) (get_local $i) ) - (br $do-once$29) ) ) (if @@ -2958,7 +2939,6 @@ (get_local $i) (i32.const 0) ) - (br $do-once$29) ) (call_import $qa) ) @@ -3583,78 +3563,73 @@ (get_local $ka) ) ) - (block $do-once$40 - (if + (if + (i32.and + (i32.gt_u + (get_local $ea) + (get_local $ka) + ) (i32.and - (i32.gt_u - (get_local $ea) + (i32.lt_u (get_local $ka) + (i32.const 2147483647) ) - (i32.and - (i32.lt_u - (get_local $ka) - (i32.const 2147483647) - ) - (i32.ne - (get_local $ja) - (i32.const -1) - ) + (i32.ne + (get_local $ja) + (i32.const -1) ) ) - (if - (i32.lt_u - (set_local $e - (i32.and - (i32.add - (i32.sub - (get_local $ca) - (get_local $ka) - ) - (set_local $U - (i32.load - (i32.const 1688) - ) - ) - ) + ) + (if + (i32.lt_u + (set_local $e + (i32.and + (i32.add (i32.sub - (i32.const 0) - (get_local $U) + (get_local $ca) + (get_local $ka) + ) + (set_local $U + (i32.load + (i32.const 1688) + ) ) ) - ) - (i32.const 2147483647) - ) - (if - (i32.eq - (call_import $ta - (get_local $e) - ) - (i32.const -1) - ) - (block - (call_import $ta - (get_local $$) + (i32.sub + (i32.const 0) + (get_local $U) ) - (br $label$break$d) ) - (block - (set_local $ma - (i32.add - (get_local $e) - (get_local $ka) - ) - ) - (br $do-once$40) + ) + (i32.const 2147483647) + ) + (if + (i32.eq + (call_import $ta + (get_local $e) ) + (i32.const -1) + ) + (block + (call_import $ta + (get_local $$) + ) + (br $label$break$d) ) (set_local $ma - (get_local $ka) + (i32.add + (get_local $e) + (get_local $ka) + ) ) ) (set_local $ma (get_local $ka) ) ) + (set_local $ma + (get_local $ka) + ) ) (if (i32.ne @@ -4487,7 +4462,6 @@ (set_local $ya (get_local $Ba) ) - (br $do-once$57) ) ) ) @@ -4541,7 +4515,6 @@ (set_local $ya (get_local $e) ) - (br $do-once$57) ) (call_import $qa) ) @@ -4652,34 +4625,31 @@ (get_local $ya) (get_local $$) ) - (block $do-once$63 - (if - (set_local $V - (i32.load - (set_local $da - (i32.add - (get_local $ma) - (i32.const 16) - ) + (if + (set_local $V + (i32.load + (set_local $da + (i32.add + (get_local $ma) + (i32.const 16) ) ) ) - (if - (i32.lt_u + ) + (if + (i32.lt_u + (get_local $V) + (get_local $e) + ) + (call_import $qa) + (block + (i32.store offset=16 + (get_local $ya) (get_local $V) - (get_local $e) ) - (call_import $qa) - (block - (i32.store offset=16 - (get_local $ya) - (get_local $V) - ) - (i32.store offset=24 - (get_local $V) - (get_local $ya) - ) - (br $do-once$63) + (i32.store offset=24 + (get_local $V) + (get_local $ya) ) ) ) @@ -4710,7 +4680,6 @@ (get_local $V) (get_local $ya) ) - (br $label$break$e) ) ) ) @@ -5171,7 +5140,6 @@ (get_local $ka) (get_local $ka) ) - (br $do-once$50) ) ) (if @@ -5224,7 +5192,6 @@ (get_local $ka) (i32.const 0) ) - (br $do-once$50) ) (call_import $qa) ) @@ -5894,7 +5861,6 @@ (get_local $ja) (get_local $ja) ) - (br $do-once$42) ) ) (if @@ -5947,7 +5913,6 @@ (get_local $ja) (i32.const 0) ) - (br $do-once$42) ) (call_import $qa) ) @@ -6645,7 +6610,6 @@ (set_local $s (get_local $v) ) - (br $do-once$2) ) ) ) @@ -6699,7 +6663,6 @@ (set_local $s (get_local $j) ) - (br $do-once$2) ) (call_import $qa) ) @@ -6825,34 +6788,31 @@ (get_local $s) (get_local $g) ) - (block $do-once$6 - (if - (set_local $o - (i32.load - (set_local $l - (i32.add - (get_local $h) - (i32.const 16) - ) + (if + (set_local $o + (i32.load + (set_local $l + (i32.add + (get_local $h) + (i32.const 16) ) ) ) - (if - (i32.lt_u + ) + (if + (i32.lt_u + (get_local $o) + (get_local $j) + ) + (call_import $qa) + (block + (i32.store offset=16 + (get_local $s) (get_local $o) - (get_local $j) ) - (call_import $qa) - (block - (i32.store offset=16 - (get_local $s) - (get_local $o) - ) - (i32.store offset=24 - (get_local $o) - (get_local $s) - ) - (br $do-once$6) + (i32.store offset=24 + (get_local $o) + (get_local $s) ) ) ) @@ -6886,7 +6846,6 @@ (set_local $n (get_local $i) ) - (br $do-once$0) ) ) (block @@ -7331,7 +7290,6 @@ (set_local $y (get_local $B) ) - (br $do-once$10) ) ) ) @@ -7387,7 +7345,6 @@ (set_local $y (get_local $w) ) - (br $do-once$10) ) (call_import $qa) ) @@ -7498,34 +7455,31 @@ (get_local $y) (get_local $v) ) - (block $do-once$14 - (if - (set_local $h - (i32.load - (set_local $i - (i32.add - (get_local $f) - (i32.const 16) - ) + (if + (set_local $h + (i32.load + (set_local $i + (i32.add + (get_local $f) + (i32.const 16) ) ) ) - (if - (i32.lt_u + ) + (if + (i32.lt_u + (get_local $h) + (get_local $w) + ) + (call_import $qa) + (block + (i32.store offset=16 + (get_local $y) (get_local $h) - (get_local $w) ) - (call_import $qa) - (block - (i32.store offset=16 - (get_local $y) - (get_local $h) - ) - (i32.store offset=24 - (get_local $h) - (get_local $y) - ) - (br $do-once$14) + (i32.store offset=24 + (get_local $h) + (get_local $y) ) ) ) @@ -7553,7 +7507,6 @@ (get_local $h) (get_local $y) ) - (br $do-once$8) ) ) ) @@ -7820,228 +7773,224 @@ (get_local $m) (i32.const 0) ) - (block $do-once$16 - (if - (i32.and - (set_local $E - (i32.load - (i32.const 1212) - ) + (if + (i32.and + (set_local $E + (i32.load + (i32.const 1212) ) - (set_local $e - (i32.shl - (i32.const 1) - (get_local $G) - ) + ) + (set_local $e + (i32.shl + (i32.const 1) + (get_local $G) ) ) - (block - (set_local $F - (i32.shl - (get_local $D) - (if - (i32.eq + ) + (block + (set_local $F + (i32.shl + (get_local $D) + (if + (i32.eq + (get_local $G) + (i32.const 31) + ) + (i32.const 0) + (i32.sub + (i32.const 25) + (i32.shr_u (get_local $G) - (i32.const 31) - ) - (i32.const 0) - (i32.sub - (i32.const 25) - (i32.shr_u - (get_local $G) - (i32.const 1) - ) + (i32.const 1) ) ) ) ) - (set_local $b - (i32.load - (get_local $s) - ) + ) + (set_local $b + (i32.load + (get_local $s) ) - (loop $while-out$18 $while-in$19 - (if - (i32.eq - (i32.and - (i32.load offset=4 - (get_local $b) - ) - (i32.const -8) - ) - (get_local $D) - ) - (block - (set_local $H + ) + (loop $while-out$18 $while-in$19 + (if + (i32.eq + (i32.and + (i32.load offset=4 (get_local $b) ) - (set_local $I - (i32.const 130) - ) - (br $while-out$18) + (i32.const -8) ) + (get_local $D) ) - (if - (set_local $y - (i32.load - (set_local $n + (block + (set_local $H + (get_local $b) + ) + (set_local $I + (i32.const 130) + ) + (br $while-out$18) + ) + ) + (if + (set_local $y + (i32.load + (set_local $n + (i32.add (i32.add - (i32.add - (get_local $b) - (i32.const 16) - ) - (i32.shl - (i32.shr_u - (get_local $F) - (i32.const 31) - ) - (i32.const 2) + (get_local $b) + (i32.const 16) + ) + (i32.shl + (i32.shr_u + (get_local $F) + (i32.const 31) ) + (i32.const 2) ) ) ) ) - (block - (set_local $F - (i32.shl - (get_local $F) - (i32.const 1) - ) - ) - (set_local $b - (get_local $y) + ) + (block + (set_local $F + (i32.shl + (get_local $F) + (i32.const 1) ) ) - (block - (set_local $J - (get_local $n) - ) - (set_local $K - (get_local $b) - ) - (set_local $I - (i32.const 127) - ) - (br $while-out$18) + (set_local $b + (get_local $y) + ) + ) + (block + (set_local $J + (get_local $n) + ) + (set_local $K + (get_local $b) + ) + (set_local $I + (i32.const 127) + ) + (br $while-out$18) + ) + ) + (br $while-in$19) + ) + (if + (i32.eq + (get_local $I) + (i32.const 127) + ) + (if + (i32.lt_u + (get_local $J) + (i32.load + (i32.const 1224) + ) + ) + (call_import $qa) + (block + (i32.store + (get_local $J) + (get_local $m) + ) + (i32.store offset=24 + (get_local $m) + (get_local $K) + ) + (i32.store offset=12 + (get_local $m) + (get_local $m) + ) + (i32.store offset=8 + (get_local $m) + (get_local $m) ) ) - (br $while-in$19) ) (if (i32.eq (get_local $I) - (i32.const 127) + (i32.const 130) ) (if - (i32.lt_u - (get_local $J) - (i32.load - (i32.const 1224) + (i32.and + (i32.ge_u + (set_local $F + (i32.load + (set_local $b + (i32.add + (get_local $H) + (i32.const 8) + ) + ) + ) + ) + (set_local $i + (i32.load + (i32.const 1224) + ) + ) + ) + (i32.ge_u + (get_local $H) + (get_local $i) ) ) - (call_import $qa) (block + (i32.store offset=12 + (get_local $F) + (get_local $m) + ) (i32.store - (get_local $J) + (get_local $b) (get_local $m) ) - (i32.store offset=24 + (i32.store offset=8 (get_local $m) - (get_local $K) + (get_local $F) ) (i32.store offset=12 (get_local $m) - (get_local $m) + (get_local $H) ) - (i32.store offset=8 - (get_local $m) + (i32.store offset=24 (get_local $m) + (i32.const 0) ) - (br $do-once$16) - ) - ) - (if - (i32.eq - (get_local $I) - (i32.const 130) - ) - (if - (i32.and - (i32.ge_u - (set_local $F - (i32.load - (set_local $b - (i32.add - (get_local $H) - (i32.const 8) - ) - ) - ) - ) - (set_local $i - (i32.load - (i32.const 1224) - ) - ) - ) - (i32.ge_u - (get_local $H) - (get_local $i) - ) - ) - (block - (i32.store offset=12 - (get_local $F) - (get_local $m) - ) - (i32.store - (get_local $b) - (get_local $m) - ) - (i32.store offset=8 - (get_local $m) - (get_local $F) - ) - (i32.store offset=12 - (get_local $m) - (get_local $H) - ) - (i32.store offset=24 - (get_local $m) - (i32.const 0) - ) - (br $do-once$16) - ) - (call_import $qa) ) + (call_import $qa) ) ) ) - (block - (i32.store - (i32.const 1212) - (i32.or - (get_local $E) - (get_local $e) - ) - ) - (i32.store - (get_local $s) - (get_local $m) - ) - (i32.store offset=24 - (get_local $m) - (get_local $s) - ) - (i32.store offset=12 - (get_local $m) - (get_local $m) - ) - (i32.store offset=8 - (get_local $m) - (get_local $m) + ) + (block + (i32.store + (i32.const 1212) + (i32.or + (get_local $E) + (get_local $e) ) ) + (i32.store + (get_local $s) + (get_local $m) + ) + (i32.store offset=24 + (get_local $m) + (get_local $s) + ) + (i32.store offset=12 + (get_local $m) + (get_local $m) + ) + (i32.store offset=8 + (get_local $m) + (get_local $m) + ) ) ) (i32.store diff --git a/test/passes/remove-unused-brs.txt b/test/passes/remove-unused-brs.txt index d4c50563d..2404e7b39 100644 --- a/test/passes/remove-unused-brs.txt +++ b/test/passes/remove-unused-brs.txt @@ -2,23 +2,27 @@ (memory 256 256) (func $b0-yes (param $i1 i32) (block $topmost + (nop) ) ) (func $b1 (param $i1 i32) (block $topmost - (i32.const 0) + (br $topmost + (i32.const 0) + ) ) ) (func $b2 (param $i1 i32) (block $topmost (block $inner - (br $topmost) + (nop) ) ) ) (func $b3-yes (param $i1 i32) (block $topmost (block $inner + (nop) ) ) ) @@ -34,7 +38,9 @@ (func $b5 (param $i1 i32) (block $topmost (block $inner - (i32.const 0) + (br $inner + (i32.const 0) + ) ) ) ) @@ -97,11 +103,15 @@ (i32.const 1) (block $block1 (i32.const 12) - (i32.const 1) + (br $topmost + (i32.const 1) + ) ) (block $block3 (i32.const 27) - (i32.const 2) + (br $topmost + (i32.const 2) + ) ) ) ) @@ -155,4 +165,77 @@ ) ) ) + (func $b16 + (block $a + (block $b + (block $c + (br $a) + ) + (br $a) + ) + (nop) + ) + (block $a + (block $b + (block $c + (nop) + ) + (nop) + ) + (nop) + ) + (block $a + (block $b + (block $c + (br $b) + ) + (br $a) + ) + (nop) + ) + ) + (func $b17 + (block $a + (if + (i32.const 0) + (block $block1 + (nop) + ) + (block $block3 + (nop) + ) + ) + ) + (block $a + (if + (i32.const 0) + (i32.const 1) + (block $block6 + (nop) + ) + ) + ) + (block $a + (if + (i32.const 0) + (block $block8 + (nop) + ) + (i32.const 1) + ) + ) + (block $c + (block $b + (if + (i32.const 0) + (block $block11 + (nop) + ) + (block $block13 + (nop) + ) + ) + ) + ) + ) ) diff --git a/test/passes/remove-unused-brs.wast b/test/passes/remove-unused-brs.wast index 8e1a557ef..2b3fb14d3 100644 --- a/test/passes/remove-unused-brs.wast +++ b/test/passes/remove-unused-brs.wast @@ -157,5 +157,78 @@ ) ) ) + (func $b16 + (block $a + (block $b + (block $c + (br $a) + ) + (br $a) + ) + (br $a) + ) + (block $a + (block $b + (block $c + (br $c) + ) + (br $b) + ) + (br $a) + ) + (block $a + (block $b + (block $c + (br $b) + ) + (br $a) + ) + (br $a) + ) + ) + (func $b17 + (block $a + (if + (i32.const 0) + (block + (br $a) + ) + (block + (br $a) + ) + ) + ) + (block $a + (if + (i32.const 0) + (i32.const 1) + (block + (br $a) + ) + ) + ) + (block $a + (if + (i32.const 0) + (block + (br $a) + ) + (i32.const 1) + ) + ) + (block $c + (block $b + (if + (i32.const 0) + (block + (br $b) + ) + (block + (br $c) + ) + ) + ) + ) + ) ) diff --git a/test/unit.fromasm b/test/unit.fromasm index 412bfcace..f3d978c88 100644 --- a/test/unit.fromasm +++ b/test/unit.fromasm @@ -228,7 +228,6 @@ (loop $while-out$13 $while-in$14 (br $label$break$Lout) ) - (br $label$break$Lout) ) ) (loop $label$break$L1 $label$continue$L1 diff --git a/test/unit.fromasm.imprecise b/test/unit.fromasm.imprecise index 363131ff3..5df8aef72 100644 --- a/test/unit.fromasm.imprecise +++ b/test/unit.fromasm.imprecise @@ -222,7 +222,6 @@ (loop $while-out$13 $while-in$14 (br $label$break$Lout) ) - (br $label$break$Lout) ) ) (loop $label$break$L1 $label$continue$L1 -- cgit v1.2.3 From 203d502f9c3c5fc1f16822d3432087785653d767 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Sat, 23 Apr 2016 21:39:52 -0700 Subject: get rid of nops in ifs --- src/passes/Vacuum.cpp | 20 ++++++++++++++++++++ test/passes/vacuum.txt | 11 +++++++++++ test/passes/vacuum.wast | 15 +++++++++++++++ 3 files changed, 46 insertions(+) (limited to 'src') diff --git a/src/passes/Vacuum.cpp b/src/passes/Vacuum.cpp index 12565f603..dd88fa0eb 100644 --- a/src/passes/Vacuum.cpp +++ b/src/passes/Vacuum.cpp @@ -21,6 +21,7 @@ #include #include #include +#include namespace wasm { @@ -62,6 +63,25 @@ struct Vacuum : public WalkerPass>> { } } } + + void visitIf(If* curr) { + if (curr->ifFalse) { + if (curr->ifFalse->is()) { + curr->ifFalse = nullptr; + } else if (curr->ifTrue->is()) { + curr->ifTrue = curr->ifFalse; + curr->ifFalse = nullptr; + curr->condition = Builder(*getModule()).makeUnary(EqZ, curr->condition, curr->condition->type); + } + } + if (!curr->ifFalse) { + // no else + if (curr->ifTrue->is()) { + // no nothing + replaceCurrent(curr->condition); + } + } + } }; static RegisterPass registerPass("vacuum", "removes obviously unneeded code"); diff --git a/test/passes/vacuum.txt b/test/passes/vacuum.txt index 103dbc6bc..d604cfa08 100644 --- a/test/passes/vacuum.txt +++ b/test/passes/vacuum.txt @@ -16,5 +16,16 @@ (i32.const 57) ) ) + (if + (i32.eqz + (i32.const 100) + ) + (i32.const 101) + ) + (if + (i32.const 102) + (i32.const 103) + ) + (i32.const 104) ) ) diff --git a/test/passes/vacuum.wast b/test/passes/vacuum.wast index a0c638eb8..28125b969 100644 --- a/test/passes/vacuum.wast +++ b/test/passes/vacuum.wast @@ -23,6 +23,21 @@ ) (i32.const 58) ) + (if + (i32.const 100) + (nop) + (i32.const 101) + ) + (if + (i32.const 102) + (i32.const 103) + (nop) + ) + (if + (i32.const 104) + (nop) + (nop) + ) ) ) -- cgit v1.2.3 From 7dcb613e392757bd5a442c89f45f885a63d7b1dd Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Sat, 23 Apr 2016 21:42:52 -0700 Subject: run optimize-instructions a second time at the end --- src/pass.cpp | 1 + test/emcc_hello_world.fromasm | 960 ++++++++++++++------------------ test/emcc_hello_world.fromasm.imprecise | 960 ++++++++++++++------------------ 3 files changed, 821 insertions(+), 1100 deletions(-) (limited to 'src') diff --git a/src/pass.cpp b/src/pass.cpp index 7095da71d..5c4f510f8 100644 --- a/src/pass.cpp +++ b/src/pass.cpp @@ -65,6 +65,7 @@ void PassRunner::addDefaultOptimizationPasses() { add("merge-blocks"); add("reorder-locals"); add("vacuum"); + add("optimize-instructions"); } void PassRunner::run(Module* module) { diff --git a/test/emcc_hello_world.fromasm b/test/emcc_hello_world.fromasm index 603d2c0bf..9d50d32b2 100644 --- a/test/emcc_hello_world.fromasm +++ b/test/emcc_hello_world.fromasm @@ -766,14 +766,12 @@ (get_local $$tio) ) (if - (i32.eqz - (i32.eq - (call_import $___syscall54 - (i32.const 54) - (get_local $$vararg_buffer) - ) - (i32.const 0) + (i32.ne + (call_import $___syscall54 + (i32.const 54) + (get_local $$vararg_buffer) ) + (i32.const 0) ) (i32.store8 offset=75 (get_local $$f) @@ -990,11 +988,9 @@ ) ) (if - (i32.eqz - (i32.eq - (get_local $$cond19) - (i32.const 0) - ) + (i32.ne + (get_local $$cond19) + (i32.const 0) ) (call $___unlockfile (get_local $$f$addr$022) @@ -1037,13 +1033,11 @@ ) (block (if - (i32.eqz - (i32.gt_s - (i32.load offset=76 - (get_local $$f) - ) - (i32.const -1) + (i32.le_s + (i32.load offset=76 + (get_local $$f) ) + (i32.const -1) ) (block (set_local $$retval$0 @@ -1918,11 +1912,9 @@ ) ) (if - (i32.eqz - (i32.eq - (get_local $$cond) - (i32.const 0) - ) + (i32.ne + (get_local $$cond) + (i32.const 0) ) (call $___unlockfile (get_local $$f) @@ -2844,20 +2836,18 @@ ) ) (if - (i32.eqz - (i32.eq - (i32.and - (i32.xor - (i32.and - (get_local $$xor) - (i32.const -2139062144) - ) + (i32.ne + (i32.and + (i32.xor + (i32.and + (get_local $$xor) (i32.const -2139062144) ) - (get_local $$sub) + (i32.const -2139062144) ) - (i32.const 0) + (get_local $$sub) ) + (i32.const 0) ) (block (set_local $$n$addr$133$lcssa @@ -3992,19 +3982,17 @@ (i32.const 0) ) (if - (i32.eqz - (i32.eq - (i32.shr_s - (i32.shl - (i32.load8_s offset=1 - (get_local $$incdec$ptr169276301) - ) - (i32.const 24) + (i32.ne + (i32.shr_s + (i32.shl + (i32.load8_s offset=1 + (get_local $$incdec$ptr169276301) ) (i32.const 24) ) - (i32.const 37) + (i32.const 24) ) + (i32.const 37) ) (block (set_local $$incdec$ptr169276$lcssa @@ -4091,11 +4079,9 @@ ) ) (if - (i32.eqz - (i32.eq - (get_local $$z$0$lcssa) - (get_local $$incdec$ptr169275) - ) + (i32.ne + (get_local $$z$0$lcssa) + (get_local $$incdec$ptr169275) ) (block (set_local $$cnt$0 @@ -4471,11 +4457,9 @@ (i32.const 0) ) (if - (i32.eqz - (i32.eq - (get_local $$l10n$1) - (i32.const 0) - ) + (i32.ne + (get_local $$l10n$1) + (i32.const 0) ) (block (set_local $$retval$0 @@ -4735,26 +4719,24 @@ ) (block (if - (i32.eqz - (i32.eq - (i32.shr_s - (i32.shl - (set_local $$32 - (i32.load8_s - (set_local $$arrayidx114 - (i32.add - (get_local $$incdec$ptr169269) - (i32.const 1) - ) + (i32.ne + (i32.shr_s + (i32.shl + (set_local $$32 + (i32.load8_s + (set_local $$arrayidx114 + (i32.add + (get_local $$incdec$ptr169269) + (i32.const 1) ) ) ) - (i32.const 24) ) (i32.const 24) ) - (i32.const 42) + (i32.const 24) ) + (i32.const 42) ) (block (if @@ -4940,11 +4922,9 @@ ) ) (if - (i32.eqz - (i32.eq - (get_local $$l10n$3) - (i32.const 0) - ) + (i32.ne + (get_local $$l10n$3) + (i32.const 0) ) (block (set_local $$retval$0 @@ -6975,11 +6955,9 @@ ) (loop $while-out$74 $while-in$75 (if - (i32.eqz - (i32.gt_u - (get_local $$z$2$i) - (get_local $$a$2$ph$i) - ) + (i32.le_u + (get_local $$z$2$i) + (get_local $$a$2$ph$i) ) (block (set_local $$z$2$i$lcssa @@ -7685,19 +7663,17 @@ ) (block (if - (i32.eqz - (i32.eq - (i32.shr_s - (i32.shl - (i32.load8_s - (get_local $$prefix$0$i) - ) - (i32.const 24) + (i32.ne + (i32.shr_s + (i32.shl + (i32.load8_s + (get_local $$prefix$0$i) ) (i32.const 24) ) - (i32.const 45) + (i32.const 24) ) + (i32.const 45) ) (block (set_local $$round377$1$i @@ -7732,14 +7708,12 @@ ) ) (if - (i32.eqz - (f64.ne - (f64.add - (get_local $$round377$1$i) - (get_local $$small$1$i) - ) + (f64.eq + (f64.add (get_local $$round377$1$i) + (get_local $$small$1$i) ) + (get_local $$round377$1$i) ) (block (set_local $$a$8$i @@ -7987,11 +7961,9 @@ ) (loop $while-out$96 $while-in$97 (if - (i32.eqz - (i32.gt_u - (get_local $$z$7$i) - (get_local $$a$9$ph$i) - ) + (i32.le_u + (get_local $$z$7$i) + (get_local $$a$9$ph$i) ) (block (set_local $$cmp450$lcssa$i @@ -8089,16 +8061,14 @@ ) ) (if - (i32.eqz - (i32.eq - (set_local $$and483$i - (i32.and - (get_local $$fl$1$and219) - (i32.const 8) - ) + (i32.ne + (set_local $$and483$i + (i32.and + (get_local $$fl$1$and219) + (i32.const 8) ) - (i32.const 0) ) + (i32.const 0) ) (block (set_local $$and610$pre$phi$iZ2D @@ -8564,11 +8534,9 @@ ) (block (if - (i32.eqz - (i32.eq - (get_local $$249) - (get_local $$add$ptr671$i) - ) + (i32.ne + (get_local $$249) + (get_local $$add$ptr671$i) ) (block (set_local $$s668$1$i @@ -8674,24 +8642,20 @@ ) (block $do-once$114 (if - (i32.eqz - (i32.eq - (get_local $$239) - (i32.const 0) - ) + (i32.ne + (get_local $$239) + (i32.const 0) ) (block (br_if $do-once$114 - (i32.eqz - (i32.eq - (i32.and - (i32.load - (get_local $$f) - ) - (i32.const 32) + (i32.ne + (i32.and + (i32.load + (get_local $$f) ) - (i32.const 0) + (i32.const 32) ) + (i32.const 0) ) ) (call $___fwritex @@ -8957,16 +8921,14 @@ ) ) (if - (i32.eqz - (i32.eq - (i32.and - (i32.load - (get_local $$f) - ) - (i32.const 32) + (i32.ne + (i32.and + (i32.load + (get_local $$f) ) - (i32.const 0) + (i32.const 32) ) + (i32.const 0) ) (block (set_local $$s753$2$i @@ -9118,16 +9080,14 @@ (i32.const 0) ) (br_if $do-once$106 - (i32.eqz - (i32.eq - (i32.and - (i32.load - (get_local $$f) - ) - (i32.const 32) + (i32.ne + (i32.and + (i32.load + (get_local $$f) ) - (i32.const 0) + (i32.const 32) ) + (i32.const 0) ) ) (call $___fwritex @@ -10246,19 +10206,17 @@ ) ) (if - (i32.eqz - (i32.eq - (i32.load - (i32.add - (get_local $$nl_type) - (i32.shl - (get_local $$i$3296) - (i32.const 2) - ) + (i32.ne + (i32.load + (i32.add + (get_local $$nl_type) + (i32.shl + (get_local $$i$3296) + (i32.const 2) ) ) - (i32.const 0) ) + (i32.const 0) ) (block (set_local $$retval$0 @@ -10344,11 +10302,9 @@ ) (block $label$break$L1 (if - (i32.eqz - (i32.gt_u - (get_local $$type) - (i32.const 20) - ) + (i32.le_u + (get_local $$type) + (i32.const 20) ) (block $switch$3 (block $switch-default$14 @@ -11846,23 +11802,21 @@ ) ) (if - (i32.eqz - (i32.eq - (i32.and - (set_local $$shr3 - (i32.shr_u - (set_local $$0 - (i32.load - (i32.const 176) - ) + (i32.ne + (i32.and + (set_local $$shr3 + (i32.shr_u + (set_local $$0 + (i32.load + (i32.const 176) ) - (get_local $$shr) ) + (get_local $$shr) ) - (i32.const 3) ) - (i32.const 0) + (i32.const 3) ) + (i32.const 0) ) (block (set_local $$3 @@ -12008,11 +11962,9 @@ ) (block (if - (i32.eqz - (i32.eq - (get_local $$shr3) - (i32.const 0) - ) + (i32.ne + (get_local $$shr3) + (i32.const 0) ) (block (set_local $$sub @@ -12261,11 +12213,9 @@ (get_local $$sub91) ) (if - (i32.eqz - (i32.eq - (get_local $$13) - (i32.const 0) - ) + (i32.ne + (get_local $$13) + (i32.const 0) ) (block (set_local $$14 @@ -12598,14 +12548,12 @@ (call_import $_abort) ) (if - (i32.eqz - (i32.lt_u - (get_local $$v$0$i$lcssa) - (set_local $$add$ptr$i - (i32.add - (get_local $$v$0$i$lcssa) - (get_local $$cond) - ) + (i32.ge_u + (get_local $$v$0$i$lcssa) + (set_local $$add$ptr$i + (i32.add + (get_local $$v$0$i$lcssa) + (get_local $$cond) ) ) ) @@ -12681,20 +12629,18 @@ ) (loop $while-out$10 $while-in$11 (if - (i32.eqz - (i32.eq - (set_local $$33 - (i32.load - (set_local $$arrayidx71$i - (i32.add - (get_local $$R$1$i) - (i32.const 20) - ) + (i32.ne + (set_local $$33 + (i32.load + (set_local $$arrayidx71$i + (i32.add + (get_local $$R$1$i) + (i32.const 20) ) ) ) - (i32.const 0) ) + (i32.const 0) ) (block (set_local $$R$1$i @@ -12770,18 +12716,16 @@ (call_import $_abort) ) (if - (i32.eqz - (i32.eq - (i32.load - (set_local $$bk47$i - (i32.add - (get_local $$28) - (i32.const 12) - ) + (i32.ne + (i32.load + (set_local $$bk47$i + (i32.add + (get_local $$28) + (i32.const 12) ) ) - (get_local $$v$0$i$lcssa) ) + (get_local $$v$0$i$lcssa) ) (call_import $_abort) ) @@ -12817,11 +12761,9 @@ ) (block $do-once$12 (if - (i32.eqz - (i32.eq - (get_local $$26) - (i32.const 0) - ) + (i32.ne + (get_local $$26) + (i32.const 0) ) (block (if @@ -12928,15 +12870,13 @@ (get_local $$26) ) (if - (i32.eqz - (i32.eq - (set_local $$41 - (i32.load offset=16 - (get_local $$v$0$i$lcssa) - ) + (i32.ne + (set_local $$41 + (i32.load offset=16 + (get_local $$v$0$i$lcssa) ) - (i32.const 0) ) + (i32.const 0) ) (if (i32.lt_u @@ -12957,15 +12897,13 @@ ) ) (if - (i32.eqz - (i32.eq - (set_local $$42 - (i32.load offset=20 - (get_local $$v$0$i$lcssa) - ) + (i32.ne + (set_local $$42 + (i32.load offset=20 + (get_local $$v$0$i$lcssa) ) - (i32.const 0) ) + (i32.const 0) ) (if (i32.lt_u @@ -13052,15 +12990,13 @@ (get_local $$rsize$0$i$lcssa) ) (if - (i32.eqz - (i32.eq - (set_local $$45 - (i32.load - (i32.const 184) - ) + (i32.ne + (set_local $$45 + (i32.load + (i32.const 184) ) - (i32.const 0) ) + (i32.const 0) ) (block (set_local $$46 @@ -13772,15 +13708,13 @@ ) ) (if - (i32.eqz - (i32.eq - (set_local $$59 - (i32.load offset=16 - (get_local $$t$48$i) - ) + (i32.ne + (set_local $$59 + (i32.load offset=16 + (get_local $$t$48$i) ) - (i32.const 0) ) + (i32.const 0) ) (block (set_local $$rsize$49$i @@ -13865,14 +13799,12 @@ (call_import $_abort) ) (if - (i32.eqz - (i32.lt_u - (get_local $$v$4$lcssa$i) - (set_local $$add$ptr$i$161 - (i32.add - (get_local $$v$4$lcssa$i) - (get_local $$and145) - ) + (i32.ge_u + (get_local $$v$4$lcssa$i) + (set_local $$add$ptr$i$161 + (i32.add + (get_local $$v$4$lcssa$i) + (get_local $$and145) ) ) ) @@ -13948,20 +13880,18 @@ ) (loop $while-out$23 $while-in$24 (if - (i32.eqz - (i32.eq - (set_local $$70 - (i32.load - (set_local $$arrayidx161$i - (i32.add - (get_local $$R$1$i$168) - (i32.const 20) - ) + (i32.ne + (set_local $$70 + (i32.load + (set_local $$arrayidx161$i + (i32.add + (get_local $$R$1$i$168) + (i32.const 20) ) ) ) - (i32.const 0) ) + (i32.const 0) ) (block (set_local $$R$1$i$168 @@ -14037,18 +13967,16 @@ (call_import $_abort) ) (if - (i32.eqz - (i32.eq - (i32.load - (set_local $$bk136$i - (i32.add - (get_local $$65) - (i32.const 12) - ) + (i32.ne + (i32.load + (set_local $$bk136$i + (i32.add + (get_local $$65) + (i32.const 12) ) ) - (get_local $$v$4$lcssa$i) ) + (get_local $$v$4$lcssa$i) ) (call_import $_abort) ) @@ -14084,11 +14012,9 @@ ) (block $do-once$25 (if - (i32.eqz - (i32.eq - (get_local $$63) - (i32.const 0) - ) + (i32.ne + (get_local $$63) + (i32.const 0) ) (block (if @@ -14195,15 +14121,13 @@ (get_local $$63) ) (if - (i32.eqz - (i32.eq - (set_local $$78 - (i32.load offset=16 - (get_local $$v$4$lcssa$i) - ) + (i32.ne + (set_local $$78 + (i32.load offset=16 + (get_local $$v$4$lcssa$i) ) - (i32.const 0) ) + (i32.const 0) ) (if (i32.lt_u @@ -14224,15 +14148,13 @@ ) ) (if - (i32.eqz - (i32.eq - (set_local $$79 - (i32.load offset=20 - (get_local $$v$4$lcssa$i) - ) + (i32.ne + (set_local $$79 + (i32.load offset=20 + (get_local $$v$4$lcssa$i) ) - (i32.const 0) ) + (i32.const 0) ) (if (i32.lt_u @@ -14818,15 +14740,13 @@ ) ) (if - (i32.eqz - (i32.lt_u - (set_local $$94 - (i32.load - (i32.const 184) - ) + (i32.ge_u + (set_local $$94 + (i32.load + (i32.const 184) ) - (get_local $$nb$0) ) + (get_local $$nb$0) ) (block (set_local $$95 @@ -15050,50 +14970,46 @@ ) ) (if - (i32.eqz - (i32.gt_u - (set_local $$and11$i - (i32.and - (set_local $$add9$i - (i32.add - (set_local $$100 - (i32.load - (i32.const 656) - ) + (i32.le_u + (set_local $$and11$i + (i32.and + (set_local $$add9$i + (i32.add + (set_local $$100 + (i32.load + (i32.const 656) ) - (set_local $$sub$i$181 - (i32.add - (get_local $$nb$0) - (i32.const 47) - ) + ) + (set_local $$sub$i$181 + (i32.add + (get_local $$nb$0) + (i32.const 47) ) ) ) - (set_local $$neg$i$182 - (i32.sub - (i32.const 0) - (get_local $$100) - ) + ) + (set_local $$neg$i$182 + (i32.sub + (i32.const 0) + (get_local $$100) ) ) ) - (get_local $$nb$0) ) + (get_local $$nb$0) ) (return (i32.const 0) ) ) (if - (i32.eqz - (i32.eq - (set_local $$101 - (i32.load - (i32.const 616) - ) + (i32.ne + (set_local $$101 + (i32.load + (i32.const 616) ) - (i32.const 0) ) + (i32.const 0) ) (if (i32.or @@ -15151,15 +15067,13 @@ ) (loop $while-out$37 $while-in$38 (if - (i32.eqz - (i32.gt_u - (set_local $$105 - (i32.load - (get_local $$sp$0$i$i) - ) + (i32.le_u + (set_local $$105 + (i32.load + (get_local $$sp$0$i$i) ) - (get_local $$104) ) + (get_local $$104) ) (if (i32.gt_u @@ -15240,11 +15154,9 @@ ) ) (if - (i32.eqz - (i32.eq - (get_local $$call83$i) - (i32.const -1) - ) + (i32.ne + (get_local $$call83$i) + (i32.const -1) ) (block (set_local $$tbase$796$i @@ -15282,15 +15194,13 @@ (i32.const 173) ) (if - (i32.eqz - (i32.eq - (set_local $$call37$i - (call_import $_sbrk - (i32.const 0) - ) + (i32.ne + (set_local $$call37$i + (call_import $_sbrk + (i32.const 0) ) - (i32.const -1) ) + (i32.const -1) ) (block (if @@ -15357,15 +15267,13 @@ ) (block (if - (i32.eqz - (i32.eq - (set_local $$111 - (i32.load - (i32.const 616) - ) + (i32.ne + (set_local $$111 + (i32.load + (i32.const 616) ) - (i32.const 0) ) + (i32.const 0) ) (br_if $do-once$39 (i32.or @@ -15501,11 +15409,9 @@ ) ) (if - (i32.eqz - (i32.eq - (get_local $$br$2$ph$i) - (i32.const -1) - ) + (i32.ne + (get_local $$br$2$ph$i) + (i32.const -1) ) (block (set_local $$tbase$796$i @@ -16295,23 +16201,21 @@ ) (block $do-once$55 (if - (i32.eqz - (i32.eq - (set_local $$148 - (i32.load offset=8 - (get_local $$add$ptr16$i$i) - ) + (i32.ne + (set_local $$148 + (i32.load offset=8 + (get_local $$add$ptr16$i$i) ) - (set_local $$arrayidx$i$48$i - (i32.add - (i32.const 216) + ) + (set_local $$arrayidx$i$48$i + (i32.add + (i32.const 216) + (i32.shl (i32.shl - (i32.shl - (get_local $$shr$i$45$i) - (i32.const 1) - ) - (i32.const 2) + (get_local $$shr$i$45$i) + (i32.const 1) ) + (i32.const 2) ) ) ) @@ -16483,20 +16387,18 @@ ) (loop $while-out$61 $while-in$62 (if - (i32.eqz - (i32.eq - (set_local $$161 - (i32.load - (set_local $$arrayidx103$i$i - (i32.add - (get_local $$R$1$i$i) - (i32.const 20) - ) + (i32.ne + (set_local $$161 + (i32.load + (set_local $$arrayidx103$i$i + (i32.add + (get_local $$R$1$i$i) + (i32.const 20) ) ) ) - (i32.const 0) ) + (i32.const 0) ) (block (set_local $$R$1$i$i @@ -16572,18 +16474,16 @@ (call_import $_abort) ) (if - (i32.eqz - (i32.eq - (i32.load - (set_local $$bk82$i$i - (i32.add - (get_local $$156) - (i32.const 12) - ) + (i32.ne + (i32.load + (set_local $$bk82$i$i + (i32.add + (get_local $$156) + (i32.const 12) ) ) - (get_local $$add$ptr16$i$i) ) + (get_local $$add$ptr16$i$i) ) (call_import $_abort) ) @@ -16649,11 +16549,9 @@ (get_local $$R$3$i$i) ) (br_if $do-once$63 - (i32.eqz - (i32.eq - (get_local $$R$3$i$i) - (i32.const 0) - ) + (i32.ne + (get_local $$R$3$i$i) + (i32.const 0) ) ) (i32.store @@ -16729,20 +16627,18 @@ (get_local $$154) ) (if - (i32.eqz - (i32.eq - (set_local $$169 - (i32.load - (set_local $$child166$i$i - (i32.add - (get_local $$add$ptr16$i$i) - (i32.const 16) - ) + (i32.ne + (set_local $$169 + (i32.load + (set_local $$child166$i$i + (i32.add + (get_local $$add$ptr16$i$i) + (i32.const 16) ) ) ) - (i32.const 0) ) + (i32.const 0) ) (if (i32.lt_u @@ -16909,21 +16805,19 @@ ) (block (if - (i32.eqz - (i32.lt_u - (set_local $$175 - (i32.load - (set_local $$174 - (i32.add - (get_local $$arrayidx223$i$i) - (i32.const 8) - ) + (i32.ge_u + (set_local $$175 + (i32.load + (set_local $$174 + (i32.add + (get_local $$arrayidx223$i$i) + (i32.const 8) ) ) ) - (i32.load - (i32.const 192) - ) + ) + (i32.load + (i32.const 192) ) ) (block @@ -17353,15 +17247,13 @@ ) (loop $while-out$73 $while-in$74 (if - (i32.eqz - (i32.gt_u - (set_local $$185 - (i32.load - (get_local $$sp$0$i$i$i) - ) + (i32.le_u + (set_local $$185 + (i32.load + (get_local $$sp$0$i$i$i) ) - (get_local $$119) ) + (get_local $$119) ) (if (i32.gt_u @@ -17608,11 +17500,9 @@ (br $while-in$76) ) (if - (i32.eqz - (i32.eq - (get_local $$cond13$i$i) - (get_local $$119) - ) + (i32.ne + (get_local $$cond13$i$i) + (get_local $$119) ) (block (i32.store @@ -18411,23 +18301,21 @@ ) (block (if - (i32.eqz - (i32.eq - (i32.and - (set_local $$27 - (i32.load - (set_local $$head209 - (i32.add - (get_local $$add$ptr6) - (i32.const 4) - ) + (i32.ne + (i32.and + (set_local $$27 + (i32.load + (set_local $$head209 + (i32.add + (get_local $$add$ptr6) + (i32.const 4) ) ) ) - (i32.const 3) ) (i32.const 3) ) + (i32.const 3) ) (block (set_local $$p$1 @@ -18485,23 +18373,21 @@ ) ) (if - (i32.eqz - (i32.eq - (set_local $$4 - (i32.load offset=8 - (get_local $$add$ptr16) - ) + (i32.ne + (set_local $$4 + (i32.load offset=8 + (get_local $$add$ptr16) ) - (set_local $$arrayidx - (i32.add - (i32.const 216) + ) + (set_local $$arrayidx + (i32.add + (i32.const 216) + (i32.shl (i32.shl - (i32.shl - (get_local $$shr) - (i32.const 1) - ) - (i32.const 2) + (get_local $$shr) + (i32.const 1) ) + (i32.const 2) ) ) ) @@ -18515,13 +18401,11 @@ (call_import $_abort) ) (if - (i32.eqz - (i32.eq - (i32.load offset=12 - (get_local $$4) - ) - (get_local $$add$ptr16) + (i32.ne + (i32.load offset=12 + (get_local $$4) ) + (get_local $$add$ptr16) ) (call_import $_abort) ) @@ -18682,20 +18566,18 @@ ) (loop $while-out$4 $while-in$5 (if - (i32.eqz - (i32.eq - (set_local $$16 - (i32.load - (set_local $$arrayidx108 - (i32.add - (get_local $$R$1) - (i32.const 20) - ) + (i32.ne + (set_local $$16 + (i32.load + (set_local $$arrayidx108 + (i32.add + (get_local $$R$1) + (i32.const 20) ) ) ) - (i32.const 0) ) + (i32.const 0) ) (block (set_local $$R$1 @@ -18771,18 +18653,16 @@ (call_import $_abort) ) (if - (i32.eqz - (i32.eq - (i32.load - (set_local $$bk82 - (i32.add - (get_local $$11) - (i32.const 12) - ) + (i32.ne + (i32.load + (set_local $$bk82 + (i32.add + (get_local $$11) + (i32.const 12) ) ) - (get_local $$add$ptr16) ) + (get_local $$add$ptr16) ) (call_import $_abort) ) @@ -18949,20 +18829,18 @@ (get_local $$9) ) (if - (i32.eqz - (i32.eq - (set_local $$24 - (i32.load - (set_local $$child171 - (i32.add - (get_local $$add$ptr16) - (i32.const 16) - ) + (i32.ne + (set_local $$24 + (i32.load + (set_local $$child171 + (i32.add + (get_local $$add$ptr16) + (i32.const 16) ) ) ) - (i32.const 0) ) + (i32.const 0) ) (if (i32.lt_u @@ -19039,11 +18917,9 @@ ) ) (if - (i32.eqz - (i32.lt_u - (get_local $$p$1) - (get_local $$add$ptr6) - ) + (i32.ge_u + (get_local $$p$1) + (get_local $$add$ptr6) ) (call_import $_abort) ) @@ -19106,12 +18982,10 @@ ) ) (if - (i32.eqz - (i32.eq - (get_local $$p$1) - (i32.load - (i32.const 196) - ) + (i32.ne + (get_local $$p$1) + (i32.load + (i32.const 196) ) ) (return) @@ -19195,23 +19069,21 @@ ) ) (if - (i32.eqz - (i32.eq - (set_local $$34 - (i32.load offset=8 - (get_local $$add$ptr6) - ) + (i32.ne + (set_local $$34 + (i32.load offset=8 + (get_local $$add$ptr6) ) - (set_local $$arrayidx279 - (i32.add - (i32.const 216) + ) + (set_local $$arrayidx279 + (i32.add + (i32.const 216) + (i32.shl (i32.shl - (i32.shl - (get_local $$shr268) - (i32.const 1) - ) - (i32.const 2) + (get_local $$shr268) + (i32.const 1) ) + (i32.const 2) ) ) ) @@ -19227,13 +19099,11 @@ (call_import $_abort) ) (if - (i32.eqz - (i32.eq - (i32.load offset=12 - (get_local $$34) - ) - (get_local $$add$ptr6) + (i32.ne + (i32.load offset=12 + (get_local $$34) ) + (get_local $$add$ptr6) ) (call_import $_abort) ) @@ -19383,20 +19253,18 @@ ) (loop $while-out$12 $while-in$13 (if - (i32.eqz - (i32.eq - (set_local $$49 - (i32.load - (set_local $$arrayidx374 - (i32.add - (get_local $$R332$1) - (i32.const 20) - ) + (i32.ne + (set_local $$49 + (i32.load + (set_local $$arrayidx374 + (i32.add + (get_local $$R332$1) + (i32.const 20) ) ) ) - (i32.const 0) ) + (i32.const 0) ) (block (set_local $$R332$1 @@ -19476,18 +19344,16 @@ (call_import $_abort) ) (if - (i32.eqz - (i32.eq - (i32.load - (set_local $$bk343 - (i32.add - (get_local $$43) - (i32.const 12) - ) + (i32.ne + (i32.load + (set_local $$bk343 + (i32.add + (get_local $$43) + (i32.const 12) ) ) - (get_local $$add$ptr6) ) + (get_local $$add$ptr6) ) (call_import $_abort) ) @@ -19522,11 +19388,9 @@ ) ) (if - (i32.eqz - (i32.eq - (get_local $$41) - (i32.const 0) - ) + (i32.ne + (get_local $$41) + (i32.const 0) ) (block (if @@ -19633,20 +19497,18 @@ (get_local $$41) ) (if - (i32.eqz - (i32.eq - (set_local $$58 - (i32.load - (set_local $$child443 - (i32.add - (get_local $$add$ptr6) - (i32.const 16) - ) + (i32.ne + (set_local $$58 + (i32.load + (set_local $$child443 + (i32.add + (get_local $$add$ptr6) + (i32.const 16) ) ) ) - (i32.const 0) ) + (i32.const 0) ) (if (i32.lt_u @@ -19667,15 +19529,13 @@ ) ) (if - (i32.eqz - (i32.eq - (set_local $$59 - (i32.load offset=4 - (get_local $$child443) - ) + (i32.ne + (set_local $$59 + (i32.load offset=4 + (get_local $$child443) ) - (i32.const 0) ) + (i32.const 0) ) (if (i32.lt_u diff --git a/test/emcc_hello_world.fromasm.imprecise b/test/emcc_hello_world.fromasm.imprecise index b8890f5ed..b303c5cac 100644 --- a/test/emcc_hello_world.fromasm.imprecise +++ b/test/emcc_hello_world.fromasm.imprecise @@ -764,14 +764,12 @@ (get_local $$tio) ) (if - (i32.eqz - (i32.eq - (call_import $___syscall54 - (i32.const 54) - (get_local $$vararg_buffer) - ) - (i32.const 0) + (i32.ne + (call_import $___syscall54 + (i32.const 54) + (get_local $$vararg_buffer) ) + (i32.const 0) ) (i32.store8 offset=75 (get_local $$f) @@ -988,11 +986,9 @@ ) ) (if - (i32.eqz - (i32.eq - (get_local $$cond19) - (i32.const 0) - ) + (i32.ne + (get_local $$cond19) + (i32.const 0) ) (call $___unlockfile (get_local $$f$addr$022) @@ -1035,13 +1031,11 @@ ) (block (if - (i32.eqz - (i32.gt_s - (i32.load offset=76 - (get_local $$f) - ) - (i32.const -1) + (i32.le_s + (i32.load offset=76 + (get_local $$f) ) + (i32.const -1) ) (block (set_local $$retval$0 @@ -1916,11 +1910,9 @@ ) ) (if - (i32.eqz - (i32.eq - (get_local $$cond) - (i32.const 0) - ) + (i32.ne + (get_local $$cond) + (i32.const 0) ) (call $___unlockfile (get_local $$f) @@ -2842,20 +2834,18 @@ ) ) (if - (i32.eqz - (i32.eq - (i32.and - (i32.xor - (i32.and - (get_local $$xor) - (i32.const -2139062144) - ) + (i32.ne + (i32.and + (i32.xor + (i32.and + (get_local $$xor) (i32.const -2139062144) ) - (get_local $$sub) + (i32.const -2139062144) ) - (i32.const 0) + (get_local $$sub) ) + (i32.const 0) ) (block (set_local $$n$addr$133$lcssa @@ -3990,19 +3980,17 @@ (i32.const 0) ) (if - (i32.eqz - (i32.eq - (i32.shr_s - (i32.shl - (i32.load8_s offset=1 - (get_local $$incdec$ptr169276301) - ) - (i32.const 24) + (i32.ne + (i32.shr_s + (i32.shl + (i32.load8_s offset=1 + (get_local $$incdec$ptr169276301) ) (i32.const 24) ) - (i32.const 37) + (i32.const 24) ) + (i32.const 37) ) (block (set_local $$incdec$ptr169276$lcssa @@ -4089,11 +4077,9 @@ ) ) (if - (i32.eqz - (i32.eq - (get_local $$z$0$lcssa) - (get_local $$incdec$ptr169275) - ) + (i32.ne + (get_local $$z$0$lcssa) + (get_local $$incdec$ptr169275) ) (block (set_local $$cnt$0 @@ -4469,11 +4455,9 @@ (i32.const 0) ) (if - (i32.eqz - (i32.eq - (get_local $$l10n$1) - (i32.const 0) - ) + (i32.ne + (get_local $$l10n$1) + (i32.const 0) ) (block (set_local $$retval$0 @@ -4733,26 +4717,24 @@ ) (block (if - (i32.eqz - (i32.eq - (i32.shr_s - (i32.shl - (set_local $$32 - (i32.load8_s - (set_local $$arrayidx114 - (i32.add - (get_local $$incdec$ptr169269) - (i32.const 1) - ) + (i32.ne + (i32.shr_s + (i32.shl + (set_local $$32 + (i32.load8_s + (set_local $$arrayidx114 + (i32.add + (get_local $$incdec$ptr169269) + (i32.const 1) ) ) ) - (i32.const 24) ) (i32.const 24) ) - (i32.const 42) + (i32.const 24) ) + (i32.const 42) ) (block (if @@ -4938,11 +4920,9 @@ ) ) (if - (i32.eqz - (i32.eq - (get_local $$l10n$3) - (i32.const 0) - ) + (i32.ne + (get_local $$l10n$3) + (i32.const 0) ) (block (set_local $$retval$0 @@ -6973,11 +6953,9 @@ ) (loop $while-out$74 $while-in$75 (if - (i32.eqz - (i32.gt_u - (get_local $$z$2$i) - (get_local $$a$2$ph$i) - ) + (i32.le_u + (get_local $$z$2$i) + (get_local $$a$2$ph$i) ) (block (set_local $$z$2$i$lcssa @@ -7683,19 +7661,17 @@ ) (block (if - (i32.eqz - (i32.eq - (i32.shr_s - (i32.shl - (i32.load8_s - (get_local $$prefix$0$i) - ) - (i32.const 24) + (i32.ne + (i32.shr_s + (i32.shl + (i32.load8_s + (get_local $$prefix$0$i) ) (i32.const 24) ) - (i32.const 45) + (i32.const 24) ) + (i32.const 45) ) (block (set_local $$round377$1$i @@ -7730,14 +7706,12 @@ ) ) (if - (i32.eqz - (f64.ne - (f64.add - (get_local $$round377$1$i) - (get_local $$small$1$i) - ) + (f64.eq + (f64.add (get_local $$round377$1$i) + (get_local $$small$1$i) ) + (get_local $$round377$1$i) ) (block (set_local $$a$8$i @@ -7985,11 +7959,9 @@ ) (loop $while-out$96 $while-in$97 (if - (i32.eqz - (i32.gt_u - (get_local $$z$7$i) - (get_local $$a$9$ph$i) - ) + (i32.le_u + (get_local $$z$7$i) + (get_local $$a$9$ph$i) ) (block (set_local $$cmp450$lcssa$i @@ -8087,16 +8059,14 @@ ) ) (if - (i32.eqz - (i32.eq - (set_local $$and483$i - (i32.and - (get_local $$fl$1$and219) - (i32.const 8) - ) + (i32.ne + (set_local $$and483$i + (i32.and + (get_local $$fl$1$and219) + (i32.const 8) ) - (i32.const 0) ) + (i32.const 0) ) (block (set_local $$and610$pre$phi$iZ2D @@ -8562,11 +8532,9 @@ ) (block (if - (i32.eqz - (i32.eq - (get_local $$249) - (get_local $$add$ptr671$i) - ) + (i32.ne + (get_local $$249) + (get_local $$add$ptr671$i) ) (block (set_local $$s668$1$i @@ -8672,24 +8640,20 @@ ) (block $do-once$114 (if - (i32.eqz - (i32.eq - (get_local $$239) - (i32.const 0) - ) + (i32.ne + (get_local $$239) + (i32.const 0) ) (block (br_if $do-once$114 - (i32.eqz - (i32.eq - (i32.and - (i32.load - (get_local $$f) - ) - (i32.const 32) + (i32.ne + (i32.and + (i32.load + (get_local $$f) ) - (i32.const 0) + (i32.const 32) ) + (i32.const 0) ) ) (call $___fwritex @@ -8955,16 +8919,14 @@ ) ) (if - (i32.eqz - (i32.eq - (i32.and - (i32.load - (get_local $$f) - ) - (i32.const 32) + (i32.ne + (i32.and + (i32.load + (get_local $$f) ) - (i32.const 0) + (i32.const 32) ) + (i32.const 0) ) (block (set_local $$s753$2$i @@ -9116,16 +9078,14 @@ (i32.const 0) ) (br_if $do-once$106 - (i32.eqz - (i32.eq - (i32.and - (i32.load - (get_local $$f) - ) - (i32.const 32) + (i32.ne + (i32.and + (i32.load + (get_local $$f) ) - (i32.const 0) + (i32.const 32) ) + (i32.const 0) ) ) (call $___fwritex @@ -10244,19 +10204,17 @@ ) ) (if - (i32.eqz - (i32.eq - (i32.load - (i32.add - (get_local $$nl_type) - (i32.shl - (get_local $$i$3296) - (i32.const 2) - ) + (i32.ne + (i32.load + (i32.add + (get_local $$nl_type) + (i32.shl + (get_local $$i$3296) + (i32.const 2) ) ) - (i32.const 0) ) + (i32.const 0) ) (block (set_local $$retval$0 @@ -10342,11 +10300,9 @@ ) (block $label$break$L1 (if - (i32.eqz - (i32.gt_u - (get_local $$type) - (i32.const 20) - ) + (i32.le_u + (get_local $$type) + (i32.const 20) ) (block $switch$3 (block $switch-default$14 @@ -11844,23 +11800,21 @@ ) ) (if - (i32.eqz - (i32.eq - (i32.and - (set_local $$shr3 - (i32.shr_u - (set_local $$0 - (i32.load - (i32.const 176) - ) + (i32.ne + (i32.and + (set_local $$shr3 + (i32.shr_u + (set_local $$0 + (i32.load + (i32.const 176) ) - (get_local $$shr) ) + (get_local $$shr) ) - (i32.const 3) ) - (i32.const 0) + (i32.const 3) ) + (i32.const 0) ) (block (set_local $$3 @@ -12006,11 +11960,9 @@ ) (block (if - (i32.eqz - (i32.eq - (get_local $$shr3) - (i32.const 0) - ) + (i32.ne + (get_local $$shr3) + (i32.const 0) ) (block (set_local $$sub @@ -12259,11 +12211,9 @@ (get_local $$sub91) ) (if - (i32.eqz - (i32.eq - (get_local $$13) - (i32.const 0) - ) + (i32.ne + (get_local $$13) + (i32.const 0) ) (block (set_local $$14 @@ -12596,14 +12546,12 @@ (call_import $_abort) ) (if - (i32.eqz - (i32.lt_u - (get_local $$v$0$i$lcssa) - (set_local $$add$ptr$i - (i32.add - (get_local $$v$0$i$lcssa) - (get_local $$cond) - ) + (i32.ge_u + (get_local $$v$0$i$lcssa) + (set_local $$add$ptr$i + (i32.add + (get_local $$v$0$i$lcssa) + (get_local $$cond) ) ) ) @@ -12679,20 +12627,18 @@ ) (loop $while-out$10 $while-in$11 (if - (i32.eqz - (i32.eq - (set_local $$33 - (i32.load - (set_local $$arrayidx71$i - (i32.add - (get_local $$R$1$i) - (i32.const 20) - ) + (i32.ne + (set_local $$33 + (i32.load + (set_local $$arrayidx71$i + (i32.add + (get_local $$R$1$i) + (i32.const 20) ) ) ) - (i32.const 0) ) + (i32.const 0) ) (block (set_local $$R$1$i @@ -12768,18 +12714,16 @@ (call_import $_abort) ) (if - (i32.eqz - (i32.eq - (i32.load - (set_local $$bk47$i - (i32.add - (get_local $$28) - (i32.const 12) - ) + (i32.ne + (i32.load + (set_local $$bk47$i + (i32.add + (get_local $$28) + (i32.const 12) ) ) - (get_local $$v$0$i$lcssa) ) + (get_local $$v$0$i$lcssa) ) (call_import $_abort) ) @@ -12815,11 +12759,9 @@ ) (block $do-once$12 (if - (i32.eqz - (i32.eq - (get_local $$26) - (i32.const 0) - ) + (i32.ne + (get_local $$26) + (i32.const 0) ) (block (if @@ -12926,15 +12868,13 @@ (get_local $$26) ) (if - (i32.eqz - (i32.eq - (set_local $$41 - (i32.load offset=16 - (get_local $$v$0$i$lcssa) - ) + (i32.ne + (set_local $$41 + (i32.load offset=16 + (get_local $$v$0$i$lcssa) ) - (i32.const 0) ) + (i32.const 0) ) (if (i32.lt_u @@ -12955,15 +12895,13 @@ ) ) (if - (i32.eqz - (i32.eq - (set_local $$42 - (i32.load offset=20 - (get_local $$v$0$i$lcssa) - ) + (i32.ne + (set_local $$42 + (i32.load offset=20 + (get_local $$v$0$i$lcssa) ) - (i32.const 0) ) + (i32.const 0) ) (if (i32.lt_u @@ -13050,15 +12988,13 @@ (get_local $$rsize$0$i$lcssa) ) (if - (i32.eqz - (i32.eq - (set_local $$45 - (i32.load - (i32.const 184) - ) + (i32.ne + (set_local $$45 + (i32.load + (i32.const 184) ) - (i32.const 0) ) + (i32.const 0) ) (block (set_local $$46 @@ -13770,15 +13706,13 @@ ) ) (if - (i32.eqz - (i32.eq - (set_local $$59 - (i32.load offset=16 - (get_local $$t$48$i) - ) + (i32.ne + (set_local $$59 + (i32.load offset=16 + (get_local $$t$48$i) ) - (i32.const 0) ) + (i32.const 0) ) (block (set_local $$rsize$49$i @@ -13863,14 +13797,12 @@ (call_import $_abort) ) (if - (i32.eqz - (i32.lt_u - (get_local $$v$4$lcssa$i) - (set_local $$add$ptr$i$161 - (i32.add - (get_local $$v$4$lcssa$i) - (get_local $$and145) - ) + (i32.ge_u + (get_local $$v$4$lcssa$i) + (set_local $$add$ptr$i$161 + (i32.add + (get_local $$v$4$lcssa$i) + (get_local $$and145) ) ) ) @@ -13946,20 +13878,18 @@ ) (loop $while-out$23 $while-in$24 (if - (i32.eqz - (i32.eq - (set_local $$70 - (i32.load - (set_local $$arrayidx161$i - (i32.add - (get_local $$R$1$i$168) - (i32.const 20) - ) + (i32.ne + (set_local $$70 + (i32.load + (set_local $$arrayidx161$i + (i32.add + (get_local $$R$1$i$168) + (i32.const 20) ) ) ) - (i32.const 0) ) + (i32.const 0) ) (block (set_local $$R$1$i$168 @@ -14035,18 +13965,16 @@ (call_import $_abort) ) (if - (i32.eqz - (i32.eq - (i32.load - (set_local $$bk136$i - (i32.add - (get_local $$65) - (i32.const 12) - ) + (i32.ne + (i32.load + (set_local $$bk136$i + (i32.add + (get_local $$65) + (i32.const 12) ) ) - (get_local $$v$4$lcssa$i) ) + (get_local $$v$4$lcssa$i) ) (call_import $_abort) ) @@ -14082,11 +14010,9 @@ ) (block $do-once$25 (if - (i32.eqz - (i32.eq - (get_local $$63) - (i32.const 0) - ) + (i32.ne + (get_local $$63) + (i32.const 0) ) (block (if @@ -14193,15 +14119,13 @@ (get_local $$63) ) (if - (i32.eqz - (i32.eq - (set_local $$78 - (i32.load offset=16 - (get_local $$v$4$lcssa$i) - ) + (i32.ne + (set_local $$78 + (i32.load offset=16 + (get_local $$v$4$lcssa$i) ) - (i32.const 0) ) + (i32.const 0) ) (if (i32.lt_u @@ -14222,15 +14146,13 @@ ) ) (if - (i32.eqz - (i32.eq - (set_local $$79 - (i32.load offset=20 - (get_local $$v$4$lcssa$i) - ) + (i32.ne + (set_local $$79 + (i32.load offset=20 + (get_local $$v$4$lcssa$i) ) - (i32.const 0) ) + (i32.const 0) ) (if (i32.lt_u @@ -14816,15 +14738,13 @@ ) ) (if - (i32.eqz - (i32.lt_u - (set_local $$94 - (i32.load - (i32.const 184) - ) + (i32.ge_u + (set_local $$94 + (i32.load + (i32.const 184) ) - (get_local $$nb$0) ) + (get_local $$nb$0) ) (block (set_local $$95 @@ -15048,50 +14968,46 @@ ) ) (if - (i32.eqz - (i32.gt_u - (set_local $$and11$i - (i32.and - (set_local $$add9$i - (i32.add - (set_local $$100 - (i32.load - (i32.const 656) - ) + (i32.le_u + (set_local $$and11$i + (i32.and + (set_local $$add9$i + (i32.add + (set_local $$100 + (i32.load + (i32.const 656) ) - (set_local $$sub$i$181 - (i32.add - (get_local $$nb$0) - (i32.const 47) - ) + ) + (set_local $$sub$i$181 + (i32.add + (get_local $$nb$0) + (i32.const 47) ) ) ) - (set_local $$neg$i$182 - (i32.sub - (i32.const 0) - (get_local $$100) - ) + ) + (set_local $$neg$i$182 + (i32.sub + (i32.const 0) + (get_local $$100) ) ) ) - (get_local $$nb$0) ) + (get_local $$nb$0) ) (return (i32.const 0) ) ) (if - (i32.eqz - (i32.eq - (set_local $$101 - (i32.load - (i32.const 616) - ) + (i32.ne + (set_local $$101 + (i32.load + (i32.const 616) ) - (i32.const 0) ) + (i32.const 0) ) (if (i32.or @@ -15149,15 +15065,13 @@ ) (loop $while-out$37 $while-in$38 (if - (i32.eqz - (i32.gt_u - (set_local $$105 - (i32.load - (get_local $$sp$0$i$i) - ) + (i32.le_u + (set_local $$105 + (i32.load + (get_local $$sp$0$i$i) ) - (get_local $$104) ) + (get_local $$104) ) (if (i32.gt_u @@ -15238,11 +15152,9 @@ ) ) (if - (i32.eqz - (i32.eq - (get_local $$call83$i) - (i32.const -1) - ) + (i32.ne + (get_local $$call83$i) + (i32.const -1) ) (block (set_local $$tbase$796$i @@ -15280,15 +15192,13 @@ (i32.const 173) ) (if - (i32.eqz - (i32.eq - (set_local $$call37$i - (call_import $_sbrk - (i32.const 0) - ) + (i32.ne + (set_local $$call37$i + (call_import $_sbrk + (i32.const 0) ) - (i32.const -1) ) + (i32.const -1) ) (block (if @@ -15355,15 +15265,13 @@ ) (block (if - (i32.eqz - (i32.eq - (set_local $$111 - (i32.load - (i32.const 616) - ) + (i32.ne + (set_local $$111 + (i32.load + (i32.const 616) ) - (i32.const 0) ) + (i32.const 0) ) (br_if $do-once$39 (i32.or @@ -15499,11 +15407,9 @@ ) ) (if - (i32.eqz - (i32.eq - (get_local $$br$2$ph$i) - (i32.const -1) - ) + (i32.ne + (get_local $$br$2$ph$i) + (i32.const -1) ) (block (set_local $$tbase$796$i @@ -16293,23 +16199,21 @@ ) (block $do-once$55 (if - (i32.eqz - (i32.eq - (set_local $$148 - (i32.load offset=8 - (get_local $$add$ptr16$i$i) - ) + (i32.ne + (set_local $$148 + (i32.load offset=8 + (get_local $$add$ptr16$i$i) ) - (set_local $$arrayidx$i$48$i - (i32.add - (i32.const 216) + ) + (set_local $$arrayidx$i$48$i + (i32.add + (i32.const 216) + (i32.shl (i32.shl - (i32.shl - (get_local $$shr$i$45$i) - (i32.const 1) - ) - (i32.const 2) + (get_local $$shr$i$45$i) + (i32.const 1) ) + (i32.const 2) ) ) ) @@ -16481,20 +16385,18 @@ ) (loop $while-out$61 $while-in$62 (if - (i32.eqz - (i32.eq - (set_local $$161 - (i32.load - (set_local $$arrayidx103$i$i - (i32.add - (get_local $$R$1$i$i) - (i32.const 20) - ) + (i32.ne + (set_local $$161 + (i32.load + (set_local $$arrayidx103$i$i + (i32.add + (get_local $$R$1$i$i) + (i32.const 20) ) ) ) - (i32.const 0) ) + (i32.const 0) ) (block (set_local $$R$1$i$i @@ -16570,18 +16472,16 @@ (call_import $_abort) ) (if - (i32.eqz - (i32.eq - (i32.load - (set_local $$bk82$i$i - (i32.add - (get_local $$156) - (i32.const 12) - ) + (i32.ne + (i32.load + (set_local $$bk82$i$i + (i32.add + (get_local $$156) + (i32.const 12) ) ) - (get_local $$add$ptr16$i$i) ) + (get_local $$add$ptr16$i$i) ) (call_import $_abort) ) @@ -16647,11 +16547,9 @@ (get_local $$R$3$i$i) ) (br_if $do-once$63 - (i32.eqz - (i32.eq - (get_local $$R$3$i$i) - (i32.const 0) - ) + (i32.ne + (get_local $$R$3$i$i) + (i32.const 0) ) ) (i32.store @@ -16727,20 +16625,18 @@ (get_local $$154) ) (if - (i32.eqz - (i32.eq - (set_local $$169 - (i32.load - (set_local $$child166$i$i - (i32.add - (get_local $$add$ptr16$i$i) - (i32.const 16) - ) + (i32.ne + (set_local $$169 + (i32.load + (set_local $$child166$i$i + (i32.add + (get_local $$add$ptr16$i$i) + (i32.const 16) ) ) ) - (i32.const 0) ) + (i32.const 0) ) (if (i32.lt_u @@ -16907,21 +16803,19 @@ ) (block (if - (i32.eqz - (i32.lt_u - (set_local $$175 - (i32.load - (set_local $$174 - (i32.add - (get_local $$arrayidx223$i$i) - (i32.const 8) - ) + (i32.ge_u + (set_local $$175 + (i32.load + (set_local $$174 + (i32.add + (get_local $$arrayidx223$i$i) + (i32.const 8) ) ) ) - (i32.load - (i32.const 192) - ) + ) + (i32.load + (i32.const 192) ) ) (block @@ -17351,15 +17245,13 @@ ) (loop $while-out$73 $while-in$74 (if - (i32.eqz - (i32.gt_u - (set_local $$185 - (i32.load - (get_local $$sp$0$i$i$i) - ) + (i32.le_u + (set_local $$185 + (i32.load + (get_local $$sp$0$i$i$i) ) - (get_local $$119) ) + (get_local $$119) ) (if (i32.gt_u @@ -17606,11 +17498,9 @@ (br $while-in$76) ) (if - (i32.eqz - (i32.eq - (get_local $$cond13$i$i) - (get_local $$119) - ) + (i32.ne + (get_local $$cond13$i$i) + (get_local $$119) ) (block (i32.store @@ -18409,23 +18299,21 @@ ) (block (if - (i32.eqz - (i32.eq - (i32.and - (set_local $$27 - (i32.load - (set_local $$head209 - (i32.add - (get_local $$add$ptr6) - (i32.const 4) - ) + (i32.ne + (i32.and + (set_local $$27 + (i32.load + (set_local $$head209 + (i32.add + (get_local $$add$ptr6) + (i32.const 4) ) ) ) - (i32.const 3) ) (i32.const 3) ) + (i32.const 3) ) (block (set_local $$p$1 @@ -18483,23 +18371,21 @@ ) ) (if - (i32.eqz - (i32.eq - (set_local $$4 - (i32.load offset=8 - (get_local $$add$ptr16) - ) + (i32.ne + (set_local $$4 + (i32.load offset=8 + (get_local $$add$ptr16) ) - (set_local $$arrayidx - (i32.add - (i32.const 216) + ) + (set_local $$arrayidx + (i32.add + (i32.const 216) + (i32.shl (i32.shl - (i32.shl - (get_local $$shr) - (i32.const 1) - ) - (i32.const 2) + (get_local $$shr) + (i32.const 1) ) + (i32.const 2) ) ) ) @@ -18513,13 +18399,11 @@ (call_import $_abort) ) (if - (i32.eqz - (i32.eq - (i32.load offset=12 - (get_local $$4) - ) - (get_local $$add$ptr16) + (i32.ne + (i32.load offset=12 + (get_local $$4) ) + (get_local $$add$ptr16) ) (call_import $_abort) ) @@ -18680,20 +18564,18 @@ ) (loop $while-out$4 $while-in$5 (if - (i32.eqz - (i32.eq - (set_local $$16 - (i32.load - (set_local $$arrayidx108 - (i32.add - (get_local $$R$1) - (i32.const 20) - ) + (i32.ne + (set_local $$16 + (i32.load + (set_local $$arrayidx108 + (i32.add + (get_local $$R$1) + (i32.const 20) ) ) ) - (i32.const 0) ) + (i32.const 0) ) (block (set_local $$R$1 @@ -18769,18 +18651,16 @@ (call_import $_abort) ) (if - (i32.eqz - (i32.eq - (i32.load - (set_local $$bk82 - (i32.add - (get_local $$11) - (i32.const 12) - ) + (i32.ne + (i32.load + (set_local $$bk82 + (i32.add + (get_local $$11) + (i32.const 12) ) ) - (get_local $$add$ptr16) ) + (get_local $$add$ptr16) ) (call_import $_abort) ) @@ -18947,20 +18827,18 @@ (get_local $$9) ) (if - (i32.eqz - (i32.eq - (set_local $$24 - (i32.load - (set_local $$child171 - (i32.add - (get_local $$add$ptr16) - (i32.const 16) - ) + (i32.ne + (set_local $$24 + (i32.load + (set_local $$child171 + (i32.add + (get_local $$add$ptr16) + (i32.const 16) ) ) ) - (i32.const 0) ) + (i32.const 0) ) (if (i32.lt_u @@ -19037,11 +18915,9 @@ ) ) (if - (i32.eqz - (i32.lt_u - (get_local $$p$1) - (get_local $$add$ptr6) - ) + (i32.ge_u + (get_local $$p$1) + (get_local $$add$ptr6) ) (call_import $_abort) ) @@ -19104,12 +18980,10 @@ ) ) (if - (i32.eqz - (i32.eq - (get_local $$p$1) - (i32.load - (i32.const 196) - ) + (i32.ne + (get_local $$p$1) + (i32.load + (i32.const 196) ) ) (return) @@ -19193,23 +19067,21 @@ ) ) (if - (i32.eqz - (i32.eq - (set_local $$34 - (i32.load offset=8 - (get_local $$add$ptr6) - ) + (i32.ne + (set_local $$34 + (i32.load offset=8 + (get_local $$add$ptr6) ) - (set_local $$arrayidx279 - (i32.add - (i32.const 216) + ) + (set_local $$arrayidx279 + (i32.add + (i32.const 216) + (i32.shl (i32.shl - (i32.shl - (get_local $$shr268) - (i32.const 1) - ) - (i32.const 2) + (get_local $$shr268) + (i32.const 1) ) + (i32.const 2) ) ) ) @@ -19225,13 +19097,11 @@ (call_import $_abort) ) (if - (i32.eqz - (i32.eq - (i32.load offset=12 - (get_local $$34) - ) - (get_local $$add$ptr6) + (i32.ne + (i32.load offset=12 + (get_local $$34) ) + (get_local $$add$ptr6) ) (call_import $_abort) ) @@ -19381,20 +19251,18 @@ ) (loop $while-out$12 $while-in$13 (if - (i32.eqz - (i32.eq - (set_local $$49 - (i32.load - (set_local $$arrayidx374 - (i32.add - (get_local $$R332$1) - (i32.const 20) - ) + (i32.ne + (set_local $$49 + (i32.load + (set_local $$arrayidx374 + (i32.add + (get_local $$R332$1) + (i32.const 20) ) ) ) - (i32.const 0) ) + (i32.const 0) ) (block (set_local $$R332$1 @@ -19474,18 +19342,16 @@ (call_import $_abort) ) (if - (i32.eqz - (i32.eq - (i32.load - (set_local $$bk343 - (i32.add - (get_local $$43) - (i32.const 12) - ) + (i32.ne + (i32.load + (set_local $$bk343 + (i32.add + (get_local $$43) + (i32.const 12) ) ) - (get_local $$add$ptr6) ) + (get_local $$add$ptr6) ) (call_import $_abort) ) @@ -19520,11 +19386,9 @@ ) ) (if - (i32.eqz - (i32.eq - (get_local $$41) - (i32.const 0) - ) + (i32.ne + (get_local $$41) + (i32.const 0) ) (block (if @@ -19631,20 +19495,18 @@ (get_local $$41) ) (if - (i32.eqz - (i32.eq - (set_local $$58 - (i32.load - (set_local $$child443 - (i32.add - (get_local $$add$ptr6) - (i32.const 16) - ) + (i32.ne + (set_local $$58 + (i32.load + (set_local $$child443 + (i32.add + (get_local $$add$ptr6) + (i32.const 16) ) ) ) - (i32.const 0) ) + (i32.const 0) ) (if (i32.lt_u @@ -19665,15 +19527,13 @@ ) ) (if - (i32.eqz - (i32.eq - (set_local $$59 - (i32.load offset=4 - (get_local $$child443) - ) + (i32.ne + (set_local $$59 + (i32.load offset=4 + (get_local $$child443) ) - (i32.const 0) ) + (i32.const 0) ) (if (i32.lt_u -- cgit v1.2.3 From 186765307f12e6c7628ad6da11b332c2bfbcaa07 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Sat, 23 Apr 2016 21:50:20 -0700 Subject: run multiple cycles of RemoveUnusedBrs --- src/passes/RemoveUnusedBrs.cpp | 16 +++++++++++++++- test/emcc_hello_world.fromasm | 1 - test/emcc_hello_world.fromasm.imprecise | 1 - test/passes/remove-unused-brs.txt | 8 ++++---- 4 files changed, 19 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/passes/RemoveUnusedBrs.cpp b/src/passes/RemoveUnusedBrs.cpp index 255d86b9c..3d6d6973f 100644 --- a/src/passes/RemoveUnusedBrs.cpp +++ b/src/passes/RemoveUnusedBrs.cpp @@ -27,6 +27,8 @@ namespace wasm { struct RemoveUnusedBrs : public WalkerPass>> { bool isFunctionParallel() { return true; } + bool anotherCycle; + typedef std::vector Flows; // list of breaks that are currently flowing. if they reach their target without @@ -68,6 +70,7 @@ struct RemoveUnusedBrs : public WalkerPassname == name) { ExpressionManipulator::nop(flows[i]); skip++; + self->anotherCycle = true; } else if (skip > 0) { flows[i - skip] = flows[i]; } @@ -79,6 +82,8 @@ struct RemoveUnusedBrs : public WalkerPassis()) { // TODO we might optimize branches out of here flows.clear(); + } else if (curr->is()) { + // ignore (could be result of a previous cycle) } else { // anything else stops the flow flows.clear(); @@ -100,6 +105,7 @@ struct RemoveUnusedBrs : public WalkerPasscondition) { // TODO: if there is a condition, join them br->condition = curr->condition; replaceCurrent(br); + anotherCycle = true; } } } @@ -125,7 +131,15 @@ struct RemoveUnusedBrs : public WalkerPass>>::walk(root); + assert(ifStack.empty()); + assert(flows.empty()); + } while (anotherCycle); + } }; static RegisterPass registerPass("remove-unused-brs", "removes breaks from locations that are not needed"); diff --git a/test/emcc_hello_world.fromasm b/test/emcc_hello_world.fromasm index 9d50d32b2..75e2bf024 100644 --- a/test/emcc_hello_world.fromasm +++ b/test/emcc_hello_world.fromasm @@ -10864,7 +10864,6 @@ (get_local $$arg) (get_local $$110) ) - (br $label$break$L1) ) ) ) diff --git a/test/emcc_hello_world.fromasm.imprecise b/test/emcc_hello_world.fromasm.imprecise index b303c5cac..4ada9b367 100644 --- a/test/emcc_hello_world.fromasm.imprecise +++ b/test/emcc_hello_world.fromasm.imprecise @@ -10862,7 +10862,6 @@ (get_local $$arg) (get_local $$110) ) - (br $label$break$L1) ) ) ) diff --git a/test/passes/remove-unused-brs.txt b/test/passes/remove-unused-brs.txt index 2404e7b39..226065f3f 100644 --- a/test/passes/remove-unused-brs.txt +++ b/test/passes/remove-unused-brs.txt @@ -169,9 +169,9 @@ (block $a (block $b (block $c - (br $a) + (nop) ) - (br $a) + (nop) ) (nop) ) @@ -187,9 +187,9 @@ (block $a (block $b (block $c - (br $b) + (nop) ) - (br $a) + (nop) ) (nop) ) -- cgit v1.2.3