summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/passes/ssa.txt36
-rw-r--r--test/passes/ssa.wast28
2 files changed, 64 insertions, 0 deletions
diff --git a/test/passes/ssa.txt b/test/passes/ssa.txt
index d3f9140af..916fed54a 100644
--- a/test/passes/ssa.txt
+++ b/test/passes/ssa.txt
@@ -1,6 +1,8 @@
(module
(type $0 (func (param i32)))
(type $1 (func))
+ (type $2 (func (result i32)))
+ (global $global$0 (mut i32) (i32.const 1))
(memory $0 0)
(func $basics (type $0) (param $x i32)
(local $y i32)
@@ -691,4 +693,38 @@
)
)
)
+ (func $func_6 (type $2) (result i32)
+ (local $result i32)
+ (local $zero i32)
+ (local $2 i32)
+ (local $3 i32)
+ (local $4 i32)
+ (loop $label$1
+ (if
+ (i32.eqz
+ (get_global $global$0)
+ )
+ (return
+ (get_local $4)
+ )
+ )
+ (set_global $global$0
+ (i32.const 0)
+ )
+ (set_local $2
+ (tee_local $4
+ (i32.const 1)
+ )
+ )
+ (br_if $label$1
+ (i32.const 0)
+ )
+ (set_local $3
+ (tee_local $4
+ (i32.const 0)
+ )
+ )
+ (br $label$1)
+ )
+ )
)
diff --git a/test/passes/ssa.wast b/test/passes/ssa.wast
index fe78aecb5..e51189b5e 100644
--- a/test/passes/ssa.wast
+++ b/test/passes/ssa.wast
@@ -1,4 +1,5 @@
(module
+ (global $global$0 (mut i32) (i32.const 1))
(func $basics (param $x i32)
(local $y i32)
(local $z f32)
@@ -311,5 +312,32 @@
)
(drop (get_local $x)) ;; can receive from either set, or input param
)
+ (func $func_6 (result i32)
+ (local $result i32)
+ (local $zero i32)
+ (loop $label$1
+ (if
+ (i32.eqz
+ (get_global $global$0)
+ )
+ (return
+ (get_local $result) ;; we eventually reach here
+ )
+ )
+ (set_global $global$0
+ (i32.const 0) ;; tell next iteration to return
+ )
+ (set_local $result
+ (i32.const 1) ;; set the return value to 1, temporarily
+ )
+ (br_if $label$1
+ (i32.const 0) ;; don't do anything here
+ )
+ (set_local $result
+ (get_local $zero) ;; set it to zero instead
+ )
+ (br $label$1) ;; back to the top, where we will return the zero
+ )
+ )
)