summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/passes/simplify-locals.txt49
-rw-r--r--test/passes/simplify-locals.wast47
2 files changed, 96 insertions, 0 deletions
diff --git a/test/passes/simplify-locals.txt b/test/passes/simplify-locals.txt
index ae1e1ddba..9e5891434 100644
--- a/test/passes/simplify-locals.txt
+++ b/test/passes/simplify-locals.txt
@@ -1024,4 +1024,53 @@
(get_local $x)
)
)
+ (func $br-value-reordering (type $FUNCSIG$i) (result i32)
+ (local $temp i32)
+ (block $outside
+ (loop $loop
+ (br_if $outside
+ (block $block (result i32)
+ (br_if $loop
+ (get_local $temp)
+ )
+ (unreachable)
+ (set_local $temp
+ (i32.const -1)
+ )
+ (i32.const 0)
+ )
+ )
+ )
+ (set_local $temp
+ (i32.const -1)
+ )
+ )
+ (unreachable)
+ )
+ (func $br-value-reordering-safe (type $FUNCSIG$i) (result i32)
+ (local $temp i32)
+ (set_local $temp
+ (block $outside (result i32)
+ (loop $loop
+ (drop
+ (get_local $temp)
+ )
+ (drop
+ (br_if $outside
+ (tee_local $temp
+ (i32.const -1)
+ )
+ (block $block (result i32)
+ (nop)
+ (i32.const 0)
+ )
+ )
+ )
+ )
+ (nop)
+ (i32.const -1)
+ )
+ )
+ (unreachable)
+ )
)
diff --git a/test/passes/simplify-locals.wast b/test/passes/simplify-locals.wast
index 10fcf1277..842e2b5af 100644
--- a/test/passes/simplify-locals.wast
+++ b/test/passes/simplify-locals.wast
@@ -940,4 +940,51 @@
(drop (i32.atomic.load (i32.const 1028)))
(drop (get_local $x))
)
+ (func $br-value-reordering (result i32)
+ (local $temp i32)
+ (block $outside
+ (loop $loop ;; we should exit this loop, hit the unreachable outside
+ ;; loop logic
+ (br_if $outside ;; we should not create a block value that adds a value to a br, if the value&condition of the br cannot be reordered,
+ ;; as the value comes first
+ (block (result i32)
+ (br_if $loop
+ (get_local $temp) ;; false, don't loop
+ )
+ (unreachable) ;; the end
+ (set_local $temp
+ (i32.const -1)
+ )
+ (i32.const 0)
+ )
+ )
+ )
+ (set_local $temp
+ (i32.const -1)
+ )
+ )
+ (unreachable)
+ )
+ (func $br-value-reordering-safe (result i32)
+ (local $temp i32)
+ (block $outside
+ (loop $loop ;; we should exit this loop, hit the unreachable outside
+ ;; loop logic
+ (drop (get_local $temp)) ;; different from above - add a use here
+ (br_if $outside ;; we should not create a block value that adds a value to a br, if the value&condition of the br cannot be reordered,
+ ;; as the value comes first
+ (block (result i32)
+ (set_local $temp ;; the use *is* in the condition, but it's ok, no conflicts
+ (i32.const -1)
+ )
+ (i32.const 0)
+ )
+ )
+ )
+ (set_local $temp
+ (i32.const -1)
+ )
+ )
+ (unreachable)
+ )
)