diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/passes/Oz.txt | 55 | ||||
-rw-r--r-- | test/passes/Oz.wast | 57 | ||||
-rw-r--r-- | test/passes/local-cse.txt | 183 | ||||
-rw-r--r-- | test/passes/local-cse.wast | 163 | ||||
-rw-r--r-- | test/passes/local-cse_ignore-implicit-traps.txt | 30 | ||||
-rw-r--r-- | test/passes/local-cse_ignore-implicit-traps.wast | 20 |
6 files changed, 508 insertions, 0 deletions
diff --git a/test/passes/Oz.txt b/test/passes/Oz.txt new file mode 100644 index 000000000..7dd706ac2 --- /dev/null +++ b/test/passes/Oz.txt @@ -0,0 +1,55 @@ +(module + (type $0 (func (param i32 i32) (result i32))) + (type $1 (func (param i32) (result i32))) + (memory $0 100 100) + (export "localcse" (func $basics)) + (export "localcse-2" (func $8)) + (func $basics (type $0) (param $0 i32) (param $1 i32) (result i32) + (local $2 i32) + (i32.add + (tee_local $2 + (i32.add + (get_local $0) + (get_local $1) + ) + ) + (get_local $2) + ) + ) + (func $8 (type $1) (param $0 i32) (result i32) + (local $1 i32) + (i32.store + (tee_local $0 + (tee_local $1 + (i32.add + (get_local $1) + (i32.const 4) + ) + ) + ) + (i32.and + (i32.load + (get_local $0) + ) + (i32.xor + (tee_local $0 + (i32.const 74) + ) + (i32.const -1) + ) + ) + ) + (i32.store + (get_local $1) + (i32.or + (i32.load + (get_local $1) + ) + (i32.and + (get_local $0) + (i32.const 8) + ) + ) + ) + ) +) diff --git a/test/passes/Oz.wast b/test/passes/Oz.wast new file mode 100644 index 000000000..fc465669e --- /dev/null +++ b/test/passes/Oz.wast @@ -0,0 +1,57 @@ +(module + (memory 100 100) + (func $basics (export "localcse") (param $x i32) ($param $y i32) (result i32) ;; -O3 does localcse + (local $x2 i32) + (local $y2 i32) + (set_local $x2 + (i32.add (get_local $x) (get_local $y)) + ) + (set_local $y2 + (i32.add (get_local $x) (get_local $y)) + ) + (i32.add (get_local $x2) (get_local $y2)) + ) + (func $8 (export "localcse-2") (param $var$0 i32) (result i32) + (local $var$1 i32) + (local $var$2 i32) + (local $var$3 i32) + (block $label$0 i32 + (i32.store + (tee_local $var$2 + (i32.add + (get_local $var$1) + (i32.const 4) + ) + ) + (i32.and + (i32.load + (get_local $var$2) + ) + (i32.xor + (tee_local $var$2 + (i32.const 74) + ) + (i32.const -1) + ) + ) + ) + (i32.store + (tee_local $var$1 + (i32.add + (get_local $var$1) + (i32.const 4) + ) + ) + (i32.or + (i32.load + (get_local $var$1) + ) + (i32.and + (get_local $var$2) + (i32.const 8) + ) + ) + ) + ) + ) +) diff --git a/test/passes/local-cse.txt b/test/passes/local-cse.txt new file mode 100644 index 000000000..1b740236e --- /dev/null +++ b/test/passes/local-cse.txt @@ -0,0 +1,183 @@ +(module + (type $0 (func)) + (type $1 (func (param i32) (result i32))) + (memory $0 100 100) + (func $basics (type $0) + (local $x i32) + (local $y i32) + (local $2 i32) + (local $3 i32) + (drop + (tee_local $2 + (i32.add + (i32.const 1) + (i32.const 2) + ) + ) + ) + (drop + (get_local $2) + ) + (if + (i32.const 0) + (nop) + ) + (drop + (i32.add + (i32.const 1) + (i32.const 2) + ) + ) + (drop + (tee_local $3 + (i32.add + (get_local $x) + (get_local $y) + ) + ) + ) + (drop + (get_local $3) + ) + (drop + (get_local $3) + ) + (call $basics) + (drop + (get_local $3) + ) + (set_local $x + (i32.const 100) + ) + (drop + (i32.add + (get_local $x) + (get_local $y) + ) + ) + ) + (func $recursive1 (type $0) + (local $x i32) + (local $y i32) + (local $2 i32) + (drop + (i32.add + (i32.const 1) + (tee_local $2 + (i32.add + (i32.const 2) + (i32.const 3) + ) + ) + ) + ) + (drop + (i32.add + (i32.const 1) + (get_local $2) + ) + ) + (drop + (get_local $2) + ) + ) + (func $recursive2 (type $0) + (local $x i32) + (local $y i32) + (local $2 i32) + (drop + (i32.add + (i32.const 1) + (tee_local $2 + (i32.add + (i32.const 2) + (i32.const 3) + ) + ) + ) + ) + (drop + (get_local $2) + ) + (drop + (i32.add + (i32.const 1) + (get_local $2) + ) + ) + ) + (func $self (type $0) + (local $x i32) + (local $y i32) + (local $2 i32) + (drop + (i32.add + (tee_local $2 + (i32.add + (i32.const 2) + (i32.const 3) + ) + ) + (get_local $2) + ) + ) + (drop + (get_local $2) + ) + ) + (func $loads (type $0) + (drop + (i32.load + (i32.const 10) + ) + ) + (drop + (i32.load + (i32.const 10) + ) + ) + ) + (func $8 (type $1) (param $var$0 i32) (result i32) + (local $var$1 i32) + (local $var$2 i32) + (local $var$3 i32) + (local $4 i32) + (block $label$0 i32 + (i32.store + (tee_local $var$2 + (tee_local $4 + (i32.add + (get_local $var$1) + (i32.const 4) + ) + ) + ) + (i32.and + (i32.load + (get_local $var$2) + ) + (i32.xor + (tee_local $var$2 + (i32.const 74) + ) + (i32.const -1) + ) + ) + ) + (i32.store + (tee_local $var$1 + (get_local $4) + ) + (i32.or + (i32.load + (get_local $var$1) + ) + (i32.and + (get_local $var$2) + (i32.const 8) + ) + ) + ) + ) + ) +) diff --git a/test/passes/local-cse.wast b/test/passes/local-cse.wast new file mode 100644 index 000000000..b1155ce9d --- /dev/null +++ b/test/passes/local-cse.wast @@ -0,0 +1,163 @@ +(module + (memory 100 100) + (func $basics + (local $x i32) + (local $y i32) + (drop + (i32.add (i32.const 1) (i32.const 2)) + ) + (drop + (i32.add (i32.const 1) (i32.const 2)) + ) + (if (i32.const 0) (nop)) + (drop ;; we can't do this yet, non-linear + (i32.add (i32.const 1) (i32.const 2)) + ) + (drop + (i32.add (get_local $x) (get_local $y)) + ) + (drop + (i32.add (get_local $x) (get_local $y)) + ) + (drop + (i32.add (get_local $x) (get_local $y)) + ) + (call $basics) ;; side effects, but no matter for our locals + (drop + (i32.add (get_local $x) (get_local $y)) + ) + (set_local $x (i32.const 100)) + (drop ;; x was changed! + (i32.add (get_local $x) (get_local $y)) + ) + ) + (func $recursive1 + (local $x i32) + (local $y i32) + (drop + (i32.add + (i32.const 1) + (i32.add + (i32.const 2) + (i32.const 3) + ) + ) + ) + (drop + (i32.add + (i32.const 1) + (i32.add + (i32.const 2) + (i32.const 3) + ) + ) + ) + (drop + (i32.add + (i32.const 2) + (i32.const 3) + ) + ) + ) + (func $recursive2 + (local $x i32) + (local $y i32) + (drop + (i32.add + (i32.const 1) + (i32.add + (i32.const 2) + (i32.const 3) + ) + ) + ) + (drop + (i32.add + (i32.const 2) + (i32.const 3) + ) + ) + (drop + (i32.add + (i32.const 1) + (i32.add + (i32.const 2) + (i32.const 3) + ) + ) + ) + ) + (func $self + (local $x i32) + (local $y i32) + (drop + (i32.add + (i32.add + (i32.const 2) + (i32.const 3) + ) + (i32.add + (i32.const 2) + (i32.const 3) + ) + ) + ) + (drop + (i32.add + (i32.const 2) + (i32.const 3) + ) + ) + ) + (func $loads + (drop + (i32.load (i32.const 10)) + ) + (drop + (i32.load (i32.const 10)) ;; implicit traps, sad + ) + ) + (func $8 (param $var$0 i32) (result i32) + (local $var$1 i32) + (local $var$2 i32) + (local $var$3 i32) + (block $label$0 i32 + (i32.store + (tee_local $var$2 + (i32.add + (get_local $var$1) + (i32.const 4) + ) + ) + (i32.and + (i32.load + (get_local $var$2) + ) + (i32.xor + (tee_local $var$2 + (i32.const 74) + ) + (i32.const -1) + ) + ) + ) + (i32.store + (tee_local $var$1 + (i32.add + (get_local $var$1) + (i32.const 4) + ) + ) + (i32.or + (i32.load + (get_local $var$1) + ) + (i32.and + (get_local $var$2) + (i32.const 8) + ) + ) + ) + ) + ) +) diff --git a/test/passes/local-cse_ignore-implicit-traps.txt b/test/passes/local-cse_ignore-implicit-traps.txt new file mode 100644 index 000000000..7b8ebba69 --- /dev/null +++ b/test/passes/local-cse_ignore-implicit-traps.txt @@ -0,0 +1,30 @@ +(module + (type $0 (func)) + (memory $0 100 100) + (func $loads (type $0) + (local $0 i32) + (drop + (tee_local $0 + (i32.load + (i32.const 10) + ) + ) + ) + (drop + (get_local $0) + ) + (drop + (i32.load offset=5 + (i32.const 10) + ) + ) + (drop + (i32.load + (i32.const 11) + ) + ) + (drop + (get_local $0) + ) + ) +) diff --git a/test/passes/local-cse_ignore-implicit-traps.wast b/test/passes/local-cse_ignore-implicit-traps.wast new file mode 100644 index 000000000..0f22084c6 --- /dev/null +++ b/test/passes/local-cse_ignore-implicit-traps.wast @@ -0,0 +1,20 @@ +(module + (memory 100 100) + (func $loads + (drop + (i32.load (i32.const 10)) + ) + (drop + (i32.load (i32.const 10)) + ) + (drop + (i32.load offset=5 (i32.const 10)) + ) + (drop + (i32.load (i32.const 11)) + ) + (drop + (i32.load (i32.const 10)) + ) + ) +) |