summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/passes/ssa.txt91
-rw-r--r--test/passes/ssa.wast44
2 files changed, 125 insertions, 10 deletions
diff --git a/test/passes/ssa.txt b/test/passes/ssa.txt
index 657ccc128..e6883c0f8 100644
--- a/test/passes/ssa.txt
+++ b/test/passes/ssa.txt
@@ -442,9 +442,12 @@
(local $4 i32)
(local $5 i32)
(local $6 i32)
+ (local $7 i32)
(set_local $3
- (tee_local $6
- (get_local $param)
+ (tee_local $7
+ (tee_local $6
+ (get_local $param)
+ )
)
)
(loop $more
@@ -460,15 +463,17 @@
)
)
(set_local $5
- (tee_local $6
- (get_local $4)
+ (tee_local $7
+ (tee_local $6
+ (get_local $4)
+ )
)
)
(br $more)
)
)
(drop
- (get_local $6)
+ (get_local $7)
)
)
(func $real-loop-outblock (; 9 ;) (type $0) (param $param i32)
@@ -478,9 +483,12 @@
(local $4 i32)
(local $5 i32)
(local $6 i32)
+ (local $7 i32)
(set_local $3
- (tee_local $6
- (get_local $param)
+ (tee_local $7
+ (tee_local $6
+ (get_local $param)
+ )
)
)
(block $stop
@@ -496,15 +504,17 @@
)
)
(set_local $5
- (tee_local $6
- (get_local $4)
+ (tee_local $7
+ (tee_local $6
+ (get_local $4)
+ )
)
)
(br $more)
)
)
(drop
- (get_local $6)
+ (get_local $7)
)
)
(func $loop-loop-param (; 10 ;) (type $0) (param $param i32)
@@ -726,4 +736,65 @@
(br $label$1)
)
)
+ (func $ssa-merge-tricky (; 15 ;) (type $2) (result i32)
+ (local $var$0 i32)
+ (local $var$1 i32)
+ (local $2 i32)
+ (local $3 i32)
+ (local $4 i32)
+ (local $5 i32)
+ (local $6 i32)
+ (local $7 i32)
+ (local $8 i32)
+ (set_local $2
+ (tee_local $8
+ (tee_local $3
+ (tee_local $7
+ (i32.const 0)
+ )
+ )
+ )
+ )
+ (loop $label$1
+ (if
+ (i32.eqz
+ (get_global $global$0)
+ )
+ (return
+ (i32.const 12345)
+ )
+ )
+ (set_global $global$0
+ (i32.const 0)
+ )
+ (if
+ (i32.eqz
+ (get_local $7)
+ )
+ (br_if $label$1
+ (i32.eqz
+ (tee_local $4
+ (tee_local $7
+ (i32.const 1)
+ )
+ )
+ )
+ )
+ )
+ (br_if $label$1
+ (i32.eqz
+ (tee_local $5
+ (tee_local $8
+ (tee_local $6
+ (tee_local $7
+ (get_local $8)
+ )
+ )
+ )
+ )
+ )
+ )
+ )
+ (i32.const -54)
+ )
)
diff --git a/test/passes/ssa.wast b/test/passes/ssa.wast
index e51189b5e..7c8617103 100644
--- a/test/passes/ssa.wast
+++ b/test/passes/ssa.wast
@@ -339,5 +339,49 @@
(br $label$1) ;; back to the top, where we will return the zero
)
)
+ (func $ssa-merge-tricky (result i32)
+ (local $var$0 i32)
+ (local $var$1 i32)
+ (set_local $var$1
+ (tee_local $var$0
+ (i32.const 0) ;; both vars start out identical
+ )
+ )
+ (loop $label$1
+ (if
+ (i32.eqz
+ (get_global $global$0)
+ )
+ (return
+ (i32.const 12345)
+ )
+ )
+ (set_global $global$0
+ (i32.const 0)
+ )
+ (if
+ (i32.eqz
+ (get_local $var$0) ;; check $0 here. this will get a phi var
+ )
+ (br_if $label$1
+ (i32.eqz
+ (tee_local $var$0 ;; set $0 to 1. here the two diverge. for the phi, we'll get a set here and above
+ (i32.const 1)
+ )
+ )
+ )
+ )
+ (br_if $label$1
+ (i32.eqz ;; indeed equal, enter loop again, and then hang prevention kicks in
+ (tee_local $var$1 ;; set them all to 0
+ (tee_local $var$0
+ (get_local $var$1) ;; this must get $1, not the phis, as even though the sets appear in both sources, we only execute 1.
+ )
+ )
+ )
+ )
+ )
+ (i32.const -54)
+ )
)