summaryrefslogtreecommitdiff
path: root/test/passes
diff options
context:
space:
mode:
authorThomas Lively <7121787+tlively@users.noreply.github.com>2020-03-10 18:52:50 -0700
committerGitHub <noreply@github.com>2020-03-10 18:52:50 -0700
commit0abc9ce8e9676c95f7ff572529eebf3018179dad (patch)
treecfe650786faef0e072ed426d70590a29095031ca /test/passes
parent8f16059d3c29e285d4effed7f0c1f84c1f2f4d9d (diff)
downloadbinaryen-0abc9ce8e9676c95f7ff572529eebf3018179dad.tar.gz
binaryen-0abc9ce8e9676c95f7ff572529eebf3018179dad.tar.bz2
binaryen-0abc9ce8e9676c95f7ff572529eebf3018179dad.zip
Update Precompute to handle tuples (#2687)
This involves replacing `Literal::makeZero` with `Literal::makeZeroes` and `Literal::makeSingleZero` and updating `isConstantExpression` to handle constant tuples as well. Also makes `Literals` its own struct and adds convenience methods on it.
Diffstat (limited to 'test/passes')
-rw-r--r--test/passes/precompute-propagate_all-features.txt21
-rw-r--r--test/passes/precompute-propagate_all-features.wast24
-rw-r--r--test/passes/precompute_all-features.txt10
-rw-r--r--test/passes/precompute_all-features.wast33
4 files changed, 87 insertions, 1 deletions
diff --git a/test/passes/precompute-propagate_all-features.txt b/test/passes/precompute-propagate_all-features.txt
index 5a0b7b3a5..ead4bb084 100644
--- a/test/passes/precompute-propagate_all-features.txt
+++ b/test/passes/precompute-propagate_all-features.txt
@@ -2,6 +2,7 @@
(type $i32_=>_none (func (param i32)))
(type $i32_=>_i32 (func (param i32) (result i32)))
(type $i32_i32_=>_i32 (func (param i32 i32) (result i32)))
+ (type $none_=>_i32_i64 (func (result i32 i64)))
(type $i32_i32_i32_=>_i32 (func (param i32 i32 i32) (result i32)))
(type $none_=>_v128 (func (result v128)))
(memory $0 10 10)
@@ -264,4 +265,24 @@
)
(local.get $x)
)
+ (func $tuple-local (; 18 ;) (result i32 i64)
+ (local $i32s (i32 i32))
+ (local $i64s (i64 i64))
+ (local.set $i32s
+ (tuple.make
+ (i32.const 42)
+ (i32.const 0)
+ )
+ )
+ (local.set $i64s
+ (tuple.make
+ (i64.const 42)
+ (i64.const 0)
+ )
+ )
+ (tuple.make
+ (i32.const 42)
+ (i64.const 0)
+ )
+ )
)
diff --git a/test/passes/precompute-propagate_all-features.wast b/test/passes/precompute-propagate_all-features.wast
index 169337fc3..f866c0ea8 100644
--- a/test/passes/precompute-propagate_all-features.wast
+++ b/test/passes/precompute-propagate_all-features.wast
@@ -175,4 +175,28 @@
(local.set $x (v8x16.load_splat (i32.const 0)))
(local.get $x)
)
+ (func $tuple-local (result i32 i64)
+ (local $i32s (i32 i32))
+ (local $i64s (i64 i64))
+ (local.set $i32s
+ (tuple.make
+ (i32.const 42)
+ (i32.const 0)
+ )
+ )
+ (local.set $i64s
+ (tuple.make
+ (i64.const 42)
+ (i64.const 0)
+ )
+ )
+ (tuple.make
+ (tuple.extract 0
+ (local.get $i32s)
+ )
+ (tuple.extract 1
+ (local.get $i64s)
+ )
+ )
+ )
)
diff --git a/test/passes/precompute_all-features.txt b/test/passes/precompute_all-features.txt
index b24c96159..4d613f06f 100644
--- a/test/passes/precompute_all-features.txt
+++ b/test/passes/precompute_all-features.txt
@@ -4,6 +4,7 @@
(type $none_=>_f64 (func (result f64)))
(type $none_=>_v128 (func (result v128)))
(type $i32_=>_none (func (param i32)))
+ (type $none_=>_i32_i64 (func (result i32 i64)))
(type $none_=>_nullref (func (result nullref)))
(memory $0 512 512)
(data (i32.const 0) "passive")
@@ -23,6 +24,7 @@
(nop)
(nop)
(nop)
+ (nop)
(loop $in
(br $in)
)
@@ -250,7 +252,13 @@
(i32.const 12)
)
)
- (func $reftype-test (; 17 ;) (result nullref)
+ (func $tuple-precompute (; 17 ;) (result i32 i64)
+ (tuple.make
+ (i32.const 42)
+ (i64.const 42)
+ )
+ )
+ (func $reftype-test (; 18 ;) (result nullref)
(ref.null)
)
)
diff --git a/test/passes/precompute_all-features.wast b/test/passes/precompute_all-features.wast
index 74b8f1317..da755bde6 100644
--- a/test/passes/precompute_all-features.wast
+++ b/test/passes/precompute_all-features.wast
@@ -48,6 +48,22 @@
(i32.const 1)
)
)
+ (drop
+ (tuple.make
+ (tuple.extract 0
+ (tuple.make
+ (i32.const 42)
+ (i32.const 0)
+ )
+ )
+ (tuple.extract 1
+ (tuple.make
+ (i64.const 0)
+ (i64.const 42)
+ )
+ )
+ )
+ )
(loop $in
(br $in)
)
@@ -344,6 +360,23 @@
(i32.const 12)
)
)
+ (func $tuple-precompute (result i32 i64)
+ (tuple.make
+ (tuple.extract 0
+ (tuple.make
+ (i32.const 42)
+ (i32.const 0)
+ )
+ )
+ (tuple.extract 1
+ (tuple.make
+ (i64.const 0)
+ (i64.const 42)
+ )
+ )
+ )
+ )
+
;; Check if Precompute pass does not crash on reference types
(func $reftype-test (result nullref)
(ref.null)