diff options
author | Alon Zakai <alonzakai@gmail.com> | 2018-04-26 14:42:40 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-26 14:42:40 -0700 |
commit | 353be4a0537de508f45ee72624d1af65bd5597dd (patch) | |
tree | a31124c5fc3a4b8fad604e52f5fc3fc25c754ffc /test/passes | |
parent | 14552064348c08159d6f8562a872c1be69e669b0 (diff) | |
download | binaryen-353be4a0537de508f45ee72624d1af65bd5597dd.tar.gz binaryen-353be4a0537de508f45ee72624d1af65bd5597dd.tar.bz2 binaryen-353be4a0537de508f45ee72624d1af65bd5597dd.zip |
Improve precompute-propagate (#1514)
Propagate constants through a tee_local. Found by Souper. Details in patch comments - basically we didn't differentiate precomputing a value and an expression.
Diffstat (limited to 'test/passes')
-rw-r--r-- | test/passes/precompute-propagate.txt | 23 | ||||
-rw-r--r-- | test/passes/precompute-propagate.wast | 28 |
2 files changed, 51 insertions, 0 deletions
diff --git a/test/passes/precompute-propagate.txt b/test/passes/precompute-propagate.txt index 262b4880c..15abe1f2e 100644 --- a/test/passes/precompute-propagate.txt +++ b/test/passes/precompute-propagate.txt @@ -1,6 +1,7 @@ (module (type $0 (func (param i32))) (type $1 (func (param i32) (result i32))) + (type $2 (func (param i32 i32) (result i32))) (func $basic (; 0 ;) (type $0) (param $p i32) (local $x i32) (set_local $x @@ -210,4 +211,26 @@ (br $loop) ) ) + (func $through-tee (; 13 ;) (type $2) (param $x i32) (param $y i32) (result i32) + (set_local $x + (tee_local $y + (i32.const 7) + ) + ) + (return + (i32.const 14) + ) + ) + (func $through-tee-more (; 14 ;) (type $2) (param $x i32) (param $y i32) (result i32) + (set_local $x + (i32.eqz + (tee_local $y + (i32.const 7) + ) + ) + ) + (return + (i32.const 7) + ) + ) ) diff --git a/test/passes/precompute-propagate.wast b/test/passes/precompute-propagate.wast index af1a21ba2..4cf440829 100644 --- a/test/passes/precompute-propagate.wast +++ b/test/passes/precompute-propagate.wast @@ -109,5 +109,33 @@ (br $loop) ) ) + (func $through-tee (param $x i32) (param $y i32) (result i32) + (set_local $x + (tee_local $y + (i32.const 7) + ) + ) + (return + (i32.add + (get_local $x) + (get_local $y) + ) + ) + ) + (func $through-tee-more (param $x i32) (param $y i32) (result i32) + (set_local $x + (i32.eqz + (tee_local $y + (i32.const 7) + ) + ) + ) + (return + (i32.add + (get_local $x) + (get_local $y) + ) + ) + ) ) |