diff options
Diffstat (limited to 'test')
4 files changed, 1299 insertions, 0 deletions
diff --git a/test/passes/rereloop.txt b/test/passes/rereloop.txt new file mode 100644 index 000000000..c15934c0b --- /dev/null +++ b/test/passes/rereloop.txt @@ -0,0 +1,707 @@ +(module + (type $0 (func)) + (type $1 (func (result i32))) + (type $2 (func (param i32) (result i32))) + (type $3 (func (param i32))) + (memory $0 0) + (func $trivial (type $0) + (local $0 i32) + (block + (nop) + ) + ) + (func $trivial2 (type $0) + (local $0 i32) + (block + (call $trivial) + (call $trivial) + ) + ) + (func $return-void (type $0) + (local $0 i32) + (block + (return) + ) + ) + (func $return-val (type $1) (result i32) + (local $0 i32) + (block + (return + (i32.const 1) + ) + ) + ) + (func $ifs (type $2) (param $x i32) (result i32) + (local $1 i32) + (block + ) + (if + (get_local $x) + (block + (block + ) + (if + (get_local $x) + (block + (block + (return + (i32.const 2) + ) + ) + ) + (block + (block + (return + (i32.const 3) + ) + ) + ) + ) + ) + (block + (block + ) + (if + (get_local $x) + (block + (block + (return + (i32.const 4) + ) + ) + ) + (block + (block + (return + (i32.const 5) + ) + ) + ) + ) + ) + ) + ) + (func $loops (type $3) (param $x i32) + (local $1 i32) + (block $block$5$break + (block + ) + (if + (get_local $x) + (block + (block $block$3$break + (block + ) + (block + (br $block$3$break) + ) + ) + (loop $shape$3$continue + (block + (call $trivial) + ) + (block + (br $shape$3$continue) + ) + ) + ) + (br $block$5$break) + ) + ) + (block + (block $block$6$break + (block + ) + (block + (br $block$6$break) + ) + ) + (block + (block $block$7$break + (loop $shape$6$continue + (block + (call $trivial) + ) + (if + (get_local $x) + (br $shape$6$continue) + (br $block$7$break) + ) + ) + ) + (block + (block $block$8$break + (block + ) + (block + (br $block$8$break) + ) + ) + (block + (block $block$11$break + (loop $shape$9$continue + (block $block$9$break + (block + (call $trivial) + ) + (if + (get_local $x) + (br $block$9$break) + (br $block$11$break) + ) + ) + (block + (block + ) + (block + (br $shape$9$continue) + ) + ) + ) + ) + (block + (block + ) + ) + ) + ) + ) + ) + ) + (func $br-out (type $3) (param $x i32) + (local $1 i32) + (block $block$2$break + (block + (call $br-out + (i32.const 5) + ) + ) + (block + (br $block$2$break) + ) + ) + (block + (block + ) + ) + ) + (func $unreachable (type $3) (param $x i32) + (local $1 i32) + (block $block$2$break + (block + ) + (if + (get_local $x) + (br $block$2$break) + (block + (block $block$11$break + (block + (call $unreachable + (i32.const 5) + ) + ) + (block + (br $block$11$break) + ) + ) + (block + (block + ) + ) + ) + ) + ) + (block + (block + ) + (if + (get_local $x) + (block + (block + (call $unreachable + (i32.const 1) + ) + (unreachable) + ) + ) + (block + (block + (call $unreachable + (i32.const 3) + ) + (return) + ) + ) + ) + ) + ) + (func $empty-blocks (type $3) (param $x i32) + (local $1 i32) + (block $block$2$break + (block + ) + (block + (br $block$2$break) + ) + ) + (block + (block $block$3$break + (block + ) + (block + (br $block$3$break) + ) + ) + (block + (block + ) + ) + ) + ) + (func $before-and-after (type $3) (param $x i32) + (local $1 i32) + (block $block$2$break + (block + (call $before-and-after + (i32.const 1) + ) + (call $before-and-after + (i32.const 2) + ) + ) + (block + (br $block$2$break) + ) + ) + (block + (block $block$3$break + (block + (call $before-and-after + (i32.const 3) + ) + (call $before-and-after + (i32.const 4) + ) + ) + (if + (get_local $x) + (br $block$3$break) + (block + (block + (call $before-and-after + (i32.const 5) + ) + ) + (block + (br $block$3$break) + ) + ) + ) + ) + (block + (block $block$5$break + (block + (call $before-and-after + (i32.const 6) + ) + ) + (block + (br $block$5$break) + ) + ) + (block + (block $block$6$break + (block + (nop) + (call $before-and-after + (i32.const 7) + ) + ) + (block + (br $block$6$break) + ) + ) + (block + (block $block$7$break + (block + (nop) + (call $before-and-after + (i32.const 8) + ) + ) + (block + (br $block$7$break) + ) + ) + (block + (block $block$8$break + (loop $shape$7$continue + (block + (call $before-and-after + (i32.const 9) + ) + ) + (if + (get_local $x) + (br $shape$7$continue) + (br $block$8$break) + ) + ) + ) + (block + (block $block$10$break + (block + (call $before-and-after + (i32.const 10) + ) + (call $before-and-after + (i32.const 11) + ) + ) + (if + (get_local $x) + (block + (block + (call $before-and-after + (i32.const 12) + ) + ) + (block + (br $block$10$break) + ) + ) + (br $block$10$break) + ) + ) + (block + (block $block$13$break + (block + (call $before-and-after + (i32.const 13) + ) + ) + (if + (get_local $x) + (block + (block + (call $before-and-after + (i32.const 14) + ) + ) + (block + (br $block$13$break) + ) + ) + (block + (block + (call $before-and-after + (i32.const 15) + ) + ) + (block + (br $block$13$break) + ) + ) + ) + ) + (block + (block $block$16$break + (block + ) + (if + (get_local $x) + (block + (block $block$15$break + (block + (call $before-and-after + (i32.const 16) + ) + ) + (block + (br $block$15$break) + ) + ) + (block + (block + ) + (block + (br $block$16$break) + ) + ) + ) + (br $block$16$break) + ) + ) + (block + (block $block$18$break + (block + (call $before-and-after + (i32.const 17) + ) + (call $before-and-after + (i32.const 18) + ) + (call $before-and-after + (i32.const 19) + ) + ) + (block + (br $block$18$break) + ) + ) + (block + (block $block$17$break + (block + (call $before-and-after + (i32.const 20) + ) + ) + (block + (br $block$17$break) + ) + ) + (block + (block $block$20$break + (block + (call $before-and-after + (i32.const 21) + ) + (call $before-and-after + (i32.const 22) + ) + ) + (block + (br $block$20$break) + ) + ) + (block + (block $block$19$break + (block + ) + (block + (br $block$19$break) + ) + ) + (block + (block $block$22$break + (block + (call $before-and-after + (i32.const 23) + ) + (call $before-and-after + (i32.const 24) + ) + ) + (block + (br $block$22$break) + ) + ) + (block + (block $block$21$break + (block + ) + (block + (br $block$21$break) + ) + ) + (block + (block + (call $before-and-after + (i32.const 25) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + ) + (func $switch (type $3) (param $x i32) + (local $1 i32) + (block $block$3$break + (block + ) + (block $switch$1$leave + (block $switch$1$default + (block $switch$1$case$3 + (br_table $switch$1$case$3 $switch$1$default + (get_local $x) + ) + ) + (block + (br $block$3$break) + ) + (br $switch$1$leave) + ) + (block + (block + (block + ) + (block + (br $block$3$break) + ) + ) + ) + (br $switch$1$leave) + ) + ) + (block + (block $block$6$break + (block + (call $switch + (i32.const 1) + ) + ) + (block $switch$3$leave + (block $switch$3$default + (block $switch$3$case$6 + (br_table $switch$3$case$6 $switch$3$case$6 $switch$3$case$6 $switch$3$default + (get_local $x) + ) + ) + (block + (br $block$6$break) + ) + (br $switch$3$leave) + ) + (block + (block + (block + (call $switch + (i32.const 2) + ) + ) + (block + (br $block$6$break) + ) + ) + ) + (br $switch$3$leave) + ) + ) + (block + (block $block$2$break + (block + (call $switch + (i32.const 3) + ) + ) + (block + (br $block$2$break) + ) + ) + (block + (block + ) + ) + ) + ) + ) + (func $no-return (type $0) + (local $0 i32) + (block $block$4$break + (block + ) + (if + (i32.const 1) + (block + (block + (drop + (i32.const 2) + ) + ) + (block + (br $block$4$break) + ) + ) + (block + (block + (drop + (i32.const 3) + ) + ) + (block + (br $block$4$break) + ) + ) + ) + ) + (block + (block + ) + ) + ) + (func $if-br-wat (type $3) (param $x i32) + (local $1 i32) + (block $block$2$break + (block $block$8$break + (block + (call $if-br-wat + (i32.const 0) + ) + ) + (if + (get_local $x) + (block + (block + (call $if-br-wat + (i32.const 1) + ) + ) + (block + (br $block$8$break) + ) + ) + (block + (block + ) + (if + (get_local $x) + (block + (block + ) + (block + (br $block$2$break) + ) + ) + (block + (block + ) + (block + (br $block$8$break) + ) + ) + ) + ) + ) + ) + (block + (block + (call $if-br-wat + (i32.const 2) + ) + ) + (block + (br $block$2$break) + ) + ) + ) + (block + (block + (call $if-br-wat + (i32.const 3) + ) + ) + ) + ) +) diff --git a/test/passes/rereloop.wast b/test/passes/rereloop.wast new file mode 100644 index 000000000..38c74ff56 --- /dev/null +++ b/test/passes/rereloop.wast @@ -0,0 +1,179 @@ +(module + (func $trivial + (nop) + ) + (func $trivial2 + (call $trivial) + (call $trivial) + ) + (func $return-void + (return) + ) + (func $return-val (result i32) + (return (i32.const 1)) + ) + (func $ifs (param $x i32) (result i32) + (if + (get_local $x) + (if + (get_local $x) + (return (i32.const 2)) + (return (i32.const 3)) + ) + ) + (if + (get_local $x) + (return (i32.const 4)) + ) + (return (i32.const 5)) + ) + (func $loops (param $x i32) + (if (get_local $x) + (loop $top + (call $trivial) + (br $top) + ) + ) + (loop $top2 + (call $trivial) + (br_if $top2 (get_local $x)) + ) + (loop $top3 + (call $trivial) + (if (get_local $x) (br $top3)) + ) + ) + (func $br-out (param $x i32) + (block $out + (call $br-out (i32.const 5)) + (br $out) + ) + ) + (func $unreachable (param $x i32) + (if (get_local $x) + (if (get_local $x) + (block + (call $unreachable (i32.const 1)) + (unreachable) + (call $unreachable (i32.const 2)) + ) + (block + (call $unreachable (i32.const 3)) + (return) + (call $unreachable (i32.const 4)) + ) + ) + ) + (block $out + (call $unreachable (i32.const 5)) + (br $out) + (call $unreachable (i32.const 6)) + ) + ) + (func $empty-blocks (param $x i32) + (block) + (block) + ) + (func $before-and-after (param $x i32) + (call $before-and-after (i32.const 1)) + (block + (call $before-and-after (i32.const 2)) + ) + (call $before-and-after (i32.const 3)) + (block $out + (call $before-and-after (i32.const 4)) + (br_if $out (get_local $x)) + (call $before-and-after (i32.const 5)) + ) + (call $before-and-after (i32.const 6)) + (loop) + (call $before-and-after (i32.const 7)) + (loop $top) + (call $before-and-after (i32.const 8)) + (loop $top2 + (call $before-and-after (i32.const 9)) + (br_if $top2 (get_local $x)) + (call $before-and-after (i32.const 10)) + ) + (call $before-and-after (i32.const 11)) + (if (get_local $x) + (call $before-and-after (i32.const 12)) + ) + (call $before-and-after (i32.const 13)) + (if (get_local $x) + (call $before-and-after (i32.const 14)) + (call $before-and-after (i32.const 15)) + ) + (if (get_local $x) + (block + (call $before-and-after (i32.const 16)) + ) + ) + (call $before-and-after (i32.const 17)) + (block + (call $before-and-after (i32.const 18)) + (block + (call $before-and-after (i32.const 19)) + ) + (call $before-and-after (i32.const 20)) + ) + (call $before-and-after (i32.const 21)) + (block + (block + (call $before-and-after (i32.const 22)) + ) + ) + (call $before-and-after (i32.const 23)) + (block $no1 + (block $no2 + (call $before-and-after (i32.const 24)) + ) + ) + (call $before-and-after (i32.const 25)) + ) + (func $switch (param $x i32) + (block $out + (block $a + (br_table $a $a (get_local $x)) + ) + (call $switch (i32.const 1)) + (block $b + (block $c + (br_table $b $b $b $c (get_local $x)) + ) + (call $switch (i32.const 2)) + ) + (call $switch (i32.const 3)) + ) + ) + (func $no-return + (if (i32.const 1) + (drop (i32.const 2)) + (drop (i32.const 3)) + ) + ) + (func $if-br-wat (param $x i32) + (call $if-br-wat + (i32.const 0) + ) + (block $label$2 + (if + (get_local $x) + (call $if-br-wat + (i32.const 1) + ) + (if + (get_local $x) + (br $label$2) ;; waka + ) + ) + (call $if-br-wat + (i32.const 2) + ) + ) + (call $if-br-wat + (i32.const 3) + ) + ) +) + diff --git a/test/passes/rereloop_dce_remove-unused-brs_remove-unused-names_simplify-locals-nostructure_vacuum_reorder-locals_coalesce-locals_simplify-locals_reorder-locals_merge-blocks_remove-unused-brs_merge-blocks_vacuum.txt b/test/passes/rereloop_dce_remove-unused-brs_remove-unused-names_simplify-locals-nostructure_vacuum_reorder-locals_coalesce-locals_simplify-locals_reorder-locals_merge-blocks_remove-unused-brs_merge-blocks_vacuum.txt new file mode 100644 index 000000000..5ed8e80c7 --- /dev/null +++ b/test/passes/rereloop_dce_remove-unused-brs_remove-unused-names_simplify-locals-nostructure_vacuum_reorder-locals_coalesce-locals_simplify-locals_reorder-locals_merge-blocks_remove-unused-brs_merge-blocks_vacuum.txt @@ -0,0 +1,234 @@ +(module + (type $0 (func)) + (type $1 (func (result i32))) + (type $2 (func (param i32) (result i32))) + (type $3 (func (param i32))) + (memory $0 0) + (func $trivial (type $0) + (nop) + ) + (func $trivial2 (type $0) + (call $trivial) + (call $trivial) + ) + (func $return-void (type $0) + (nop) + ) + (func $return-val (type $1) (result i32) + (i32.const 1) + ) + (func $ifs (type $2) (param $0 i32) (result i32) + (if i32 + (get_local $0) + (if i32 + (get_local $0) + (i32.const 2) + (i32.const 3) + ) + (if i32 + (get_local $0) + (i32.const 4) + (i32.const 5) + ) + ) + ) + (func $loops (type $3) (param $0 i32) + (if + (get_local $0) + (loop $shape$3$continue + (call $trivial) + (br $shape$3$continue) + ) + ) + (loop $shape$6$continue + (call $trivial) + (br_if $shape$6$continue + (get_local $0) + ) + ) + (block $block$11$break + (loop $shape$9$continue + (call $trivial) + (br_if $shape$9$continue + (i32.eqz + (i32.eqz + (get_local $0) + ) + ) + ) + ) + ) + ) + (func $br-out (type $3) (param $0 i32) + (call $br-out + (i32.const 5) + ) + ) + (func $unreachable (type $3) (param $0 i32) + (if + (i32.eqz + (get_local $0) + ) + (call $unreachable + (i32.const 5) + ) + ) + (if + (get_local $0) + (block + (call $unreachable + (i32.const 1) + ) + (unreachable) + ) + (call $unreachable + (i32.const 3) + ) + ) + ) + (func $empty-blocks (type $3) (param $0 i32) + (nop) + ) + (func $before-and-after (type $3) (param $0 i32) + (call $before-and-after + (i32.const 1) + ) + (call $before-and-after + (i32.const 2) + ) + (call $before-and-after + (i32.const 3) + ) + (call $before-and-after + (i32.const 4) + ) + (if + (i32.eqz + (get_local $0) + ) + (call $before-and-after + (i32.const 5) + ) + ) + (call $before-and-after + (i32.const 6) + ) + (call $before-and-after + (i32.const 7) + ) + (call $before-and-after + (i32.const 8) + ) + (loop $shape$7$continue + (call $before-and-after + (i32.const 9) + ) + (br_if $shape$7$continue + (get_local $0) + ) + ) + (call $before-and-after + (i32.const 10) + ) + (call $before-and-after + (i32.const 11) + ) + (if + (get_local $0) + (call $before-and-after + (i32.const 12) + ) + ) + (call $before-and-after + (i32.const 13) + ) + (if + (get_local $0) + (call $before-and-after + (i32.const 14) + ) + (call $before-and-after + (i32.const 15) + ) + ) + (if + (get_local $0) + (call $before-and-after + (i32.const 16) + ) + ) + (call $before-and-after + (i32.const 17) + ) + (call $before-and-after + (i32.const 18) + ) + (call $before-and-after + (i32.const 19) + ) + (call $before-and-after + (i32.const 20) + ) + (call $before-and-after + (i32.const 21) + ) + (call $before-and-after + (i32.const 22) + ) + (call $before-and-after + (i32.const 23) + ) + (call $before-and-after + (i32.const 24) + ) + (call $before-and-after + (i32.const 25) + ) + ) + (func $switch (type $3) (param $0 i32) + (block $block$6$break + (call $switch + (i32.const 1) + ) + (block $switch$3$default + (block $switch$3$case$6 + (br_table $switch$3$case$6 $switch$3$case$6 $switch$3$case$6 $switch$3$default + (get_local $0) + ) + ) + (br $block$6$break) + ) + (call $switch + (i32.const 2) + ) + ) + (call $switch + (i32.const 3) + ) + ) + (func $no-return (type $0) + (nop) + ) + (func $if-br-wat (type $3) (param $0 i32) + (block $block$2$break + (call $if-br-wat + (i32.const 0) + ) + (if + (get_local $0) + (call $if-br-wat + (i32.const 1) + ) + (br_if $block$2$break + (get_local $0) + ) + ) + (call $if-br-wat + (i32.const 2) + ) + ) + (call $if-br-wat + (i32.const 3) + ) + ) +) diff --git a/test/passes/rereloop_dce_remove-unused-brs_remove-unused-names_simplify-locals-nostructure_vacuum_reorder-locals_coalesce-locals_simplify-locals_reorder-locals_merge-blocks_remove-unused-brs_merge-blocks_vacuum.wast b/test/passes/rereloop_dce_remove-unused-brs_remove-unused-names_simplify-locals-nostructure_vacuum_reorder-locals_coalesce-locals_simplify-locals_reorder-locals_merge-blocks_remove-unused-brs_merge-blocks_vacuum.wast new file mode 100644 index 000000000..38c74ff56 --- /dev/null +++ b/test/passes/rereloop_dce_remove-unused-brs_remove-unused-names_simplify-locals-nostructure_vacuum_reorder-locals_coalesce-locals_simplify-locals_reorder-locals_merge-blocks_remove-unused-brs_merge-blocks_vacuum.wast @@ -0,0 +1,179 @@ +(module + (func $trivial + (nop) + ) + (func $trivial2 + (call $trivial) + (call $trivial) + ) + (func $return-void + (return) + ) + (func $return-val (result i32) + (return (i32.const 1)) + ) + (func $ifs (param $x i32) (result i32) + (if + (get_local $x) + (if + (get_local $x) + (return (i32.const 2)) + (return (i32.const 3)) + ) + ) + (if + (get_local $x) + (return (i32.const 4)) + ) + (return (i32.const 5)) + ) + (func $loops (param $x i32) + (if (get_local $x) + (loop $top + (call $trivial) + (br $top) + ) + ) + (loop $top2 + (call $trivial) + (br_if $top2 (get_local $x)) + ) + (loop $top3 + (call $trivial) + (if (get_local $x) (br $top3)) + ) + ) + (func $br-out (param $x i32) + (block $out + (call $br-out (i32.const 5)) + (br $out) + ) + ) + (func $unreachable (param $x i32) + (if (get_local $x) + (if (get_local $x) + (block + (call $unreachable (i32.const 1)) + (unreachable) + (call $unreachable (i32.const 2)) + ) + (block + (call $unreachable (i32.const 3)) + (return) + (call $unreachable (i32.const 4)) + ) + ) + ) + (block $out + (call $unreachable (i32.const 5)) + (br $out) + (call $unreachable (i32.const 6)) + ) + ) + (func $empty-blocks (param $x i32) + (block) + (block) + ) + (func $before-and-after (param $x i32) + (call $before-and-after (i32.const 1)) + (block + (call $before-and-after (i32.const 2)) + ) + (call $before-and-after (i32.const 3)) + (block $out + (call $before-and-after (i32.const 4)) + (br_if $out (get_local $x)) + (call $before-and-after (i32.const 5)) + ) + (call $before-and-after (i32.const 6)) + (loop) + (call $before-and-after (i32.const 7)) + (loop $top) + (call $before-and-after (i32.const 8)) + (loop $top2 + (call $before-and-after (i32.const 9)) + (br_if $top2 (get_local $x)) + (call $before-and-after (i32.const 10)) + ) + (call $before-and-after (i32.const 11)) + (if (get_local $x) + (call $before-and-after (i32.const 12)) + ) + (call $before-and-after (i32.const 13)) + (if (get_local $x) + (call $before-and-after (i32.const 14)) + (call $before-and-after (i32.const 15)) + ) + (if (get_local $x) + (block + (call $before-and-after (i32.const 16)) + ) + ) + (call $before-and-after (i32.const 17)) + (block + (call $before-and-after (i32.const 18)) + (block + (call $before-and-after (i32.const 19)) + ) + (call $before-and-after (i32.const 20)) + ) + (call $before-and-after (i32.const 21)) + (block + (block + (call $before-and-after (i32.const 22)) + ) + ) + (call $before-and-after (i32.const 23)) + (block $no1 + (block $no2 + (call $before-and-after (i32.const 24)) + ) + ) + (call $before-and-after (i32.const 25)) + ) + (func $switch (param $x i32) + (block $out + (block $a + (br_table $a $a (get_local $x)) + ) + (call $switch (i32.const 1)) + (block $b + (block $c + (br_table $b $b $b $c (get_local $x)) + ) + (call $switch (i32.const 2)) + ) + (call $switch (i32.const 3)) + ) + ) + (func $no-return + (if (i32.const 1) + (drop (i32.const 2)) + (drop (i32.const 3)) + ) + ) + (func $if-br-wat (param $x i32) + (call $if-br-wat + (i32.const 0) + ) + (block $label$2 + (if + (get_local $x) + (call $if-br-wat + (i32.const 1) + ) + (if + (get_local $x) + (br $label$2) ;; waka + ) + ) + (call $if-br-wat + (i32.const 2) + ) + ) + (call $if-br-wat + (i32.const 3) + ) + ) +) + |