summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2018-11-14 16:26:56 -0800
committerGitHub <noreply@github.com>2018-11-14 16:26:56 -0800
commit4442d98dbfcd54c8e920bd11bb376a1003957daa (patch)
tree852b7a3f03f56ba57c93e65b5a7687379654682e /test
parent145846c563e06a82309a48437b8abb050054812f (diff)
downloadbinaryen-4442d98dbfcd54c8e920bd11bb376a1003957daa.tar.gz
binaryen-4442d98dbfcd54c8e920bd11bb376a1003957daa.tar.bz2
binaryen-4442d98dbfcd54c8e920bd11bb376a1003957daa.zip
Restructure ifs with a value (#1743)
We previously had code to recreate an if from a block+branch when possible, but not when the block had a return value. This PR adds support to restructure that too, into an if with a value.
Diffstat (limited to 'test')
-rw-r--r--test/passes/remove-unused-brs.txt57
-rw-r--r--test/passes/remove-unused-brs.wast56
2 files changed, 113 insertions, 0 deletions
diff --git a/test/passes/remove-unused-brs.txt b/test/passes/remove-unused-brs.txt
index b5bcce9f2..03eb7b716 100644
--- a/test/passes/remove-unused-brs.txt
+++ b/test/passes/remove-unused-brs.txt
@@ -1946,4 +1946,61 @@
)
)
)
+ (func $drop-restructure-if (; 81 ;) (type $3) (param $x i32) (param $y i32) (result i32)
+ (if (result i32)
+ (get_local $y)
+ (get_local $x)
+ (block $label$2 (result i32)
+ (nop)
+ (i32.const 0)
+ )
+ )
+ )
+ (func $drop-restructure-if-final (; 82 ;) (type $3) (param $x i32) (param $y i32) (result i32)
+ (if (result i32)
+ (get_local $y)
+ (get_local $x)
+ (block $label$2 (result i32)
+ (nop)
+ (unreachable)
+ )
+ )
+ )
+ (func $drop-restructure-if-middle (; 83 ;) (type $3) (param $x i32) (param $y i32) (result i32)
+ (if (result i32)
+ (get_local $y)
+ (get_local $x)
+ (block $label$2 (result i32)
+ (nop)
+ (nop)
+ (i32.const 0)
+ )
+ )
+ )
+ (func $drop-restructure-if-bad (; 84 ;) (type $3) (param $x i32) (param $y i32) (result i32)
+ (block $label$2 (result i32)
+ (drop
+ (br_if $label$2
+ (tee_local $y
+ (get_local $x)
+ )
+ (get_local $y)
+ )
+ )
+ (i32.const 0)
+ )
+ )
+ (func $drop-restructure-if-bad-2 (; 85 ;) (type $3) (param $x i32) (param $y i32) (result i32)
+ (block $label$2 (result i32)
+ (drop
+ (br_if $label$2
+ (get_local $y)
+ (tee_local $y
+ (get_local $x)
+ )
+ )
+ )
+ (i32.const 0)
+ )
+ )
)
diff --git a/test/passes/remove-unused-brs.wast b/test/passes/remove-unused-brs.wast
index 8325b47ac..7f77fd00c 100644
--- a/test/passes/remove-unused-brs.wast
+++ b/test/passes/remove-unused-brs.wast
@@ -1561,5 +1561,61 @@
)
)
)
+ (func $drop-restructure-if (param $x i32) (param $y i32) (result i32)
+ (block $label$2 (result i32)
+ (drop
+ (br_if $label$2
+ (get_local $x)
+ (get_local $y)
+ )
+ )
+ (i32.const 0)
+ )
+ )
+ (func $drop-restructure-if-final (param $x i32) (param $y i32) (result i32)
+ (block $label$2 (result i32)
+ (drop
+ (br_if $label$2
+ (get_local $x)
+ (get_local $y)
+ )
+ )
+ (unreachable)
+ )
+ )
+ (func $drop-restructure-if-middle (param $x i32) (param $y i32) (result i32)
+ (block $label$2 (result i32)
+ (drop
+ (br_if $label$2
+ (get_local $x)
+ (get_local $y)
+ )
+ )
+ (nop) ;; the middle
+ (i32.const 0)
+ )
+ )
+ (func $drop-restructure-if-bad (param $x i32) (param $y i32) (result i32)
+ (block $label$2 (result i32)
+ (drop
+ (br_if $label$2
+ (tee_local $y (get_local $x))
+ (get_local $y)
+ )
+ )
+ (i32.const 0)
+ )
+ )
+ (func $drop-restructure-if-bad-2 (param $x i32) (param $y i32) (result i32)
+ (block $label$2 (result i32)
+ (drop
+ (br_if $label$2
+ (get_local $y)
+ (tee_local $y (get_local $x))
+ )
+ )
+ (i32.const 0)
+ )
+ )
)