summaryrefslogtreecommitdiff
path: root/test/passes
diff options
context:
space:
mode:
Diffstat (limited to 'test/passes')
-rw-r--r--test/passes/simplify-locals.txt104
-rw-r--r--test/passes/simplify-locals.wast64
2 files changed, 153 insertions, 15 deletions
diff --git a/test/passes/simplify-locals.txt b/test/passes/simplify-locals.txt
index a84ac43a0..cc84c35d5 100644
--- a/test/passes/simplify-locals.txt
+++ b/test/passes/simplify-locals.txt
@@ -71,9 +71,7 @@
(i32.const 48)
(i32.const 96)
)
- (set_local $a
- (i32.const 17)
- )
+ (i32.const 17)
(i32.const 18)
)
(block $block3
@@ -183,18 +181,17 @@
(call_import $waka)
)
(block $out-of-block
- (set_local $a
- (i32.const 1337)
- )
+ (nop)
+ (nop)
(block $b
(block $c
- (br $b)
- )
- (set_local $a
- (i32.const 9876)
+ (br $b
+ (i32.const 1337)
+ )
)
+ (nop)
+ (i32.const 9876)
)
- (get_local $a)
)
(block $loopey
(set_local $a
@@ -213,13 +210,11 @@
(local $b i32)
(block $switch$0
(block $switch-default$6
- (set_local $b
- (i32.const 60)
- )
+ (nop)
)
)
(return
- (get_local $b)
+ (i32.const 60)
)
)
(func $memories (param $i2 i32) (param $i3 i32) (param $bi2 i32) (param $bi3 i32) (param $ci3 i32) (param $di3 i32)
@@ -443,4 +438,83 @@
)
)
)
+ (func $block-returns
+ (local $x i32)
+ (set_local $x
+ (block $out
+ (nop)
+ (br_if $out
+ (block $waka
+ (nop)
+ (br_if $waka
+ (i32.const 12)
+ (i32.const 1)
+ )
+ (nop)
+ (i32.const 34)
+ )
+ (i32.const 1)
+ )
+ (get_local $x)
+ (block $waka2
+ (set_local $x
+ (if
+ (i32.const 1)
+ (block
+ (nop)
+ (i32.const 13)
+ )
+ (block
+ (nop)
+ (i32.const 24)
+ )
+ )
+ )
+ (nop)
+ )
+ (br_if $out
+ (if
+ (i32.const 1)
+ (block $block3
+ (nop)
+ (i32.const 14)
+ )
+ (block $block5
+ (nop)
+ (i32.const 25)
+ )
+ )
+ (i32.const 1)
+ )
+ (block $sink-out-of-me-i-have-but-one-exit
+ (nop)
+ )
+ (nop)
+ (i32.const 99)
+ )
+ )
+ )
+ (func $multiple (param $s i32) (param $r i32) (param $f i32) (param $p i32) (param $t i32) (param $m i32)
+ (nop)
+ (set_local $r
+ (i32.add
+ (get_local $f)
+ (get_local $p)
+ )
+ )
+ (set_local $t
+ (get_local $p)
+ )
+ (set_local $p
+ (i32.load
+ (i32.const 0)
+ )
+ )
+ (i32.store
+ (get_local $r)
+ (get_local $t)
+ )
+ (get_local $m)
+ (get_local $t)
+ )
)
diff --git a/test/passes/simplify-locals.wast b/test/passes/simplify-locals.wast
index 1b71c46b5..5f1db4bdb 100644
--- a/test/passes/simplify-locals.wast
+++ b/test/passes/simplify-locals.wast
@@ -387,5 +387,69 @@
)
)
)
+ (func $block-returns
+ (local $x i32)
+ (block $out
+ (block $waka
+ (set_local $x (i32.const 12))
+ (br_if $waka
+ (i32.const 1)
+ )
+ (set_local $x (i32.const 34))
+ )
+ (br_if $out ;; barrier
+ (i32.const 1)
+ )
+ (get_local $x) ;; a use, so setlocals are not all killed
+ (block $waka2
+ (if
+ (i32.const 1)
+ (set_local $x (i32.const 13))
+ (set_local $x (i32.const 24))
+ )
+ (if
+ (i32.const 1)
+ (block
+ (set_local $x (i32.const 14))
+ )
+ (block
+ (set_local $x (i32.const 25))
+ )
+ )
+ )
+ (br_if $out ;; barrier
+ (i32.const 1)
+ )
+ (block $sink-out-of-me-i-have-but-one-exit
+ (set_local $x (i32.const 99))
+ )
+ (get_local $x)
+ )
+ )
+ (func $multiple (param $s i32) (param $r i32) (param $f i32) (param $p i32) (param $t i32) (param $m i32)
+ (set_local $s
+ (get_local $m)
+ )
+ (set_local $r
+ (i32.add
+ (get_local $f)
+ (get_local $p)
+ )
+ )
+ (set_local $t ;; t is equal to p's original value; p must not be set to before t gets that value
+ (get_local $p)
+ )
+ (set_local $p
+ (i32.load
+ (i32.const r)
+ )
+ )
+ (i32.store
+ (get_local $r)
+ (get_local $t)
+ )
+ (get_local $s)
+ (get_local $t)
+ )
)