diff options
author | Alon Zakai <alonzakai@gmail.com> | 2018-04-30 19:40:30 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-30 19:40:30 -0700 |
commit | e020f4a2cb44fcbfd56c95a4a097f08cddc8367e (patch) | |
tree | 4bc1ff221fd7a0bad812c065bb205ee2fa870e30 /test/passes | |
parent | ec426c6b8ba87c5c5107ed30497ad13252dd3258 (diff) | |
download | binaryen-e020f4a2cb44fcbfd56c95a4a097f08cddc8367e.tar.gz binaryen-e020f4a2cb44fcbfd56c95a4a097f08cddc8367e.tar.bz2 binaryen-e020f4a2cb44fcbfd56c95a4a097f08cddc8367e.zip |
--simplify-locals-nonesting (#1525)
Add a version of simplify-locals which does not create nesting. This keeps the IR flat (in the sense of --flatten).
Also refactor simpify-locals to be a template, so the various modes are all template parameters.
Diffstat (limited to 'test/passes')
-rw-r--r-- | test/passes/converge_O3_metrics.bin.txt | 44 | ||||
-rw-r--r-- | test/passes/simplify-locals-nonesting.txt | 202 | ||||
-rw-r--r-- | test/passes/simplify-locals-nonesting.wast | 262 |
3 files changed, 479 insertions, 29 deletions
diff --git a/test/passes/converge_O3_metrics.bin.txt b/test/passes/converge_O3_metrics.bin.txt index ab88c57d0..452c2378d 100644 --- a/test/passes/converge_O3_metrics.bin.txt +++ b/test/passes/converge_O3_metrics.bin.txt @@ -2,15 +2,15 @@ total [funcs] : 9 [memory-data] : 28 [table-data] : 429 - [total] : 145 + [total] : 137 [vars] : 5 - binary : 14 + binary : 12 block : 9 break : 3 call : 3 call_import : 1 call_indirect : 4 - const : 50 + const : 48 drop : 3 get_global : 1 get_local : 20 @@ -18,7 +18,7 @@ total load : 16 loop : 1 set_global : 1 - set_local : 11 + set_local : 7 store : 5 (module (type $0 (func (param i32 i32) (result i32))) @@ -141,17 +141,7 @@ total ) (block $label$2 (if - (tee_local $0 - (i32.sub - (tee_local $0 - (i32.add - (get_local $0) - (i32.const 10888) - ) - ) - (i32.const 10888) - ) - ) + (get_local $0) (br_if $label$2 (call_indirect (type $1) (get_local $1) @@ -227,12 +217,10 @@ total (i32.const 1) (i32.add (i32.load offset=36 - (tee_local $0 - (i32.load - (i32.add - (get_local $0) - (i32.const 32) - ) + (i32.load + (i32.add + (get_local $0) + (i32.const 32) ) ) ) @@ -250,10 +238,8 @@ total (get_local $2) (i32.add (i32.load offset=36 - (tee_local $0 - (i32.load offset=32 - (get_local $0) - ) + (i32.load offset=32 + (get_local $0) ) ) (i32.const 8) @@ -267,15 +253,15 @@ total [funcs] : 9 [memory-data] : 28 [table-data] : 429 - [total] : 136 -9 + [total] : 136 -1 [vars] : 4 -1 - binary : 12 -2 + binary : 12 block : 9 break : 3 call : 3 call_import : 1 call_indirect : 4 - const : 48 -2 + const : 48 drop : 3 get_global : 1 get_local : 20 @@ -283,7 +269,7 @@ total load : 16 loop : 1 set_global : 1 - set_local : 6 -5 + set_local : 6 -1 store : 5 (module (type $0 (func (param i32 i32) (result i32))) diff --git a/test/passes/simplify-locals-nonesting.txt b/test/passes/simplify-locals-nonesting.txt new file mode 100644 index 000000000..903c97df5 --- /dev/null +++ b/test/passes/simplify-locals-nonesting.txt @@ -0,0 +1,202 @@ +(module + (type $0 (func (param i64 i64 i64) (result i32))) + (type $1 (func (param i32) (result i32))) + (func $figure-1a (; 0 ;) (type $0) (param $a i64) (param $x i64) (param $y i64) (result i32) + (local $i i32) + (local $j i32) + (local $r i32) + (local $6 i64) + (local $7 i64) + (local $8 i32) + (local $9 i64) + (local $10 i64) + (local $11 i32) + (local $12 i32) + (local $13 i32) + (local $14 i32) + (local $15 i32) + (local $16 i32) + (local $17 i32) + (block $block + (nop) + (nop) + (nop) + (nop) + (nop) + (nop) + (nop) + (nop) + (nop) + (nop) + (set_local $12 + (i64.eq + (get_local $a) + (get_local $x) + ) + ) + (set_local $13 + (i64.ne + (get_local $a) + (get_local $y) + ) + ) + (nop) + (nop) + (nop) + (set_local $15 + (i32.and + (get_local $12) + (get_local $13) + ) + ) + (return + (get_local $15) + ) + (unreachable) + ) + (nop) + (return + (get_local $16) + ) + ) + (func $figure-1b (; 1 ;) (type $0) (param $a i64) (param $x i64) (param $y i64) (result i32) + (local $i i32) + (local $j i32) + (local $r i32) + (local $6 i64) + (local $7 i64) + (local $8 i32) + (local $9 i64) + (local $10 i64) + (local $11 i32) + (local $12 i64) + (local $13 i64) + (local $14 i32) + (local $15 i32) + (local $16 i32) + (local $17 i32) + (local $18 i32) + (block $block + (nop) + (nop) + (set_local $8 + (i64.lt_s + (get_local $x) + (get_local $y) + ) + ) + (if + (get_local $8) + (block $block0 + (block $block1 + (nop) + (nop) + (nop) + (nop) + (nop) + (nop) + (nop) + (nop) + (nop) + (nop) + (set_local $15 + (i64.eq + (get_local $a) + (get_local $x) + ) + ) + (set_local $16 + (i64.ne + (get_local $a) + (get_local $y) + ) + ) + (nop) + (nop) + (nop) + (set_local $18 + (i32.and + (get_local $15) + (get_local $16) + ) + ) + (return + (get_local $18) + ) + (unreachable) + ) + (unreachable) + ) + (block $block2 + (unreachable) + (unreachable) + ) + ) + ) + (unreachable) + ) + (func $figure-3-if (; 2 ;) (type $1) (param $x i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + (local $8 i32) + (local $9 i32) + (local $10 i32) + (block $block + (block $block3 + (nop) + (set_local $2 + (i32.and + (get_local $x) + (i32.const 1) + ) + ) + (if + (get_local $2) + (block $block4 + (nop) + (nop) + (set_local $x + (i32.add + (get_local $x) + (i32.const 1) + ) + ) + (nop) + ) + (block $block5 + (nop) + (nop) + (set_local $x + (i32.add + (get_local $x) + (i32.const 2) + ) + ) + (nop) + ) + ) + ) + (nop) + (nop) + (set_local $8 + (i32.and + (get_local $x) + (i32.const 1) + ) + ) + (return + (get_local $8) + ) + (unreachable) + ) + (nop) + (return + (get_local $9) + ) + ) +) diff --git a/test/passes/simplify-locals-nonesting.wast b/test/passes/simplify-locals-nonesting.wast new file mode 100644 index 000000000..99fcbf4c6 --- /dev/null +++ b/test/passes/simplify-locals-nonesting.wast @@ -0,0 +1,262 @@ +(module + (type $0 (func (param i64 i64 i64) (result i32))) + (type $1 (func (param i32) (result i32))) + (func $figure-1a (; 0 ;) (type $0) (param $a i64) (param $x i64) (param $y i64) (result i32) + (local $i i32) + (local $j i32) + (local $r i32) + (local $6 i64) + (local $7 i64) + (local $8 i32) + (local $9 i64) + (local $10 i64) + (local $11 i32) + (local $12 i32) + (local $13 i32) + (local $14 i32) + (local $15 i32) + (local $16 i32) + (local $17 i32) + (block + (set_local $6 + (get_local $a) + ) + (set_local $7 + (get_local $x) + ) + (set_local $8 + (i64.eq + (get_local $6) + (get_local $7) + ) + ) + (set_local $i + (get_local $8) + ) + (nop) + (set_local $9 + (get_local $a) + ) + (set_local $10 + (get_local $y) + ) + (set_local $11 + (i64.ne + (get_local $9) + (get_local $10) + ) + ) + (set_local $j + (get_local $11) + ) + (nop) + (set_local $12 + (get_local $i) + ) + (set_local $13 + (get_local $j) + ) + (set_local $14 + (i32.and + (get_local $12) + (get_local $13) + ) + ) + (set_local $r + (get_local $14) + ) + (nop) + (set_local $15 + (get_local $r) + ) + (return + (get_local $15) + ) + (unreachable) + ) + (set_local $17 + (get_local $16) + ) + (return + (get_local $17) + ) + ) + (func $figure-1b (; 1 ;) (type $0) (param $a i64) (param $x i64) (param $y i64) (result i32) + (local $i i32) + (local $j i32) + (local $r i32) + (local $6 i64) + (local $7 i64) + (local $8 i32) + (local $9 i64) + (local $10 i64) + (local $11 i32) + (local $12 i64) + (local $13 i64) + (local $14 i32) + (local $15 i32) + (local $16 i32) + (local $17 i32) + (local $18 i32) + (block + (set_local $6 + (get_local $x) + ) + (set_local $7 + (get_local $y) + ) + (set_local $8 + (i64.lt_s + (get_local $6) + (get_local $7) + ) + ) + (if + (get_local $8) + (block + (block $block + (set_local $9 + (get_local $a) + ) + (set_local $10 + (get_local $x) + ) + (set_local $11 + (i64.eq + (get_local $9) + (get_local $10) + ) + ) + (set_local $i + (get_local $11) + ) + (nop) + (set_local $12 + (get_local $a) + ) + (set_local $13 + (get_local $y) + ) + (set_local $14 + (i64.ne + (get_local $12) + (get_local $13) + ) + ) + (set_local $j + (get_local $14) + ) + (nop) + (set_local $15 + (get_local $i) + ) + (set_local $16 + (get_local $j) + ) + (set_local $17 + (i32.and + (get_local $15) + (get_local $16) + ) + ) + (set_local $r + (get_local $17) + ) + (nop) + (set_local $18 + (get_local $r) + ) + (return + (get_local $18) + ) + (unreachable) + ) + (unreachable) + ) + (block + (unreachable) + (unreachable) + ) + ) + ) + (unreachable) + ) + (func $figure-3-if (; 2 ;) (type $1) (param $x i32) (result i32) + (local $1 i32) + (local $2 i32) + (local $3 i32) + (local $4 i32) + (local $5 i32) + (local $6 i32) + (local $7 i32) + (local $8 i32) + (local $9 i32) + (local $10 i32) + (block + (block + (set_local $1 + (get_local $x) + ) + (set_local $2 + (i32.and + (get_local $1) + (i32.const 1) + ) + ) + (if + (get_local $2) + (block + (set_local $3 + (get_local $x) + ) + (set_local $4 + (i32.add + (get_local $3) + (i32.const 1) + ) + ) + (set_local $x + (get_local $4) + ) + (nop) + ) + (block + (set_local $5 + (get_local $x) + ) + (set_local $6 + (i32.add + (get_local $5) + (i32.const 2) + ) + ) + (set_local $x + (get_local $6) + ) + (nop) + ) + ) + ) + (nop) + (set_local $7 + (get_local $x) + ) + (set_local $8 + (i32.and + (get_local $7) + (i32.const 1) + ) + ) + (return + (get_local $8) + ) + (unreachable) + ) + (set_local $10 + (get_local $9) + ) + (return + (get_local $10) + ) + ) +) |