summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2019-04-29 10:15:42 -0700
committerGitHub <noreply@github.com>2019-04-29 10:15:42 -0700
commitba8cade3019758243ebda74c1a563e38687d4ba9 (patch)
treef811fd06d7d163b944838c72599f78972e259591 /test
parent7c3d4cd8d9f102af24ad32f6bf86e79a4f850c4f (diff)
downloadbinaryen-ba8cade3019758243ebda74c1a563e38687d4ba9.tar.gz
binaryen-ba8cade3019758243ebda74c1a563e38687d4ba9.tar.bz2
binaryen-ba8cade3019758243ebda74c1a563e38687d4ba9.zip
Properly handle optimizing out a set from inside the value of another set in SimplifyLocals (#2064)
Details in lengthy comment in the source. Fixes #2063
Diffstat (limited to 'test')
-rw-r--r--test/passes/simplify-locals.txt22
-rw-r--r--test/passes/simplify-locals.wast29
2 files changed, 51 insertions, 0 deletions
diff --git a/test/passes/simplify-locals.txt b/test/passes/simplify-locals.txt
new file mode 100644
index 000000000..b743ea528
--- /dev/null
+++ b/test/passes/simplify-locals.txt
@@ -0,0 +1,22 @@
+(module
+ (type $0 (func (result i32)))
+ (func $sink-from-inside (; 0 ;) (type $0) (result i32)
+ (local $0 i32)
+ (local $1 i32)
+ (local $2 i32)
+ (nop)
+ (i32.and
+ (select
+ (i32.const 0)
+ (i32.const 1)
+ (i32.const 1)
+ )
+ (block $block (result i32)
+ (nop)
+ (nop)
+ (nop)
+ (i32.const 1)
+ )
+ )
+ )
+)
diff --git a/test/passes/simplify-locals.wast b/test/passes/simplify-locals.wast
new file mode 100644
index 000000000..3208b76de
--- /dev/null
+++ b/test/passes/simplify-locals.wast
@@ -0,0 +1,29 @@
+(module
+ (func $sink-from-inside (result i32)
+ (local $0 i32)
+ (local $1 i32)
+ (local $2 i32)
+ (local.set $2
+ (block (result i32)
+ (local.set $0
+ (i32.const 1)
+ )
+ (drop
+ (local.get $0)
+ )
+ (local.set $1 ;; after we sink this, must be careful about sinking the parent, to not reorder other things badly
+ (select
+ (i32.const 0)
+ (i32.const 1)
+ (local.get $0)
+ )
+ )
+ (i32.const 1)
+ )
+ )
+ (i32.and
+ (local.get $1)
+ (local.get $2)
+ )
+ )
+)