diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/emcc_O2_hello_world.fromasm | 44 | ||||
-rw-r--r-- | test/emcc_hello_world.fromasm | 139 | ||||
-rw-r--r-- | test/memorygrowth.fromasm | 10 | ||||
-rw-r--r-- | test/passes/code-pushing_ignore-implicit-traps.txt (renamed from test/passes/code-pushing.txt) | 0 | ||||
-rw-r--r-- | test/passes/code-pushing_ignore-implicit-traps.wast (renamed from test/passes/code-pushing.wast) | 0 | ||||
-rw-r--r-- | test/passes/optimize-instructions_optimize-level=2_ignore-implicit-traps.txt (renamed from test/passes/optimize-instructions_optimize-level=2.txt) | 0 | ||||
-rw-r--r-- | test/passes/optimize-instructions_optimize-level=2_ignore-implicit-traps.wast (renamed from test/passes/optimize-instructions_optimize-level=2.wast) | 0 | ||||
-rw-r--r-- | test/passes/remove-unused-brs_shrink-level=1.txt | 36 | ||||
-rw-r--r-- | test/passes/remove-unused-brs_shrink-level=1.wast | 25 | ||||
-rw-r--r-- | test/passes/remove-unused-brs_shrink-level=1_ignore-implicit-traps.txt | 125 | ||||
-rw-r--r-- | test/passes/remove-unused-brs_shrink-level=1_ignore-implicit-traps.wast | 80 |
11 files changed, 357 insertions, 102 deletions
diff --git a/test/emcc_O2_hello_world.fromasm b/test/emcc_O2_hello_world.fromasm index 5ac3b57bb..1cc6427ef 100644 --- a/test/emcc_O2_hello_world.fromasm +++ b/test/emcc_O2_hello_world.fromasm @@ -1935,7 +1935,8 @@ ) ) (if - (select + (if i32 + (get_local $12) (i32.lt_u (get_local $3) (i32.sub @@ -1946,7 +1947,6 @@ ) ) (i32.const 0) - (get_local $12) ) (block (if @@ -3668,19 +3668,12 @@ ) ) (if - (select - (i32.and - (i32.lt_u - (get_local $13) - (get_local $20) - ) - (i32.ge_u - (get_local $13) - (get_local $46) + (if i32 + (if i32 + (i32.eq + (get_local $7) + (i32.const 203) ) - ) - (i32.const 0) - (select (i32.eqz (i32.and (i32.load offset=12 @@ -3690,11 +3683,18 @@ ) ) (i32.const 0) - (i32.eq - (get_local $7) - (i32.const 203) + ) + (i32.and + (i32.lt_u + (get_local $13) + (get_local $20) + ) + (i32.ge_u + (get_local $13) + (get_local $46) ) ) + (i32.const 0) ) (block (i32.store @@ -8117,7 +8117,11 @@ ) ) (set_local $15 - (select + (if i32 + (i32.eq + (get_local $17) + (i32.const 2) + ) (i32.const 0) (i32.sub (get_local $2) @@ -8125,10 +8129,6 @@ (get_local $16) ) ) - (i32.eq - (get_local $17) - (i32.const 2) - ) ) ) ) diff --git a/test/emcc_hello_world.fromasm b/test/emcc_hello_world.fromasm index 690c869ca..7dbe75147 100644 --- a/test/emcc_hello_world.fromasm +++ b/test/emcc_hello_world.fromasm @@ -1065,7 +1065,11 @@ ) ) (set_local $2 - (select + (if i32 + (i32.eq + (get_local $4) + (i32.const 2) + ) (i32.const 0) (i32.sub (get_local $2) @@ -1073,10 +1077,6 @@ (get_local $1) ) ) - (i32.eq - (get_local $4) - (i32.const 2) - ) ) ) ) @@ -4198,7 +4198,13 @@ ) ) ) - (select + (if f64 + (i32.eq + (i32.load8_s + (get_local $9) + ) + (i32.const 45) + ) (f64.neg (f64.add (get_local $15) @@ -4217,12 +4223,6 @@ ) (get_local $15) ) - (i32.eq - (i32.load8_s - (get_local $9) - ) - (i32.const 45) - ) ) ) ) @@ -6220,20 +6220,20 @@ ) ) (br_if $do-once115 - (i32.or - (i32.and - (get_local $17) - (i32.lt_s - (get_local $7) - (i32.const 1) - ) + (i32.and + (get_local $17) + (i32.lt_s + (get_local $7) + (i32.const 1) ) - (i32.and - (i32.load - (get_local $0) - ) - (i32.const 32) + ) + ) + (br_if $do-once115 + (i32.and + (i32.load + (get_local $0) ) + (i32.const 32) ) ) (drop @@ -13480,7 +13480,7 @@ (i32.eq (tee_local $5 (i32.and - (tee_local $8 + (tee_local $7 (i32.load (i32.add (get_local $0) @@ -13495,12 +13495,12 @@ ) (call $_abort) ) - (set_local $7 + (set_local $8 (i32.add (get_local $1) (tee_local $0 (i32.and - (get_local $8) + (get_local $7) (i32.const -8) ) ) @@ -13509,7 +13509,7 @@ (block $do-once (if (i32.and - (get_local $8) + (get_local $7) (i32.const 1) ) (block @@ -13521,6 +13521,11 @@ ) ) (block + (set_local $7 + (i32.load + (get_local $1) + ) + ) (if (i32.eqz (get_local $5) @@ -13534,11 +13539,7 @@ (get_local $1) (i32.sub (i32.const 0) - (tee_local $8 - (i32.load - (get_local $1) - ) - ) + (get_local $7) ) ) ) @@ -13548,7 +13549,7 @@ ) (set_local $0 (i32.add - (get_local $8) + (get_local $7) (get_local $0) ) ) @@ -13567,7 +13568,7 @@ (i32.load (tee_local $2 (i32.add - (get_local $7) + (get_local $8) (i32.const 4) ) ) @@ -13617,13 +13618,13 @@ ) (set_local $5 (i32.shr_u - (get_local $8) + (get_local $7) (i32.const 3) ) ) (if (i32.lt_u - (get_local $8) + (get_local $7) (i32.const 256) ) (block @@ -13778,7 +13779,7 @@ (i32.load (tee_local $4 (i32.add - (tee_local $8 + (tee_local $7 (i32.add (get_local $1) (i32.const 16) @@ -13793,11 +13794,11 @@ (if (tee_local $5 (i32.load - (get_local $8) + (get_local $7) ) ) (set_local $4 - (get_local $8) + (get_local $7) ) (block (set_local $6 @@ -13809,7 +13810,7 @@ ) (loop $while-in (if - (tee_local $8 + (tee_local $7 (i32.load (tee_local $10 (i32.add @@ -13821,7 +13822,7 @@ ) (block (set_local $5 - (get_local $8) + (get_local $7) ) (set_local $4 (get_local $10) @@ -13830,7 +13831,7 @@ ) ) (if - (tee_local $8 + (tee_local $7 (i32.load (tee_local $10 (i32.add @@ -13842,7 +13843,7 @@ ) (block (set_local $5 - (get_local $8) + (get_local $7) ) (set_local $4 (get_local $10) @@ -13883,7 +13884,7 @@ (if (i32.ne (i32.load - (tee_local $8 + (tee_local $7 (i32.add (get_local $10) (i32.const 12) @@ -13908,7 +13909,7 @@ ) (block (i32.store - (get_local $8) + (get_local $7) (get_local $4) ) (i32.store @@ -14044,7 +14045,7 @@ (get_local $12) ) (if - (tee_local $8 + (tee_local $7 (i32.load (tee_local $4 (i32.add @@ -14056,17 +14057,17 @@ ) (if (i32.lt_u - (get_local $8) + (get_local $7) (get_local $5) ) (call $_abort) (block (i32.store offset=16 (get_local $6) - (get_local $8) + (get_local $7) ) (i32.store offset=24 - (get_local $8) + (get_local $7) (get_local $6) ) ) @@ -14128,7 +14129,7 @@ (if (i32.ge_u (get_local $2) - (get_local $7) + (get_local $8) ) (call $_abort) ) @@ -14139,7 +14140,7 @@ (i32.load (tee_local $0 (i32.add - (get_local $7) + (get_local $8) (i32.const 4) ) ) @@ -14181,7 +14182,7 @@ (block (if (i32.eq - (get_local $7) + (get_local $8) (i32.load (i32.const 200) ) @@ -14231,7 +14232,7 @@ ) (if (i32.eq - (get_local $7) + (get_local $8) (i32.load (i32.const 196) ) @@ -14293,14 +14294,14 @@ (block (set_local $4 (i32.load offset=12 - (get_local $7) + (get_local $8) ) ) (if (i32.ne (tee_local $1 (i32.load offset=8 - (get_local $7) + (get_local $8) ) ) (tee_local $0 @@ -14331,7 +14332,7 @@ (i32.load offset=12 (get_local $1) ) - (get_local $7) + (get_local $8) ) (call $_abort) ) @@ -14392,7 +14393,7 @@ ) ) ) - (get_local $7) + (get_local $8) ) (set_local $14 (get_local $0) @@ -14413,7 +14414,7 @@ (block (set_local $6 (i32.load offset=24 - (get_local $7) + (get_local $8) ) ) (block $do-once6 @@ -14421,10 +14422,10 @@ (i32.eq (tee_local $0 (i32.load offset=12 - (get_local $7) + (get_local $8) ) ) - (get_local $7) + (get_local $8) ) (block (if @@ -14435,7 +14436,7 @@ (i32.add (tee_local $1 (i32.add - (get_local $7) + (get_local $8) (i32.const 16) ) ) @@ -14530,7 +14531,7 @@ (i32.lt_u (tee_local $4 (i32.load offset=8 - (get_local $7) + (get_local $8) ) ) (i32.load @@ -14549,7 +14550,7 @@ ) ) ) - (get_local $7) + (get_local $8) ) (call $_abort) ) @@ -14563,7 +14564,7 @@ ) ) ) - (get_local $7) + (get_local $8) ) (block (i32.store @@ -14588,14 +14589,14 @@ (block (if (i32.eq - (get_local $7) + (get_local $8) (i32.load (tee_local $0 (i32.add (i32.shl (tee_local $3 (i32.load offset=28 - (get_local $7) + (get_local $8) ) ) (i32.const 2) @@ -14654,7 +14655,7 @@ ) ) ) - (get_local $7) + (get_local $8) ) (i32.store (get_local $0) @@ -14692,7 +14693,7 @@ (i32.load (tee_local $0 (i32.add - (get_local $7) + (get_local $8) (i32.const 16) ) ) diff --git a/test/memorygrowth.fromasm b/test/memorygrowth.fromasm index d6800684d..e33525578 100644 --- a/test/memorygrowth.fromasm +++ b/test/memorygrowth.fromasm @@ -8170,7 +8170,11 @@ ) ) (set_local $15 - (select + (if i32 + (i32.eq + (get_local $17) + (i32.const 2) + ) (i32.const 0) (i32.sub (get_local $2) @@ -8178,10 +8182,6 @@ (get_local $16) ) ) - (i32.eq - (get_local $17) - (i32.const 2) - ) ) ) ) diff --git a/test/passes/code-pushing.txt b/test/passes/code-pushing_ignore-implicit-traps.txt index f09d0dfb5..f09d0dfb5 100644 --- a/test/passes/code-pushing.txt +++ b/test/passes/code-pushing_ignore-implicit-traps.txt diff --git a/test/passes/code-pushing.wast b/test/passes/code-pushing_ignore-implicit-traps.wast index e1cb30f4a..e1cb30f4a 100644 --- a/test/passes/code-pushing.wast +++ b/test/passes/code-pushing_ignore-implicit-traps.wast diff --git a/test/passes/optimize-instructions_optimize-level=2.txt b/test/passes/optimize-instructions_optimize-level=2_ignore-implicit-traps.txt index 243421e8c..243421e8c 100644 --- a/test/passes/optimize-instructions_optimize-level=2.txt +++ b/test/passes/optimize-instructions_optimize-level=2_ignore-implicit-traps.txt diff --git a/test/passes/optimize-instructions_optimize-level=2.wast b/test/passes/optimize-instructions_optimize-level=2_ignore-implicit-traps.wast index 7874907f3..7874907f3 100644 --- a/test/passes/optimize-instructions_optimize-level=2.wast +++ b/test/passes/optimize-instructions_optimize-level=2_ignore-implicit-traps.wast diff --git a/test/passes/remove-unused-brs_shrink-level=1.txt b/test/passes/remove-unused-brs_shrink-level=1.txt index 68015f73f..b81c12abe 100644 --- a/test/passes/remove-unused-brs_shrink-level=1.txt +++ b/test/passes/remove-unused-brs_shrink-level=1.txt @@ -4,7 +4,7 @@ (type $2 (func (result i32))) (memory $0 256 256) (func $b14 (type $2) (result i32) - (block $topmost i32 + (drop (select (block $block1 i32 (i32.const 12) @@ -15,6 +15,34 @@ (i32.const 1) ) ) + (drop + (if i32 + (i32.const 1) + (i32.load + (i32.const 10) + ) + (i32.const 27) + ) + ) + (drop + (if i32 + (i32.const 1) + (i32.rem_s + (i32.const 11) + (i32.const 12) + ) + (i32.const 27) + ) + ) + (drop + (if i32 + (i32.const 1) + (i32.trunc_u/f64 + (f64.const 12.34) + ) + (i32.const 27) + ) + ) ) (func $join-br_ifs (type $1) (block $out @@ -85,11 +113,11 @@ (nop) ) ) - (block $out80 - (br_if $out80 + (block $out83 + (br_if $out83 (i32.const 1) ) - (br_if $out80 + (br_if $out83 (call $b14) ) ) diff --git a/test/passes/remove-unused-brs_shrink-level=1.wast b/test/passes/remove-unused-brs_shrink-level=1.wast index 5a2234de6..e48ced178 100644 --- a/test/passes/remove-unused-brs_shrink-level=1.wast +++ b/test/passes/remove-unused-brs_shrink-level=1.wast @@ -3,8 +3,8 @@ (type $0 (func (param i32))) (type $1 (func)) (type $2 (func (result i32))) - (func $b14 (type $2) (result i32) - (block $topmost i32 + (func $b14 (type $2) + (drop (if i32 ;; with shrinking, this can become a select (i32.const 1) (block $block1 i32 @@ -15,6 +15,27 @@ ) ) ) + (drop + (if i32 + (i32.const 1) + (i32.load (i32.const 10)) ;; load may have side effects, unless ignored + (i32.const 27) + ) + ) + (drop + (if i32 + (i32.const 1) + (i32.rem_s (i32.const 11) (i32.const 12)) ;; rem may have side effects, unless ignored + (i32.const 27) + ) + ) + (drop + (if i32 + (i32.const 1) + (i32.trunc_u/f64 (f64.const 12.34)) ;; float to int may have side effects, unless ignored + (i32.const 27) + ) + ) ) (func $join-br_ifs (block $out diff --git a/test/passes/remove-unused-brs_shrink-level=1_ignore-implicit-traps.txt b/test/passes/remove-unused-brs_shrink-level=1_ignore-implicit-traps.txt new file mode 100644 index 000000000..35cfd53c8 --- /dev/null +++ b/test/passes/remove-unused-brs_shrink-level=1_ignore-implicit-traps.txt @@ -0,0 +1,125 @@ +(module + (type $0 (func (param i32))) + (type $1 (func)) + (type $2 (func (result i32))) + (memory $0 256 256) + (func $b14 (type $2) (result i32) + (drop + (select + (block $block1 i32 + (i32.const 12) + ) + (block $block3 i32 + (i32.const 27) + ) + (i32.const 1) + ) + ) + (drop + (select + (i32.load + (i32.const 10) + ) + (i32.const 27) + (i32.const 1) + ) + ) + (drop + (select + (i32.rem_s + (i32.const 11) + (i32.const 12) + ) + (i32.const 27) + (i32.const 1) + ) + ) + (drop + (select + (i32.trunc_u/f64 + (f64.const 12.34) + ) + (i32.const 27) + (i32.const 1) + ) + ) + ) + (func $join-br_ifs (type $1) + (block $out + (br_if $out + (i32.or + (i32.const 1) + (i32.const 2) + ) + ) + (nop) + (br_if $out + (i32.const 3) + ) + ) + (block $out2 + (block $out3 + (br_if $out2 + (i32.const 1) + ) + (br_if $out3 + (i32.const 2) + ) + (br_if $out2 + (i32.const 3) + ) + ) + (unreachable) + ) + (block $out4 + (block $out5 + (br_if $out4 + (i32.const 1) + ) + (br_if $out5 + (i32.or + (i32.const 2) + (i32.const 3) + ) + ) + (nop) + ) + (unreachable) + ) + (block $out6 + (block $out7 + (br_if $out6 + (i32.or + (i32.const 1) + (i32.const 2) + ) + ) + (nop) + (br_if $out7 + (i32.const 3) + ) + ) + (unreachable) + ) + (if + (i32.eqz + (i32.or + (call $b14) + (i32.const 0) + ) + ) + (block + (nop) + (nop) + ) + ) + (block $out83 + (br_if $out83 + (i32.const 1) + ) + (br_if $out83 + (call $b14) + ) + ) + ) +) diff --git a/test/passes/remove-unused-brs_shrink-level=1_ignore-implicit-traps.wast b/test/passes/remove-unused-brs_shrink-level=1_ignore-implicit-traps.wast new file mode 100644 index 000000000..e48ced178 --- /dev/null +++ b/test/passes/remove-unused-brs_shrink-level=1_ignore-implicit-traps.wast @@ -0,0 +1,80 @@ +(module + (memory 256 256) + (type $0 (func (param i32))) + (type $1 (func)) + (type $2 (func (result i32))) + (func $b14 (type $2) + (drop + (if i32 ;; with shrinking, this can become a select + (i32.const 1) + (block $block1 i32 + (i32.const 12) + ) + (block $block3 i32 + (i32.const 27) + ) + ) + ) + (drop + (if i32 + (i32.const 1) + (i32.load (i32.const 10)) ;; load may have side effects, unless ignored + (i32.const 27) + ) + ) + (drop + (if i32 + (i32.const 1) + (i32.rem_s (i32.const 11) (i32.const 12)) ;; rem may have side effects, unless ignored + (i32.const 27) + ) + ) + (drop + (if i32 + (i32.const 1) + (i32.trunc_u/f64 (f64.const 12.34)) ;; float to int may have side effects, unless ignored + (i32.const 27) + ) + ) + ) + (func $join-br_ifs + (block $out + (br_if $out (i32.const 1)) + (br_if $out (i32.const 2)) + (br_if $out (i32.const 3)) + ) + (block $out2 + (block $out3 + (br_if $out2 (i32.const 1)) + (br_if $out3 (i32.const 2)) + (br_if $out2 (i32.const 3)) + ) + (unreachable) + ) + (block $out4 + (block $out5 + (br_if $out4 (i32.const 1)) + (br_if $out5 (i32.const 2)) + (br_if $out5 (i32.const 3)) + ) + (unreachable) + ) + (block $out6 + (block $out7 + (br_if $out6 (i32.const 1)) + (br_if $out6 (i32.const 2)) + (br_if $out7 (i32.const 3)) + ) + (unreachable) + ) + (block $out8 + (br_if $out8 (call $b14)) ;; side effect + (br_if $out8 (i32.const 0)) + ) + (block $out8 + (br_if $out8 (i32.const 1)) + (br_if $out8 (call $b14)) ;; side effect + ) + ) +) + |