diff options
Diffstat (limited to 'test/passes')
-rw-r--r-- | test/passes/optimize-instructions.txt | 20 | ||||
-rw-r--r-- | test/passes/optimize-instructions.wast | 16 | ||||
-rw-r--r-- | test/passes/simplify-locals-nostructure.txt | 65 | ||||
-rw-r--r-- | test/passes/simplify-locals-nostructure.wast | 32 | ||||
-rw-r--r-- | test/passes/simplify-locals-notee-nostructure.txt | 65 | ||||
-rw-r--r-- | test/passes/simplify-locals-notee-nostructure.wast | 32 | ||||
-rw-r--r-- | test/passes/simplify-locals-notee.txt | 66 | ||||
-rw-r--r-- | test/passes/simplify-locals-notee.wast | 32 | ||||
-rw-r--r-- | test/passes/simplify-locals.txt | 82 | ||||
-rw-r--r-- | test/passes/simplify-locals.wast | 29 |
10 files changed, 429 insertions, 10 deletions
diff --git a/test/passes/optimize-instructions.txt b/test/passes/optimize-instructions.txt index 226f1766e..cb043f155 100644 --- a/test/passes/optimize-instructions.txt +++ b/test/passes/optimize-instructions.txt @@ -373,6 +373,26 @@ (call $ne0) (nop) ) + (if + (i32.or + (call $ne0) + (call $ne0) + ) + (nop) + ) + (if + (i32.and + (i32.ne + (call $ne0) + (i32.const 0) + ) + (i32.ne + (call $ne0) + (i32.const 0) + ) + ) + (nop) + ) (i32.const 1) ) (func $recurse-bool (type $1) diff --git a/test/passes/optimize-instructions.wast b/test/passes/optimize-instructions.wast index dfa6365f9..3cf756548 100644 --- a/test/passes/optimize-instructions.wast +++ b/test/passes/optimize-instructions.wast @@ -294,6 +294,22 @@ (if (i32.ne (i32.const 0) (call $ne0)) (nop) ) + ;; through an or + (if + (i32.or + (i32.ne (i32.const 0) (call $ne0)) + (i32.ne (i32.const 0) (call $ne0)) + ) + (nop) + ) + ;; but not an and + (if + (i32.and + (i32.ne (i32.const 0) (call $ne0)) + (i32.ne (i32.const 0) (call $ne0)) + ) + (nop) + ) (i32.const 1) ) (func $recurse-bool diff --git a/test/passes/simplify-locals-nostructure.txt b/test/passes/simplify-locals-nostructure.txt new file mode 100644 index 000000000..9d85e1ddc --- /dev/null +++ b/test/passes/simplify-locals-nostructure.txt @@ -0,0 +1,65 @@ +(module + (type $0 (func)) + (memory $0 0) + (func $contrast (type $0) + (local $x i32) + (local $y i32) + (local $z i32) + (local $a i32) + (local $b i32) + (nop) + (if + (tee_local $x + (i32.const 1) + ) + (nop) + ) + (if + (get_local $x) + (nop) + ) + (nop) + (drop + (if i32 + (i32.const 2) + (i32.const 3) + (i32.const 4) + ) + ) + (nop) + (drop + (block $block i32 + (i32.const 5) + ) + ) + (if + (i32.const 6) + (set_local $a + (i32.const 7) + ) + (set_local $a + (i32.const 8) + ) + ) + (drop + (get_local $a) + ) + (block $val + (if + (i32.const 10) + (block $block4 + (set_local $b + (i32.const 11) + ) + (br $val) + ) + ) + (set_local $b + (i32.const 12) + ) + ) + (drop + (get_local $b) + ) + ) +) diff --git a/test/passes/simplify-locals-nostructure.wast b/test/passes/simplify-locals-nostructure.wast new file mode 100644 index 000000000..e7b827f55 --- /dev/null +++ b/test/passes/simplify-locals-nostructure.wast @@ -0,0 +1,32 @@ +(module + (func $contrast ;; check for tee and structure sinking + (local $x i32) + (local $y i32) + (local $z i32) + (local $a i32) + (local $b i32) + (set_local $x (i32.const 1)) + (if (get_local $x) (nop)) + (if (get_local $x) (nop)) + (set_local $y (if i32 (i32.const 2) (i32.const 3) (i32.const 4))) + (drop (get_local $y)) + (set_local $z (block i32 (i32.const 5))) + (drop (get_local $z)) + (if (i32.const 6) + (set_local $a (i32.const 7)) + (set_local $a (i32.const 8)) + ) + (drop (get_local $a)) + (block $val + (if (i32.const 10) + (block + (set_local $b (i32.const 11)) + (br $val) + ) + ) + (set_local $b (i32.const 12)) + ) + (drop (get_local $b)) + ) +) + diff --git a/test/passes/simplify-locals-notee-nostructure.txt b/test/passes/simplify-locals-notee-nostructure.txt new file mode 100644 index 000000000..d631b9d83 --- /dev/null +++ b/test/passes/simplify-locals-notee-nostructure.txt @@ -0,0 +1,65 @@ +(module + (type $0 (func)) + (memory $0 0) + (func $contrast (type $0) + (local $x i32) + (local $y i32) + (local $z i32) + (local $a i32) + (local $b i32) + (set_local $x + (i32.const 1) + ) + (if + (get_local $x) + (nop) + ) + (if + (get_local $x) + (nop) + ) + (nop) + (drop + (if i32 + (i32.const 2) + (i32.const 3) + (i32.const 4) + ) + ) + (nop) + (drop + (block $block i32 + (i32.const 5) + ) + ) + (if + (i32.const 6) + (set_local $a + (i32.const 7) + ) + (set_local $a + (i32.const 8) + ) + ) + (drop + (get_local $a) + ) + (block $val + (if + (i32.const 10) + (block $block4 + (set_local $b + (i32.const 11) + ) + (br $val) + ) + ) + (set_local $b + (i32.const 12) + ) + ) + (drop + (get_local $b) + ) + ) +) diff --git a/test/passes/simplify-locals-notee-nostructure.wast b/test/passes/simplify-locals-notee-nostructure.wast new file mode 100644 index 000000000..e7b827f55 --- /dev/null +++ b/test/passes/simplify-locals-notee-nostructure.wast @@ -0,0 +1,32 @@ +(module + (func $contrast ;; check for tee and structure sinking + (local $x i32) + (local $y i32) + (local $z i32) + (local $a i32) + (local $b i32) + (set_local $x (i32.const 1)) + (if (get_local $x) (nop)) + (if (get_local $x) (nop)) + (set_local $y (if i32 (i32.const 2) (i32.const 3) (i32.const 4))) + (drop (get_local $y)) + (set_local $z (block i32 (i32.const 5))) + (drop (get_local $z)) + (if (i32.const 6) + (set_local $a (i32.const 7)) + (set_local $a (i32.const 8)) + ) + (drop (get_local $a)) + (block $val + (if (i32.const 10) + (block + (set_local $b (i32.const 11)) + (br $val) + ) + ) + (set_local $b (i32.const 12)) + ) + (drop (get_local $b)) + ) +) + diff --git a/test/passes/simplify-locals-notee.txt b/test/passes/simplify-locals-notee.txt new file mode 100644 index 000000000..fc48429d7 --- /dev/null +++ b/test/passes/simplify-locals-notee.txt @@ -0,0 +1,66 @@ +(module + (type $0 (func)) + (memory $0 0) + (func $contrast (type $0) + (local $x i32) + (local $y i32) + (local $z i32) + (local $a i32) + (local $b i32) + (set_local $x + (i32.const 1) + ) + (if + (get_local $x) + (nop) + ) + (if + (get_local $x) + (nop) + ) + (nop) + (drop + (if i32 + (i32.const 2) + (i32.const 3) + (i32.const 4) + ) + ) + (nop) + (drop + (block $block i32 + (i32.const 5) + ) + ) + (nop) + (drop + (if i32 + (i32.const 6) + (block i32 + (nop) + (i32.const 7) + ) + (block i32 + (nop) + (i32.const 8) + ) + ) + ) + (nop) + (drop + (block $val i32 + (if + (i32.const 10) + (block $block4 + (nop) + (br $val + (i32.const 11) + ) + ) + ) + (nop) + (i32.const 12) + ) + ) + ) +) diff --git a/test/passes/simplify-locals-notee.wast b/test/passes/simplify-locals-notee.wast new file mode 100644 index 000000000..e7b827f55 --- /dev/null +++ b/test/passes/simplify-locals-notee.wast @@ -0,0 +1,32 @@ +(module + (func $contrast ;; check for tee and structure sinking + (local $x i32) + (local $y i32) + (local $z i32) + (local $a i32) + (local $b i32) + (set_local $x (i32.const 1)) + (if (get_local $x) (nop)) + (if (get_local $x) (nop)) + (set_local $y (if i32 (i32.const 2) (i32.const 3) (i32.const 4))) + (drop (get_local $y)) + (set_local $z (block i32 (i32.const 5))) + (drop (get_local $z)) + (if (i32.const 6) + (set_local $a (i32.const 7)) + (set_local $a (i32.const 8)) + ) + (drop (get_local $a)) + (block $val + (if (i32.const 10) + (block + (set_local $b (i32.const 11)) + (br $val) + ) + ) + (set_local $b (i32.const 12)) + ) + (drop (get_local $b)) + ) +) + diff --git a/test/passes/simplify-locals.txt b/test/passes/simplify-locals.txt index 36424193b..c9601940b 100644 --- a/test/passes/simplify-locals.txt +++ b/test/passes/simplify-locals.txt @@ -15,6 +15,68 @@ (import "env" "moddi" (func $___udivmoddi4 (param i32 i32 i32 i32 i32) (result i32))) (import "env" "lp" (func $lp (param i32 i32) (result i32))) (memory $0 256 256) + (func $contrast (type $FUNCSIG$v) + (local $x i32) + (local $y i32) + (local $z i32) + (local $a i32) + (local $b i32) + (nop) + (if + (tee_local $x + (i32.const 1) + ) + (nop) + ) + (if + (get_local $x) + (nop) + ) + (nop) + (drop + (if i32 + (i32.const 2) + (i32.const 3) + (i32.const 4) + ) + ) + (nop) + (drop + (block $block i32 + (i32.const 5) + ) + ) + (nop) + (drop + (if i32 + (i32.const 6) + (block i32 + (nop) + (i32.const 7) + ) + (block i32 + (nop) + (i32.const 8) + ) + ) + ) + (nop) + (drop + (block $val i32 + (if + (i32.const 10) + (block $block4 + (nop) + (br $val + (i32.const 11) + ) + ) + ) + (nop) + (i32.const 12) + ) + ) + ) (func $b0-yes (type $4) (param $i1 i32) (local $x i32) (local $y i32) @@ -225,7 +287,7 @@ (nop) (set_local $a (block $block i32 - (block $block4 + (block $block5 (nop) (i32.store (i32.const 104) @@ -239,8 +301,8 @@ ) (call $waka) (set_local $a - (block $block5 i32 - (block $block6 + (block $block6 i32 + (block $block7 (nop) (i32.store (i32.const 106) @@ -258,8 +320,8 @@ ) (call $waka) (set_local $a - (block $block7 i32 - (block $block8 + (block $block8 i32 + (block $block9 (nop) (i32.store (i32.const 108) @@ -281,8 +343,8 @@ ) (call $waka) (set_local $a - (block $block9 i32 - (block $block10 + (block $block10 i32 + (block $block11 (nop) (i32.store (i32.const 110) @@ -703,10 +765,10 @@ (drop (get_local $x) ) - (block $moar17 + (block $moar18 (set_local $y - (block $block18 i32 - (br_if $moar17 + (block $block19 i32 + (br_if $moar18 (get_local $y) ) (i32.const 0) diff --git a/test/passes/simplify-locals.wast b/test/passes/simplify-locals.wast index 06907a570..a8fc75f06 100644 --- a/test/passes/simplify-locals.wast +++ b/test/passes/simplify-locals.wast @@ -12,6 +12,35 @@ (import $_i64Subtract "env" "i64sub" (param i32 i32 i32 i32) (result i32)) (import $___udivmoddi4 "env" "moddi" (param i32 i32 i32 i32 i32) (result i32)) (import $lp "env" "lp" (param i32 i32) (result i32)) + (func $contrast ;; check for tee and structure sinking + (local $x i32) + (local $y i32) + (local $z i32) + (local $a i32) + (local $b i32) + (set_local $x (i32.const 1)) + (if (get_local $x) (nop)) + (if (get_local $x) (nop)) + (set_local $y (if i32 (i32.const 2) (i32.const 3) (i32.const 4))) + (drop (get_local $y)) + (set_local $z (block i32 (i32.const 5))) + (drop (get_local $z)) + (if (i32.const 6) + (set_local $a (i32.const 7)) + (set_local $a (i32.const 8)) + ) + (drop (get_local $a)) + (block $val + (if (i32.const 10) + (block + (set_local $b (i32.const 11)) + (br $val) + ) + ) + (set_local $b (i32.const 12)) + ) + (drop (get_local $b)) + ) (func $b0-yes (type $4) (param $i1 i32) (local $x i32) (local $y i32) |