diff options
-rw-r--r-- | src/passes/RemoveUnusedBrs.cpp | 63 | ||||
-rw-r--r-- | test/emcc_hello_world.fromasm | 1174 | ||||
-rw-r--r-- | test/two_sides.fromasm | 104 |
3 files changed, 669 insertions, 672 deletions
diff --git a/src/passes/RemoveUnusedBrs.cpp b/src/passes/RemoveUnusedBrs.cpp index 0ff48381f..a89c69312 100644 --- a/src/passes/RemoveUnusedBrs.cpp +++ b/src/passes/RemoveUnusedBrs.cpp @@ -24,6 +24,45 @@ namespace wasm { struct RemoveUnusedBrs : public Pass { + // 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 + void visitIf(If* curr) override { + if (!curr->ifFalse) return; + if (curr->type != none) 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->dyn_cast<Block>(); + 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<Block>(); + Break* br = last->dyn_cast<Break>(); + 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<Break>(); // 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) override { if (curr->name.isNull()) return; if (curr->list.size() == 0) return; @@ -37,30 +76,6 @@ struct RemoveUnusedBrs : public Pass { curr->list[curr->list.size()-1] = br->value; // can replace with the value } } - } else if (If* ifelse = curr->list.back()->dyn_cast<If>()) { - if (!ifelse->ifFalse) return; - if (ifelse->type != none) return; - // an if_else that indirectly returns a value by breaking to this block can potentially remove both breaks - auto process = [&curr](Expression *side, bool doIt) { - Block* b = side->dyn_cast<Block>(); - if (!b) return false; - Expression* last = b->list.back(); - Break* br = last->dyn_cast<Break>(); - if (!br) return false; - if (br->condition) return false; - if (!br->value) return false; - if (br->name != curr->name) return false; - if (doIt) { - b->list[b->list.size()-1] = br->value; - } - return true; - }; - // do both, or none - if (process(ifelse->ifTrue, false) && process(ifelse->ifFalse, false)) { - process(ifelse->ifTrue, true); - process(ifelse->ifFalse, true); - ifelse->type = curr->type; // if_else now returns a value - } } } }; diff --git a/test/emcc_hello_world.fromasm b/test/emcc_hello_world.fromasm index 574eb098a..1ced56e05 100644 --- a/test/emcc_hello_world.fromasm +++ b/test/emcc_hello_world.fromasm @@ -31729,105 +31729,99 @@ (i32.const 0) ) ) - (if_else - (i32.eq - (get_local $$d_sroa_1_4_extract_trunc) - (i32.const 0) - ) - (block - (if - (get_local $$4) - (block - (i32.store align=4 - (get_local $$rem) - (i32.rem_u - (get_local $$n_sroa_0_0_extract_trunc) - (get_local $$d_sroa_0_0_extract_trunc) - ) - ) - (i32.store align=4 - (i32.add + (br $topmost + (if_else + (i32.eq + (get_local $$d_sroa_1_4_extract_trunc) + (i32.const 0) + ) + (block + (if + (get_local $$4) + (block + (i32.store align=4 (get_local $$rem) - (i32.const 4) + (i32.rem_u + (get_local $$n_sroa_0_0_extract_trunc) + (get_local $$d_sroa_0_0_extract_trunc) + ) + ) + (i32.store align=4 + (i32.add + (get_local $$rem) + (i32.const 4) + ) + (i32.const 0) ) - (i32.const 0) ) ) - ) - (set_local $$_0$1 - (i32.const 0) - ) - (set_local $$_0$0 - (i32.div_u - (get_local $$n_sroa_0_0_extract_trunc) - (get_local $$d_sroa_0_0_extract_trunc) + (set_local $$_0$1 + (i32.const 0) ) - ) - (br $topmost - (block - (i32.store align=4 - (i32.const 168) - (get_local $$_0$1) + (set_local $$_0$0 + (i32.div_u + (get_local $$n_sroa_0_0_extract_trunc) + (get_local $$d_sroa_0_0_extract_trunc) ) - (get_local $$_0$0) ) - ) - ) - (block - (if - (i32.eq - (get_local $$4) - (i32.const 0) + (i32.store align=4 + (i32.const 168) + (get_local $$_0$1) ) - (block - (set_local $$_0$1 - (i32.const 0) - ) - (set_local $$_0$0 + (get_local $$_0$0) + ) + (block + (if + (i32.eq + (get_local $$4) (i32.const 0) ) - (br $topmost - (block - (i32.store align=4 - (i32.const 168) - (get_local $$_0$1) + (block + (set_local $$_0$1 + (i32.const 0) + ) + (set_local $$_0$0 + (i32.const 0) + ) + (br $topmost + (block + (i32.store align=4 + (i32.const 168) + (get_local $$_0$1) + ) + (get_local $$_0$0) ) - (get_local $$_0$0) ) ) ) - ) - (i32.store align=4 - (get_local $$rem) - (i32.and - (get_local $$a$0) - (i32.const -1) - ) - ) - (i32.store align=4 - (i32.add + (i32.store align=4 (get_local $$rem) - (i32.const 4) + (i32.and + (get_local $$a$0) + (i32.const -1) + ) ) - (i32.and - (get_local $$a$1) + (i32.store align=4 + (i32.add + (get_local $$rem) + (i32.const 4) + ) + (i32.and + (get_local $$a$1) + (i32.const 0) + ) + ) + (set_local $$_0$1 (i32.const 0) ) - ) - (set_local $$_0$1 - (i32.const 0) - ) - (set_local $$_0$0 - (i32.const 0) - ) - (br $topmost - (block - (i32.store align=4 - (i32.const 168) - (get_local $$_0$1) - ) - (get_local $$_0$0) + (set_local $$_0$0 + (i32.const 0) ) + (i32.store align=4 + (i32.const 168) + (get_local $$_0$1) + ) + (get_local $$_0$0) ) ) ) @@ -31840,690 +31834,680 @@ ) ) (block $do-once$0 - (if_else - (i32.eq - (get_local $$d_sroa_0_0_extract_trunc) - (i32.const 0) - ) - (block - (if - (get_local $$17) - (block - (if - (i32.ne - (get_local $$rem) - (i32.const 0) - ) - (block - (i32.store align=4 + (br $topmost + (if_else + (i32.eq + (get_local $$d_sroa_0_0_extract_trunc) + (i32.const 0) + ) + (block + (if + (get_local $$17) + (block + (if + (i32.ne (get_local $$rem) - (i32.rem_u - (get_local $$n_sroa_1_4_extract_trunc) - (get_local $$d_sroa_0_0_extract_trunc) - ) + (i32.const 0) ) - (i32.store align=4 - (i32.add + (block + (i32.store align=4 (get_local $$rem) - (i32.const 4) + (i32.rem_u + (get_local $$n_sroa_1_4_extract_trunc) + (get_local $$d_sroa_0_0_extract_trunc) + ) + ) + (i32.store align=4 + (i32.add + (get_local $$rem) + (i32.const 4) + ) + (i32.const 0) ) - (i32.const 0) ) ) - ) - (set_local $$_0$1 - (i32.const 0) - ) - (set_local $$_0$0 - (i32.div_u - (get_local $$n_sroa_1_4_extract_trunc) - (get_local $$d_sroa_0_0_extract_trunc) + (set_local $$_0$1 + (i32.const 0) ) - ) - (br $topmost - (block - (i32.store align=4 - (i32.const 168) - (get_local $$_0$1) + (set_local $$_0$0 + (i32.div_u + (get_local $$n_sroa_1_4_extract_trunc) + (get_local $$d_sroa_0_0_extract_trunc) + ) + ) + (br $topmost + (block + (i32.store align=4 + (i32.const 168) + (get_local $$_0$1) + ) + (get_local $$_0$0) ) - (get_local $$_0$0) ) ) ) - ) - (if - (i32.eq - (get_local $$n_sroa_0_0_extract_trunc) - (i32.const 0) - ) - (block - (if - (i32.ne - (get_local $$rem) - (i32.const 0) - ) - (block - (i32.store align=4 + (if + (i32.eq + (get_local $$n_sroa_0_0_extract_trunc) + (i32.const 0) + ) + (block + (if + (i32.ne (get_local $$rem) (i32.const 0) ) - (i32.store align=4 - (i32.add + (block + (i32.store align=4 (get_local $$rem) - (i32.const 4) + (i32.const 0) ) - (i32.rem_u - (get_local $$n_sroa_1_4_extract_trunc) - (get_local $$d_sroa_1_4_extract_trunc) + (i32.store align=4 + (i32.add + (get_local $$rem) + (i32.const 4) + ) + (i32.rem_u + (get_local $$n_sroa_1_4_extract_trunc) + (get_local $$d_sroa_1_4_extract_trunc) + ) ) ) ) - ) - (set_local $$_0$1 - (i32.const 0) - ) - (set_local $$_0$0 - (i32.div_u - (get_local $$n_sroa_1_4_extract_trunc) - (get_local $$d_sroa_1_4_extract_trunc) + (set_local $$_0$1 + (i32.const 0) ) - ) - (br $topmost - (block - (i32.store align=4 - (i32.const 168) - (get_local $$_0$1) + (set_local $$_0$0 + (i32.div_u + (get_local $$n_sroa_1_4_extract_trunc) + (get_local $$d_sroa_1_4_extract_trunc) + ) + ) + (br $topmost + (block + (i32.store align=4 + (i32.const 168) + (get_local $$_0$1) + ) + (get_local $$_0$0) ) - (get_local $$_0$0) ) ) ) - ) - (set_local $$37 - (i32.sub - (get_local $$d_sroa_1_4_extract_trunc) - (i32.const 1) - ) - ) - (if - (i32.eq - (i32.and - (get_local $$37) + (set_local $$37 + (i32.sub (get_local $$d_sroa_1_4_extract_trunc) + (i32.const 1) ) - (i32.const 0) ) - (block - (if - (i32.ne - (get_local $$rem) - (i32.const 0) + (if + (i32.eq + (i32.and + (get_local $$37) + (get_local $$d_sroa_1_4_extract_trunc) ) - (block - (i32.store align=4 + (i32.const 0) + ) + (block + (if + (i32.ne (get_local $$rem) - (i32.or - (i32.const 0) - (i32.and - (get_local $$a$0) - (i32.const -1) - ) - ) + (i32.const 0) ) - (i32.store align=4 - (i32.add + (block + (i32.store align=4 (get_local $$rem) - (i32.const 4) + (i32.or + (i32.const 0) + (i32.and + (get_local $$a$0) + (i32.const -1) + ) + ) ) - (i32.or - (i32.and - (get_local $$37) - (get_local $$n_sroa_1_4_extract_trunc) + (i32.store align=4 + (i32.add + (get_local $$rem) + (i32.const 4) ) - (i32.and - (get_local $$a$1) - (i32.const 0) + (i32.or + (i32.and + (get_local $$37) + (get_local $$n_sroa_1_4_extract_trunc) + ) + (i32.and + (get_local $$a$1) + (i32.const 0) + ) ) ) ) ) - ) - (set_local $$_0$1 - (i32.const 0) - ) - (set_local $$_0$0 - (i32.shr_u - (get_local $$n_sroa_1_4_extract_trunc) - (call $_llvm_cttz_i32 - (get_local $$d_sroa_1_4_extract_trunc) + (set_local $$_0$1 + (i32.const 0) + ) + (set_local $$_0$0 + (i32.shr_u + (get_local $$n_sroa_1_4_extract_trunc) + (call $_llvm_cttz_i32 + (get_local $$d_sroa_1_4_extract_trunc) + ) ) ) - ) - (br $topmost - (block - (i32.store align=4 - (i32.const 168) - (get_local $$_0$1) + (br $topmost + (block + (i32.store align=4 + (i32.const 168) + (get_local $$_0$1) + ) + (get_local $$_0$0) ) - (get_local $$_0$0) ) ) ) - ) - (set_local $$49 - (i32.clz - (get_local $$d_sroa_1_4_extract_trunc) - ) - ) - (set_local $$51 - (i32.sub - (get_local $$49) + (set_local $$49 (i32.clz - (get_local $$n_sroa_1_4_extract_trunc) + (get_local $$d_sroa_1_4_extract_trunc) ) ) - ) - (if - (i32.le_u - (get_local $$51) - (i32.const 30) - ) - (block - (set_local $$57 - (i32.add - (get_local $$51) - (i32.const 1) - ) - ) - (set_local $$58 - (i32.sub - (i32.const 31) - (get_local $$51) + (set_local $$51 + (i32.sub + (get_local $$49) + (i32.clz + (get_local $$n_sroa_1_4_extract_trunc) ) ) - (set_local $$sr_1_ph - (get_local $$57) + ) + (if + (i32.le_u + (get_local $$51) + (i32.const 30) ) - (set_local $$r_sroa_0_1_ph - (i32.or - (i32.shl - (get_local $$n_sroa_1_4_extract_trunc) - (get_local $$58) + (block + (set_local $$57 + (i32.add + (get_local $$51) + (i32.const 1) + ) + ) + (set_local $$58 + (i32.sub + (i32.const 31) + (get_local $$51) ) + ) + (set_local $$sr_1_ph + (get_local $$57) + ) + (set_local $$r_sroa_0_1_ph + (i32.or + (i32.shl + (get_local $$n_sroa_1_4_extract_trunc) + (get_local $$58) + ) + (i32.shr_u + (get_local $$n_sroa_0_0_extract_trunc) + (get_local $$57) + ) + ) + ) + (set_local $$r_sroa_1_1_ph (i32.shr_u - (get_local $$n_sroa_0_0_extract_trunc) + (get_local $$n_sroa_1_4_extract_trunc) (get_local $$57) ) ) - ) - (set_local $$r_sroa_1_1_ph - (i32.shr_u - (get_local $$n_sroa_1_4_extract_trunc) - (get_local $$57) + (set_local $$q_sroa_0_1_ph + (i32.const 0) + ) + (set_local $$q_sroa_1_1_ph + (i32.shl + (get_local $$n_sroa_0_0_extract_trunc) + (get_local $$58) + ) ) + (br $do-once$0) ) - (set_local $$q_sroa_0_1_ph + ) + (if + (i32.eq + (get_local $$rem) (i32.const 0) ) - (set_local $$q_sroa_1_1_ph - (i32.shl - (get_local $$n_sroa_0_0_extract_trunc) - (get_local $$58) + (block + (set_local $$_0$1 + (i32.const 0) + ) + (set_local $$_0$0 + (i32.const 0) + ) + (br $topmost + (block + (i32.store align=4 + (i32.const 168) + (get_local $$_0$1) + ) + (get_local $$_0$0) + ) ) ) - (br $do-once$0) ) - ) - (if - (i32.eq + (i32.store align=4 (get_local $$rem) - (i32.const 0) - ) - (block - (set_local $$_0$1 + (i32.or (i32.const 0) + (i32.and + (get_local $$a$0) + (i32.const -1) + ) ) - (set_local $$_0$0 - (i32.const 0) + ) + (i32.store align=4 + (i32.add + (get_local $$rem) + (i32.const 4) ) - (br $topmost - (block - (i32.store align=4 - (i32.const 168) - (get_local $$_0$1) - ) - (get_local $$_0$0) + (i32.or + (get_local $$n_sroa_1_4_extract_shift$0) + (i32.and + (get_local $$a$1) + (i32.const 0) ) ) ) - ) - (i32.store align=4 - (get_local $$rem) - (i32.or + (set_local $$_0$1 (i32.const 0) - (i32.and - (get_local $$a$0) - (i32.const -1) - ) - ) - ) - (i32.store align=4 - (i32.add - (get_local $$rem) - (i32.const 4) ) - (i32.or - (get_local $$n_sroa_1_4_extract_shift$0) - (i32.and - (get_local $$a$1) - (i32.const 0) - ) + (set_local $$_0$0 + (i32.const 0) ) - ) - (set_local $$_0$1 - (i32.const 0) - ) - (set_local $$_0$0 - (i32.const 0) - ) - (br $topmost - (block - (i32.store align=4 - (i32.const 168) - (get_local $$_0$1) - ) - (get_local $$_0$0) + (i32.store align=4 + (i32.const 168) + (get_local $$_0$1) ) + (get_local $$_0$0) ) - ) - (block - (if - (i32.eq - (get_local $$17) - (i32.const 0) - ) - (block - (set_local $$117 - (i32.clz - (get_local $$d_sroa_1_4_extract_trunc) - ) + (block + (if + (i32.eq + (get_local $$17) + (i32.const 0) ) - (set_local $$119 - (i32.sub - (get_local $$117) + (block + (set_local $$117 (i32.clz - (get_local $$n_sroa_1_4_extract_trunc) + (get_local $$d_sroa_1_4_extract_trunc) ) ) - ) - (if - (i32.le_u - (get_local $$119) - (i32.const 31) - ) - (block - (set_local $$125 - (i32.add - (get_local $$119) - (i32.const 1) + (set_local $$119 + (i32.sub + (get_local $$117) + (i32.clz + (get_local $$n_sroa_1_4_extract_trunc) ) ) - (set_local $$126 - (i32.sub - (i32.const 31) - (get_local $$119) - ) + ) + (if + (i32.le_u + (get_local $$119) + (i32.const 31) ) - (set_local $$130 - (i32.shr_s + (block + (set_local $$125 + (i32.add + (get_local $$119) + (i32.const 1) + ) + ) + (set_local $$126 (i32.sub + (i32.const 31) (get_local $$119) + ) + ) + (set_local $$130 + (i32.shr_s + (i32.sub + (get_local $$119) + (i32.const 31) + ) (i32.const 31) ) - (i32.const 31) ) - ) - (set_local $$sr_1_ph - (get_local $$125) - ) - (set_local $$r_sroa_0_1_ph - (i32.or + (set_local $$sr_1_ph + (get_local $$125) + ) + (set_local $$r_sroa_0_1_ph + (i32.or + (i32.and + (i32.shr_u + (get_local $$n_sroa_0_0_extract_trunc) + (get_local $$125) + ) + (get_local $$130) + ) + (i32.shl + (get_local $$n_sroa_1_4_extract_trunc) + (get_local $$126) + ) + ) + ) + (set_local $$r_sroa_1_1_ph (i32.and (i32.shr_u - (get_local $$n_sroa_0_0_extract_trunc) + (get_local $$n_sroa_1_4_extract_trunc) (get_local $$125) ) (get_local $$130) ) + ) + (set_local $$q_sroa_0_1_ph + (i32.const 0) + ) + (set_local $$q_sroa_1_1_ph (i32.shl - (get_local $$n_sroa_1_4_extract_trunc) + (get_local $$n_sroa_0_0_extract_trunc) (get_local $$126) ) ) + (br $do-once$0) ) - (set_local $$r_sroa_1_1_ph - (i32.and - (i32.shr_u - (get_local $$n_sroa_1_4_extract_trunc) - (get_local $$125) - ) - (get_local $$130) - ) - ) - (set_local $$q_sroa_0_1_ph + ) + (if + (i32.eq + (get_local $$rem) (i32.const 0) ) - (set_local $$q_sroa_1_1_ph - (i32.shl - (get_local $$n_sroa_0_0_extract_trunc) - (get_local $$126) + (block + (set_local $$_0$1 + (i32.const 0) + ) + (set_local $$_0$0 + (i32.const 0) + ) + (br $topmost + (block + (i32.store align=4 + (i32.const 168) + (get_local $$_0$1) + ) + (get_local $$_0$0) + ) ) ) - (br $do-once$0) ) - ) - (if - (i32.eq + (i32.store align=4 (get_local $$rem) - (i32.const 0) - ) - (block - (set_local $$_0$1 + (i32.or (i32.const 0) + (i32.and + (get_local $$a$0) + (i32.const -1) + ) ) - (set_local $$_0$0 - (i32.const 0) + ) + (i32.store align=4 + (i32.add + (get_local $$rem) + (i32.const 4) ) - (br $topmost - (block - (i32.store align=4 - (i32.const 168) - (get_local $$_0$1) - ) - (get_local $$_0$0) + (i32.or + (get_local $$n_sroa_1_4_extract_shift$0) + (i32.and + (get_local $$a$1) + (i32.const 0) ) ) ) - ) - (i32.store align=4 - (get_local $$rem) - (i32.or + (set_local $$_0$1 (i32.const 0) - (i32.and - (get_local $$a$0) - (i32.const -1) - ) ) - ) - (i32.store align=4 - (i32.add - (get_local $$rem) - (i32.const 4) - ) - (i32.or - (get_local $$n_sroa_1_4_extract_shift$0) - (i32.and - (get_local $$a$1) - (i32.const 0) - ) + (set_local $$_0$0 + (i32.const 0) ) - ) - (set_local $$_0$1 - (i32.const 0) - ) - (set_local $$_0$0 - (i32.const 0) - ) - (br $topmost - (block - (i32.store align=4 - (i32.const 168) - (get_local $$_0$1) + (br $topmost + (block + (i32.store align=4 + (i32.const 168) + (get_local $$_0$1) + ) + (get_local $$_0$0) ) - (get_local $$_0$0) ) ) ) - ) - (set_local $$66 - (i32.sub - (get_local $$d_sroa_0_0_extract_trunc) - (i32.const 1) - ) - ) - (if - (i32.ne - (i32.and - (get_local $$66) + (set_local $$66 + (i32.sub (get_local $$d_sroa_0_0_extract_trunc) + (i32.const 1) ) - (i32.const 0) ) - (block - (set_local $$86 - (i32.add - (i32.clz - (get_local $$d_sroa_0_0_extract_trunc) - ) - (i32.const 33) + (if + (i32.ne + (i32.and + (get_local $$66) + (get_local $$d_sroa_0_0_extract_trunc) ) + (i32.const 0) ) - (set_local $$88 - (i32.sub - (get_local $$86) - (i32.clz - (get_local $$n_sroa_1_4_extract_trunc) + (block + (set_local $$86 + (i32.add + (i32.clz + (get_local $$d_sroa_0_0_extract_trunc) + ) + (i32.const 33) ) ) - ) - (set_local $$89 - (i32.sub - (i32.const 64) - (get_local $$88) - ) - ) - (set_local $$91 - (i32.sub - (i32.const 32) - (get_local $$88) - ) - ) - (set_local $$92 - (i32.shr_s - (get_local $$91) - (i32.const 31) - ) - ) - (set_local $$95 - (i32.sub - (get_local $$88) - (i32.const 32) - ) - ) - (set_local $$105 - (i32.shr_s - (get_local $$95) - (i32.const 31) - ) - ) - (set_local $$sr_1_ph - (get_local $$88) - ) - (set_local $$r_sroa_0_1_ph - (i32.or - (i32.and - (i32.shr_s - (i32.sub - (get_local $$91) - (i32.const 1) - ) - (i32.const 31) - ) - (i32.shr_u + (set_local $$88 + (i32.sub + (get_local $$86) + (i32.clz (get_local $$n_sroa_1_4_extract_trunc) - (get_local $$95) ) ) - (i32.and - (i32.or - (i32.shl - (get_local $$n_sroa_1_4_extract_trunc) - (get_local $$91) - ) - (i32.shr_u - (get_local $$n_sroa_0_0_extract_trunc) - (get_local $$88) - ) - ) - (get_local $$105) + ) + (set_local $$89 + (i32.sub + (i32.const 64) + (get_local $$88) ) ) - ) - (set_local $$r_sroa_1_1_ph - (i32.and - (get_local $$105) - (i32.shr_u - (get_local $$n_sroa_1_4_extract_trunc) + (set_local $$91 + (i32.sub + (i32.const 32) (get_local $$88) ) ) - ) - (set_local $$q_sroa_0_1_ph - (i32.and - (i32.shl - (get_local $$n_sroa_0_0_extract_trunc) - (get_local $$89) + (set_local $$92 + (i32.shr_s + (get_local $$91) + (i32.const 31) ) - (get_local $$92) ) - ) - (set_local $$q_sroa_1_1_ph - (i32.or - (i32.and - (i32.or - (i32.shl - (get_local $$n_sroa_1_4_extract_trunc) - (get_local $$89) + (set_local $$95 + (i32.sub + (get_local $$88) + (i32.const 32) + ) + ) + (set_local $$105 + (i32.shr_s + (get_local $$95) + (i32.const 31) + ) + ) + (set_local $$sr_1_ph + (get_local $$88) + ) + (set_local $$r_sroa_0_1_ph + (i32.or + (i32.and + (i32.shr_s + (i32.sub + (get_local $$91) + (i32.const 1) + ) + (i32.const 31) ) (i32.shr_u - (get_local $$n_sroa_0_0_extract_trunc) + (get_local $$n_sroa_1_4_extract_trunc) (get_local $$95) ) ) - (get_local $$92) + (i32.and + (i32.or + (i32.shl + (get_local $$n_sroa_1_4_extract_trunc) + (get_local $$91) + ) + (i32.shr_u + (get_local $$n_sroa_0_0_extract_trunc) + (get_local $$88) + ) + ) + (get_local $$105) + ) ) + ) + (set_local $$r_sroa_1_1_ph + (i32.and + (get_local $$105) + (i32.shr_u + (get_local $$n_sroa_1_4_extract_trunc) + (get_local $$88) + ) + ) + ) + (set_local $$q_sroa_0_1_ph (i32.and (i32.shl (get_local $$n_sroa_0_0_extract_trunc) - (get_local $$91) + (get_local $$89) ) - (i32.shr_s - (i32.sub - (get_local $$88) - (i32.const 33) + (get_local $$92) + ) + ) + (set_local $$q_sroa_1_1_ph + (i32.or + (i32.and + (i32.or + (i32.shl + (get_local $$n_sroa_1_4_extract_trunc) + (get_local $$89) + ) + (i32.shr_u + (get_local $$n_sroa_0_0_extract_trunc) + (get_local $$95) + ) + ) + (get_local $$92) + ) + (i32.and + (i32.shl + (get_local $$n_sroa_0_0_extract_trunc) + (get_local $$91) + ) + (i32.shr_s + (i32.sub + (get_local $$88) + (i32.const 33) + ) + (i32.const 31) ) - (i32.const 31) ) ) ) + (br $do-once$0) ) - (br $do-once$0) - ) - ) - (if - (i32.ne - (get_local $$rem) - (i32.const 0) ) - (block - (i32.store align=4 + (if + (i32.ne (get_local $$rem) - (i32.and - (get_local $$66) - (get_local $$n_sroa_0_0_extract_trunc) - ) - ) - (i32.store align=4 - (i32.add - (get_local $$rem) - (i32.const 4) - ) (i32.const 0) ) - ) - ) - (if_else - (i32.eq - (get_local $$d_sroa_0_0_extract_trunc) - (i32.const 1) - ) - (block - (set_local $$_0$1 - (i32.or - (get_local $$n_sroa_1_4_extract_shift$0) + (block + (i32.store align=4 + (get_local $$rem) (i32.and - (get_local $$a$1) - (i32.const 0) + (get_local $$66) + (get_local $$n_sroa_0_0_extract_trunc) ) ) - ) - (set_local $$_0$0 - (i32.or - (i32.const 0) - (i32.and - (get_local $$a$0) - (i32.const -1) + (i32.store align=4 + (i32.add + (get_local $$rem) + (i32.const 4) ) + (i32.const 0) ) ) - (br $topmost - (block - (i32.store align=4 - (i32.const 168) - (get_local $$_0$1) + ) + (if_else + (i32.eq + (get_local $$d_sroa_0_0_extract_trunc) + (i32.const 1) + ) + (block + (set_local $$_0$1 + (i32.or + (get_local $$n_sroa_1_4_extract_shift$0) + (i32.and + (get_local $$a$1) + (i32.const 0) + ) ) - (get_local $$_0$0) ) - ) - ) - (block - (set_local $$78 - (call $_llvm_cttz_i32 - (get_local $$d_sroa_0_0_extract_trunc) + (set_local $$_0$0 + (i32.or + (i32.const 0) + (i32.and + (get_local $$a$0) + (i32.const -1) + ) + ) + ) + (i32.store align=4 + (i32.const 168) + (get_local $$_0$1) ) + (get_local $$_0$0) ) - (set_local $$_0$1 - (i32.or - (i32.const 0) - (i32.shr_u - (get_local $$n_sroa_1_4_extract_trunc) - (get_local $$78) + (block + (set_local $$78 + (call $_llvm_cttz_i32 + (get_local $$d_sroa_0_0_extract_trunc) ) ) - ) - (set_local $$_0$0 - (i32.or - (i32.shl - (get_local $$n_sroa_1_4_extract_trunc) - (i32.sub - (i32.const 32) + (set_local $$_0$1 + (i32.or + (i32.const 0) + (i32.shr_u + (get_local $$n_sroa_1_4_extract_trunc) (get_local $$78) ) ) - (i32.shr_u - (get_local $$n_sroa_0_0_extract_trunc) - (get_local $$78) - ) ) - ) - (br $topmost - (block - (i32.store align=4 - (i32.const 168) - (get_local $$_0$1) + (set_local $$_0$0 + (i32.or + (i32.shl + (get_local $$n_sroa_1_4_extract_trunc) + (i32.sub + (i32.const 32) + (get_local $$78) + ) + ) + (i32.shr_u + (get_local $$n_sroa_0_0_extract_trunc) + (get_local $$78) + ) ) - (get_local $$_0$0) ) + (i32.store align=4 + (i32.const 168) + (get_local $$_0$1) + ) + (get_local $$_0$0) ) ) ) diff --git a/test/two_sides.fromasm b/test/two_sides.fromasm index 49cd25218..9bf643e2a 100644 --- a/test/two_sides.fromasm +++ b/test/two_sides.fromasm @@ -5,76 +5,74 @@ (func $_test (param $i1 i32) (param $i2 i32) (param $i3 i32) (param $i4 i32) (param $i5 i32) (result i32) (local $d6 f64) (block $topmost - (if_else - (i32.eq - (get_local $i5) - (i32.const 0) - ) - (block - (set_local $d6 - (f64.convert_s/i32 - (i32.mul - (get_local $i4) - (get_local $i3) - ) - ) + (br $topmost + (if_else + (i32.eq + (get_local $i5) + (i32.const 0) ) - (set_local $d6 - (f64.mul - (f64.add - (f64.convert_s/i32 + (block + (set_local $d6 + (f64.convert_s/i32 + (i32.mul + (get_local $i4) (get_local $i3) ) - (get_local $d6) ) - (f64.add - (f64.convert_s/i32 - (get_local $i4) + ) + (set_local $d6 + (f64.mul + (f64.add + (f64.convert_s/i32 + (get_local $i3) + ) + (get_local $d6) + ) + (f64.add + (f64.convert_s/i32 + (get_local $i4) + ) + (get_local $d6) ) - (get_local $d6) ) ) - ) - (set_local $i5 - (call_import $f64-to-int - (get_local $d6) + (set_local $i5 + (call_import $f64-to-int + (get_local $d6) + ) ) - ) - (br $topmost (get_local $i5) ) - ) - (block - (set_local $d6 - (f64.convert_s/i32 - (i32.mul - (get_local $i2) - (get_local $i1) + (block + (set_local $d6 + (f64.convert_s/i32 + (i32.mul + (get_local $i2) + (get_local $i1) + ) ) ) - ) - (set_local $d6 - (f64.mul - (f64.add - (f64.convert_s/i32 - (get_local $i3) + (set_local $d6 + (f64.mul + (f64.add + (f64.convert_s/i32 + (get_local $i3) + ) + (get_local $d6) ) - (get_local $d6) - ) - (f64.add - (get_local $d6) - (f64.convert_s/i32 - (get_local $i4) + (f64.add + (get_local $d6) + (f64.convert_s/i32 + (get_local $i4) + ) ) ) ) - ) - (set_local $i5 - (call_import $f64-to-int - (get_local $d6) + (set_local $i5 + (call_import $f64-to-int + (get_local $d6) + ) ) - ) - (br $topmost (get_local $i5) ) ) |